The best way to do this is to use commands at breakpoints.
You can direct GDB to execute certain commands (for example, to increase the counter) when you hit two breakpoints. Execution stops conditionally based on the number of these variables / flags.
. , . . , .