From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by sourceware.org (Postfix) with ESMTPS id 9042D3857C51 for ; Fri, 18 Nov 2022 16:05:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9042D3857C51 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-io1-xd2b.google.com with SMTP id y6so4121727iof.9 for ; Fri, 18 Nov 2022 08:05:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Sy5qfw/C3itqT2CI6GY8sZiJtaLFruxIXbsytZ+qEkE=; b=MMY38FVfoQKigmggKmYN8XnQYzDokZag9nwLlx+R0P3I+owU+USHpowwoVoCeeK5px vDTbZ+syA5plxsWrj3PTI1YxJM2QDsZ/PiDUk8HM1w6JGc4EEpLAeEULNGM4FjzURIHZ Wcjy4F2a3gbgauVMEj24tvSICvD7vx76yhTZ4XGKIzFs5YqFvuLE3O3HC9hwrIba4mT6 1s0lDhY77MeYfbszho2bWmSkLGzBJT9DuLDzFPE60XAfiJ9re2kwS8FLFGYT8rHzdN0G r/1m0BflzVtqYdgVf0FqhrrECeokq60dUAb75xssAxtyv2U4Ok3rlRRvymvLkg1M+cJo MlRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Sy5qfw/C3itqT2CI6GY8sZiJtaLFruxIXbsytZ+qEkE=; b=RJMI9oe9ii+kEsnRIC/BX8r483Xs5QP8ljNTsPtvKtoKHkOJZzdy8hA/DqiuBITg5K FLAAGwMjM0hsIUAfPI4yIME2S9+2UDSHgPkJGhZVxp/NjP0t3jp3H9BJpKlYdvc/7Mmd b8ohfrmczpQ/ZaN0eIm+xwMh31HKvB/Bxxr2N3mp2PY/o8/zbiR9lKxveN6+9JAJogdY Hu1mju+upI5JKPG5TL6XVacmbOtQ1QhsT99eaijdUCLxsRHbVkjoZQHVSDEa67NUkp2i qPU2Ar6iOqlLuqlgdaK9i0vsZaQmt+wWsIwBORi/zHKaWfB/wLXEI1nH9Nm1nx6g5Nkg fT7A== X-Gm-Message-State: ANoB5pm9RHQQ9FVT7wlUKTL8d3FCfG1PMcFDCJbSIn4edNXnACj/TxpU Am8lXEXoU3Cq3FSHAjtb+OOGAo9xnKzBaA== X-Google-Smtp-Source: AA0mqf7UQVF3v/JPO8Mni91YaPBIvi8qf0lTNBa8ngcPjCOJUR1bNQ3gVBokyPvW/I+4u58T8SnNvg== X-Received: by 2002:a02:cb96:0:b0:363:9f1c:e5 with SMTP id u22-20020a02cb96000000b003639f1c00e5mr3510738jap.187.1668787553780; Fri, 18 Nov 2022 08:05:53 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id m22-20020a02a156000000b003751b68b84esm1316875jah.32.2022.11.18.08.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 08:05:53 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Fix crash in "document" command Date: Fri, 18 Nov 2022 09:05:47 -0700 Message-Id: <20221118160547.1336252-1-tromey@adacore.com> X-Mailer: git-send-email 2.34.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.1 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: 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\"\\." -- 2.34.3