Fix for using macho in Pry/IRB#431
Conversation
Using 'macho' in Pry/IRB was slow due to the editor printing the entire contents of @raw_data, this makes the inspect element print only the length of the view.
|
LGTM! Mind fixing the lint? |
|
Doing so now - also adding a MachOFile reference to MachOView so that you can navigate backwards from a command to the file (some commands make use of other commands in a file such as MH_FILESET_ENTRY to the LC_LOAD at the same address) |
Cool, that should be fine as long as we don't break any APIs that allow for dynamic construction/creation of LCs 🙂 |
|
Looking to exercise new code paths now |
Simple solution was to attach the MachOFile to the MachOView so navigation would be |
First example of load commands that are able to navigate from one to the other (LC_FILESET_ENTRY is paired to a LC_SEGMENT64 that occurs at the same fileoff). This should provide required test coverage of MachOView to MachOFile navigation
|
Ok I'm a bad person... This PR expanded scope to cover the use case. The E2E capability is load BootKernelCollection in pry (fast due to the @raw_data fix) Iterate over FH_FILESET_ENTRY and map each to .segment and extract |
|
Added some tests to make CI happy |
|
LGTM structurally, although I'm a little bit confused by what's going on with |
Let me do some more testing - it seems to me that the .kc file has I'm thinking of creating a Git LFS repo for text mach-os (large ones like kc files and prelink kernels that can be brought into testing if you want the other larger types. |
|
Makes sense! I didn't realize each had a |
|
We have a unified CI configuration set up for Homebrew, so I think we're good without commit hooks for the time being. |
|
Oh, I misunderstood. Sure, as long as they're opt-in, I would accept a PR enabling them for |
woodruffw
left a comment
There was a problem hiding this comment.
LGTM! We should give some though to perhaps refactoring MachOView entirely so that it doesn't effectively have two copies/references of the raw Mach-O data in it, now that we store both macho_file and raw_data. In particular, raw_data is probably replaceable with an offset and length for macho_file.raw_data. But that can wait for another PR.
Using 'macho' in Pry/IRB was slow due to the editor printing the entire contents of @raw_data, this makes the inspect element print only the length of the view.