Debug Info¶
Debug Info is a mechanism for importing types, function signatures, data variables, and more from either the original binary (e.g. an ELF compiled with debug info) or a supplemental file (e.g. a PDB or .debug file).
Currently, debug info plugins are limited to applying types, function signatures, data variables, and local stack variables, but in the future will include line number information, comments, and possibly more.
Supported Formats¶
We currently support PDBs and DWARF (which are both open source), though you can also register your own debug info parser through the API.
Binary Ninja will automatically try to access relevant PDBs from specified local folders and Microsoft's symbol server (see the PDB settings for more information).
Binary Ninja's DWARF loader supports loading information compiled into binaries, information from external files (.dwo, .debug, etc.), and information from external .dSYM files as well.
Applying Debug Info¶
Debug Info is automatically applied by default if available.
However, for some file formats, you may wish to specify an external source of Debug Info using the Analysis/Import Debug Info from External File menu option.
Blocking Debug Info¶
You can control if debug information is imported for a file by changing the setting analysis.debugInfo.internal. You can import debug information at any point later by using the menu action Analysis/Import Debug Info.
PDB Notes¶
Binary Ninja will make a best effort to find relevant PDBs and apply debug info from them when you open a binary. Some PDBs can be very large and take a significant amount of time to process. When you open a file with a large PDB, you'll see a progress indicator in the status bar at the bottom of the application.
DWARF Notes¶
DWARF information is imported from files that contain DWARF sections. Binary Ninja can automatically locate and load separate DWARF information through several methods:
- Debuginfod servers: If
network.enableDebuginfodis enabled, Binary Ninja will query the debuginfod servers configured innetwork.debuginfodServers - Sibling debug files: If
analysis.debugInfo.loadSiblingDebugFilesis enabled, Binary Ninja will look for files of the form<filename>.debugand<filename>.dSYMin the same directory as the binary - Debug directories: Binary Ninja will search the directories specified in
analysis.debugInfo.debugDirectoriesfor debug files stored by the binary's build ID
If automatic loading does not succeed, you can still manually import debug info from an external file using the Analysis/Import Debug Info from External File menu option.
DWARF Import Limitations¶
DWARF version 5 is mostly backwards compatible with DWARF version 4, which we originally targeted with our DWARF import plugin, with the caveats described in this issue.
Components are supported by the API, but not in the parser. The same issue as above would also allow us to support components more easily as well.
DWARF Export Limitations¶
Our DWARF Export plugin is also open source and uses a different system from our debug information import plugins. It also does not support function-local variable names or types. The export plugin currently will export the global variables, function prototypes, and all the types in your binary view except for ones that are FunctionTypeClass or VarArgsTypeClass.
Special Note for .dSYM Files¶
Binary Ninja will automatically load .dSYM files given the following:
- The
.dSYMfile is adjacent on the filesystem to the binary being analyzed - The
.dSYMfile is namedX.dSYM, whereXis the name of the binary being analyzed analysis.debugInfo.loadSiblingDebugFilesis enabled
When a .dSYM file is not automatically loaded, you will need to manually import the debug info contained in the .dSYM.
For example, you could have the file hello.macho that you would like to import debug info for. Thankfully, you also have hello.dSYM. So you open hello.macho with options, find the "External Debug Info File" and provide the hello.dSYM file. When the file opens, you notice that no information was imported and the log reads "No available/valid parsers for file." This is because hello.dSYM is a bundle. The actual path you needed to provide for the "External Debug Info File" setting would look something like hello.dSYM/Contents/Resources/DWARF/hello.
