From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 0BC543858C53; Wed, 17 Apr 2024 12:43:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0BC543858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713357785; bh=FTo38lZRPTfUNCnZNKrJgkFOHUSWbZ8uDAYSyJO8Ta4=; h=From:To:Subject:Date:From; b=mboPQ3xk+b30tCNigJ6is3j0xoEPH7i7BfwDXHJOjhhQfE+OHUNM+tnAmnNJuxF04 nVd5Rlx7xcKalgUiGsfamucIbMCSXoCUnRLVH6QTZTfHVR4AQ9XGLWDkXINqd9BQ0o z/ffOGXUMd5lEMhtsHJfM4+HJfvGWUdTwFsiks7Y= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/record: add an assert in cmd_record_start X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: c25c939387cfc378c01fb5eb7f49c78c03b8cdcb X-Git-Newrev: 6e4f0b3ea0d49c4fd11002a8074eb49e7838b4b2 Message-Id: <20240417124305.0BC543858C53@sourceware.org> Date: Wed, 17 Apr 2024 12:43:05 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D6e4f0b3ea0d4= 9c4fd11002a8074eb49e7838b4b2 commit 6e4f0b3ea0d49c4fd11002a8074eb49e7838b4b2 Author: Andrew Burgess Date: Mon Apr 15 14:10:05 2024 +0100 gdb/record: add an assert in cmd_record_start =20 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: =20 (gdb) record blah =20 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). =20 As such, the only way to invoke the 'record' command is like: =20 (gdb) record =20 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. =20 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. =20 There should be no user visible changes after this commit. =20 Approved-By: Tom Tromey 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); } =20 -/* Alias for "target record". */ +/* Alias for "target record-full". */ =20 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 =3D=3D nullptr); execute_command ("target record-full", from_tty); }