gdb/testsuite: fix "set temporary breakpoint" DUPLICATEs

Commit c67f4e538 ("gdb/testsuite: make gdb.ada/mi_prot.exp stop at
expected location") introduced some DUPLICATEs in MI tests using
mi_continue_to_line, for example:

    DUPLICATE: gdb.ada/mi_ref_changeable.exp: mi_continue_to_line: set temporary breakpoint

These test names were previously differentiated by the location passed
to mi_continue_to_line.  Since the location can contain a path, that
commit removed the location from the test name, in favor of a hardcoded
string "set temporary breakpoint", hence removing the differentiator.

mi_continue_to_line receives a "test" parameter, containing a test
name.  Add a "with_test_prefix" with that name, so that all tests
recorded during mi_continue_to_line have this in their name.

mi_continue_to_line passes that "test" string to mi_get_stop_line, that
is a bit superfluous.  mi_get_stop_line only uses that string in case of
failures (it doesn't record a pass if everything goes fine).  Since it's
not crucial, just remove it, and adjust all callers.

Adjust three gdb.mi/mi-var-*.exp tests to use prefixes to differentiate
the multiple calls to mi_run_inline_test (which calls
mi_continue_to_line).

Change-Id: I511c6caa70499f8657b1cde37d71068d74d56a74
This commit is contained in:
Simon Marchi 2022-04-21 15:05:32 -04:00
parent 31de881f8f
commit 0b84fbd54e
6 changed files with 17 additions and 16 deletions

View file

@ -596,7 +596,7 @@ set inline_tests {
# Needs to be last, following tests rely on this. # Needs to be last, following tests rely on this.
lappend inline_tests floating lappend inline_tests floating
foreach inline_test $inline_tests { foreach_with_prefix inline_test $inline_tests {
if { [mi_run_inline_test $inline_test] < 0 } { if { [mi_run_inline_test $inline_test] < 0 } {
return -1 return -1
} }

View file

@ -46,7 +46,7 @@ set inline_tests {
path_expression path_expression
} }
foreach inline_test $inline_tests { foreach_with_prefix inline_test $inline_tests {
if { [mi_run_inline_test $inline_test] < 0 } { if { [mi_run_inline_test $inline_test] < 0 } {
return -1 return -1
} }

View file

@ -119,7 +119,7 @@ set inline_tests {
skip_type_update_when_not_use_rtti skip_type_update_when_not_use_rtti
} }
foreach inline_test $inline_tests { foreach_with_prefix inline_test $inline_tests {
if { [mi_run_inline_test $inline_test] < 0 } { if { [mi_run_inline_test $inline_test] < 0 } {
return -1 return -1
} }

View file

@ -50,7 +50,7 @@ mi_gdb_test "source ${remote_python_file}" ".*\\^done." "load python file"
# Multiple blocks test # Multiple blocks test
mi_continue_to_line [gdb_get_line_number {Inner test breakpoint} ${srcfile}] \ mi_continue_to_line [gdb_get_line_number {Inner test breakpoint} ${srcfile}] \
"step to breakpoint" "step to first breakpoint"
mi_gdb_test "-stack-list-locals --all-values" \ mi_gdb_test "-stack-list-locals --all-values" \
"\\^done,locals=\\\[{name=\"h\",value=\"9\"},{name=\"f\",value=\"42\"},{name=\"g\",value=\"19\"},{name=\"bar\",value=\"$hex \\\\\"Inside block x2\\\\\"\"},{name=\"d\",value=\"15\"},{name=\"e\",value=\"14\"},{name=\"foo\",value=\"$hex \\\\\"Inside block\\\\\"\"},{name=\"str\",value=\"$hex \\\\\"The End\\\\\"\"},{name=\"st2\",value=\"$hex \\\\\"Is Near\\\\\"\"},{name=\"b\",value=\"12\"},{name=\"c\",value=\"5\"}\\\]" \ "\\^done,locals=\\\[{name=\"h\",value=\"9\"},{name=\"f\",value=\"42\"},{name=\"g\",value=\"19\"},{name=\"bar\",value=\"$hex \\\\\"Inside block x2\\\\\"\"},{name=\"d\",value=\"15\"},{name=\"e\",value=\"14\"},{name=\"foo\",value=\"$hex \\\\\"Inside block\\\\\"\"},{name=\"str\",value=\"$hex \\\\\"The End\\\\\"\"},{name=\"st2\",value=\"$hex \\\\\"Is Near\\\\\"\"},{name=\"b\",value=\"12\"},{name=\"c\",value=\"5\"}\\\]" \
@ -62,7 +62,7 @@ mi_gdb_test "-stack-list-locals --all-values" \
"stack-list-locals --all-values frame filters enabled" "stack-list-locals --all-values frame filters enabled"
mi_continue_to_line [gdb_get_line_number {Backtrace end breakpoint} ${srcfile}] \ mi_continue_to_line [gdb_get_line_number {Backtrace end breakpoint} ${srcfile}] \
"step to breakpoint" "step to second breakpoint"
set any "\[^\"\]+" set any "\[^\"\]+"

View file

@ -231,7 +231,7 @@ mi_varobj_update_dynamic container2 \
mi_continue_to_line \ mi_continue_to_line \
[gdb_get_line_number {MI outer breakpoint here} ${srcfile}] \ [gdb_get_line_number {MI outer breakpoint here} ${srcfile}] \
"step to outer breakpoint" "step to first outer breakpoint"
mi_create_dynamic_varobj outer outer 1 \ mi_create_dynamic_varobj outer outer 1 \
"create outer varobj" "create outer varobj"
@ -261,7 +261,7 @@ mi_varobj_update_with_type_change container int 0 "update after type change"
mi_continue_to_line \ mi_continue_to_line \
[gdb_get_line_number {break to inspect struct and union} ${srcfile}] \ [gdb_get_line_number {break to inspect struct and union} ${srcfile}] \
"step to outer breakpoint" "step to second outer breakpoint"
with_test_prefix "varobj nscont" { with_test_prefix "varobj nscont" {
mi_create_dynamic_varobj nscont nstype 1 \ mi_create_dynamic_varobj nscont nstype 1 \

View file

@ -1865,14 +1865,15 @@ proc mi_send_resuming_command {command test} {
# Does not check that the line is the same as requested. # Does not check that the line is the same as requested.
# The caller can check itself if required. # The caller can check itself if required.
proc_with_prefix mi_continue_to_line {location test} { proc_with_prefix mi_continue_to_line {location test} {
with_test_prefix $test {
mi_tbreak $location "set temporary breakpoint" mi_tbreak $location "set temporary breakpoint"
mi_send_resuming_command "exec-continue" "continue to breakpoint" mi_send_resuming_command "exec-continue" "continue to breakpoint"
return [mi_get_stop_line $test] return [mi_get_stop_line]
}
} }
# Wait until gdb prints the current line. # Wait until gdb prints the current line.
proc mi_get_stop_line {test} { proc mi_get_stop_line {} {
global mi_gdb_prompt global mi_gdb_prompt
global async global async
@ -1888,10 +1889,10 @@ proc mi_get_stop_line {test} {
return $expect_out(1,string) return $expect_out(1,string)
} }
-re ".*$mi_gdb_prompt" { -re ".*$mi_gdb_prompt" {
fail "wait for stop ($test)" fail "wait for stop (unexpected output)"
} }
timeout { timeout {
fail "wait for stop ($test)" fail "wait for stop (timeout)"
} }
} }
} }
@ -1958,7 +1959,7 @@ proc mi_run_inline_test { testcase } {
if { [mi_run_cmd] < 0 } { if { [mi_run_cmd] < 0 } {
return -1 return -1
} }
set line_now [mi_get_stop_line "$testcase: step to $line"] set line_now [mi_get_stop_line]
set first 0 set first 0
} elseif {$line_now!=$line} { } elseif {$line_now!=$line} {
set line_now [mi_continue_to_line "$mi_autotest_source:$line" "continue to $line"] set line_now [mi_continue_to_line "$mi_autotest_source:$line" "continue to $line"]
@ -1976,7 +1977,7 @@ proc mi_run_inline_test { testcase } {
if { [mi_send_resuming_command "exec-next" "$testcase: step over $line"] != 0 } { if { [mi_send_resuming_command "exec-next" "$testcase: step over $line"] != 0 } {
return -1 return -1
} }
set line_now [mi_get_stop_line "$testcase: step over $line"] set line_now [mi_get_stop_line]
# We probably want to use 'uplevel' so that statements # We probably want to use 'uplevel' so that statements
# have direct access to global variables that the # have direct access to global variables that the