From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 420793858D28 for ; Sat, 19 Nov 2022 12:24:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 420793858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x42d.google.com with SMTP id d9so13211835wrm.13 for ; Sat, 19 Nov 2022 04:24:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rsxz70g7zNXVF3djgC7ySoHcLPzgWJQ/tYCKVYFcK3o=; b=gLYWGEQN80IwXlfsAtLVuTfyjfJf/LEIPdWwwpVBGDLFzFfyCpB7CKJwpHbk3yKSoT qE3BlJT+hz+VhqOF8LYw1zGq8Q+JW+tQSH9rIT2j7nFgRBs2cQ2pMJtu7VJb0qnge8lQ dzRyTarbuAXkeaiS+sagy+7shV2vpJyhxv4SEcWrSj4HsvSzr7+7Gmj71LMEqeHPO6JE g+cubami4sDeY3TjSnevQI8ksXwBTekN1JLUQffNRTS4aLVY8HebmkKZ/PioXdMf2BXQ X5Tfy/odjzcRZT+i6kNdavfxPqQQ4/SJaajiL3Om/LQH850JNk0OfBkKP4GqtZowc8Mp ZEqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rsxz70g7zNXVF3djgC7ySoHcLPzgWJQ/tYCKVYFcK3o=; b=pmoeLY4qT90gPpV+RTWA8QtGSf3fyZhPdbRNO/jSIIifkK5C+YtaCqXW0V1biZp5ex A4ISMnR3CEqr5OTZH3biHYtZB/+vQFArZTHkfbXJSuxA9Ai2Bso9rL7BRTPzkkdSMdpE AdvP3QzJwyPE++nyglXsGbV/Qv0Y9lP2Fjyi9hMJu54/vr/RAuavX7F0Xql1acLEy96o FSVdsL+nSQyymHvat5TUndIy6oa6U7oovRJE1g05KajgbaUqxSmqpdF08FIWdV4lcoEV 5q2NnybetGYWWZnfA8zvrHFKEC+4LlKDF5RJamhIno/YPloa5j2Alvb+85l/psarljqR WZtw== X-Gm-Message-State: ANoB5pmIbkBfvVOw4b029EhI1yDUpBL4MDsuPMilDnd+ZbYfZ0Vj3Tx4 p6vWZNSMq/m1hOKqbayi8D+Dd/mQ5ZWE X-Google-Smtp-Source: AA0mqf7V3vangx6B9F4ABaW23YjgnrXMH6dQRRUtW9uzLjDaob7k/WZRNZqpSkbm2C7rPVUhKSop9Q== X-Received: by 2002:adf:d085:0:b0:241:b3d6:d6a0 with SMTP id y5-20020adfd085000000b00241b3d6d6a0mr6750225wrh.617.1668860669997; Sat, 19 Nov 2022 04:24:29 -0800 (PST) Received: from takamaka.gnat.com ([2a01:cb22:1d5:1100:9e9b:96af:1fc2:dddb]) by smtp.gmail.com with ESMTPSA id l8-20020a5d4bc8000000b002238ea5750csm5250275wrt.72.2022.11.19.04.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Nov 2022 04:24:29 -0800 (PST) Received: by takamaka.gnat.com (Postfix, from userid 1000) id 5D1BE814E0; Sat, 19 Nov 2022 16:24:27 +0400 (+04) Date: Sat, 19 Nov 2022 16:24:27 +0400 From: Joel Brobecker To: Tom Tromey via Gdb-patches Cc: Tom Tromey , Joel Brobecker Subject: Re: [PATCH] Fix crash in "document" command Message-ID: References: <20221118160547.1336252-1-tromey@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221118160547.1336252-1-tromey@adacore.com> X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Tom, On Fri, Nov 18, 2022 at 09:05:47AM -0700, Tom Tromey via Gdb-patches wrote: > 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. > --- > 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_tty, > validate_comname (&comname); > > lookup_cmd_composition (comfull, &alias, &prefix_cmd, &c); > + if (c == nullptr) > + error (_("Undefined command: \"%s\"."), comfull); > > if (c->theclass != class_user > && (alias == nullptr || alias->theclass != class_alias)) > diff --git a/gdb/testsuite/gdb.base/document.exp b/gdb/testsuite/gdb.base/document.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\"\\." Thanks for the fix. This looks good to me! -- Joel