From patchwork Fri Feb 6 15:31:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 4940 Received: (qmail 10052 invoked by alias); 6 Feb 2015 15:32:02 -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 10033 invoked by uid 89); 6 Feb 2015 15:32:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg21.ericsson.net Received: from usevmg21.ericsson.net (HELO usevmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 06 Feb 2015 15:32:00 +0000 Received: from EUSAAHC006.ericsson.se (Unknown_Domain [147.117.188.90]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id E1.0E.25146.3EE74D45; Fri, 6 Feb 2015 09:44:20 +0100 (CET) Received: from [142.133.110.232] (147.117.188.8) by smtp-am.internal.ericsson.com (147.117.188.92) with Microsoft SMTP Server id 14.3.210.2; Fri, 6 Feb 2015 10:31:56 -0500 Message-ID: <54D4DE6C.9050709@ericsson.com> Date: Fri, 6 Feb 2015 10:31:56 -0500 From: Simon Marchi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Pedro Alves CC: GDB Patches Subject: Re: [PATCH] "enable count" user input error handling (PR gdb/15678) References: <51CB340E.2080705@ericsson.com> <51CB3DB8.50908@redhat.com> In-Reply-To: <51CB3DB8.50908@redhat.com> X-IsSubscribed: yes On 13-06-26 03:15 PM, Pedro Alves wrote: > On 06/26/2013 07:33 PM, Simon Marchi wrote: >> Typing "enable count" by itself crashes GDB. Also, if you omit the >> breakpoint number/range, the error message is not very clear: >> >> (gdb) enable count 2 >> warning: bad breakpoint number at or near '' >> (gdb) enable count >> Segmentation fault (core dumped) >> >> With this patch, the error messages are slightly more helpful: >> >> (gdb) enable count 2 >> Argument required (one or more breakpoint numbers). > > Most if not all enable/disable breakpoint-and-similars commands > when not passed a breakpoint number apply to all breakpoints. > Supporting that would make it possible to disable the count > for all breakpoints with just "enable count 0". > > WDY(all)T of making that work? > >> (gdb) enable count >> Argument required (hit count). >> >> They are not as helpful to the user as I would like, but it's better >> than crashing. Suggestions are welcome. >> >> Simon >> >> gdb/ChangeLog: >> 2013-06-26 Simon Marchi >> >> * breakpoint.c (map_breakpoint_numbers): Check for empty args >> string. >> (enable_count_command): Check args for NULL value. >> >> gdb/testsuite/ChangeLog: >> 2013-06-26 Simon Marchi >> >> * gdb.base/ena-dis-br.exp: Test "enable count" for bad user input. > > This is OK. Please add a line to the ChangeLog entries mentioning > the PR number. That'll make the commit automatically be logged with > the PR (provided the ChangeLog entry is pasted in the commit log). > See existing entries for examples, or the contribution > checklist page in the wiki for a more format explanation. > > Thanks! While scanning the bugzilla, I realized that this patch was never pushed. I submitted it before I had my copyright assignment and then forgot about it. So I added the PR number in the changelog and pushed it like that, since it's not very critical. From b9d6130764916fac3d9bcfde2d672053a0ef3316 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 2 Feb 2015 14:57:31 -0500 Subject: [PATCH] "enable count" user input error handling (PR gdb/15678) Typing "enable count" by itself crashes GDB. Also, if you omit the breakpoint number/range, the error message is not very clear: (gdb) enable count 2 warning: bad breakpoint number at or near '' (gdb) enable count Segmentation fault (core dumped) With this patch, the error messages are slightly more helpful: (gdb) enable count 2 Argument required (one or more breakpoint numbers). (gdb) enable count Argument required (hit count). gdb/ChangeLog: PR gdb/15678 * breakpoint.c (map_breakpoint_numbers): Check for empty args string. (enable_count_command): Check args for NULL value. gdb/testsuite/ChangeLog: PR gdb/15678 * gdb.base/ena-dis-br.exp: Test "enable count" for bad user input. --- gdb/ChangeLog | 6 ++++++ gdb/breakpoint.c | 9 +++++++-- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.base/ena-dis-br.exp | 8 ++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7c7e878..dbeef19 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2015-02-06 Simon Marchi + + PR gdb/15678 + * breakpoint.c (map_breakpoint_numbers): Check for empty args string. + (enable_count_command): Check args for NULL value. + 2015-02-05 Doug Evans * guile/scm-frame.c: Fix spelling errors in a comment. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index af0c2cf..2804453 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -14880,7 +14880,7 @@ map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *, int match; struct get_number_or_range_state state; - if (args == 0) + if (args == 0 || *args == '\0') error_no_arg (_("one or more breakpoint numbers")); init_number_or_range (&state, args); @@ -15217,7 +15217,12 @@ do_map_enable_count_breakpoint (struct breakpoint *bpt, void *countptr) static void enable_count_command (char *args, int from_tty) { - int count = get_number (&args); + int count; + + if (args == NULL) + error_no_arg (_("hit count")); + + count = get_number (&args); map_breakpoint_numbers (args, do_map_enable_count_breakpoint, &count); } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f8ca4e8..c458bd7 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-02-06 Simon Marchi + + PR gdb/15678 + * gdb.base/ena-dis-br.exp: Test "enable count" for bad user input. + 2015-02-06 Pedro Alves * gdb.threads/attach-many-short-lived-threads.c (SECONDS): New diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp index adb4001..84f84cae 100644 --- a/gdb/testsuite/gdb.base/ena-dis-br.exp +++ b/gdb/testsuite/gdb.base/ena-dis-br.exp @@ -151,6 +151,14 @@ set bp [break_at $bp_location7 "line $bp_location7"] set bp2 [break_at marker1 " line $bp_location15"] +gdb_test "enable count" \ + "Argument required \\(hit count\\)\\." \ + "enable count missing arguments" + +gdb_test "enable count 2" \ + "Argument required \\(one or more breakpoint numbers\\)\\." \ + "enable count missing breakpoint number" + gdb_test_no_output "enable count 2 $bp" "disable break with count" gdb_test "continue" \