This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug gdb/18149] New: The gdb cannot evaluate a C++ expression generated by the "-var-info-path-expression" for member of class.
- From: "mihail.nistor at freescale dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Thu, 19 Mar 2015 19:19:16 +0000
- Subject: [Bug gdb/18149] New: The gdb cannot evaluate a C++ expression generated by the "-var-info-path-expression" for member of class.
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=18149
Bug ID: 18149
Summary: The gdb cannot evaluate a C++ expression generated by
the "-var-info-path-expression" for member of class.
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: mihail.nistor at freescale dot com
Created attachment 8199
--> https://sourceware.org/bugzilla/attachment.cgi?id=8199&action=edit
an example, gdb and gcc information
The Eclipse CDT C++ uses the "-var-info-path-expression" command from âmiâ to
obtain the expression for a certain variable. After that the expression is
evaluated by using the "-data-evaluate-expression" command from mi and finally
the result will be displayed in the detail panel from Variable/Expression View.
Let's have an example:
class A
{
public:
A():_a(1) {}
private:
int _a;
};
class B: public A
{
public:
B(double b);
private:
double _b;
};
B::B(double b):A()
{
_b = b; // line 23 in test.cpp is here !
}
The reproducible steps are below:
1) The command line to compile the test case
g++ -O0 -g -o test.elf test.cpp
2) Start the gdb
gdb test.elf
3) Set a break-point at line 23 in the test.cpp file
(gdb) b test.cpp:23
4) run
(gdb) run
5) Create a variable for "this" and explore the member of class;
after that try to evaluate the expression obtained
from the "-var-info-path-expression" command
(gdb) interpreter-exec mi "-var-create --thread 1 --frame 0 - * this"
response from gdb == >
^done,name="var1",numchild="2",value="0x7fffffffe860",type="B *
const",thread-id="1",has_more="0"
(gdb) interpreter-exec mi "-var-list-children var1"
response from gdb == >
^done,numchild="2",children=[child={name="var1.A",exp="A",numchild="1",type="A",thread-id="1"},child={name="var1.private",exp="private",numchild="1",thread-id="1"}],has_more="0"
(gdb) interpreter-exec mi "-var-list-children var1.A"
response from gdb == >
^done,numchild="1",children=[child={name="var1.A.private",exp="private",numchild="1",thread-id="1"}],has_more="0"
(gdb) interpreter-exec mi "-var-info-path-expression var1.A"
response from gdb == > ^done,path_expr="(*(class A*) this)"
(gdb) print (*(class A*) this)
response from gdb == > This context has class, union or enum A, not a struct.
(gdb) print (*(struct A*) this)
response from gdb == > This context has class, union or enum A, not a struct.
(gdb) interpreter-exec mi '-data-evaluate-expression --thread 1 --frame 0
"(*(struct A*) this)"'
response from gdb == > ^error,msg="This context has class, union or enum A, not
a struct."
Here you can see the first type of C++ expression that cannot be evaluated!
(gdb) interpreter-exec mi "-var-list-children var1.A.private"
response from gdb == >
^done,numchild="1",children=[child={name="var1.A.private._a",exp="_a",numchild="0",type="int",thread-id="1"}],has_more="0"
(gdb) interpreter-exec mi "-var-list-children var1.A.private._a"
response from gdb == > ^done,numchild="0",has_more="0"
(gdb) interpreter-exec mi "-var-info-path-expression var1.A.private._a"
response from gdb == > ^done,path_expr="(((*(class A*) this))._a)"
(gdb) print (((*(class A*) this))._a)
response from gdb == > This context has class, union or enum A, not a struct.
(gdb) print (((*(struct A*) this))._a)
response from gdb == > This context has class, union or enum A, not a struct.
(gdb) interpreter-exec mi '-data-evaluate-expression --thread 1 --frame 0
"(((*(class A*) this))._a)"'
response from gdb == > ^error,msg="This context has class, union or enum A, not
a struct."
Here you can see the second type of C++ expression that cannot be evaluated!
--
You are receiving this mail because:
You are on the CC list for the bug.