This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Add proper error message instead of gdb_assert
Daniel Jacobowitz schrieb:
On Mon, Mar 03, 2008 at 12:28:51PM -0800, Michael Snyder wrote:
On Mon, 2008-03-03 at 20:55 +0100, Mark Kettenis wrote:
Sorry, but I don't see why your error message is "proper". The
gdb_assert() should never fail; the fact that it does means that you
have a bug elsewhere in gdb.
Isn't that what the "internal error" call is for?
gdb_assert calls internal_error anyway.
What about the attached patch? It gives an error message in value_assign if you try to
access lval_register < 0. I guess this is much better for the user than a crashed GDB session.
What do you think ?
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
diff -urpN gdb-6.7-orig/gdb/valops.c gdb-6.7/gdb/valops.c
--- gdb-6.7-orig/gdb/valops.c 2007-08-23 20:08:46.000000000 +0200
+++ gdb-6.7/gdb/valops.c 2008-03-03 22:05:59.000000000 +0100
@@ -623,10 +623,12 @@ value_assign (struct value *toval, struc
struct frame_info *frame;
int value_reg;
- /* Figure out which frame this is in currently. */
- frame = frame_find_by_id (VALUE_FRAME_ID (toval));
value_reg = VALUE_REGNUM (toval);
+ if (value_reg < 0)
+ error (_("Invalid register %d"), value_reg);
+ /* Figure out which frame this is in currently. */
+ frame = frame_find_by_id (VALUE_FRAME_ID (toval));
if (!frame)
error (_("Value being assigned to is no longer active."));