Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB: Break on func1 only if previous break was on func2

Tags:

c++

c

gdb

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?

like image 804
Randomblue Avatar asked Nov 04 '22 16:11

Randomblue


1 Answers

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.

like image 70
Deepanjan Mazumdar Avatar answered Nov 08 '22 16:11

Deepanjan Mazumdar