This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 3/4] Handle parse number error in goto_bookmark_command
- From: Yao Qi <yao at codesourcery dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Thu, 6 Mar 2014 15:07:42 +0800
- Subject: Re: [PATCH 3/4] Handle parse number error in goto_bookmark_command
- Authentication-results: sourceware.org; auth=none
- References: <1394023608-10761-1-git-send-email-yao at codesourcery dot com> <1394023608-10761-4-git-send-email-yao at codesourcery dot com> <20140305143813 dot GC16858 at adacore dot com>
On 03/05/2014 10:38 PM, Joel Brobecker wrote:
>> (gdb) goto-bookmark 1.1
>> > goto-bookmark: no bookmark found for '1.1'.
> I would use "invalid bookmark number"...
>
OK, this message is fine to me. Patch is updated and pushed in.
--
Yao (éå)
Handle parse number error in goto_bookmark_command
In GDB mainline, the error message for goto-bookmark
isn't perfect.
(gdb) goto-bookmark 1.1
goto-bookmark: no bookmark found for ''.
This patch tweaks the error message by checking the return value of
get_number. With patch applied, it becomes:
(gdb) goto-bookmark 1.1
goto-bookmark: invalid bookmark number '1.1'.
gdb:
2014-03-06 Yao Qi <yao@codesourcery.com>
* reverse.c (goto_bookmark_command): Add local 'p'. Emit error
early if get_number returns zero. Use 'p' instead of 'args'.
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8088e64..3a1124a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2014-03-06 Yao Qi <yao@codesourcery.com>
+ * reverse.c (goto_bookmark_command): Add local 'p'. Emit error
+ early if get_number returns zero. Use 'p' instead of 'args'.
+
+2014-03-06 Yao Qi <yao@codesourcery.com>
+
* cli/cli-utils.c (get_number_trailer): Add '\n' at the end of
message.
diff --git a/gdb/reverse.c b/gdb/reverse.c
index 582252c..30a0328 100644
--- a/gdb/reverse.c
+++ b/gdb/reverse.c
@@ -250,6 +250,7 @@ goto_bookmark_command (char *args, int from_tty)
{
struct bookmark *b;
unsigned long num;
+ char *p = args;
if (args == NULL || args[0] == '\0')
error (_("Command requires an argument."));
@@ -274,6 +275,10 @@ goto_bookmark_command (char *args, int from_tty)
/* General case. Bookmark identified by bookmark number. */
num = get_number (&args);
+
+ if (num == 0)
+ error (_("goto-bookmark: invalid bookmark number '%s'."), p);
+
ALL_BOOKMARKS (b)
if (b->number == num)
break;
@@ -285,7 +290,7 @@ goto_bookmark_command (char *args, int from_tty)
return;
}
/* Not found. */
- error (_("goto-bookmark: no bookmark found for '%s'."), args);
+ error (_("goto-bookmark: no bookmark found for '%s'."), p);
}
static int