gdb/testsuite: Expand gdb.cp/mb-ctor.exp to test dynamic allocation
authorBruno Larsen <blarsen@redhat.com>
Tue, 7 Jun 2022 19:07:07 +0000 (16:07 -0300)
committerBruno Larsen <blarsen@redhat.com>
Thu, 30 Jun 2022 17:13:08 +0000 (14:13 -0300)
When testing GDB's ability to stop in constructors, gdb.cp/mb-ctor.exp
only tested objects allocated on the stack. This commit adds a couple of
dynamic allocations and tests if GDB can stop in it as well.

gdb/testsuite/gdb.cp/mb-ctor.cc
gdb/testsuite/gdb.cp/mb-ctor.exp

index c54b4fece486927d379dac2458953c29d9d7b57a..faa59f16459d0c38b8e4b51b4cd8978d90d21ae5 100644 (file)
@@ -64,5 +64,11 @@ int main()
      DeeplyDerived's ctor.  */
   DeeplyDerived dd(15);
 
+  Derived *dyn_d = new Derived (24);
+  DeeplyDerived *dyn_dd = new DeeplyDerived (42);
+
+  delete dyn_d;
+  delete dyn_dd;
+
   return 0;
 }
index f5f5d9143d1a4a2a22bf5f00fc84d9791e80ab99..5a3c0a4a90f0efca274ba52145c43e956aa7247d 100644 (file)
@@ -55,6 +55,24 @@ gdb_test "continue" \
 
 gdb_continue_to_breakpoint "set breakpoint here, second time" ".* breakpoint here"
 
+gdb_test "continue" \
+    ".*Breakpoint.*Derived.*i=24.*" \
+    "run to breakpoint 1 dynamic v1"
+
+gdb_continue_to_breakpoint "set breakpoint here, first dynamic time"\
+    ".* breakpoint here"
+
+gdb_test "continue" \
+    ".*Breakpoint.*Derived.*i=42.*" \
+    "run to breakpoint 1 dynamic v2"
+
+gdb_continue_to_breakpoint "set breakpoint here, second dynamic time"\
+    ".* breakpoint here"
+
+gdb_test "continue" ".*Breakpoint.*~Derived.*" "Run to dynamic destructor v1"
+
+gdb_test "continue" ".*Breakpoint.*~Derived.*" "Run to dynamic destructor v2"
+
 gdb_test "continue" \
     ".*Breakpoint.*~Derived.*" \
     "run to breakpoint 3 v1"