This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Catch exceptions in dump_prefix_expression
- From: dje at google dot com (Doug Evans)
- To: gdb-patches at sourceware dot org
- Date: Thu, 22 Sep 2011 10:44:47 -0700 (PDT)
- Subject: [patch] Catch exceptions in dump_prefix_expression
Hi.
While playing with implementing typeof I ran into behaviour which
changes depending on whether "set debug exp" was set,
which shouldn't happen.
I will check this in in a few days if there are no objections.
2011-09-22 Doug Evans <dje@google.com>
* expprint.c (dump_prefix_expression): Don't allow exceptions to
leak out.
Index: expprint.c
===================================================================
RCS file: /cvs/src/src/gdb/expprint.c,v
retrieving revision 1.52
diff -u -p -r1.52 expprint.c
--- expprint.c 17 Jun 2011 20:24:22 -0000 1.52
+++ expprint.c 22 Sep 2011 17:39:12 -0000
@@ -33,6 +33,7 @@
#include "objfiles.h"
#include "gdb_assert.h"
#include "valprint.h"
+#include "exceptions.h"
#ifdef HAVE_CTYPE_H
#include <ctype.h>
@@ -1007,7 +1008,19 @@ dump_prefix_expression (struct expressio
gdb_print_host_address (exp, stream);
fputs_filtered (", after conversion to prefix form:\nExpression: `", stream);
if (exp->elts[0].opcode != OP_TYPE)
- print_expression (exp, stream);
+ {
+ volatile struct gdb_exception except;
+
+ /* This can throw an error, which we don't want to let through
+ as this is for debugging purposes. */
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ print_expression (exp, stream);
+ }
+ if (except.reason < 0)
+ fprintf_filtered (stream, "(Error in expression: %s)",
+ except.message);
+ }
else
fputs_filtered ("Type printing not yet supported....", stream);
fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",