I am using the GDB Python interface to handle Breakpoints
import gdb
class MyBP(gdb.Breakpoint):
def stop(self):
print("stop called "+str(self.hit_count))
return True
bp = MyBP("test.c:22")
This works as expected. The hit_count is increased after the "stop" method returns.
Now when I want to use a conditional breakpoint:
bp.condition="some_value==2"
it is not working as expected. The stop method is always executed regardless whether the condition is true or false. If the stop method returns "True" the breakpoint will only halt the program if the condition is also true. The hit_count is increased after the Stop method returns and the condition holds.
So it seems as if GDB is only applying the condition check after the Stop method was called.
How can I ensure that the Stop method is only called when the condition holds?