From patchwork Wed Nov 25 00:34:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 9816 Received: (qmail 86667 invoked by alias); 25 Nov 2015 00:34:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 86599 invoked by uid 89); 25 Nov 2015 00:34:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 25 Nov 2015 00:34:47 +0000 Received: by wmww144 with SMTP id w144so160378325wmw.1 for ; Tue, 24 Nov 2015 16:34:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=MyzYJnEkTVXXCwrJi8oKXpiH1u/ulMNdKR8XyNCN34c=; b=ITWARuQ12t8b0MeCk7nd3u9pkq6zIWUONw2M12IZH/g1iyF71do/9hJBwOcVmniH8W akg9IqAUcldxR8/xwfV2fxED3CLYj94w2Q8n3q37yf1qOHZR+R9EJV8AoGtCQOV24vpD IHpCqSDRJfvfPdRypXJ19fkebFuPX1r3rZ7xykuhSjkuORtc0DNA18uI/TZhPhSDYZDL lZ4U2GEXTOomgnV25HW8Ys7Hm/xFyOOYSYxARz4yrB6Aa7795+yyLfgYYM3hAM6JlFOE qpbf03gK/lYRHfufkTY08v7OnnslCmYrMe6QOS0BRhfMzK5qohMTU9YCKLQrUSifOYDF oSyQ== X-Gm-Message-State: ALoCoQkuU2KuRcTc+79sDXQ2+6M7dr5bfCg+8NjTHXOMsoTxD+0DcHd28hre53DkNa/fGAUMSyJB X-Received: by 10.194.109.169 with SMTP id ht9mr16127672wjb.13.1448411684392; Tue, 24 Nov 2015 16:34:44 -0800 (PST) Received: from localhost (host86-138-95-213.range86-138.btcentralplus.com. [86.138.95.213]) by smtp.gmail.com with ESMTPSA id d66sm899173wma.21.2015.11.24.16.34.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Nov 2015 16:34:43 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 5/7] gdb: 'list' command, tweak handling of +/- arguments. Date: Wed, 25 Nov 2015 00:34:30 +0000 Message-Id: <0af61eb3baed9334e8dc0aae2b572d87e2807fa8.1448411122.git.andrew.burgess@embecosm.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes There is an inconsistency with the handling of the special +/- arguments to the list command. For the very first time that list is used (after the inferior has changed locations) then only the first character of the argument string is checked, so 'list +BLAH' will operate as 'list +' and 'list -----FOO' will operate as 'list -'. This compares to each subsequent use of list, where the whole argument string is checked, so 'list +BLAH' will try to list lines of code around the function '+BLAH'. This commit unifies the behaviour so that the whole argument string is checked, in order to list the next 10, or previous 10 lines from a file only 'list +' and 'list -' are now valid. gdb/ChangeLog: * cli/cli-cmds.c (list_command): Check that the argument string is a single character, either '+' or '-'. gdb/testsuite/ChangeLog: * gdb.base/list.exp (test_list_invalid_args): New function, defined, and called. --- gdb/ChangeLog | 5 +++++ gdb/cli/cli-cmds.c | 6 +++--- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.base/list.exp | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a19ed49..4099267 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2015-11-24 Andrew Burgess + * cli/cli-cmds.c (list_command): Check that the argument string is + a single character, either '+' or '-'. + +2015-11-24 Andrew Burgess + * cli/cli-cmds.c (list_command): Move all handling of +/- arguments into a single if block. diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index c47526f..be84f81 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -907,7 +907,7 @@ list_command (char *arg, int from_tty) cleanup = make_cleanup (null_cleanup, NULL); /* Pull in the current default source line if necessary. */ - if (arg == NULL || arg[0] == '+' || arg[0] == '-') + if (arg == NULL || ((arg[0] == '+' || arg[0] == '-') && arg[1] == '\0')) { set_default_source_symtab_and_line (); cursal = get_current_source_symtab_and_line (); @@ -935,7 +935,7 @@ list_command (char *arg, int from_tty) /* "l" or "l +" lists next ten lines. */ - if (arg == NULL || strcmp (arg, "+") == 0) + if (arg == NULL || arg[0] == '+') { print_source_lines (cursal.symtab, cursal.line, cursal.line + get_lines_to_list (), 0); @@ -944,7 +944,7 @@ list_command (char *arg, int from_tty) /* "l -" lists previous ten lines, the ones before the ten just listed. */ - if (strcmp (arg, "-") == 0) + if (arg[0] == '-') { print_source_lines (cursal.symtab, max (get_first_line_listed () diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 60bd923..009044c 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2015-11-24 Andrew Burgess + * gdb.base/list.exp (test_list_invalid_args): New function, + defined, and called. + +2015-11-24 Andrew Burgess + * gdb.base/list.exp (test_list): Make test names unique. 2015-11-23 Simon Marchi diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp index 84ae251..1b9d4e6 100644 --- a/gdb/testsuite/gdb.base/list.exp +++ b/gdb/testsuite/gdb.base/list.exp @@ -505,6 +505,24 @@ proc test_only_end {} { gdb_test "list ,5" "list ,5\r\n4\[ \t\]\[^\r\n\]*\r\n5\[ \t\]\[^\r\n\]*" } +proc test_list_invalid_args {} { + global binfile + + clean_restart ${binfile} + gdb_test "list -INVALID" \ + "invalid explicit location argument, \"-INVALID\"" \ + "First use of \"list -INVALID\"" + gdb_test "list -INVALID" \ + "invalid explicit location argument, \"-INVALID\"" \ + "Second use of \"list -INVALID\"" + + clean_restart ${binfile} + gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \ + "First use of \"list +INVALID\"" + gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \ + "Second use of \"list +INVALID\"" +} + # Start with a fresh gdb. gdb_exit @@ -527,6 +545,7 @@ if [ set_listsize 10 ] then { test_list_filename_and_function test_forward_search test_only_end + test_list_invalid_args } # Follows tests that require execution.