]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/testsuite: add no-delete-breakpoints option to 'runto' proc
authorAndrew Burgess <aburgess@redhat.com>
Fri, 16 Aug 2024 11:01:54 +0000 (12:01 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Wed, 28 Aug 2024 09:39:21 +0000 (10:39 +0100)
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>
gdb/testsuite/gdb.cp/breakpoint-shlib-func.exp
gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
gdb/testsuite/lib/gdb.exp

index 9924d9b69856435568b6dc163beda6bfaae3b255..085020f50e97496f54810b440a52d6073c73537f 100644 (file)
@@ -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.
index 401af0df0d2456d435cd16847abb19b746ec6d84..450d890f189601d33e71601e7550d1850294fa29 100644 (file)
@@ -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\\\]\\) "
index 1c49b6a36d77115d0437d9c3f30cf3654eace556..2d33470b0ea1c4598f51c4e4476de7dd7ace4c4f 100644 (file)
@@ -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.