* gdb.cp/mb-ctor.exp: Add multi-line source statement test.
authorDoug Evans <dje@google.com>
Wed, 29 Apr 2009 22:45:11 +0000 (22:45 +0000)
committerDoug Evans <dje@google.com>
Wed, 29 Apr 2009 22:45:11 +0000 (22:45 +0000)
* gdb.cp/mb-ctor.cc: Ditto.
* gdb.cp/mb-inline.exp: Add multi-line source statement test.
* gdb.cp/mb-inline.h (multi_line_foo): New function.
* gdb.cp/mb-inline1.cc: Call it.
* gdb.cp/mb-inline2.cc: Ditto.
* gdb.cp/mb-templates.exp: Add multi-line source statement test.
* gdb.cp/mb-templates.cc (multi_line_foo): New template.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/mb-ctor.cc
gdb/testsuite/gdb.cp/mb-ctor.exp
gdb/testsuite/gdb.cp/mb-inline.exp
gdb/testsuite/gdb.cp/mb-inline.h
gdb/testsuite/gdb.cp/mb-inline1.cc
gdb/testsuite/gdb.cp/mb-inline2.cc
gdb/testsuite/gdb.cp/mb-templates.cc
gdb/testsuite/gdb.cp/mb-templates.exp

index 11e481592e040d3c77e4112bd6fe6480324fc0c7..8e8744b99f886fc15febd8d03b9f0c6c7ae47ebc 100644 (file)
@@ -1,3 +1,14 @@
+2009-04-29  Doug Evans  <dje@google.com>
+
+       * gdb.cp/mb-ctor.exp: Add multi-line source statement test.
+       * gdb.cp/mb-ctor.cc: Ditto.
+       * gdb.cp/mb-inline.exp: Add multi-line source statement test.
+       * gdb.cp/mb-inline.h (multi_line_foo): New function.
+       * gdb.cp/mb-inline1.cc: Call it.
+       * gdb.cp/mb-inline2.cc: Ditto.
+       * gdb.cp/mb-templates.exp: Add multi-line source statement test.
+       * gdb.cp/mb-templates.cc (multi_line_foo): New template.
+
 2009-04-29  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * gdb.base/macscp.exp: New `options' parameter `-DFROM_COMMANDLINE'.
index 48a8c5f1af73eef3cb28cee5f3b43a95ad87978f..c2992601a163062d4e1d1982d3b8f0a7a86d8f10 100644 (file)
@@ -28,11 +28,19 @@ public:
   ~Derived();
 private:
   int i;
+  int i2;
 };
 
 Derived::Derived(int i) : Base(i)
 {
   this->i = i;
+  /* The next statement is spread over two lines on purpose to exercise
+     a bug where breakpoints set on all but the last line of a statement
+     would not get multiple breakpoints.
+     The second line's text for gdb_get_line_number is a subset of the
+     first line so that we don't care which line gdb prints when it stops.  */
+  this->i2 = // set breakpoint here
+    i; // breakpoint here
 }
 
 Derived::~Derived()
index dffc78ad82d82c3eb52ea73acf2fe379bcdebb49..c4ef64cc6901cc124a92f0afd47904ce43e1f989 100644 (file)
@@ -43,6 +43,11 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
+if ![runto_main] then {
+    perror "couldn't run to breakpoint"
+    continue
+}
+
 # Set a breakpoint with multiple locations
 # and a condition.
 
@@ -50,34 +55,31 @@ gdb_test "break 'Derived::Derived(int)'" \
     "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
     "set-breakpoint at ctor"
 
+gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
+
 gdb_test "break 'Derived::~Derived()'" \
     "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
     "set-breakpoint at dtor"
 
-gdb_run_cmd
-gdb_expect {
-    -re "Breakpoint \[0-9\]+,.*Derived.*i=7.*$gdb_prompt $" {
-       pass "run to breakpoint"
-    }
-    -re "$gdb_prompt $" {
-       fail "run to breakpoint"
-    }
-    timeout {
-       fail "run to breakpoint (timeout)"
-    }
-}
+gdb_test "continue" \
+    ".*Breakpoint.*Derived.*i=7.*" \
+    "run to breakpoint 1 v1"
+
+gdb_continue_to_breakpoint "set breakpoint here" ".* breakpoint here"
 
 gdb_test "continue" \
     ".*Breakpoint.*Derived.*i=15.*" \
-    "run to breakpoint 2"
+    "run to breakpoint 1 v2"
+
+gdb_continue_to_breakpoint "set breakpoint here" ".* breakpoint here"
 
 gdb_test "continue" \
     ".*Breakpoint.*~Derived.*" \
