public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: change 'if' to gdb_assert in update_dprintf_command_list
@ 2024-03-31 10:28 Andrew Burgess
0 siblings, 0 replies; only message in thread
From: Andrew Burgess @ 2024-03-31 10:28 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3d42db971fc7cb0a5fe9b4526b12539019b5c27e
commit 3d42db971fc7cb0a5fe9b4526b12539019b5c27e
Author: Andrew Burgess <aburgess@redhat.com>
Date: Wed Apr 5 15:37:00 2023 +0100
gdb: change 'if' to gdb_assert in update_dprintf_command_list
I noticed in update_dprintf_command_list that we handle the case where
the bp_dprintf style breakpoint doesn't have a format and args string.
However, I don't believe such a situation is possible. The obvious
approach certainly already catches this case:
(gdb) dprintf main
Format string required
If it is possible to create a dprintf breakpoint without a format and
args string then I think we should be catching this case and handling
it at creation time, rather than having GDB just ignore the situation
later on.
And so, I propose that we change the 'if' that ignores the case where
the format/args string is empty, and instead assert that we do always
have a format/args string. The original code, that handled an empty
format/args string has existed since commit e7e0cddfb0d4, which is
when dprintf support was added to GDB.
If I'm correct and this situation can't ever happen then there should
be no user visible changes after this commit.
Diff:
---
gdb/breakpoint.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 044d424d06c..8346c43925c 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -8529,8 +8529,9 @@ update_dprintf_command_list (struct breakpoint *b)
const char *dprintf_args = b->extra_string.get ();
gdb::unique_xmalloc_ptr<char> printf_line = nullptr;
- if (!dprintf_args)
- return;
+ /* Trying to create a dprintf breakpoint without a format and args
+ string should be detected at creation time. */
+ gdb_assert (dprintf_args != nullptr);
dprintf_args = skip_spaces (dprintf_args);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-03-31 10:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-31 10:28 [binutils-gdb] gdb: change 'if' to gdb_assert in update_dprintf_command_list 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).