Search code examples
gdbconditional-breakpoint

GDB Break if frame is in backtrace


I want to set a condition on a gdb breakpoint to only break if a certain function name appears in the backtrace. What's the best way to do this?


Solution

  • I am not sure how to do exactly what you ask for, but a possible workaround, if you have access to the source code of the relevant function, is to set some global boolean variable to true in the beginning of the function, and set it to false just before the function exits. Then you could set a conditional breakpoint (using the condition command) to stop only when this boolean variable is true.