From: Felix Willgerodt via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org, felix.willgerodt@intel.com
Subject: [PATCH 1/2] gdb: Allow address space qualifier parsing in C++.
Date: Fri, 26 Mar 2021 15:26:08 +0100 [thread overview]
Message-ID: <20210326142609.245016-2-felix.willgerodt@intel.com> (raw)
In-Reply-To: <20210326142609.245016-1-felix.willgerodt@intel.com>
The goal of this patch is to allow target dependent address space qualifiers
in the C++ expression parser. This can be useful for memory examination on
targets that actually use different address spaces in hardware without
having to deep-dive into implementation details of the whole solution.
GDB uses the @ symbol to parse address space qualifiers. The only current
user that I am aware of is the __flash support for avr, which was added in
"Add support for the __flash qualifier on AVR"
(487d975399dfcb2bb2f0998a7d12bd62acdd9fa1) and only works for C.
One use-case of the AVR patch is:
~~~
const __flash char data_in_flash = 0xab;
int
main (void)
{
const __flash char *pointer_to_flash = &data_in_flash;
}
~~~
~~~
(gdb) print pointer_to_flash
$1 = 0x1e8 <data_in_flash> "\253"
(gdb) print/x *pointer_to_flash
$2 = 0xab
(gdb) x/x pointer_to_flash
0x1e8 <data_in_flash>: 0xXXXXXXab
(gdb)
(gdb) p/x *(char* @flash) pointer_to_flash
$3 = 0xab
~~~
I want to enable a similar usage of e.g. @local in C++.
Before this patch (using "set debug parser on"):
~~~
(gdb) p *(int* @local) 0x1234
(...)
Reading a token: Next token is token '@' ()
Shifting token '@' ()
Entering state 46
Reading a token: Next token is token UNKNOWN_CPP_NAME (ssym<name=local, sym=(null), field_of_this=0>)
A syntax error in expression, near `local) &x'.
~~~
After:
~~~
(gdb) p *(int* @local) 0x1234
(...)
Reading a token: Next token is token '@' ()
Shifting token '@' ()
Entering state 46
Reading a token: Next token is token UNKNOWN_CPP_NAME (ssym<name=local, sym=(null), field_of_this=0>)
Shifting token UNKNOWN_CPP_NAME (ssym<name=local, sym=(null), field_of_this=0>)
Entering state 121
Reducing stack by rule 278 (line 1773):
$1 = token UNKNOWN_CPP_NAME (ssym<name=local, sym=(null), field_of_this=0>)
-> $$ = nterm name ()
Stack now 0 49 52 76 222 337 46
Entering state 167
Reducing stack by rule 131 (line 1225):
$1 = token '@' ()
$2 = nterm name ()
Unknown address space specifier: "local"
~~~
The "Unknown address space qualifier" is the right behaviour, as I ran this
on a target that doesn't have multiple address spaces and therefore obviously
no support for such qualifiers.
gdb/ChangeLog:
2021-03-19 Felix Willgerodt <felix.willgerodt@intel.com>
* c-exp.y (single_qualifier): Handle UNKNOWN_CPP_NAME.
---
gdb/c-exp.y | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index c0e4b494f3d..e2ceb2057a1 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1266,6 +1266,11 @@ single_qualifier:
cpstate->type_stack.insert (pstate,
copy_name ($2.stoken).c_str ());
}
+ | '@' UNKNOWN_CPP_NAME
+ {
+ cpstate->type_stack.insert (pstate,
+ copy_name ($2.stoken).c_str ());
+ }
;
qualifier_seq_noopt:
--
2.25.4
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
next prev parent reply other threads:[~2021-03-26 14:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-26 14:26 [PATCH 0/2] Expression parser fixes for address space qualifiers Felix Willgerodt via Gdb-patches
2021-03-26 14:26 ` Felix Willgerodt via Gdb-patches [this message]
2021-04-01 18:16 ` [PATCH 1/2] gdb: Allow address space qualifier parsing in C++ Tom Tromey
2021-04-02 12:33 ` Willgerodt, Felix via Gdb-patches
2021-04-02 12:47 ` Luis Machado via Gdb-patches
2021-04-02 16:48 ` Simon Marchi via Gdb-patches
2021-04-02 16:51 ` Simon Marchi via Gdb-patches
2021-04-05 2:32 ` Simon Marchi via Gdb-patches
2021-04-06 9:30 ` Willgerodt, Felix via Gdb-patches
2021-03-26 14:26 ` [PATCH 2/2] gdb: Fix reduce/reduce conflicts for qualifier_seq_noopt in the C parser Felix Willgerodt via Gdb-patches
2021-04-01 18:20 ` Tom Tromey
2021-04-02 12:33 ` Willgerodt, Felix via Gdb-patches
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=20210326142609.245016-2-felix.willgerodt@intel.com \
--to=gdb-patches@sourceware.org \
--cc=felix.willgerodt@intel.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