public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb/record: add an assert in cmd_record_start
@ 2024-04-17 12:43 Andrew Burgess
0 siblings, 0 replies; only message in thread
From: Andrew Burgess @ 2024-04-17 12:43 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6e4f0b3ea0d49c4fd11002a8074eb49e7838b4b2
commit 6e4f0b3ea0d49c4fd11002a8074eb49e7838b4b2
Author: Andrew Burgess <aburgess@redhat.com>
Date: Mon Apr 15 14:10:05 2024 +0100
gdb/record: add an assert in cmd_record_start
The 'record' command is both a prefix command AND an alias for 'target
record-full'. As it is a prefix command, if a user types:
(gdb) record blah
Then GDB will look for, and try to invoke the 'blah' sub-command.
This will either succeed (if blah is found) or throw an error (if blah
is not found).
As such, the only way to invoke the 'record' command is like:
(gdb) record
It is impossible to pass arguments to the 'record' command. As we
know this is true then we can assert this in cmd_record_start.
I added this assert because initially I was going to try forwarding
ARGS from cmd_record_start to the 'target record-full' command, but
then I realised passing arguments to 'record' was impossible.
There should be no user visible changes after this commit.
Approved-By: Tom Tromey <tom@tromey.com>
Diff:
---
gdb/record.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/record.c b/gdb/record.c
index 25a4c1e71b6..5b1093dd12e 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -260,11 +260,16 @@ show_record_debug (struct ui_file *file, int from_tty,
value);
}
-/* Alias for "target record". */
+/* Alias for "target record-full". */
static void
cmd_record_start (const char *args, int from_tty)
{
+ /* As 'record' is a prefix command then if the user types 'record blah'
+ GDB will search for the 'blah' sub-command and either run that instead
+ of calling this function, or throw an error if 'blah' doesn't exist.
+ As a result, we only get here if no args are given. */
+ gdb_assert (args == nullptr);
execute_command ("target record-full", from_tty);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-17 12:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17 12:43 [binutils-gdb] gdb/record: add an assert in cmd_record_start 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).