GDB: Break on func1 only if previous break was on func2
I have two functions, func1 and func2, each with a breakpoint set.
Is it possible to have GDB stop on the func2 breakpoint iff the previous breakpoint hit was func1?
The best way to do this is to use commands in breakpoints.
You can direct GDB to execute certain commands (like, to increment a counter) when the two breakpoints are hit. The execution is halted conditionally based on the count of these variables/flags.
I found this information on this link. Please refer the same for further details. The article is very well-written with proper examples. Hope this helps.