From patchwork Wed Nov 25 00:34:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 9817 Received: (qmail 86988 invoked by alias); 25 Nov 2015 00:34:54 -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 86918 invoked by uid 89); 25 Nov 2015 00:34:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-wm0-f45.google.com Received: from mail-wm0-f45.google.com (HELO mail-wm0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 25 Nov 2015 00:34:49 +0000 Received: by wmuu63 with SMTP id u63so118228035wmu.0 for ; Tue, 24 Nov 2015 16:34:46 -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=JNnhsJBHudp20XEe9ojviyyzJm+r0ViFU0F4pJHNT7U=; b=UkdsAzd0xJ0+4OpX7PC/H2UFuo9WnkUwuVu9B7nHGPoodhVmcM5nQIT6xC4ST9savQ FI5nDsP/3/a62YZxkDXWwi7Um2XF0wE9D3xVdRiDq029KSGzszDtQ8XsDU5thMNUmMOZ saK13J/XeikcIUh4HlkknSoPveUXLHu0BNmwX2lsmxw88SQC1mUa24aB0Lmz6+cAmx6i 8+ek7t4YgJj1YW0eB/R9HGcwXfXPBNBqHzWaFigs70SCXas2SCb89kxrUDovbosHdJPo Q1+PNh/9deCsy/3hFXsCbT7/dHSfwg7NK6G4iZ6OybVzXD1o7u8YWo7Hf8n4pCmP94hY Xirg== X-Gm-Message-State: ALoCoQkcqtXXXQFifNKirdIsGVPNig3Uj3XJl8O7H3BfKi/NFdJKTZ1m6+OzMu0C4mYRoBKCsWaN X-Received: by 10.28.64.7 with SMTP id n7mr1254039wma.30.1448411686089; Tue, 24 Nov 2015 16:34:46 -0800 (PST) Received: from localhost (host86-138-95-213.range86-138.btcentralplus.com. [86.138.95.213]) by smtp.gmail.com with ESMTPSA id t5sm952986wmt.1.2015.11.24.16.34.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Nov 2015 16:34:45 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 6/7] gdb: Add an error when 'list -' reaches the start of a file. Date: Wed, 25 Nov 2015 00:34:31 +0000 Message-Id: <3cbf859f648e8f9df42755149ecac45a17603eca.1448411122.git.andrew.burgess@embecosm.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes When a a user uses 'list +' to list forward through a source file they eventually reach the end of the source file. Subsequent uses of 'list +' result in an error message like this, that let the user know they are at the end of the source file: Line number XXX out of range; FILENAME has YYY lines. Compare this to the current behaviour of 'list -' which lists backwards through a source file. When the user reaches the beginning of the source file, subsequent uses of 'list -' result in the command silently returning. This can be confusing if the previous uses of 'list -' have scrolled off the users display, the user receives no reminder that the have already seen the start of the file. After this commit a use of 'list -' when the user has already seen the start of a file will receive the following error: Already at the start of FILENAME. gdb/ChangeLog: * cli/cli-cmds.c (list_command): Add an error when trying to use '-' to scan read off the start of the source file. gdb/testsuite/ChangeLog: * gdb.base/list.exp (test_list_forward): Add end of file error test. (test_repeat_list_command): Add end of file error test. (test_list_backwards): Add beginning of file error test. --- gdb/ChangeLog | 5 +++++ gdb/cli/cli-cmds.c | 3 +++ gdb/testsuite/ChangeLog | 7 +++++++ gdb/testsuite/gdb.base/list.exp | 12 ++++++++++++ 4 files changed, 27 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4099267..278acb5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2015-11-24 Andrew Burgess + * cli/cli-cmds.c (list_command): Add an error when trying to use + '-' to scan read off the start of the source file. + +2015-11-24 Andrew Burgess + * cli/cli-cmds.c (list_command): Check that the argument string is a single character, either '+' or '-'. diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index be84f81..5e7ef0a 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -946,6 +946,9 @@ list_command (char *arg, int from_tty) listed. */ if (arg[0] == '-') { + if (get_first_line_listed () == 1) + error ("Already at the start of %s.", + symtab_to_filename_for_display (cursal.symtab)); print_source_lines (cursal.symtab, max (get_first_line_listed () - get_lines_to_list (), 1), diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 009044c..717e887 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,12 @@ 2015-11-24 Andrew Burgess + * gdb.base/list.exp (test_list_forward): Add end of file error + test. + (test_repeat_list_command): Add end of file error test. + (test_list_backwards): Add beginning of file error test. + +2015-11-24 Andrew Burgess + * gdb.base/list.exp (test_list_invalid_args): New function, defined, and called. diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp index 1b9d4e6..87878f6 100644 --- a/gdb/testsuite/gdb.base/list.exp +++ b/gdb/testsuite/gdb.base/list.exp @@ -244,6 +244,10 @@ proc test_list_forward {} { } pass "successive list commands to page forward ($testcnt tests)" + + gdb_test "list" "Line number 44 out of range; \[^\r\n\]+ has 43 lines\." \ + "End of file error after \"list\" command." + gdb_stop_suppressing_tests } @@ -287,6 +291,10 @@ proc test_repeat_list_command {} { } pass "repeat list commands to page forward using 'return' ($testcnt tests)" + + gdb_test "list" "Line number 44 out of range; \[^\r\n\]+ has 43 lines\." \ + "End of file error after using 'return' to repeat the list command." + gdb_stop_suppressing_tests } @@ -324,6 +332,10 @@ proc test_list_backwards {} { } pass "$testcnt successive \"list -\" commands to page backwards" + + gdb_test "list -" "Already at the start of .*\." \ + "Beginning of file error after \"list -\" command." + gdb_stop_suppressing_tests }