aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2009-04-29 22:45:11 +0000
committerDoug Evans <dje@google.com>2009-04-29 22:45:11 +0000
commit9ab4e7442222be784ac8ffbb33631f7172acf7ad (patch)
tree10767ccea5521f748a14d7fb0f6afedfdf2c9ebf /gdb/testsuite
parentc5af0dad33ff96dbb404710539f01b011cff0453 (diff)
downloadgdb-9ab4e7442222be784ac8ffbb33631f7172acf7ad.zip
gdb-9ab4e7442222be784ac8ffbb33631f7172acf7ad.tar.gz
gdb-9ab4e7442222be784ac8ffbb33631f7172acf7ad.tar.bz2
* 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.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog11
-rw-r--r--gdb/testsuite/gdb.cp/mb-ctor.cc8
-rw-r--r--gdb/testsuite/gdb.cp/mb-ctor.exp32
-rw-r--r--gdb/testsuite/gdb.cp/mb-inline.exp22
-rw-r--r--gdb/testsuite/gdb.cp/mb-inline.h7
-rw-r--r--gdb/testsuite/gdb.cp/mb-inline1.cc2
-rw-r--r--gdb/testsuite/gdb.cp/mb-inline2.cc2
-rw-r--r--gdb/testsuite/gdb.cp/mb-templates.cc12
-rw-r--r--gdb/testsuite/gdb.cp/mb-templates.exp22
9 files changed, 101 insertions, 17 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 11e4815..8e8744b 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -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'.
diff --git a/gdb/testsuite/gdb.cp/mb-ctor.cc b/gdb/testsuite/gdb.cp/mb-ctor.cc
index 48a8c5f..c299260 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 dffc78a..c4ef64c 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 5a507df..3763525 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 8ff5649..8de8b92 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 11c0113..22d1116 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 7c44f3f..8dea2a4 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 a7d4e2e..649d7ed 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<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;
}
diff --git a/gdb/testsuite/gdb.cp/mb-templates.exp b/gdb/testsuite/gdb.cp/mb-templates.exp
index e32dc52..5f93228 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<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>"