From: Tom Tromey <tom@tromey.com>
To: Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org>
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: Re: [PATCH 2/2] gdb: fix crash when getting the value of a label symbol
Date: Wed, 14 Dec 2022 09:17:47 -0700 [thread overview]
Message-ID: <87cz8mdkno.fsf@tromey.com> (raw)
In-Reply-To: <9ec9a8db6a02169c4b18248f131715c54811550a.1671013621.git.aburgess@redhat.com> (Andrew Burgess via Gdb-patches's message of "Wed, 14 Dec 2022 10:28:33 +0000")
>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:
Andrew> (gdb) p some_label
Andrew> No symbol "some_label" in current context.
...
Andrew> This all seems a little strange to me, it feels like asking about a
Andrew> goto label would not be an unreasonable thing for a user to do.
The issue is that that in C, there's no way to refer to a label in an
expression, so we'd need an extension of some kind. GNU C has the "&&"
address-of-label extension, I suppose we could do that:
(info "(gcc) Labels as Values")
Andrew> The problem is that label symbols are created using the
Andrew> builtin_core_addr type, which is a pure integer type.
Andrew> The fix I propose is to change the type used for the value of the
Andrew> label symbol, instead of using builtin_core_addr type, we could use
Andrew> builtin_func_ptr, after this calling store_typed_address is fine (the
Andrew> call to store_typed_address is done indirectly through
Andrew> value_from_pointer).
In the GNU C extension, a label value uses "void *" as the type.
Unclear to me which is preferable, or if users are even likely to notice
or care if we decide to change it (like, when/if we implement the
extension).
Anyway the patch looks fine to me.
Tom
next prev parent reply other threads:[~2022-12-14 16:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 10:28 [PATCH 0/2] Fix crash when accessing symbol value from Python API Andrew Burgess
2022-12-14 10:28 ` [PATCH 1/2] gdb: use gdb_assert not internal_error Andrew Burgess
2022-12-14 16:07 ` Tom Tromey
2022-12-15 13:10 ` Andrew Burgess
2022-12-14 10:28 ` [PATCH 2/2] gdb: fix crash when getting the value of a label symbol Andrew Burgess
2022-12-14 16:17 ` Tom Tromey [this message]
2022-12-15 13:25 ` Andrew Burgess
2022-12-15 19:28 ` 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=87cz8mdkno.fsf@tromey.com \
--to=tom@tromey.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).