This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2 PR gdb/16841] virtual inheritance via typedef cannot find base
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Weimin Pan <weimin dot pan at oracle dot com>, <gdb-patches at sourceware dot org>
- Date: Fri, 7 Sep 2018 23:04:11 +0100
- Subject: Re: [PATCH v2 PR gdb/16841] virtual inheritance via typedef cannot find base
- References: <1535067835-60808-1-git-send-email-weimin.pan@oracle.com> <4958cf6a-a9ab-9448-0017-a4317d5a09ad@ericsson.com>
Here's a suggestion of modifications for the test, implementing what
I mentioned. Feel free to change it as you wish.
>From 70cc479b7465b119c2aacd092167ebb5c60dd70b Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Fri, 7 Sep 2018 23:00:28 +0100
Subject: [PATCH] Modifications to the test
---
gdb/testsuite/gdb.cp/virtbase2.cc | 7 +++-
gdb/testsuite/gdb.cp/virtbase2.exp | 68 +++++++++++++++++++++++++++-----------
2 files changed, 54 insertions(+), 21 deletions(-)
diff --git a/gdb/testsuite/gdb.cp/virtbase2.cc b/gdb/testsuite/gdb.cp/virtbase2.cc
index 4f7631e..4620ef5 100644
--- a/gdb/testsuite/gdb.cp/virtbase2.cc
+++ b/gdb/testsuite/gdb.cp/virtbase2.cc
@@ -1,4 +1,9 @@
-struct base {
+struct superbase {
+ int x;
+ superbase () : x(22) {}
+};
+
+struct base : superbase {
int i; double d;
base() : i(55), d(6.6) {}
};
diff --git a/gdb/testsuite/gdb.cp/virtbase2.exp b/gdb/testsuite/gdb.cp/virtbase2.exp
index c29ff1c..854f81e 100644
--- a/gdb/testsuite/gdb.cp/virtbase2.exp
+++ b/gdb/testsuite/gdb.cp/virtbase2.exp
@@ -28,23 +28,51 @@ if {![runto_main]} then {
continue
}
-gdb_breakpoint "derived::func_d"
-gdb_continue_to_breakpoint "continue to derived::func_d"
-gdb_test "print i" " = 55" "i in base class"
-gdb_test "print derived::i" " = 55" "i in base class"
-gdb_test "print derived::base::i" " = 55" "i in base class"
-gdb_test "print base::i" " = 55" "i in base class"
-gdb_test "print d" " = 6.5999999999999996" "d in base class"
-gdb_test "print derived::d" " = 6.5999999999999996" "d in base class"
-gdb_test "print derived::base::d" " = 6.5999999999999996" "d in base class"
-gdb_test "print base::d" " = 6.5999999999999996" "d in base class"
-gdb_breakpoint "foo::func_f"
-gdb_continue_to_breakpoint "continue to foo::func_f"
-gdb_test "print i" " = 55" "i in base class"
-gdb_test "print derived::i" " = 55" "i in base class"
-gdb_test "print derived::base::i" " = 55" "i in base class"
-gdb_test "print base::i" " = 55" "i in base class"
-gdb_test "print d" " = 6.5999999999999996" "d in base class"
-gdb_test "print derived::d" " = 6.5999999999999996" "d in base class"
-gdb_test "print derived::base::d" " = 6.5999999999999996" "d in base class"
-gdb_test "print base::d" " = 6.5999999999999996" "d in base class"
+proc make_scope_list { scopes } {
+ if { [llength $scopes] == 1 } {
+ return [list "" "${scopes}::"]
+ }
+
+ # Pop the first element, save the first scope.
+ set this_scope [lindex $scopes 0]
+ set scopes [lreplace $scopes 0 0]
+
+ set child_result [make_scope_list $scopes]
+
+ # Add a copy of the child's result without this scope...
+ set result $child_result
+
+ # ... and a copy of the child's result with this scope.
+ foreach r $child_result {
+ lappend result "${this_scope}::$r"
+ }
+
+ return $result
+}
+
+proc test_variables_in_base { scopes } {
+ foreach scope [make_scope_list $scopes] {
+ gdb_test "print ${scope}i" " = 55"
+ gdb_test "print ${scope}d" " = 6.5999999999999996"
+ }
+}
+
+proc test_variables_in_superbase { scopes } {
+ foreach scope [make_scope_list $scopes] {
+ gdb_test "print ${scope}x" " = 22"
+ }
+}
+
+with_test_prefix "derived::func_d" {
+ gdb_breakpoint "derived::func_d"
+ gdb_continue_to_breakpoint "continue to derived::func_d"
+ test_variables_in_base {derived base}
+ test_variables_in_superbase {derived base superbase}
+}
+
+with_test_prefix "foo::func_f" {
+ gdb_breakpoint "foo::func_f"
+ gdb_continue_to_breakpoint "continue to foo::func_f"
+ test_variables_in_base {foo derived base}
+ test_variables_in_superbase {foo derived base superbase}
+}
--
2.7.4