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

Loading variable names from DWARF and PDB #7863

Open
SjRNMzU opened this issue Jul 5, 2017 · 2 comments · Fixed by #17434
Open

Loading variable names from DWARF and PDB #7863

SjRNMzU opened this issue Jul 5, 2017 · 2 comments · Fixed by #17434
Assignees
Labels
debug-info DWARF DWARF symbols and types debug information enhancement Hacktoberfest PDB PDB and CodeView debug symbols formats from Microsoft RAnal vars Variables analysis and inference

Comments

@SjRNMzU
Copy link
Contributor

SjRNMzU commented Jul 5, 2017

DWARF

Radare2 does not output variable/attribute names (DW_AT_name). As a result, local function variables in binaries with debuginfo aren't named and still use "local_XX".

For example:

  1. Compile a binary with "-g3"
  2. Compare the output of objdump -g a.out, readelf --debug-dump=info a.out and rabin2 -d a.out

It would be fantastic if we could automatically rename "local_XX" by thier DW_AT_name for binaries with debuginfo.

PDB

Same applies here

@XVilka XVilka added the RAnal label Sep 11, 2017
@XVilka XVilka added this to the 1.8.0 milestone Sep 11, 2017
@radare radare modified the milestones: 2.1.0, 2.3.0 Nov 24, 2017
@radare radare modified the milestones: 2.3.0, 9999 Jan 28, 2018
@XVilka XVilka added the vars Variables analysis and inference label Jun 25, 2018
@XVilka XVilka modified the milestones: 9999, 2.9.0 - pre-r2con Jun 25, 2018
@XVilka XVilka changed the title dwarf: Missing variable names Loading variable names from DWARF and PDB Jun 25, 2018
@XVilka XVilka added the Windows Microsoft Windows platform support issues label Jun 25, 2018
@XVilka XVilka modified the milestones: 2.9.0 - pre-r2con, 2.8.0 Jul 10, 2018
@XVilka XVilka modified the milestones: 2.8.0, 2.9.0 - pre-r2con Aug 3, 2018
@radare radare modified the milestones: 2.9.0, 3.0 Aug 31, 2018
@sivaramaaa sivaramaaa modified the milestones: 3.0, 3.1.0 Oct 8, 2018
@XVilka XVilka added PDB PDB and CodeView debug symbols formats from Microsoft DWARF DWARF symbols and types debug information and removed Windows Microsoft Windows platform support issues labels Oct 19, 2018
@radare radare modified the milestones: 3.1.0, 3.2.0 Nov 15, 2018
@sivaramaaa sivaramaaa modified the milestones: 3.2.0, 3.3.0 Dec 29, 2018
@XVilka XVilka modified the milestones: 3.3.0, 3.5.0 Feb 10, 2019
@XVilka XVilka added this to To do in Type Analysis Improvements via automation Apr 3, 2019
@XVilka XVilka modified the milestones: 3.5.0, 3.6.0 May 5, 2019
@radare radare modified the milestones: 3.6.0, 3.7.0 Jun 17, 2019
@radare radare modified the milestones: 3.7.0, 3.8.0 - after r2con Jul 30, 2019
@XVilka XVilka modified the milestones: 3.9.0, 4.0.0 Sep 14, 2019
@radare radare removed this from the 4.0.0 milestone Oct 23, 2019
@XVilka
Copy link
Contributor

XVilka commented Jul 8, 2020

@HoundThe apart from types - please be sure to add tests for variable and function names as well.

@HoundThe HoundThe linked a pull request Aug 20, 2020 that will close this issue
7 tasks
@HoundThe
Copy link
Contributor

HoundThe commented Aug 20, 2020

^ The DWARF PR added integration of the DWARF variable info into functions, but it's still far from perfect as DWARF is very complex format (So I wouldn't close it)

I'll just specify some things that are still in my head for future reference of what's missing to DWARF variables.

  • Very often, especially unoptimized binaries are using location in Call frame information (CFA stored in .debug_frame section, for some binaries it's in the .eh_frame), but we don't even parse this section yet.
  • There are sometimes multiple scopes (lexical_block in DWARF) that we ignore and take all variables from a function (not sure if there is even ability to show scope information in the disassembly), so we can have a name collision so the last one added in the function scope wins, so some cache to keep track of existing variables and creating some unique name (maybe just checking if it can be successfully added, if not -> append maybe an offset or smth should work too).
  • There is even some problem of variable existing on multiple locations based on the place of the function, DWARF has a location lists for this, right now we take a longest range the variable lives in and show that, I couldn't think of better solution to this, when variables can exists on different places at different times. Maybe this isn't possible to show in disassembly but might be good in future for decompiler?
  • I've added parsing for .debug_loc (where the location lists are) but GCC has a GNU extension to those with location views. maybe adding support for those? But this is probably just a detail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug-info DWARF DWARF symbols and types debug information enhancement Hacktoberfest PDB PDB and CodeView debug symbols formats from Microsoft RAnal vars Variables analysis and inference
Projects
Development

Successfully merging a pull request may close this issue.

6 participants