gdb.base/break.exp C++ify

Some adjustments to make gdb.base/break.exp work when compiled as a
C++ program.  Passes cleanly with Clang++, but not with G++.  The
latter puts a breakpoint at an unexpected line in one case.  It seems
like a bug that gcc and g++ behave differently here.

gdb/testsuite/ChangeLog:

	* gdb.base/break.exp (func): New.  Use it throughout when
	expecting a function name.
This commit is contained in:
Pedro Alves
2020-09-17 23:33:40 +01:00
parent 73e18ac9da
commit 52bb090268
2 changed files with 33 additions and 22 deletions

View File

@ -1,3 +1,8 @@
2020-09-17 Pedro Alves <pedro@palves.net>
* gdb.base/break.exp (func): New. Use it throughout when
expecting a function name.
2020-09-17 Pedro Alves <pedro@palves.net>
* gdb.base/display.exp: Issue "set print asm-demangle on".

View File

@ -121,16 +121,22 @@ set main_line $bp_location6
set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
# In C++ mode, we see a full prototype; in C mode, we only see the
# function name, with no parameter info.
proc func {name} {
return "${name}(?:\(\[^\r\n\]*\))?"
}
gdb_test "info break" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.*
\[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile1:$bp_location8.*
\[0-9\]+\[\t \]+breakpoint keep y.* in factorial at .*$srcfile:$bp_location7.*
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.*
\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfile:$bp_location3.*
\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:$bp_location4" \
\[0-9\]+\[\t \]+breakpoint keep y.* in [func main] at .*$srcfile:$main_line.*
\[0-9\]+\[\t \]+breakpoint keep y.* in [func marker2] at .*$srcfile1:$bp_location8.*
\[0-9\]+\[\t \]+breakpoint keep y.* in [func factorial] at .*$srcfile:$bp_location7.*
\[0-9\]+\[\t \]+breakpoint keep y.* in [func main] at .*$srcfile:$bp_location1.*
\[0-9\]+\[\t \]+breakpoint keep y.* in [func main] at .*$srcfile:$bp_location1.*
\[0-9\]+\[\t \]+breakpoint keep y.* in [func main] at .*$srcfile:$bp_location2.*
\[0-9\]+\[\t \]+breakpoint keep y.* in [func multi_line_if_conditional] at .*$srcfile:$bp_location3.*
\[0-9\]+\[\t \]+breakpoint keep y.* in [func multi_line_while_conditional] at .*$srcfile:$bp_location4" \
"breakpoint info"
#
@ -149,7 +155,7 @@ gdb_test_multiple "info break 2 4 6" "info break 2 4 6" {
set see1 1
exp_continue
}
-re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in marker2 at \[^\r\n\]*" {
-re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
set see2 1
exp_continue
}
@ -186,11 +192,11 @@ set see5 0
set see6 0
gdb_test_multiple "info break 3-5" "info break 3-5" {
-re "1\[\t \]+breakpoint *keep y.* in main at .*:$main_line\[^\r\n\]*" {
-re "1\[\t \]+breakpoint *keep y.* in [func main] at .*:$main_line\[^\r\n\]*" {
set see1 1
exp_continue
}
-re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in marker2 at \[^\r\n\]*" {
-re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
set see2 1
exp_continue
}
@ -243,11 +249,11 @@ set see5 0
set see6 0
gdb_test_multiple "info break" "check disable with history values" {
-re "1\[\t \]+breakpoint *keep y.* in main at .*:$main_line\[^\r\n\]*" {
-re "1\[\t \]+breakpoint *keep y.* in [func main] at .*:$main_line\[^\r\n\]*" {
set see1 1
exp_continue
}
-re "2\[\t \]+breakpoint *keep n\[^\r\n\]* in marker2 at \[^\r\n\]*" {
-re "2\[\t \]+breakpoint *keep n\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
set see2 1
exp_continue
}
@ -289,11 +295,11 @@ set see5 0
set see6 0
gdb_test_multiple "info break" "check disable with convenience values" {
-re "1\[\t \]+breakpoint *keep y.* in main at .*:$main_line\[^\r\n\]*" {
-re "1\[\t \]+breakpoint *keep y.* in [func main] at .*:$main_line\[^\r\n\]*" {
set see1 1
exp_continue
}
-re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in marker2 at \[^\r\n\]*" {
-re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
set see2 1
exp_continue
}
@ -452,12 +458,12 @@ gdb_test "tbreak $srcfile:$bp_location11" "Temporary breakpoint.*at.* file .*$s
# check to see what breakpoints are set (temporary this time)
#
gdb_test "info break" "Num Type.*Disp Enb Address.*What.*\[\r\n\]
\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\]
\[0-9\]+\[\t \]+breakpoint del.*y.*in factorial at .*$srcfile:$bp_location7.*\[\r\n\]
\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location1.*\[\r\n\]
\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location6.*\[\r\n\]
\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location2.*\[\r\n\]
\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location11.*" \
\[0-9\]+\[\t \]+breakpoint del.*y.*in [func main] at .*$srcfile:$main_line.*\[\r\n\]
\[0-9\]+\[\t \]+breakpoint del.*y.*in [func factorial] at .*$srcfile:$bp_location7.*\[\r\n\]
\[0-9\]+\[\t \]+breakpoint del.*y.*in [func main] at .*$srcfile:$bp_location1.*\[\r\n\]
\[0-9\]+\[\t \]+breakpoint del.*y.*in [func main] at .*$srcfile:$bp_location6.*\[\r\n\]
\[0-9\]+\[\t \]+breakpoint del.*y.*in [func main] at .*$srcfile:$bp_location2.*\[\r\n\]
\[0-9\]+\[\t \]+breakpoint del.*y.*in [func main] at .*$srcfile:$bp_location11.*" \
"Temporary breakpoint info"
@ -606,7 +612,7 @@ gdb_test "break marker2" \
"set breakpoint on to-be-called function"
gdb_test "print marker2(99)" \
"The program being debugged stopped while in a function called from GDB.\r\nEvaluation of the expression containing the function\r\n.marker2. will be abandoned.\r\nWhen the function is done executing, GDB will silently stop.*" \
"The program being debugged stopped while in a function called from GDB.\r\nEvaluation of the expression containing the function\r\n.[func marker2]. will be abandoned.\r\nWhen the function is done executing, GDB will silently stop.*" \
"hit breakpoint on called function"
# As long as we're stopped (breakpointed) in a called function,