public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/breakpoint: use warning function instead of gdb_printf
@ 2023-05-17  9:40 Andrew Burgess
  2023-05-17 18:54 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2023-05-17  9:40 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

Noticed that in breakpoint.c, in one place, we do this:

  gdb_printf (_("warning: Error removing "
                "breakpoint %d\n"),
                old_loc->owner->number);

Instead of using the `warning` function.  There are a number of
differences between using gdb_printf like this and calling `warning`,
the main one is probably that real warnings are sent to gdb_stderr,
while the above gdb_printf call will go to gdb_stdout.

In this commit I:

  1. Change to call `warning`, we can drop the "warning: " prefix from
  the string in breakpoint.c,

  2. Update the warning text, I now start with a lower case 'e', which
  I believe is the GDB style for warnings,

  3. And I have included the address of the bp_location in the warning
  messsage,

  4. Finally, I update all the tests (2) that include this error
  message.
---
 gdb/breakpoint.c                                       | 6 +++---
 gdb/testsuite/gdb.base/break-main-file-remove-fail.exp | 4 ++--
 gdb/testsuite/gdb.base/hw-sw-break-same-address.exp    | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index fdb184ae81f..552b789cba1 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -11342,9 +11342,9 @@ update_global_location_list (enum ugll_insert_mode insert_mode)
 		     Note that at this point, old_loc->owner is still
 		     valid, as delete_breakpoint frees the breakpoint
 		     only after calling us.  */
-		  gdb_printf (_("warning: Error removing "
-				"breakpoint %d\n"), 
-			      old_loc->owner->number);
+		  warning (_("error removing breakpoint %d at %s"),
+			   old_loc->owner->number,
+			   paddress (old_loc->gdbarch, old_loc->address));
 		}
 	      removed = true;
 	    }
diff --git a/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp b/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp
index c7cf4f3df00..5e689fae5d3 100644
--- a/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp
+++ b/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp
@@ -100,7 +100,7 @@ proc test_remove_bp { initial_load } {
 	# get_integer_valueof.
 	set munmap -1
 	gdb_test_multiple "print /d ${munmap_expr}" "get result of munmap call" {
-	    -re -wrap "^(?:warning: Error removing breakpoint $::decimal\r\n)?\\$\[0-9\]* = (\[-\]*\[0-9\]*).*" {
+	    -re -wrap "^(?:warning: error removing breakpoint $::decimal at $::hex\r\n)?\\$\[0-9\]* = (\[-\]*\[0-9\]*).*" {
 		set munmap $expect_out(1,string)
 		pass $gdb_test_name
 	    }
@@ -112,7 +112,7 @@ proc test_remove_bp { initial_load } {
 	}
 
 	gdb_test "delete \$bpnum" \
-	    "warning: Error removing breakpoint .*" \
+	    "^warning: error removing breakpoint $::decimal at $::hex" \
 	    "failure to remove breakpoint warns"
     }
 }
diff --git a/gdb/testsuite/gdb.base/hw-sw-break-same-address.exp b/gdb/testsuite/gdb.base/hw-sw-break-same-address.exp
index 9f941186454..6ac69e5630f 100644
--- a/gdb/testsuite/gdb.base/hw-sw-break-same-address.exp
+++ b/gdb/testsuite/gdb.base/hw-sw-break-same-address.exp
@@ -50,7 +50,7 @@ with_test_prefix "hw-sw" {
     # A bad GDB debugging against GDBserver would output a warning
     # here:
     #  delete breakpoints
-    #  warning: Error removing breakpoint 3
+    #  warning: error removing breakpoint 3 at <ADDRESS>
     #  (gdb) FAIL: gdb.base/hw-sw-break-same-address.exp: hw-sw: delete breakpoints
     gdb_test_no_output "delete breakpoints"
 }

base-commit: 66b8e6c7b8d3c137029f4f2ab8c5b798aa1cbdd7
-- 
2.25.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb/breakpoint: use warning function instead of gdb_printf
  2023-05-17  9:40 [PATCH] gdb/breakpoint: use warning function instead of gdb_printf Andrew Burgess
@ 2023-05-17 18:54 ` Tom Tromey
  2023-05-19  9:15   ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2023-05-17 18:54 UTC (permalink / raw)
  To: Andrew Burgess via Gdb-patches; +Cc: Andrew Burgess

>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:

Andrew> Instead of using the `warning` function.  There are a number of
Andrew> differences between using gdb_printf like this and calling `warning`,
Andrew> the main one is probably that real warnings are sent to gdb_stderr,
Andrew> while the above gdb_printf call will go to gdb_stdout.

Andrew> In this commit I:
...

Looks good to me.

Reviewed-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb/breakpoint: use warning function instead of gdb_printf
  2023-05-17 18:54 ` Tom Tromey
@ 2023-05-19  9:15   ` Andrew Burgess
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2023-05-19  9:15 UTC (permalink / raw)
  To: Tom Tromey, Andrew Burgess via Gdb-patches

Tom Tromey <tom@tromey.com> writes:

>>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Andrew> Instead of using the `warning` function.  There are a number of
> Andrew> differences between using gdb_printf like this and calling `warning`,
> Andrew> the main one is probably that real warnings are sent to gdb_stderr,
> Andrew> while the above gdb_printf call will go to gdb_stdout.
>
> Andrew> In this commit I:
> ...
>
> Looks good to me.
>
> Reviewed-By: Tom Tromey <tom@tromey.com>

Pushed.

Thanks,
Andrew


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-19  9:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17  9:40 [PATCH] gdb/breakpoint: use warning function instead of gdb_printf Andrew Burgess
2023-05-17 18:54 ` Tom Tromey
2023-05-19  9:15   ` Andrew Burgess

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).