From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 2/3] gdb/record: add an assert in cmd_record_start
Date: Mon, 15 Apr 2024 15:19:27 +0100 [thread overview]
Message-ID: <483ec76476d7b95641fa486c65249ce62d8690ca.1713190701.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1713190701.git.aburgess@redhat.com>
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.
---
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);
}
--
2.25.4
next prev parent reply other threads:[~2024-04-15 14:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-15 14:19 [PATCH 0/3] Small cleanups in gdb/record*.c code Andrew Burgess
2024-04-15 14:19 ` [PATCH 1/3] gdb/record: remove unnecessary use of filename_completer Andrew Burgess
2024-04-15 14:19 ` Andrew Burgess [this message]
2024-04-15 14:19 ` [PATCH 3/3] gdb/record: minor clean, remove some unneeded arguments Andrew Burgess
2024-04-15 14:41 ` Eli Zaretskii
2024-04-16 14:12 ` Keith Seitz
2024-04-16 17:18 ` [PATCH 0/3] Small cleanups in gdb/record*.c code Tom Tromey
2024-04-17 13:48 ` Andrew Burgess
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=483ec76476d7b95641fa486c65249ce62d8690ca.1713190701.git.aburgess@redhat.com \
--to=aburgess@redhat.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).