From: Marc Khouzam <marc.khouzam@ericsson.com>
To: "'gdb-patches@sourceware.org'" <gdb-patches@sourceware.org>
Subject: [RFC][patch] Tweak output of -var-info-path-expression
Date: Thu, 09 Sep 2010 20:01:00 -0000 [thread overview]
Message-ID: <F7CE05678329534C957159168FA70DEC5718DBD843@EUSAACMS0703.eamcs.ericsson.se> (raw)
Hi,
Bug 11912 (http://sourceware.org/bugzilla/show_bug.cgi?id=11912)
is causing a syntax error when casting to a class in
certain cases. (see small session below for example)
In cases as 'print (*(myClass*) this)'
the parser is confusing the class name 'myClass' with its
constructor name (if it is defined) and complains that the
cast is bad.
In the bugzilla, the work-around is to use the 'class' keyword
'print (*(class myClass*) this)'
to tell the parser we want the class and not the constructor.
That works.
The problem is that the output of -var-info-path-expression
does not use that workaround and therefore can give an expression
that causes a syntax error.
I'm suggesting to add the workaround to the output of
-var-info-path-expression when it casts.
It would be nicer to fix the parser problem but that
seems much more complicated (at least for me).
I've attached a patch in hopes of comments but I have to
admit that the implications of this change are not clear to me.
Thanks for any feedback
Marc
2010-09-08 Marc Khouzam <marc.khouzam@ericsson.com>
* varobj.c (cplus_describe_child): Add `class'
keyword to avoid confusion with constructor name.
### Eclipse Workspace Patch 1.0
#P src
Index: gdb/varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.160
diff -u -r1.160 varobj.c
--- gdb/varobj.c 19 Aug 2010 07:34:27 -0000 1.160
+++ gdb/varobj.c 9 Sep 2010 16:07:36 -0000
@@ -3314,8 +3314,14 @@
will create an lvalue, for all appearences, so we don't
need to use more fancy:
*(Base1*)(&d)
- construct. */
- *cfull_expression = xstrprintf ("(%s(%s%s) %s)",
+ construct.
+
+ When we are in the scope of the base class or of one
+ of its children, the type field name will be interpreted
+ as a constructor, if it exists. Therefore, we must
+ indicate that the name is a class name by using the
+ 'class' keyword. I think 'struct' or '::' would also work. */
+ *cfull_expression = xstrprintf ("(%s(class %s%s) %s)",
ptr,
TYPE_FIELD_NAME (type, index),
ptr,
Session showing problem:
> gdb.7.3 a.out
GNU gdb (GDB) 7.2.50.20100831-cvs
(gdb) l 1
1 class bar {};
2 class foo: bar {
3 public:
4 foo() {} // Comment this line to make things work
5 void test() { return; }
6 // foo *g;
7 };
8
9 int main(void)
10 {
11 foo f;
12 f.test();
13 return 0;
14 }
(gdb) b 5
Breakpoint 1 at 0x8048457: file base.cc, line 5.
(gdb) r
Starting program: /local/lmckhou/testing/a.out
Breakpoint 1, foo::test (this=0xbfffbbf3) at base.cc:5
5 void test() { return; }
(gdb) interpreter-exec mi "-var-create - * this"
^done,name="var1",numchild="1",value="0xbfffbbf3",type="foo * const",thread-id="1",has_more="0"
(gdb) interpreter-exec mi "-var-list-children var1"
^done,numchild="1",children=[child={name="var1.bar",exp="bar",numchild="0",type="bar",thread-id="1"}],has_more="0"
(gdb) interpreter-exec mi "-var-info-path-expression var1.bar"
^done,path_expr="(*(bar*) this)"
(gdb) interpreter-exec mi '-data-evaluate-expression "(*(bar*) this)"'
^error,msg="A syntax error in expression, near `) this)'."
(gdb) interpreter-exec mi '-data-evaluate-expression "(*(class bar*) this)"'
^done,value="{<No data fields>}"
next reply other threads:[~2010-09-09 19:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-09 20:01 Marc Khouzam [this message]
2010-09-11 17: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=F7CE05678329534C957159168FA70DEC5718DBD843@EUSAACMS0703.eamcs.ericsson.se \
--to=marc.khouzam@ericsson.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