0

I have a function that I am trying to examine. I want to find all callers of this function, but there are a few issues:

  • I am doing this to understand the code because I did not write it, but I need to know exactly how it behaves
  • It runs through the STL beforehand, so I can't just use something like callgrind to get it's immediate callers

There is a stack trace of 10+ function calls until you get to actual code that is not in the STL that caused this function to be invoked. But those STL entry points vary, as it is a compare function and calls for is_equal go through a different sequence than those that go through not_equal, etc. I will need to do this for at least 10+ different functions, and I want to streamline this as much as possible.

I want a tool that can dump each unique, full backtrace each time the function is called. Does anybody know a tool that can do this?

I am using gdb and c++ on Ubuntu 14.04.

user1661781
  • 327
  • 2
  • 16

1 Answers1

2

You can make gdb execute a series of commands each time a given breakpoint is executed, e.g.,

break someFunction
commands
bt
continue
end

The feature is mentioned in gdb scripting: execute commands at selected breakpoint, which has a link to the online documentation for gdb 5.1.7 Breakpoint Command Lists

Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105