From: Doug Evans Date: Wed, 29 Apr 2009 22:45:11 +0000 (+0000) Subject: * gdb.cp/mb-ctor.exp: Add multi-line source statement test. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9ab4e7442222be784ac8ffbb33631f7172acf7ad;p=binutils-gdb.git * 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. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 11e481592e0..8e8744b99f8 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2009-04-29 Doug Evans + + * 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 * gdb.base/macscp.exp: New `options' parameter `-DFROM_COMMANDLINE'. diff --git a/gdb/testsuite/gdb.cp/mb-ctor.cc b/gdb/testsuite/gdb.cp/mb-ctor.cc index 48a8c5f1af7..c2992601a16 100644 --- a/gdb/testsuite/gdb.cp/mb-ctor.cc +++ b/gdb/testsuite/gdb.cp/mb-ctor.cc @@ -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() diff --git a/gdb/testsuite/gdb.cp/mb-ctor.exp b/gdb/testsuite/gdb.cp/mb-ctor.exp index dffc78ad82d..c4ef64cc690 100644 --- a/gdb/testsuite/gdb.cp/mb-ctor.exp +++ b/gdb/testsuite/gdb.cp/mb-ctor.exp @@ -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.*" \ diff --git a/gdb/testsuite/gdb.cp/mb-inline.exp b/gdb/testsuite/gdb.cp/mb-inline.exp index 5a507dfd40e..3763525d7d1 100644 --- a/gdb/testsuite/gdb.cp/mb-inline.exp +++ b/gdb/testsuite/gdb.cp/mb-inline.exp @@ -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" diff --git a/gdb/testsuite/gdb.cp/mb-inline.h b/gdb/testsuite/gdb.cp/mb-inline.h index 8ff5649a393..8de8b92342c 100644 --- a/gdb/testsuite/gdb.cp/mb-inline.h +++ b/gdb/testsuite/gdb.cp/mb-inline.h @@ -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 (); diff --git a/gdb/testsuite/gdb.cp/mb-inline1.cc b/gdb/testsuite/gdb.cp/mb-inline1.cc index 11c01139045..22d11161fc4 100644 --- a/gdb/testsuite/gdb.cp/mb-inline1.cc +++ b/gdb/testsuite/gdb.cp/mb-inline1.cc @@ -23,7 +23,7 @@ int afn () { - return foo (0); + return foo (0) + multi_line_foo (0); } int diff --git a/gdb/testsuite/gdb.cp/mb-inline2.cc b/gdb/testsuite/gdb.cp/mb-inline2.cc index 7c44f3ff2ff..8dea2a4a33b 100644 --- a/gdb/testsuite/gdb.cp/mb-inline2.cc +++ b/gdb/testsuite/gdb.cp/mb-inline2.cc @@ -21,5 +21,5 @@ int bfn () { - return foo (1); + return foo (1) + multi_line_foo (1); } diff --git a/gdb/testsuite/gdb.cp/mb-templates.cc b/gdb/testsuite/gdb.cp/mb-templates.cc index a7d4e2e7138..649d7eda69f 100644 --- a/gdb/testsuite/gdb.cp/mb-templates.cc +++ b/gdb/testsuite/gdb.cp/mb-templates.cc @@ -8,6 +8,13 @@ void foo(T i) std::cout << "hi\n"; // set breakpoint here } +template +void multi_line_foo(T i) +{ + std::cout // set multi-line breakpoint here + << "hi\n"; +} + int main() { foo(0); @@ -16,4 +23,9 @@ int main() foo(1); foo(2); foo(2); + + multi_line_foo(0); + multi_line_foo(0); + + return 0; } diff --git a/gdb/testsuite/gdb.cp/mb-templates.exp b/gdb/testsuite/gdb.cp/mb-templates.exp index e32dc52dcbe..5f93228d99d 100644 --- a/gdb/testsuite/gdb.cp/mb-templates.exp +++ b/gdb/testsuite/gdb.cp/mb-templates.exp @@ -165,3 +165,25 @@ gdb_test "continue" \ ".*Breakpoint.*foo \\(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 \\(i=0\\).*" \ + "run to multi_line_foo breakpoint 2 " +gdb_test "continue" \ + ".*Breakpoint.*multi_line_foo \\(i=0\\).*" \ + "run to multi_line_foo breakpoint 2 "