Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Weimin Pan <weimin.pan@oracle.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH v2 PR gdb/16841] virtual inheritance via typedef cannot find base
Date: Fri, 07 Sep 2018 22:04:00 -0000	[thread overview]
Message-ID: <19388904-5ebe-7240-1352-35a348087825@ericsson.com> (raw)
In-Reply-To: <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


  reply	other threads:[~2018-09-07 22:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-24  0:21 Weimin Pan
2018-09-07 21:26 ` Simon Marchi
2018-09-07 22:04   ` Simon Marchi [this message]
2018-09-08  0:12   ` Weimin Pan
2018-09-08  8:51     ` Simon Marchi
2018-09-07 21:42 ` Tom Tromey
2018-09-08  0:19   ` Weimin Pan

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=19388904-5ebe-7240-1352-35a348087825@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=weimin.pan@oracle.com \
    /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