This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 3/4] Handle parse number error in goto_bookmark_command
- From: Yao Qi <yao at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Wed, 5 Mar 2014 20:46:47 +0800
- Subject: [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>
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: no bookmark found for '1.1'.
gdb:
2014-03-05 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'.
---
gdb/reverse.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/gdb/reverse.c b/gdb/reverse.c
index 582252c..0ceecf9 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: no bookmark found for '%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
--
1.7.7.6