Reputation: 1
We are trying to implement the customized gdb tool for specific environment. We have Linux- Centos operating systems.
Trying to implement the gdb functionality with some customization. Our tool will be attached to the PID (already running process), which will start debugging session. we would like to read the symbols information (symbol table) and print as much as possible information of symbols (mainly the data type, address and size).
We are able to read the symbol table using the readelf, file commands in gdb, and able to print some information related to local/global variables. But we are not able to find the exact command to print the addresses and sizes of the variables.
Upvotes: 0
Views: 273
Reputation: 7228
You can use the ptype command and sizeof in expressions in gdb:
(gdb) ptype exit
type = int ()
(gdb) print sizeof(argc)
$1 = 4
This of course requires that debuginfo and not just the symbol table to be available, e.g. for ELF, this requires the .debug_{aranges,info,abbrev,...} sections and not just .shstrtab, .symtab, and .strtab.
Upvotes: 1