OSDN Git Service

* gdb.cp/mb-ctor.exp: Add multi-line source statement test.
authordevans <devans>
Wed, 29 Apr 2009 22:45:10 +0000 (22:45 +0000)
committerdevans <devans>
Wed, 29 Apr 2009 22:45:10 +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 11e4815..8e8744b 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 48a8c5f..c299260 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 dffc78a..c4ef64c 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 5a507df..3763525 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 8ff5649..8de8b92 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 11c0113..22d1116 100644 (file)
@@ -23,7 +23,7 @@
 int
 afn ()
 {
-  return foo (0);
+  return foo (0) + multi_line_foo (0);
 }
 
 int
index 7c44f3f..8dea2a4 100644 (file)
@@ -21,5 +21,5 @@
 int
 bfn ()
 {
-  return foo (1);
+  return foo (1) + multi_line_foo (1);
 }
index a7d4e2e..649d7ed 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 e32dc52..5f93228 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>"