This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Teach "info breakpoints" to show the address of a -location watchpoint
- From: Pedro Alves <palves at redhat dot com>
- To: Patrick Palka <patrick at parcs dot ath dot cx>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Fri, 1 Apr 2016 12:05:58 +0100
- Subject: Re: [PATCH] Teach "info breakpoints" to show the address of a -location watchpoint
- Authentication-results: sourceware.org; auth=none
- References: <1459013683-30018-1-git-send-email-patrick at parcs dot ath dot cx> <56FADA3D dot 4020501 at redhat dot com> <CA+C-WL-8D=JS714SYxtm0bfhHcb=1T8Yh9qT8_F6QyK851otZA at mail dot gmail dot com>
On 03/30/2016 01:48 AM, Patrick Palka wrote:
> On Tue, Mar 29, 2016 at 3:40 PM, Pedro Alves <palves@redhat.com> wrote:
>> On 03/26/2016 05:34 PM, Patrick Palka wrote:
>>> Currently the "info breakpoints" command leaves empty the Address column
>>> corresponding to a -location watchpoint, even though there is an address
>>> internally tied to this watchpoint. Instead of printing nothing, this
>>> patch makes the type and the computed address of the -location
>>> watchpoint get printed. Conviently the exp_string_reparse already has a
>>> pretty-printed string that contains this information.
>>>
>>> The new output of "info breakpoints" looks something like:
>>>
>>> Num Type Disp Enb Address What
>>> 2 hw watchpoint keep y (tree_code *) 0x00007ffff7ff4990 -location decl.base.code
>>>
>>
>> Hmm, isn't this going to look more awkward the longer the type name is?
>> Do we include C++ namespaces in there as well? Usually, the column
>> that has variable width is the last one.
>>
>> If you're looking for the width of the watched range, a shorter alternative
>> would be to not print the type, but instead use ADDR:LEN notation, like:
>>
>> Num Type Disp Enb Address What
>> 2 hw watchpoint keep y 0x00007ffff7ff4990:4 -location decl.base.code
>>
>> WDYT?
>
> If only the last column should have a variable length, then what about
> appending the type and address to the last column, so that the output
> looks like:
>
> Num Type Disp Enb Address What
> 2 hw watchpoint keep y -location
> decl.base.code at (tree_code *) 0x00007ffff7ff4990
>
> or what about recursing through component accesses and printing the
> location of the base object, like so
>
> Num Type Disp Enb Address What
> 2 hw watchpoint keep y -location
> decl.base.code at &((some_struct *) 0x00007ffff7ff4900).base.code
>
> The latter output would give us the most information, including
> bitfield information (if e.g. the "code" field is a bitfield).
In the latter case, don't you want to see the final resolved address,
and the type of "code"? Like, assuming type int, and offset from
base by 0x10 bytes:
Num Type Disp Enb Address What
2 hw watchpoint keep y -location decl.base.code at (int *) 0x00007ffff7ff4910
Or, going the direction of showing the whole path, we could have everything in, by
showing an (int *) cast before the "&", and using the "Address" column for the final
resolved address, like:
Num Type Disp Enb Address What
2 hw watchpoint keep y 0x00007ffff7ff4910 -location decl.base.code at (int *) &((some_struct *) 0x00007ffff7ff4900).base.code
And using the ADDR:LEN notation idea:
Num Type Disp Enb Address What
2 hw watchpoint keep y 0x00007ffff7ff4910:4 -location decl.base.code at (int *) &((some_struct *) 0x00007ffff7ff4900).base.code
Hard to judge what's best without trying it out for a while.
Thanks,
Pedro Alves