user982740
user982740

Reputation: 203

Tracing function calls in C++ using gdb

I have a system developed in C++ on Linux platform. I am doing some debugging of this system. I want to look for the complete sequence of function calls to a function. Lets assume the functions are called in the following sequence

function_1 -> function_2 -> function_3 -> function_4

If I put a break point at function_4, the execution will be holded at that point. I want to see that functions_1, function_2 and function_3 are called before function_4. If there any gdb command to trace these function calls?

Thanks, Ankur

Upvotes: 3

Views: 4624

Answers (3)

Adrian Cornish
Adrian Cornish

Reputation: 23848

If function_1() calls function_2() which calls function_3() etc

You can set your breakpoint in function_4() and you use the command

where

To print a backtrace of the stack

Another tool that may be useful is valgrind with the callgrind tool

Upvotes: 1

StilesCrisis
StilesCrisis

Reputation: 16290

You want a backtrace. The gdb command bt will show exactly what you are interested in.

Upvotes: 8

Related Questions