Can I call the built-in functions in gdb and / or fix them using GCC?

We all know that built-in functions can make debugging more difficult as they can be removed from stacks, etc. But suppose I want to call a built-in function from gdb, and I know its name and its arguments. I think I can do it, but I get the following:

Cannot evaluate function -- may be inlined

I used nmto list the characters in the library I used, and found that the functions I want to call were not there. No big surprise. I would like you to be able to create visible definitions of these built-in functions. I have access to header files that contain inline definitions currently, but I cannot change these headers. Perhaps there is some way to tell the compiler to emit definitions of all the built-in functions that it sees in the translation block? Or some other trick that might make it easier to call and verify the results of inline functions in gdb?

I am using GCC 4.7.2 and GDB 7.5.1 for Linux. And I can’t switch to a non-optimized build, because I am debugging the main dumps from production (in development, I would just turn off the optimization, then everything will be easier).

+3
source share
2 answers

One way to get the compiler to generate the called version of the built-in function is to include code that takes the address of the function. There is also an option that you can provide gcc. From the gcc documentation for built-in functions :

, ,    , ,    . GCC    ,   -fkeep- .

+4

GCC -gdwarf-2 .

11.1 GDB:

gdb , inlining - gcc, dwarf 2, , . gdb 2. gcc 4.1 ('DW_AT_call_file ' DW_AT_call_line); gdb gcc. .

. 3.9 GCC

+1

All Articles