diff options
author | Andrew Burgess <aburgess@redhat.com> | 2024-08-16 12:01:54 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2024-08-28 10:39:21 +0100 |
commit | 0e6430633515f78599840ac0ab82e20f46654363 (patch) | |
tree | 93abff538b714a160adbd3942207454c4209d2f2 /gdb | |
parent | be85cdf4159c1f130778959d3ddff7c44f5eacde (diff) | |
download | binutils-0e6430633515f78599840ac0ab82e20f46654363.zip binutils-0e6430633515f78599840ac0ab82e20f46654363.tar.gz binutils-0e6430633515f78599840ac0ab82e20f46654363.tar.bz2 |
gdb/testsuite: add no-delete-breakpoints option to 'runto' proc
New 'no-delete-breakpoints' option for the 'runto' proc. This option
disables the delete_breakpoints call early on in this proc.
There are a couple of places in the testsuite where I have used:
proc no_delete_breakpoints {} {}
with_override delete_breakpoints no_delete_breakpoints {
if {![runto_main]} {
return
}
}
In order to avoid the deleting all breakpoints when I call
runto_main. I was about to add yet another instance of this pattern
and I figured that it's time to do this properly.
This commit adds the new option to 'runto' which causes the
delete_breakpoints call to be skipped.
And, we now forward any arguments from 'runto_main' through to
'runto', this means I can now just do:
if {![runto_main no-delete-breakpoints]} {
return
}
which I think is cleaner and easier to understand.
I've updated the two tests I found that use the old with_override
approach.
There should be no change in what is tested after this commit.
Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/gdb.cp/breakpoint-shlib-func.exp | 13 | ||||
-rw-r--r-- | gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp | 19 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 17 |
3 files changed, 20 insertions, 29 deletions
diff --git a/gdb/testsuite/gdb.cp/breakpoint-shlib-func.exp b/gdb/testsuite/gdb.cp/breakpoint-shlib-func.exp index 9924d9b..085020f 100644 --- a/gdb/testsuite/gdb.cp/breakpoint-shlib-func.exp +++ b/gdb/testsuite/gdb.cp/breakpoint-shlib-func.exp @@ -47,18 +47,9 @@ gdb_load_shlib $libobj gdb_test "break foo" "Breakpoint $decimal at $hex" gdb_test "info breakpoints" "<foo\\(\\)@plt>" -# This is used as an override for delete_breakpoints when we don't -# want functions in gdb.exp to delete breakpoints behind the scenes -# for us. -proc do_not_delete_breakpoints {} { - # Just do nothing. -} - # Runto main, but don't delete all the breakpoints. -with_override delete_breakpoints do_not_delete_breakpoints { - if {![runto_main]} { - return -1 - } +if {![runto_main no-delete-breakpoints]} { + return -1 } # The breakpoint should now be showing in `foo` for real. diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp index 401af0d..450d890 100644 --- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp +++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp @@ -195,12 +195,6 @@ proc test_urls {urls pattern_re test} { $test } -# Used as a replacement for delete_breakpoints while calling -# runto_main in one case where we don't want to delete all the -# breakpoints. -proc disable_delete_breakpoints {} { -} - # Uses the global variables DEBUGDIR and DB which are setup elsewhere # in this script. # @@ -234,14 +228,15 @@ proc_with_prefix local_url { } { # the contents of DW_AT_comp_dir and DW_AT_name. gdb_test "set cwd $debugdir" "" "file [file tail $binfile] cwd" gdb_breakpoint $lineno - with_override delete_breakpoints disable_delete_breakpoints { - if {![runto_main]} { - return - } - gdb_continue_to_breakpoint "runto breakpoint in main" \ - ".* Breakpoint here\\. .*" + + # Run to main, but don't delete all breakpoints. + if {![runto_main no-delete-breakpoints]} { + return } + gdb_continue_to_breakpoint "runto breakpoint in main" \ + ".* Breakpoint here\\. .*" + # GDB should now find the executable file. set enable_debuginfod_question \ "Enable debuginfod for this session. \\(y or \\\[n\\\]\\) " diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 1c49b6a..2d33470 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -750,19 +750,24 @@ proc gdb_breakpoint { linespec args } { # single quoted C++ function specifier. # # If there are additional arguments, pass them to gdb_breakpoint. -# We recognize no-message/message ourselves. +# We recognize no-message/message ourselves as well as no-delete-brekpoints. # # no-message is messed up here, like gdb_breakpoint: to preserve # historical usage fails are always printed by default. # no-message: turns off printing of fails (and passes, but they're already off) # message: turns on printing of passes (and fails, but they're already on) +# +# The 'no-delete-brekpoints' option stops this proc from deleting all +# breakpoints. proc runto { linespec args } { global gdb_prompt global bkptno_numopt_re global decimal - delete_breakpoints + if {[lsearch -exact $args no-delete-breakpoints] == -1} { + delete_breakpoints + } set print_pass 0 set print_fail 1 @@ -838,11 +843,11 @@ proc runto { linespec args } { # Ask gdb to run until we hit a breakpoint at main. # -# N.B. This function deletes all existing breakpoints. -# If you don't want that, use gdb_start_cmd. +# N.B. By default this function deletes all existing breakpoints. If +# you don't want that then pass the 'no-delete-breakpoints' argument. -proc runto_main { } { - return [runto main qualified] +proc runto_main { args } { + return [runto main qualified {*}$args] } ### Continue, and expect to hit a breakpoint. |