[binutils] Problems about utilizing BFD in a symbolic debugger
Rui Hong
hongrui16@mails.ucas.ac.cn
Wed Mar 16 07:36:56 GMT 2022
Hi everyone,
Glad to join the binutils community.
I'm using C to make a symbolic debugger inside a software simulator for RISCV/ELF(DWARF) executable and starting to use binutils-bfd to implement features about symbol/DWARF handling.
Using BFD doc/bfd.h, I've found BFD functions like bfd_find_nearest_line, bfd_canonicalize_symtab to implement features on "symbol-->address-->line", such as command 'b main / b func_name', or showing correct file and line after 'b *0x40000040' command.
But I do not find any other BFD functions on "line-->address", to implement command like 'b main.c:14'.
And the symbol table in ELF or what the bfd_canonicalize_symtab returns seems to be a rather simple symbol table with no variable in the source file, which makes it harder to get a variable's location to implement command like 'p var1'(do I really have to parse DWARF manually?)
I really need advice or some code examples anywhere(I'm looking into GDB source code right now, but it's quite complex. Even a rough location of the code would be helpful)
To sum my questions:
1. how can I map file:line to actual address using BFD?
2. how to build a complete symbol table with variables and their locations in it using BFD?
3. how to get the original complete line number table from .debug_line section using BFD?
Any advice, code example or location of code would be helpful!
Kind regards,
Rui
More information about the Binutils
mailing list