SEGV during AX eval of OP_DOUBLE (unsupported)
authorJoel Brobecker <brobecker@gnat.com>
Wed, 21 Mar 2012 15:16:24 +0000 (15:16 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Wed, 21 Mar 2012 15:16:24 +0000 (15:16 +0000)
To reproduce the problem, simply try the following with any program:

    (gdb) maintenance agent-eval 1.0
    Critical error handler: process [...] terminated due to access violation

(this is on Windows; on GNU/Linux, the libc copes better)

The problem is quite simple: gen_expr is given an expression that
contains an unrecognized operator (OP_DOUBLE in this case). When that
happens, it tries to report an error with a string image of the operator
in the error message.  Conversion of the opcode into a string is done
using op_string which, despite its name, probably is not what the author
was looking for.  This function returns NULL for a lot of the opcodes,
thus triggering the crash.

There is a function that corresponds to what we are looking for:
expprint.c:op_name. It was static, though, so I made it non-static,
and used it from ax-gdb.c:gen_expr.

gdb/ChangeLog:

        * expression.h (op_name): Add declaration.
        * expprint.c (op_name): Remove declaration.  Make non-static.
        * ax-gdb.c (gen_expr): Use op_name instead of op_string.

gdb/ChangeLog
gdb/ax-gdb.c
gdb/expprint.c
gdb/expression.h

index 53440677db1f8b933f86530d37a0ff7a6edc06cd..aff420c29e9a408126ebda5b0f50ce13d57bd304 100644 (file)
@@ -1,3 +1,9 @@
+2012-03-21  Joel Brobecker  <brobecker@adacore.com>
+
+       * expression.h (op_name): Add declaration.
+       * expprint.c (op_name): Remove declaration.  Make non-static.
+       * ax-gdb.c (gen_expr): Use op_name instead of op_string.
+
 2012-03-21  Thomas Schwinge  <thomas@codesourcery.com>
 
        * amd64-linux-nat.c (amd64_linux_siginfo_fixup): Use siginfo_t instead
index a76e7817206f6becec6b430863be248990129b68..aaefed6f6a2fd921e7c66d561dc5daf104dfc234 100644 (file)
@@ -2217,7 +2217,7 @@ gen_expr (struct expression *exp, union exp_element **pc,
 
     default:
       error (_("Unsupported operator %s (%d) in expression."),
-            op_string (op), op);
+            op_name (exp, op), op);
     }
 }
 
index d9d9b8fc873d541ca07d94c69abd1fcb46d2df23..fd1fccb0693b2f0ed7b1d481dbed8b26f44066ae 100644 (file)
@@ -647,12 +647,11 @@ op_string (enum exp_opcode op)
 /* Support for dumping the raw data from expressions in a human readable
    form.  */
 
-static char *op_name (struct expression *, enum exp_opcode);
 static int dump_subexp_body (struct expression *exp, struct ui_file *, int);
 
 /* Name for OPCODE, when it appears in expression EXP.  */
 
-static char *
+char *
 op_name (struct expression *exp, enum exp_opcode opcode)
 {
   return exp->language_defn->la_exp_desc->op_name (opcode);
index be26002998511e4a94f12a865a950fe0cc8a6926..ace58f2b4764599394de7d242911eb6fdd3f718c 100644 (file)
@@ -137,6 +137,8 @@ extern struct value *evaluate_subexp_standard
 
 extern void print_expression (struct expression *, struct ui_file *);
 
+extern char *op_name (struct expression *exp, enum exp_opcode opcode);
+
 extern char *op_string (enum exp_opcode);
 
 extern void dump_raw_expression (struct expression *,
This page took 0.030753 seconds and 4 git commands to generate.