public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 1/5] Save breakpoints so they are automatically pending
Date: Sun, 29 Jan 2023 09:21:01 -0700	[thread overview]
Message-ID: <20230129162105.526266-2-tom@tromey.com> (raw)
In-Reply-To: <20230129162105.526266-1-tom@tromey.com>

PR breakpoints/18183 points out that breakpoints saved with the "save
breakpoints" command can be slightly inconvenient, depending on "set
breakpoint pending".

This patch makes use of the new "with" command to save breakpoints
such that they will automatically be made pending, if necessary, when
being restored.

Unfortunately, reloading a breakpoint saved this way will also print:

    No symbol table is loaded.  Use the "file" command.

This seems strange to me, and also a bit useless, but changing
create_breakpoint not to call exception_print in the AUTO_BOOLEAN_TRUE
case caused other regressions, so I've left it as-is for the time
being.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=18183
---
 gdb/breakpoint.c                        |  1 +
 gdb/testsuite/gdb.base/catch-signal.exp | 10 +++++-----
 gdb/testsuite/gdb.base/save-bp.exp      | 20 ++++++++++++++++++++
 gdb/testsuite/gdb.base/ui-redirect.exp  |  7 ++++---
 4 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 00cc2ab401c..bd11d26fca4 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -14170,6 +14170,7 @@ save_breakpoints (const char *filename, int from_tty,
       if (filter && !filter (tp))
 	continue;
 
+      fp.puts ("with breakpoint pending on -- ");
       tp->print_recreate (&fp);
 
       /* Note, we can't rely on tp->number for anything, as we can't
diff --git a/gdb/testsuite/gdb.base/catch-signal.exp b/gdb/testsuite/gdb.base/catch-signal.exp
index 774eb8ee856..2e3160c2a33 100644
--- a/gdb/testsuite/gdb.base/catch-signal.exp
+++ b/gdb/testsuite/gdb.base/catch-signal.exp
@@ -128,10 +128,10 @@ foreach {arg desc} {"" "standard signals" \
     set data [split $file_data "\n"]
     close $fd
 
-    if {$arg == ""} {
-	set pattern "catch signal"
-    } else {
-	set pattern "catch signal $arg"
+    set prefix  "with breakpoint pending on -- "
+    set pattern "${prefix}catch signal"
+    if {$arg != ""} {
+	append pattern " $arg"
     }
     gdb_assert {[expr [llength $data] == 3]} \
 	"Number of lines of save breakpoints for '$arg'"
@@ -139,7 +139,7 @@ foreach {arg desc} {"" "standard signals" \
     gdb_assert {[string match $pattern [lindex $data 0]]} \
 	"1st line of save breakpoints for '$arg'"
     # Check the second line.
-    gdb_assert {[string match "break main" [lindex $data 1]]} \
+    gdb_assert {[string match "${prefix}break main" [lindex $data 1]]} \
         "2nd line of save breakpoints for '$arg'"
     # Check the trailing newline.
     gdb_assert {[string match "" [lindex $data 2]]} \
diff --git a/gdb/testsuite/gdb.base/save-bp.exp b/gdb/testsuite/gdb.base/save-bp.exp
index a39712c7f5c..daa7509ae8e 100644
--- a/gdb/testsuite/gdb.base/save-bp.exp
+++ b/gdb/testsuite/gdb.base/save-bp.exp
@@ -89,3 +89,23 @@ gdb_test_sequence "info break" "info break" [list				\
   "\[\r\n\]+\[ \t\]+printf"							\
   "\[\r\n\]+$disabled_row_start main at \[^\r\n\]*$srcfile:$loc_bp8"		\
 ]
+
+clean_restart
+gdb_test "source $bps" "" "source bps without symbol file"
+
+set pending "\[0-9\]+ +breakpoint +keep +y +<PENDING> +"
+set disabled_pending "\[0-9\]+ +breakpoint +keep +n +<PENDING> +"
+set dprintf_pending "\[0-9\]+ +dprintf +keep +y +<PENDING> +"
+gdb_test_sequence "info break" "info break without symbol file" \
+    [list							\
+	 "\[\r\n\]+Num +Type +Disp +Enb +Address +What"		\
+	 "\[\r\n\]+$pending break_me"				\
+	 "\[\r\n\]+$pending $srcfile:$loc_bp2"			\
+	 "\[\r\n\]+$pending $srcfile:$loc_bp3 +thread 1"	\
+	 "\[\r\n\]+$pending $srcfile:$loc_bp4"			\
+	 "\[\r\n\]+\[ \t\]+stop only if i == 1( \\((host|target) evals\\))?" \
+	 "\[\r\n\]+$pending $srcfile:$loc_bp5"			\
+	 "\[\r\n\]+\[ \t\]+silent"				\
+	 "\[\r\n\]+$dprintf_pending $srcfile:$loc_bp5,"		\
+	 "\[\r\n\]+$disabled_pending $srcfile:$loc_bp8"		\
+	]
diff --git a/gdb/testsuite/gdb.base/ui-redirect.exp b/gdb/testsuite/gdb.base/ui-redirect.exp
index c0ba4f11809..a95e4fa6e90 100644
--- a/gdb/testsuite/gdb.base/ui-redirect.exp
+++ b/gdb/testsuite/gdb.base/ui-redirect.exp
@@ -42,13 +42,14 @@ gdb_test_no_output "end"
 gdb_breakpoint "foo"
 gdb_breakpoint "bar"
 
+set prefix  "with breakpoint pending on -- "
 set cmds [multi_line_input \
-	      "break -qualified main" \
+	      "${prefix}break -qualified main" \
 	      "  commands" \
 	      "    print 1" \
 	      "  end" \
-	      "break foo" \
-	      "break bar"]
+	      "${prefix}break foo" \
+	      "${prefix}break bar"]
 set cmds "$cmds\n"
 set outdir [standard_output_file {}]
 set cmds_file "$outdir/cmds.txt"
-- 
2.39.1


  reply	other threads:[~2023-01-29 16:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-29 16:21 [PATCH 0/5] Additions to "save" command Tom Tromey
2023-01-29 16:21 ` Tom Tromey [this message]
2023-01-31 15:14   ` [PATCH 1/5] Save breakpoints so they are automatically pending Alexandra Petlanova Hajkova
2023-01-29 16:21 ` [PATCH 2/5] Move show_user_1 to cli-cmds.c Tom Tromey
2023-01-29 16:21 ` [PATCH 3/5] Add "save user" command Tom Tromey
2023-01-29 16:57   ` Eli Zaretskii
2023-01-30 14:53   ` Pedro Alves
2023-01-30 23:35     ` Tom Tromey
2023-01-29 16:21 ` [PATCH 4/5] Add "save skip" command Tom Tromey
2023-01-29 16:54   ` Eli Zaretskii
2023-01-29 16:21 ` [PATCH 5/5] Add "save history" command Tom Tromey
2023-01-29 16:56   ` Eli Zaretskii
2023-01-30 14:50   ` Pedro Alves
2023-01-30 15:12     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230129162105.526266-2-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).