From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 311F33854561; Mon, 28 Nov 2022 13:49:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 311F33854561 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669643364; bh=g3NYXLcCLJzsiZPEdxI0w+wr9i3lZBcX3kV9dfshsI0=; h=From:To:Subject:Date:From; b=cUQZBB5PGMsybDY+S1xASTcXzqmkonmvixHyT/SGFt3EHWSw4fT1MXxTIGKWDaAin 44nNRB8mmaRBB9FmFTrk3vrwQQN1NT/Q5Mj65PDeLMMf07xgJ+02+tSf5pA3ul2TGU PnEdDhiGt0pu0BuZjM5n1K1PfJXmRUXTikBUt+/k= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix crash in "document" command X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 76cd77dc729b03d6b33c683323594479e33a3f9a X-Git-Newrev: b70e9270fbafd43a3fece0c7dd52cabd70854dfd Message-Id: <20221128134924.311F33854561@sourceware.org> Date: Mon, 28 Nov 2022 13:49:24 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db70e9270fbaf= d43a3fece0c7dd52cabd70854dfd commit b70e9270fbafd43a3fece0c7dd52cabd70854dfd Author: Tom Tromey Date: Fri Nov 18 09:04:39 2022 -0700 Fix crash in "document" command =20 PR cli/29800 points out that "document" will now crash when the argument is an undefined command. This is a regression due to the "document user-defined aliases" patch. =20 Approved-By: Joel Brobecker Reviewed-By: Philippe Waroquiers Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29800 Diff: --- gdb/cli/cli-script.c | 2 ++ gdb/testsuite/gdb.base/document.exp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 2442f7ae38b..2101d6fface 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -1515,6 +1515,8 @@ do_document_command (const char *comname, int from_tt= y, validate_comname (&comname); =20 lookup_cmd_composition (comfull, &alias, &prefix_cmd, &c); + if (c =3D=3D nullptr) + error (_("Undefined command: \"%s\"."), comfull); =20 if (c->theclass !=3D class_user && (alias =3D=3D nullptr || alias->theclass !=3D class_alias)) diff --git a/gdb/testsuite/gdb.base/document.exp b/gdb/testsuite/gdb.base/d= ocument.exp index 2d8f6b88090..6f426510d29 100644 --- a/gdb/testsuite/gdb.base/document.exp +++ b/gdb/testsuite/gdb.base/document.exp @@ -28,3 +28,7 @@ gdb_test_multiple "define do-document" "" { } gdb_test_no_output "do-document" "invoke do-document" gdb_test "help do-document" "usage: do-document" "invoke help do-document" + +# Test that document of a non-existing command prints an error. There +# was a regression at one point causing this to crash. +gdb_test "document nosuchcommand" "Undefined command: \"nosuchcommand\"\\."