-    "run to breakpoint 3"
+    "run to breakpoint 3 v1"
 
 gdb_test "continue" \
     ".*Breakpoint.*~Derived.*" \
-    "run to breakpoint 4"
+    "run to breakpoint 3 v2"
 
 gdb_test "continue" \
     ".*exited normally.*" \
index 5a507dfd40ed645dc8a8faca94109022f14f32d0..3763525d7d1d2ecd964517e726abe9ba72b75790 100644 (file)
@@ -106,3 +106,25 @@ gdb_expect {
 gdb_test "continue" \
     ".*Program exited normally.*" \
     "continue with disabled breakpoint 1.2"
+
+# Make sure we can set a breakpoint on a source statement that spans
+# multiple lines.
+
+delete_breakpoints
+
+set bp_location [gdb_get_line_number "set multi-line breakpoint here" $hdrfile]
+
+if { ![runto_main] } {
+    fail "Can't run to main for multi_line_foo tests."
+    return 0
+}
+
+gdb_test "break $hdrfile:$bp_location" \
+    "Breakpoint.*at.* file .*$hdrfile, line.*\\(2 locations\\).*" \
+    "set multi_line_foo breakpoint"
+gdb_test "continue" \
+    ".*Breakpoint.*multi_line_foo \\(i=0\\).*" \
+    "run to multi_line_foo breakpoint 4 afn"
+gdb_test "continue" \
+    ".*Breakpoint.*multi_line_foo \\(i=1\\).*" \
+    "run to multi_line_foo breakpoint 4 bfn"
index 8ff5649a3935efc706f917469c0a40676952286f..8de8b92342c67b93ee357ce23ec63e0026e93c2b 100644 (file)
@@ -26,5 +26,12 @@ foo (int i)
   return i; // set breakpoint here
 }
 
+static int
+multi_line_foo (int i)
+{
+  return // set multi-line breakpoint here
+    i;
+}
+
 extern int afn ();
 extern int bfn ();
index 11c01139045642ad961bad3d1956304d546d2002..22d11161fc4b83ce513db5c5b03a37b5d952a69f 100644 (file)
@@ -23,7 +23,7 @@
 int
 afn ()
 {
-  return foo (0);
+  return foo (0) + multi_line_foo (0);
 }
 
 int
index 7c44f3ff2ff4b1ac9db82dc22d6c0480a7183a14..8dea2a4a33b4f53b6da45bf420bf39ac21f69275 100644 (file)
@@ -21,5 +21,5 @@
 int
 bfn ()
 {
-  return foo (1);
+  return foo (1) + multi_line_foo (1);
 }
index a7d4e2e7138d1fe250f2816d7d077ddda86ee275..649d7eda69fbaa4e2aa1ca3fcf8f15f553ebc7b0 100644 (file)
@@ -8,6 +8,13 @@ void foo(T i)
   std::cout << "hi\n"; // set breakpoint here
 }
 
+template<class T>
+void multi_line_foo(T i)
+{
+  std::cout // set multi-line breakpoint here
+    << "hi\n";
+}
+
 int main()
 {
     foo<int>(0);
@@ -16,4 +23,9 @@ int main()
     foo<double>(1);
     foo<int>(2);
     foo<double>(2);
+
+    multi_line_foo<int>(0);
+    multi_line_foo<double>(0);
+
+    return 0;
 }
index e32dc52dcbefe120f8ac671f87b668e5621193f6..5f93228d99d66d5121bc789f46422830a5e85c5e 100644 (file)
@@ -165,3 +165,25 @@ gdb_test "continue" \
     ".*Breakpoint.*foo<int> \\(i=1\\).*" \
     "instantiation: run to breakpoint 2"
 
+
+# Make sure we can set a breakpoint on a source statement that spans
+# multiple lines.
+
+delete_breakpoints
+
+set bp_location [gdb_get_line_number "set multi-line breakpoint here"]
+
+if { ![runto_main] } {
+    fail "Can't run to main for multi_line_foo tests."
+    return 0
+}
+
+gdb_test "break $srcfile:$bp_location" \
+    "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
+    "set multi_line_foo breakpoint"
+gdb_test "continue" \
+    ".*Breakpoint.*multi_line_foo<int> \\(i=0\\).*" \
+    "run to multi_line_foo breakpoint 2 <int>"
+gdb_test "continue" \
+    ".*Breakpoint.*multi_line_foo<double> \\(i=0\\).*" \
+    "run to multi_line_foo breakpoint 2 <double>"