symbolic icon indicating copy to clipboard operation
symbolic copied to clipboard

Provide access to inner `goblin` object types from `..Object` structs

Open ranweiler opened this issue 4 years ago • 1 comments

Unless I missed something in the docs, this doesn't seem possible right now. This would pair naturally with the existing data() accessors that exist, which provide access to the (unparsed) raw file data.

For example, this would imply an accessor method to the private field PeObject.pe.

Motivation

Here's a motivating situation:

  1. I've parsed a buffer into an Object via Object::parse()
  2. I have recognized that the Object variant is an Object::Pe, containing a PeObject
  3. I'd like to access the raw CodeView data in the PE (if present), as part of searching for the PDB using SymFindFileInPathW.

Notably, SymFindFileInPathW takes the signature and age as search parameters.

Workarounds

Now, the above example almost has workaround solutions in PeObject. I can use PeObject::debug_file_name(), and the signature and age are partially encoded in the DebugId available via PeObject::debug_id() (though it looks like the signature itself gets truncated).

But in general, what'd I'd always prefer is the ability to leverage the lower-level parsed PE from goblin. Then I'm free to query extremely format-specific data, without burdening the API of the Object structs in symbolic.

I'd be happy to open a PR for this, if it sounds reasonable. I think the main question is how you'd like the new public accessor methods to be named!

ranweiler avatar Dec 17 '21 22:12 ranweiler

Ideally symbolic would be independant of the underlying object parsing library, meaning that we shouldn’t expose that. Exposing that also means its types become part of our public API, meaning that we would have to do a major version release everytime we want to update to another semver major of goblin.

However I see that we already re-export something from goblin here, which is unfortunate :-(

https://github.com/getsentry/symbolic/blob/283afaac99f22039c84f7467964a0f996835c4bc/symbolic-debuginfo/src/pe.rs#L16-L17

Swatinem avatar Dec 21 '21 14:12 Swatinem

I think this is a valid usecase, but rather not something specific for symbolic. We would like to hide the exact implementation details as much as possible.

I would recommend just using goblin directly, or maybe https://github.com/gimli-rs/object.

Swatinem avatar Jan 25 '23 14:01 Swatinem