This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFC: fix PR c++/9197
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 25 Mar 2013 11:23:16 -0600
- Subject: Re: RFC: fix PR c++/9197
- References: <87d2xcvjny dot fsf at fleche dot redhat dot com>
>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
Tom> This fixes PR c++/9197.
Here is what I am checking in.
I added some comments and I updated the test suite a bit... on Fedora
18, GCC now seems to emit debuginfo for all the constructors, causing
the earlier test additions to fail.
Built and regtested on x86-64 Fedora 18.
Tom
2013-03-08 Tom Tromey <tromey@redhat.com>
PR c++/9197:
* opencl-lang.c (evaluate_subexp_opencl) <STRUCTOP_STRUCT>: Use
value_struct_elt, not lookup_struct_elt_type.
* eval.c (evaluate_subexp_standard) <STRUCTOP_STRUCT,
STRUCTOP_PTR>: Use value_struct_elt, not lookup_struct_elt_type.
* expression.h (EVAL_AVOID_SIDE_EFFECTS): Update comment.
2013-03-08 Tom Tromey <tromey@redhat.com>
* gdb.cp/m-static.exp: Add constructor ptype tests.
* gdb.cp/m-static.cc (single_constructor): New class.
(main): Make instance of single_constructor.
gdb/ChangeLog | 9 +++++++++
gdb/eval.c | 30 ++++++------------------------
gdb/expression.h | 5 ++++-
gdb/opencl-lang.c | 13 ++++---------
gdb/testsuite/ChangeLog | 6 ++++++
gdb/testsuite/gdb.cp/m-static.cc | 9 +++++++++
gdb/testsuite/gdb.cp/m-static.exp | 10 ++++++++++
7 files changed, 48 insertions(+), 34 deletions(-)
diff --git a/gdb/eval.c b/gdb/eval.c
index 146840e..a91ba22 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1847,18 +1847,9 @@ evaluate_subexp_standard (struct type *expect_type,
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (lookup_struct_elt_type (value_type (arg1),
- &exp->elts[pc + 2].string,
- 0),
- lval_memory);
- else
- {
- struct value *temp = arg1;
-
- return value_struct_elt (&temp, NULL, &exp->elts[pc + 2].string,
- NULL, "structure");
- }
+ /* Also handle EVAL_AVOID_SIDE_EFFECTS. */
+ return value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string,
+ NULL, "structure");
case STRUCTOP_PTR:
tem = longest_to_int (exp->elts[pc + 1].longconst);
@@ -1908,18 +1899,9 @@ evaluate_subexp_standard (struct type *expect_type,
}
}
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (lookup_struct_elt_type (value_type (arg1),
- &exp->elts[pc + 2].string,
- 0),
- lval_memory);
- else
- {
- struct value *temp = arg1;
-
- return value_struct_elt (&temp, NULL, &exp->elts[pc + 2].string,
- NULL, "structure pointer");
- }
+ /* Also handle EVAL_AVOID_SIDE_EFFECTS. */
+ return value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string,
+ NULL, "structure pointer");
case STRUCTOP_MEMBER:
case STRUCTOP_MPTR:
diff --git a/gdb/expression.h b/gdb/expression.h
index 6b96b12..9252dd2 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -128,7 +128,10 @@ enum noside
type (inaccuracy: anything that is
listed as being in a register in
the function in which it was
- declared will be lval_register). */
+ declared will be lval_register).
+ Ideally this would not even read
+ target memory, but currently it
+ does in many situations. */
};
extern struct value *evaluate_subexp_standard
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 819a832..d7e66c4 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1035,15 +1035,10 @@ Cannot perform conditional operation on vectors with different sizes"));
}
else
{
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return
- value_zero (lookup_struct_elt_type
- (value_type (arg1),&exp->elts[pc + 2].string, 0),
- lval_memory);
- else
- return value_struct_elt (&arg1, NULL,
- &exp->elts[pc + 2].string, NULL,
- "structure");
+ /* Also handle EVAL_AVOID_SIDE_EFFECTS. */
+ return value_struct_elt (&arg1, NULL,
+ &exp->elts[pc + 2].string, NULL,
+ "structure");
}
}
default:
diff --git a/gdb/testsuite/gdb.cp/m-static.cc b/gdb/testsuite/gdb.cp/m-static.cc
index eadbdfc..cb871e8 100644
--- a/gdb/testsuite/gdb.cp/m-static.cc
+++ b/gdb/testsuite/gdb.cp/m-static.cc
@@ -31,6 +31,14 @@ public:
}
};
+// An object with a single constructor.
+class single_constructor
+{
+public:
+ single_constructor () { }
+ ~single_constructor () { }
+};
+
const bool gnu_obj_1::test;
const int gnu_obj_1::key1;
long gnu_obj_1::key2 = 77;
@@ -81,6 +89,7 @@ int main()
gnu_obj_2<long> test2(roman);
gnu_obj_3<long> test3(greek);
gnu_obj_4 test4;
+ single_constructor test5;
test4.dummy = test4.elsewhere;
test4.dummy = 0;
diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
index 5d1cb8b..b31922a 100644
--- a/gdb/testsuite/gdb.cp/m-static.exp
+++ b/gdb/testsuite/gdb.cp/m-static.exp
@@ -69,6 +69,16 @@ gdb_test "print test1.key2" "\\$\[0-9\]* = 77" "simple object, static long"
# simple object, static enum
gdb_test "print test1.value" "\\$\[0-9\]* = oriental" "simple object, static enum"
+gdb_test "print test5.single_constructor" \
+ { = {void \(single_constructor \* const\)} 0x[0-9a-f]+ <single_constructor::single_constructor\(\)>} \
+ "simple object instance, print constructor"
+gdb_test "ptype test5.single_constructor" \
+ {type = void \(single_constructor \* const\)} \
+ "simple object instance, ptype constructor"
+gdb_test "ptype single_constructor::single_constructor" \
+ {type = void \(single_constructor \* const\)} \
+ "simple object class, ptype constructor"
+
gdb_test "print test1.'~gnu_obj_1'" \
{ = {void \(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
"simple object instance, print quoted destructor"
--
1.8.1.4