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

Resolve Context Trace Symbols #743

Merged
merged 4 commits into from
Oct 14, 2021
Merged

Conversation

mahaloz
Copy link
Contributor

@mahaloz mahaloz commented Oct 13, 2021

Resolve Context Trace Symbols

Description/Motivation/Screenshots

This PR is more of an opinion feature than an actual new feature. In context_trace, the function responsible for printing the backtrace of an execution, there is a line that will construct what is printed to gef when gdb can't find a name for the current context frame. In that case, GEF will always print an instruction; however, it does not attempt to resolve symbols again for that address.

I purpose the change to call the very standard function gdb_get_location_from_symbol on the frame to check if gdb has knowledge of symbols. You may be asking, how can this branch ever trigger? It can trigger when the user manually adds his own symbols via add-symbol-file. The effort to add it, and the execution overhead are minimal (on my testing).

Lastly, this PR serves as a more robust way for external users to override how symbol resolving works in GEF. Take the case where a user overrides gdb_get_location_from_symbol, they now can have a custom symbol table that is architecture independent. Since gdb_get_location_from_symbol is used in nearly every other context function, it feels right to use it here as well.

Here is an example of what this little fix can look like once a user knows a symbol (ignore symbols in code):
image

How Has This Been Tested?

Architecture Yes/No Comments
x86-32 ✔️
x86-64 ✔️
ARM ✖️
AARCH64 ✖️
MIPS ✖️
POWERPC ✖️
SPARC ✖️
RISC-V ✖️
make test ✖️

Checklist

  • My PR was done against the dev branch, not master.
  • My code follows the code style of this project.
  • My change includes a change to the documentation, if required.
  • My change adds tests as appropriate.
  • I have read and agree to the CONTRIBUTING document.

@mahaloz
Copy link
Contributor Author

mahaloz commented Oct 13, 2021

Additionally, this could be applied to context_threads, which should, imo, also use the normalized gdb_get_location_from_symbol

@mahaloz mahaloz mentioned this pull request Oct 13, 2021
5 tasks
@mahaloz
Copy link
Contributor Author

mahaloz commented Oct 13, 2021

Actually, yeah it is really trivial to fix threads as well. I made a separate PR: #744. Feel free to reject both. All discussion can happen here if you like.

Copy link
Collaborator

@daniellimws daniellimws 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. I think it's nice to have (and waiting for your add-symbol command 😃 )

@hugsy hugsy merged commit 48ed480 into hugsy:dev Oct 14, 2021
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

3 participants