From: Pedro Alves <palves@redhat.com>
To: Alan Hayward <Alan.Hayward@arm.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
nd <nd@arm.com>
Subject: Re: [PATCH] AArch64 pauth: Indicate unmasked addresses in backtrace
Date: Wed, 17 Jul 2019 14:44:00 -0000 [thread overview]
Message-ID: <a6f26bd1-7b3f-b6b2-1963-3638469268dd@redhat.com> (raw)
In-Reply-To: <68E9D3EF-D6A5-44C9-A87C-916EC6970435@arm.com>
On 7/17/19 2:35 PM, Alan Hayward wrote:
>
>> Once they learn something, often being concise
>> helps -- or in other words, once you learn what "<unmasked>" or "U" or whatever
>> is, and you're used to it, what would you rather see? What's the main
>> information you're looking for when staring at the backtrace? Thoughts
>> like that should guide the output too, IMO.
>
> PAC is the official abbreviation for the feature, so maybe :PAC works best.
Reading https://lwn.net/Articles/767695/ , I see mention of
Insert a PAC into a pointer
Strip a PAC from a pointer
Would ":PAC" make it read like the address _includes_ PAC bits?
>
> (gdb) bt
> 0 0x0000000000400490 in puts@plt ()
> 1 0x00000000004005dc in foo ("hello") at cbreak-lib.c:6
> 2 0x0000000000400604:PAC in bar () at cbreak-lib.c:12
> 3 0x0000000000400620:PAC in barbar () at cbreak.c:17
> 4 0x00000000004005b4 in main () at cbreak-3.c:10
>
>
> Some of my attempts at different representations:
> 2 0x0000000000400604* in bar () at cbreak-lib.c:12
> 2 0x0000000000400604! in bar () at cbreak-lib.c:12
> 2 0x0000000000400604U in bar () at cbreak-lib.c:122
> 2 0x0000000000400604:U in bar () at cbreak-lib.c:122
> 2 0x0000000000400604<U> in bar () at cbreak-lib.c:12
> 2 0x0000000000400604[U] in bar () at cbreak-lib.c:12
> 2 0x0000000000400604<M> in bar () at cbreak-lib.c:12
> 2 0x0000000000400604<P> in bar () at cbreak-lib.c:12
> 2 0x0000000000400604<PAC> in bar () at cbreak-lib.c:12
> 2 0x0000000000400604PAC in bar () at cbreak-lib.c:12
> 2 0x0000000000400604:PAC in bar () at cbreak-lib.c:12
> 2 0x0000000000400604,PAC in bar () at cbreak-lib.c:12
>
> I found a single character was too hidden. A single character or symbol was also
> a little confusing - my brain read U as unsigned, * as pointer, [] as an array.
>
> I also like ,PAC as it might be easier to add future extensions.
I'd go with either:
2 0x0000000000400604 (PAC) in bar () at cbreak-lib.c:12
2 0x0000000000400604 [PAC] in bar () at cbreak-lib.c:12
Not having the space may make it a little bit harder
to focus on low digits of the address.
> my brain read U as unsigned, * as pointer, [] as an array.
If you make it like 0x0000000000400604U, then I can see that.
But not so much with:
2 0x0000000000400604 [U] in bar () at cbreak-lib.c:12
You don't have to use a single letter, though:
2 0x0000000000400604 [UN] in bar () at cbreak-lib.c:12
[] seems natural as a way to group some flags/properties to me.
We already use it here for example:
(top-gdb) info registers $eflags
eflags 0x206 [ PF IF ]
I guess I'm saying that it depends on context, and I wouldn't
be worried with [] being confused with C arrays. Afterall,
< and > also have meaning in C/C++... More than one meaning,
actually. :-)
>>> /* If address signing is enabled, mask off the signature bits from ADDR, using
>>> - the register values in THIS_FRAME. */
>>> + the register values in THIS_FRAME. IS_LR indicates if ADDR is from the link
>>> + register for the current frame. */
>>>
>>> static CORE_ADDR
>>> aarch64_frame_unmask_address (struct gdbarch_tdep *tdep,
>>> - struct frame_info *this_frame,
>>> - CORE_ADDR addr)
>>> + struct frame_info *this_frame, CORE_ADDR addr,
>>> + bool is_lr = true)
>>
>> I didn't see anywhere in the patch that passes is_lr == true?
>>
>> Looks like the patch is a nop?
>
> Yes, the is_lr check will always be true.
> The function is designed to be for any address, but right now itâs only used for
> the link register. But, I didnât want someone in the future using it as a generic
> address unmask function and it causing the link register to be marked.
>
> An other option was to add a warning to the comment block above the function. Or
> do the lr marking in the caller (but then that adds extra logic).
>
> Maybe the better option would be to rename the function to
> aarch64_frame_unmask_lr_address.
Yes, I think that renaming is the best option. People remove
unnecessary parameters all the time, when they notice some
parameter isn't really necessary. If someone needs a more
generic aarch64_frame_unmask_address for all kinds of
addresses, they can always factor out a new aarch64_frame_unmask_address
that looks like today's version, and
make aarch64_frame_unmask_lr_address call it + mark the frame.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2019-07-17 14:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-17 8:14 Alan Hayward
2019-07-17 11:15 ` Pedro Alves
2019-07-17 13:36 ` Alan Hayward
2019-07-17 14:44 ` Pedro Alves [this message]
2019-07-17 15:02 ` Simon Marchi
2019-07-17 15:18 ` Pedro Alves
2019-07-17 16:07 ` Alan Hayward
2019-07-17 16:41 ` Pedro Alves
2019-07-17 17:34 ` Alan Hayward
2019-07-18 13:48 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a6f26bd1-7b3f-b6b2-1963-3638469268dd@redhat.com \
--to=palves@redhat.com \
--cc=Alan.Hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=nd@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox