* 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.
This commit is contained in:
Doug Evans 2009-04-29 22:45:11 +00:00
parent c5af0dad33
commit 9ab4e74422
9 changed files with 101 additions and 17 deletions

View 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> 2009-04-29 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/macscp.exp: New `options' parameter `-DFROM_COMMANDLINE'. * gdb.base/macscp.exp: New `options' parameter `-DFROM_COMMANDLINE'.

View file

@ -28,11 +28,19 @@ public:
~Derived(); ~Derived();
private: private:
int i; int i;
int i2;
}; };
Derived::Derived(int i) : Base(i) Derived::Derived(int i) : Base(i)
{ {
this->i = 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() Derived::~Derived()

View file

@ -43,6 +43,11 @@ gdb_start
gdb_reinitialize_dir $srcdir/$subdir gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile} gdb_load ${binfile}
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
# Set a breakpoint with multiple locations # Set a breakpoint with multiple locations
# and a condition. # and a condition.
@ -50,34 +55,31 @@ gdb_test "break 'Derived::Derived(int)'" \
"Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \ "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
"set-breakpoint at ctor" "set-breakpoint at ctor"
gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
gdb_test "break 'Derived::~Derived()'" \ gdb_test "break 'Derived::~Derived()'" \
"Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \ "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
"set-breakpoint at dtor" "set-breakpoint at dtor"
gdb_run_cmd gdb_test "continue" \
gdb_expect { ".*Breakpoint.*Derived.*i=7.*" \
-re "Breakpoint \[0-9\]+,.*Derived.*i=7.*$gdb_prompt $" { "run to breakpoint 1 v1"
pass "run to breakpoint"
} gdb_continue_to_breakpoint "set breakpoint here" ".* breakpoint here"
-re "$gdb_prompt $" {
fail "run to breakpoint"
}
timeout {
fail "run to breakpoint (timeout)"
}
}
gdb_test "continue" \ gdb_test "continue" \
".*Breakpoint.*Derived.*i=15.*" \ ".*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" \ gdb_test "continue" \
".*Breakpoint.*~Derived.*" \ ".*Breakpoint.*~Derived.*" \
"run to breakpoint 3" "run to breakpoint 3 v1"
gdb_test "continue" \ gdb_test "continue" \
".*Breakpoint.*~Derived.*" \ ".*Breakpoint.*~Derived.*" \
"run to breakpoint 4" "run to breakpoint 3 v2"
gdb_test "continue" \ gdb_test "continue" \
".*exited normally.*" \ ".*exited normally.*" \

View file

@ -106,3 +106,25 @@ gdb_expect {
gdb_test "continue" \ gdb_test "continue" \
".*Program exited normally.*" \ ".*Program exited normally.*" \
"continue with disabled breakpoint 1.2" "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"

View file

@ -26,5 +26,12 @@ foo (int i)
return i; // set breakpoint here return i; // set breakpoint here
} }
static int
multi_line_foo (int i)
{
return // set multi-line breakpoint here
i;
}
extern int afn (); extern int afn ();
extern int bfn (); extern int bfn ();

View file

@ -23,7 +23,7 @@
int int
afn () afn ()
{ {
return foo (0); return foo (0) + multi_line_foo (0);
} }
int int

View file

@ -21,5 +21,5 @@
int int
bfn () bfn ()
{ {
return foo (1); return foo (1) + multi_line_foo (1);
} }

View file

@ -8,6 +8,13 @@ void foo(T i)
std::cout << "hi\n"; // set breakpoint here 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() int main()
{ {
foo<int>(0); foo<int>(0);
@ -16,4 +23,9 @@ int main()
foo<double>(1); foo<double>(1);
foo<int>(2); foo<int>(2);
foo<double>(2); foo<double>(2);
multi_line_foo<int>(0);
multi_line_foo<double>(0);
return 0;
} }

View file

@ -165,3 +165,25 @@ gdb_test "continue" \
".*Breakpoint.*foo<int> \\(i=1\\).*" \ ".*Breakpoint.*foo<int> \\(i=1\\).*" \
"instantiation: run to breakpoint 2" "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>"