From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 144D1385842D for ; Tue, 7 Dec 2021 23:14:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 144D1385842D Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-494-f78a4NfaMg2A_KfYT1_6Ag-1; Tue, 07 Dec 2021 18:13:57 -0500 X-MC-Unique: f78a4NfaMg2A_KfYT1_6Ag-1 Received: by mail-wm1-f70.google.com with SMTP id j71-20020a1c234a000000b00342f418ae7cso1988831wmj.1 for ; Tue, 07 Dec 2021 15:13:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HvYjauqZARqIPrNWGbo1zBy3u0y42S4B0YcYwaPEnKk=; b=nNjTdPX/NPSVEBiWWOF8BIlQUhk617XYJTrAzfXVa5MyqS8I1oraWlystcimebIcZl sk4HsKzvxV8QbpdyGXXDzcamU5zNISCjw213DcO01+UHIWysj69gMnfIQkgF3XSAvm4k bCuedtuiUU20AX79P+fnQqZk0a0rjSXSGXRF/KSxwzcgyUm5H3SHdwR/mjSLweY1pYlD oC1b5KnAkae50Jpu6k0OjmgaIMcIrlMLt9hQiKp3pw3aCXBNJMFwNE+nbdb23AXuQfh/ psuIAd/jPakjVejFb5SPBhnt9fE8QJemXx4/ci83xgviApbWqJlwOciA6f02h+rLlqzE RZjg== X-Gm-Message-State: AOAM531tUbz4WLxO8Xc/XPPJsP+KPIvG3psvi6llJ3jRyIuU/6JLtkCF iMHyEk7sADm8gvzO6yshyYn9v2R/Dc1spebmSOZuK2F6WmbcArhNdDDE8QTVco63wot3dLB8jp4 3Qr7MrOZZHESjWDsbyJtVCwFvtUOnkmE1ZuijiNYnZFVP/Gm1sYLetzvOSva6ba9TGVbBp/T2yw == X-Received: by 2002:a05:600c:4154:: with SMTP id h20mr10767500wmm.189.1638918836217; Tue, 07 Dec 2021 15:13:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3qVe2nXDz3lUL156ec/qlQwQdr1Ccz7lXqXfnIYB2jJomahgA6v+D9GnoZG2TY8E1UnCo0A== X-Received: by 2002:a05:600c:4154:: with SMTP id h20mr10767477wmm.189.1638918836034; Tue, 07 Dec 2021 15:13:56 -0800 (PST) Received: from localhost (host86-134-238-138.range86-134.btcentralplus.com. [86.134.238.138]) by smtp.gmail.com with ESMTPSA id j134sm1019632wmj.3.2021.12.07.15.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Dec 2021 15:13:55 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 5/5] gdb: handle calls to edit command passing only a linespec condition Date: Tue, 7 Dec 2021 23:13:45 +0000 Message-Id: <0eb79d1b7493f0646e6c66e3a69b3767418b2fb4.1638918701.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Dec 2021 23:14:02 -0000 While working on the previous commit to fix PR cli/28668, I noticed that the 'edit' command would suffer from the same problem. That is, something like: (gdb) edit task 123 would cause GDB to break. For a full explanation of what's going on here, see the commit message for the previous commit. As with the previous commit, this issue can be prevented by detecting, and throwing, a junk at the end of the line error earlier, before calling decode_line_1. So, that's what this commit does. I've also added some tests for this issue. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28668 --- gdb/cli/cli-cmds.c | 7 ++++--- gdb/testsuite/gdb.linespec/errors.exp | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 857cc8ab45d..d577acf01e4 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -968,6 +968,10 @@ edit_command (const char *arg, int from_tty) arg1 = arg; event_location_up location = string_to_event_location (&arg1, current_language); + + if (*arg1) + error (_("Junk at end of line specification.")); + std::vector sals = decode_line_1 (location.get (), DECODE_LINE_LIST_MODE, NULL, NULL, 0); @@ -987,9 +991,6 @@ edit_command (const char *arg, int from_tty) sal = sals[0]; - if (*arg1) - error (_("Junk at end of line specification.")); - /* If line was specified by address, first print exactly which line, and which file. In this case, sal.symtab == 0 means address is outside of all known source files, not that user diff --git a/gdb/testsuite/gdb.linespec/errors.exp b/gdb/testsuite/gdb.linespec/errors.exp index a46558e7d74..496612d75ea 100644 --- a/gdb/testsuite/gdb.linespec/errors.exp +++ b/gdb/testsuite/gdb.linespec/errors.exp @@ -29,11 +29,18 @@ gdb_test "list fooc:/foo/bar/baz.c:1" "No source file named fooc." gdb_test "list fooc:/foo/bar/baz.c" "No source file named fooc." # PR cli/28665 -gdb_test "list task 123" \ - "Junk at end of line specification\\." -gdb_test "list if (0)" \ - "Junk at end of line specification\\." -gdb_test "list thread 1" \ - "Junk at end of line specification\\." -gdb_test "list -force-condition" \ - "Junk at end of line specification\\." +save_vars { env(EDITOR) } { + setenv EDITOR true + + foreach cmd {list edit} { + gdb_test "${cmd} task 123" \ + "Junk at end of line specification\\." + gdb_test "${cmd} if (0)" \ + "Junk at end of line specification\\." + gdb_test "${cmd} thread 1" \ + "Junk at end of line specification\\." + gdb_test "${cmd} -force-condition" \ + "Junk at end of line specification\\." + } +} + -- 2.25.4