This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] AArch64 pauth: Indicate unmasked addresses in backtrace
- From: Alan Hayward <Alan dot Hayward at arm dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Simon Marchi <simon dot marchi at polymtl dot ca>, "gdb-patches\\@sourceware.org" <gdb-patches at sourceware dot org>, nd <nd at arm dot com>
- Date: Wed, 17 Jul 2019 17:34:31 +0000
- Subject: Re: [PATCH] AArch64 pauth: Indicate unmasked addresses in backtrace
- Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=arm.com;dmarc=pass action=none header.from=arm.com;dkim=pass header.d=arm.com;arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F15E3gBJMbjwzKDXmKc0qM78SYGFq5I6s0gS3j2Ebso=; b=UcqR8vuhNaYDxX1o8FJSxhR2I7jX3AfRM6IMU0VjyPK25M8czrx0M723hhvk/JtamJOXu/Bp4ZWpwOwA5FuUwzKca9sJYkrvT6/h5/VQePwgPo+VcYaVnOzuCteCd1z8p7oMy2Upph/GGMOqxnHAVUM8exmuRCNw7cYtm8B5AcXYJoac9FXTTnRnlQ5NLrfb/NOyue24AeW+O9SowSOXeFJM72n+guzWnnIkrBmj4m2tbFeTjKntVE3R4cy972LzN60lQElYF4n7lpIIY6bJZcPzDUsUVZEz/Ie9HKQg9HT6DCQ5EF2MMHhKssjTm7ZS20ttc3izHA/BnEjckjtUrg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mERydwuS0rScrmSLd6V2C3iSltjfmJrk+0V0HSI4Dp4hS+bpY5oWIecIuTGugohSqXgydl5djGehtWDlyBzutq/pWxRKdBK6UOmXRcYyTqv2hBK/5i5GUzfQfIMx0iMS/eanh54Q6/Sr73Dxz5uKdiQ++3d7yv/rqkCiOh6ZVrrdxcdeBW22fNfEW5qfLry2XLEr8FzOVJgt3D8wjtWLfAf1QLOaAzIA2Mmt286HIjF0nyU30pVQySLfvkH9x48dI4VPC9AlmfansNPzwAu4goojhTFCuy26lZp8ARCfZ95k9wBoIH3RxBNd10r6KjwM5X5n2GtALWxyZeZvxeMYpw==
- Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan dot Hayward at arm dot com;
- References: <20190717081336.68835-1-alan.hayward@arm.com> <dfb2cbaf-f3a6-f0b3-2080-44bba21d77d3@redhat.com> <68E9D3EF-D6A5-44C9-A87C-916EC6970435@arm.com> <e5c0663d5eda768e30cea646c3b37726@polymtl.ca> <9c474f28-30f3-2428-d147-4474471a61ba@redhat.com> <8009C474-AE70-4A5B-A2D9-EB3B90626D95@arm.com> <ed33a79b-c628-9d9d-bb86-a303bda53750@redhat.com>
> On 17 Jul 2019, at 17:41, Pedro Alves <palves@redhat.com> wrote:
>
> On 7/17/19 5:07 PM, Alan Hayward wrote:
>
>>> I almost suggested the same, but didn't when I realized that we
>>> don't always print the addresses:
>>>
>>> (top-gdb) bt
>>> #0 gdb_main (args=0x7fffffffd3a0) at src/gdb/main.c:1186
>>> #1 0x0000000000469a7e in main (argc=1, argv=0x7fffffffd4a8) at src/gdb/gdb.c:32
>>>
>>
>> What’s the reason for that? Surely we always know the address of a function
>> in the backtrace? Can it happen in the middle of a backtrace?
>
> "It always worked that way", at least for me.
>
> We show an address if the PC is pointing to the middle
> of a line, or we don't have debug info. If pointing at a line
> exactly, then we show no address.
>
> (gdb) frame
> #0 main (argc=1, argv=0x7fffffffd4a8) at src/gdb/gdb.c:29
> 29 args.argc = argc;
> (gdb) si
> 0x0000000000469a5f 29 args.argc = argc;
> (gdb) frame
> #0 0x0000000000469a5f in main (argc=1, argv=0x7fffffffd4a8) at src/gdb/gdb.c:29
> 29 args.argc = argc;
>
>
> Same logic for when displaying the frame where a program stops, when
> stepping, ctrl-c, breakpoint hits, etc.
>
> Breakpoint 5, main (argc=1, argv=0x7fffffffd4a8) at src/gdb/gdb.c:28
> ^^^^
> 28 memset (&args, 0, sizeof args);
> (gdb) p /x $pc
> $1 = 0x469a46
> (top-gdb) del
> Delete all breakpoints? (y or n) y
> (top-gdb) r
> The program being debugged has been started already.
> Start it from the beginning? (y or n) y
> Starting program: build/gdb/gdb
> Breakpoint 6, 0x0000000000469a4a in main (argc=1, argv=0x7fffffffd4a8) at src/gdb/gdb.c:28
> ^^^^^^^^^^^^^^^^^^^^^^^^^^
> 28 memset (&args, 0, sizeof args);
Excellent, thanks.
>
>>
>>
>>> But if you do want to align the addresses, you could do that by
>>> specifying a width for the "addr" column.
>>
>>> If "[U]" is rare, given no column
>>> headers, the spaces may look a bit odd, though.
>>
>> In general, it depends how a binary/library was compiled. But I’d expect a binary
>> to either have it in most functions or none.
>>
>> Should be easy enough to remove the extra spaces if the system doesn’t support PAC.
>>
>>
>>> Maybe you'd want to pre-compute
>>> the max column width by looking at the max number of frames that fit on a
>>> page, or something along those lines.
>>>
>>
>> hmmm... ok. I’ll see what I can do there.
>
> If most functions have it, then I wouldn't bother trying to compute
> the max column width.
>
> But then if most functions have it, I wonder what's the point of
> showing the marker, though. :-) Would it make sense to reverse
> the logic?
>
I think it’s still better this way around. It indicates that PAC is being used.
You might, for example, be running 8.0 binaries on 8.3 system, which has then
linked against your libc etc which is using 8.3 PAC.
(You can also run 8.3 PAC on 8.0, as the relevant stuff will just turn into nops).
> Thanks,
> Pedro Alves