This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Tentative: add -location option to clear command
- From: Giles Atkinson <gatk at btinternet dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 29 Mar 2016 15:50:23 +0100
- Subject: Re: Tentative: add -location option to clear command
- Authentication-results: sourceware.org; auth=none
- References: <F3638BB1-F4C1-4AE8-8E67-F3A1F88E4BFE at btinternet dot com>
I did not see any responses to the message below.
If there is something more I should do for this patch to be considered,
can someone please tell me what it is.
Thanks,
Giles
On 20 Feb 2016, at 19:17, Giles Atkinson wrote:
> 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
> <patch.gz>