public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: Fix reduce/reduce conflicts for qualifier_seq_noopt in the C parser.
@ 2021-04-20 6:50 Felix Willgerodt
0 siblings, 0 replies; only message in thread
From: Felix Willgerodt @ 2021-04-20 6:50 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=184dcd81c7972c3fd3557ec4a04064529ee3ca8d
commit 184dcd81c7972c3fd3557ec4a04064529ee3ca8d
Author: Felix Willgerodt <felix.willgerodt@intel.com>
Date: Tue Apr 20 08:44:17 2021 +0200
gdb: Fix reduce/reduce conflicts for qualifier_seq_noopt in the C parser.
This fixes a problem with GDB's address space qualifier parsing. GDB uses
'@' as a way to express an address space in expression evaluation. This can
currently lead to a crash for "Add support for the __flash qualifier on AVR"
(487d975399dfcb2bb2f0998a7d12bd62acdd9fa1), the only user I am aware of.
Program:
~~~
const __flash char data_in_flash = 0xab;
int
main (void)
{
const __flash char *pointer_to_flash = &data_in_flash;
}
~~~
Before:
~~~
(gdb) p data_in_flash
$1 = -85 '\253'
(gdb) p *(const char * @flash) pointer_to_flash
$2 = -85 '\253'
(gdb) p *(@flash const char *) pointer_to_flash
type-stack.c:201: internal-error: type* type_stack::follow_types(type*): unrecognized tp_ value in follow_types
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
~~~
After:
~~~
(gdb) p data_in_flash
$1 = -85 '\253'
(gdb) p *(const char *) pointer_to_flash
$2 = 0 '\000'
(gdb) p *(const char * @flash) pointer_to_flash
$3 = -85 '\253'
(gdb) p *(@flash const char *) pointer_to_flash
$4 = 0 '\000'
(gdb)
~~~
Note that how the binding of this qualifier is interpreted and resolved for an
address/pointer is target specific. Hence only the prepended qualifier works
for AVR, even if it seems syntactically incorrect. I won't change this for
AVR, as I am not familiar with that target.
Bison now also complains about less conflicts:
Before:
YACC c-exp.c
gdb/gdb/c-exp.y: warning: 153 shift/reduce conflicts [-Wconflicts-sr]
gdb/gdb/c-exp.y: warning: 70 reduce/reduce conflicts [-Wconflicts-rr]
After:
YACC c-exp.c
gdb/gdb/c-exp.y: warning: 60 shift/reduce conflicts [-Wconflicts-sr]
gdb/gdb/c-exp.y: warning: 69 reduce/reduce conflicts [-Wconflicts-rr]
gdb/ChangeLog:
2021-04-20 Felix Willgerodt <felix.willgerodt@intel.com>
* c-exp.y (qualifier_seq_noopt): Replace qualifier_seq with
qualifier_seq_noopt.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/c-exp.y | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8692c0f8c43..a601300e955 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-20 Felix Willgerodt <felix.willgerodt@intel.com>
+
+ * c-exp.y (qualifier_seq_noopt): Replace qualifier_seq with
+ qualifier_seq_noopt.
+
2021-04-20 Felix Willgerodt <felix.willgerodt@intel.com>
* c-exp.y (single_qualifier): Handle UNKNOWN_CPP_NAME.
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 3e416f4e2c7..93b10f05b7d 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1276,7 +1276,7 @@ single_qualifier:
qualifier_seq_noopt:
single_qualifier
- | qualifier_seq single_qualifier
+ | qualifier_seq_noopt single_qualifier
;
qualifier_seq:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-20 6:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20 6:50 [binutils-gdb] gdb: Fix reduce/reduce conflicts for qualifier_seq_noopt in the C parser Felix Willgerodt
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).