This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Greetings. This patch adds a variation of the "clear" command, "clear -location", so that (some) watchpoints can be removed by expression. The idea is to support setting watchpoints in dynamically-allocated memory, removing them automatically when the memory is released. Something like this: # Break on malloc()d memory initialisation. break new_stuff:init commands watch -location new->foo[0] commands printf "Item %d next %p\n", it->count, it->next bt continue end continue end # # Break just before free(). break free_stuff:release commands clear -location old->foo[0] continue end The delete command will not work here without an external mechanism to associate the watchpoint number with the memory address. Some background to this is in the recent thread "Dynamic watchpoints in dynamic memory" on the gdb list. The change works by pulling out bits of the watch and clear commands into new functions, and re-using them. No real understanding of gdb internals was needed, so there may be some subtle errors. In making parse_expression_for_watchpoint(), I removed what looked like redundant stripping of whitespace from the expression. In its current form, the change appears to pass the tests as well as the original. (I get some variation with repeated runs of "make check".) The results for changes named "watch*" and "break*" seem identical. If the change can be accepted in principle, I will add tests, and documention changes. There is also a potential extension to other watchpoints (set without -location). The clear command would only remove watchpoints after failing to match any breakpoints, and would probably select watchpoints to be removed by matching the frame and parsed expression. Diff is relative to 7.10.1. Thanks, Giles
Attachment:
patch.gz
Description: GNU Zip compressed data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |