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]

Error out if the offset value isn't of integral type, in agent expressions


I've applied the patch below.  It cures this:

(gdb) list
1       char array[10];
2
3       int main ()
4       {
5               return 0;
6       }
(gdb) ptype main
type = int (void)
(gdb) maint agent array[main]
                        ^^^^
../../src/gdb/ax-gdb.c:969: internal-error: gen_ptradd: Assertion `TYPE_CODE (value2->type) == TYPE_CODE_INT' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

If not obvious, `main' is a function.  One now gets:

(gdb) maint agent array[main]
Argument to arithmetic operation not a number or boolean.

-- 
Pedro Alves

2010-02-11  Pedro Alves  <pedro@codesourcery.com>

	* ax-gdb.c (gen_exp_binop_rest) [BINOP_SUBSCRIPT]: Error out if
	the offset value isn't of integral type.

---
 gdb/ax-gdb.c |    3 +++
 1 file changed, 3 insertions(+)

Index: src/gdb/ax-gdb.c
===================================================================
--- src.orig/gdb/ax-gdb.c	2010-02-11 22:40:03.000000000 +0000
+++ src/gdb/ax-gdb.c	2010-02-11 22:40:29.000000000 +0000
@@ -1910,6 +1910,9 @@ cannot subscript requested type: cannot 
 	      }
 	  }
 
+	if (!is_integral_type (value2->type))
+	  error (_("Argument to arithmetic operation not a number or boolean."));
+
 	gen_ptradd (ax, value, value1, value2);
 	gen_deref (ax, value);
 	break;


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