tags:

views:

34

answers:

1

Hi,

I am using GDB to understand a C++ program. I put a break in the middle of the running which turns to be something like:

break main.cpp:500

and I would like to see which functions have been called before. I tried "backtrace" but it shows only info about main, as previous calls to previous functions have already finished.

My question is how can I get (with GDB or another method) the info about which functions have been called before this point, even if the call has been returned.

Thanks

A: 

A gdb script might be a solution for your problem.

Create a script that puts break point to each possibly called function. At break prints the stack with 'bt' and continue the execution.

You should put an other break point to main.cpp:500 to quit from debugging.

b 'main.cpp::500'
commands 1
    detach
    quit
end

break 'A::f1()'
break 'A::f2()'
while true
continue
bt
end



You can start the script like this:

gdb --command ./gdbscript.gdb fpmanager 

If you have too much possibly called function you can grep the code to find all.

Vereb