/pygdb2/test/set_watchpoint.py

https://bitbucket.org/antocuni/pygdb2/ · Python · 20 lines · 17 code · 3 blank · 0 comment · 3 complexity · fd5e52662fef16c871732a0dccadd388 MD5 · raw file

  1. import ctypes
  2. import pygdb2
  3. def main():
  4. print 'program starting'
  5. buf = ctypes.c_int()
  6. buf.value = 42
  7. adr = ctypes.cast(ctypes.pointer(buf), ctypes.c_void_p)
  8. pygdb2.execute("watch *(int*)%d" % adr.value) # enter gdb when we write to this memory
  9. i = 0
  10. while i < 5:
  11. print i
  12. i += 1
  13. if i == 2:
  14. buf.value = 43 # we should enter gdb here
  15. print 'program stopping'
  16. if __name__ == '__main__':
  17. main()