This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH V2] 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: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>, nd <nd at arm dot com>
- Date: Thu, 8 Aug 2019 08:55:33 +0000
- Subject: Re: [PATCH V2] 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=/7N4gmSAyYVHKuh4htSNeskNjkM5ZxTR6lbubEtzyQo=; b=eVujo3vnJJ5KMAe6tXuN7RuWMRpbIO4ofqKV4GsYNs5zZjtZy3WHdX8cc033GneQkCLuhZCjPmpYhryi73qH1321GNJ0LGIeM3k/4HD7CLd4j4PJkFPwmZ70Qy8+dGfKuNorb8Mqm5hVlGS1u2fZ/wtmSQKkD3KBAej/Hjv0/b1mm8HJsVY7w1gG/1t3b2yU990iPitEVwPNoiPaxCkkphFOK4ZW+GQWKXSD5sCmvcEHe1NaR7rYSHZlfYzQVazEn30KlFQrHQ7svxPQiaAKqG3sMuMpyEOHYIZ87Sk/N5wHnRjJ0h3vgvMoI/cov3C07i7DXVpAb5t+yeD5CSaTcA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OISXCkBleEuFXrtmL2RPtKsNyhU92+X7LSb4EKrWK/t8Cm73Bm2KDxF9PaHoT3IrVGri5zjYXrKeMDub6CgGyEviftyM319QkS61EJZRCH5R2RqR91TYfyMN1A4kBDXHA1PBTj823aVPdWD9mgv/W58UGaIfl3z7zU63lkvbFIjQLLm87QWiJcggnP8Y7VNF5EUwKRfW7+W1f2GcRc+jPxyLDwXZu93KUrnPB97Crz6G4O1SyQzut7ApErQpdE0yLbgbdCmS/JzMdXJMPkucsSP+bREkI4Y1YZplxOFfO13nGI/HZXVu724bcP43XW2LBugBBR9C9P1Pj0ktQOWGkA==
- Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan dot Hayward at arm dot com;
- References: <20190730144123.11135-1-alan.hayward@arm.com> <728af5fa-8e3d-845c-d72f-60b1d2067643@redhat.com>
> On 7 Aug 2019, at 20:24, Pedro Alves <palves@redhat.com> wrote:
>
> On 7/30/19 3:41 PM, Alan Hayward wrote:
>
>> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
>> index 0fcd131f71..b7dba2f918 100644
>> --- a/gdb/doc/gdb.texinfo
>> +++ b/gdb/doc/gdb.texinfo
>> @@ -24380,6 +24380,14 @@ but the lengths of the @code{z} and @code{p} registers will not change. This
>> is a known limitation of @value{GDBN} and does not affect the execution of the
>> target process.
>>
>> +@subsubsection AArch64 Pointer Authentication.
>> +@cindex AArch64 Pointer Authentication.
>> +
>> +When @value{GDBN} is debugging the AArch64 architecture, and the program is
>> +using the v8.3-A feature Pointer Authentication (PAC), then whenever the link
>> +register @code{$lr} is pointing to an PAC function it's value will be masked.
>
> s/it's value/its value/
>
>> +When GDB prints a backtrace, any addresses that required unmasking will be
>> +postfixed with the marker [PAC].
>>
>
>> diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
>> index a2a96ac0d3..d805ec68f2 100644
>> --- a/gdb/python/py-framefilter.c
>> +++ b/gdb/python/py-framefilter.c
>> @@ -901,6 +901,8 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
>> {
>> annotate_frame_address ();
>> out->field_core_addr ("addr", gdbarch, address);
>> + if (get_frame_pc_masked (frame))
>> + out->field_string ("pac", " [PAC]");
>> annotate_frame_address_end ();
>> out->text (" in ");
>> }
>> diff --git a/gdb/stack.c b/gdb/stack.c
>> index 7833ca4aeb..9d49809895 100644
>> --- a/gdb/stack.c
>> +++ b/gdb/stack.c
>> @@ -1298,7 +1298,11 @@ print_frame (const frame_print_options &fp_opts,
>> {
>> annotate_frame_address ();
>> if (pc_p)
>> - uiout->field_core_addr ("addr", gdbarch, pc);
>> + {
>> + uiout->field_core_addr ("addr", gdbarch, pc);
>> + if (get_frame_pc_masked (frame))
>> + uiout->field_string ("pac", " [PAC]");
>
> Hmm, I had suggested considering MI in the previous iteration, but
> I was just thinking of including the "[PAC]" text in the
> "addr" field. If we're adding a new field, then a few extra
> things need to be considered:
>
> #1 - documentation, both manual and NEWS should mention this new MI field.
>
> #2 - calling the attribute "pac" makes it architecture specific.
> I.e., to make use of it, a frontend will have to have Aarch64 awareness?
> Not sure that is a good thing.
>
> #3 - The MI attribute is called "pac", and its content is
> literally " [PAC]". I'd find that odd if I were a frontend author:
> the content is right aligned with a space, making doing anything with
> it other than appending it to the address text probably look odd,
> unless you bake in awareness of the attribute's text... If I saw
> an attribute named "pac", I'd expect it to be a boolean? At the
> least, the left space should not be part of the field, I think?
> Maybe we should rename the field to something else, like "addr_attr"
> for "address attributes" or something.
I hadn’t realised the implications doing that would have, and had assumed
you couldn’t add to a field that had already been used.
I had (prematurely) pushed the patch. Is this additional fix ok?
Alan.
Move backtrace PAC marker into addr field
PAC does not need its own field and should instead be part of
the addr field.
gdb/ChangeLog:
2019-08-08 Alan Hayward <alan.hayward@arm.com>
* stack.c (print_frame): Move PAC into addr field.
gdb/doc/ChangeLog:
2019-08-08 Alan Hayward <alan.hayward@arm.com>
* gdb.texinfo (AArch64 Pointer Authentication): Fix typo.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 7f8c0aff1c..c8ca757989 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -24395,7 +24395,7 @@ target process.
When @value{GDBN} is debugging the AArch64 architecture, and the program is
using the v8.3-A feature Pointer Authentication (PAC), then whenever the link
-register @code{$lr} is pointing to an PAC function it's value will be masked.
+register @code{$lr} is pointing to an PAC function its value will be masked.
When GDB prints a backtrace, any addresses that required unmasking will be
postfixed with the marker [PAC].
diff --git a/gdb/stack.c b/gdb/stack.c
index 0859815baf..c599caf51c 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1301,7 +1301,7 @@ print_frame (const frame_print_options &fp_opts,
{
uiout->field_core_addr ("addr", gdbarch, pc);
if (get_frame_pc_masked (frame))
- uiout->field_string ("pac", " [PAC]");
+ uiout->field_string ("addr", " [PAC]");
}
else
uiout->field_string ("addr", "<unavailable>",