This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/5] Emit wrong value error when parsing range


The current code in get_number_or_range doesn't check the return value
of get_number, so current gdb does:

 (gdb) thread apply 1-1.2 bt
 inverted range

which is a little bit confusing.  This patch adds a check to
get_number's return value, and emit error "wrong value" if return
value is zero.  With this patch applied, gdb prints:

 (gdb) thread apply 1-1.2 bt
 wrong value

gdb:

2014-03-13  Yao Qi  <yao@codesourcery.com>

	* cli/cli-utils.c (get_number_or_range): Error out if get_number
	returns zero.
---
 gdb/cli/cli-utils.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c
index a0ebc11..d59a231 100644
--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -146,7 +146,9 @@ get_number_or_range (struct get_number_or_range_state *state)
 	  temp = &state->end_ptr; 
 	  state->end_ptr = skip_spaces (state->string + 1);
 	  state->end_value = get_number (temp);
-	  if (state->end_value < state->last_retval) 
+	  if (state->end_value == 0)
+	    error (_("wrong value"));
+	  else if (state->end_value < state->last_retval) 
 	    {
 	      error (_("inverted range"));
 	    }
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]