Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to print module_name:offset, or address of frame #44

Merged
merged 5 commits into from Apr 25, 2021

Conversation

s1341
Copy link
Contributor

@s1341 s1341 commented Apr 23, 2021

This PR adds the ability to print the module_name:offset (or address, if module_name cannot be found) of each frame. This helps when debugging black-box third-party code.

Currently, module name resolution is implemented by walking the /proc/self/maps pseudo-file. This is available on most unix-like OSes, with the notable exception of macos/ios. As such, this feature is a noop on those system.

The feature is both hidden behind a feature flag (print-addresses), because it has a regex dependency, and must be explicitly turned on by calling print_addresses(true) on the BacktracePrinter.

Copy link
Owner

@athre0z athre0z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general, thanks for this!

I added a few minor comments. I'm wondering whether it would make sense to remove the cfg restrictions from print_addresses etc and to only keep it for module_info. The fallback function for module_info could then just always return None/Err. As far as I see, this should be the only thing that's really platform dependent here? Should probably also rename the feature into something like resolve-modules then.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@s1341
Copy link
Contributor Author

s1341 commented Apr 25, 2021

I've applied all review issues. Please let me know if there is anything else you'd like.

Copy link
Owner

@athre0z athre0z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cfg condition on the module_info fallback doesn't seem to be the proper inverse of the Linux implementation. I commented on how I imagined it, but perhaps there is a good reason for doing it like you're doing it that I just fail to see?

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
s1341 and others added 2 commits April 25, 2021 17:41
Co-authored-by: Joel Höner <joel@zyantific.com>
Co-authored-by: Joel Höner <joel@zyantific.com>
@s1341
Copy link
Contributor Author

s1341 commented Apr 25, 2021

If you could cut a version when you've merged, it would be greatly appreciated.

@athre0z athre0z merged commit d25c611 into athre0z:master Apr 25, 2021
@athre0z
Copy link
Owner

athre0z commented Apr 25, 2021

Will do. Thanks for the PR! :)

@athre0z
Copy link
Owner

athre0z commented Apr 25, 2021

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants