+2008-06-05 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * Makefile.in: Update dependencies.
+ * dwarf2expr.c: New include "gdb_assert.h".
+ (new_dwarf_expr_context): Initialize MAX_RECURSION_DEPTH.
+ (dwarf_expr_eval): Sanity check the RECURSION_DEPTH count.
+ (execute_stack_op): Error out on too large RECURSION_DEPTH.
+ Increase/decrease RECURSION_DEPTH around the function.
+
2008-06-05 Daniel Jacobowitz <dan@codesourcery.com>
* remote.c (get_offsets): Handle a single segment.
dfp.o: dfp.c $(defs_h) $(expression_h) $(gdbtypes_h) $(value_h) $(dfp_h) \
$(decimal128_h) $(decimal64_h) $(decimal32_h)
dwarf2expr.o: dwarf2expr.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(value_h) \
- $(gdbcore_h) $(elf_dwarf2_h) $(dwarf2expr_h)
+ $(gdbcore_h) $(elf_dwarf2_h) $(dwarf2expr_h) $(gdb_assert_h)
dwarf2-frame.o: dwarf2-frame.c $(defs_h) $(dwarf2expr_h) $(elf_dwarf2_h) \
$(frame_h) $(frame_base_h) $(frame_unwind_h) $(gdbcore_h) \
$(gdbtypes_h) $(symtab_h) $(objfiles_h) $(regcache_h) \
#include "gdbcore.h"
#include "elf/dwarf2.h"
#include "dwarf2expr.h"
+#include "gdb_assert.h"
/* Local prototypes. */
retval->stack = xmalloc (retval->stack_allocated * sizeof (CORE_ADDR));
retval->num_pieces = 0;
retval->pieces = 0;
+ retval->max_recursion_depth = 0x100;
return retval;
}
void
dwarf_expr_eval (struct dwarf_expr_context *ctx, gdb_byte *addr, size_t len)
{
+ int old_recursion_depth = ctx->recursion_depth;
+
execute_stack_op (ctx, addr, addr + len);
+
+ /* CTX RECURSION_DEPTH becomes invalid if an exception was thrown here. */
+
+ gdb_assert (ctx->recursion_depth == old_recursion_depth);
}
/* Decode the unsigned LEB128 constant at BUF into the variable pointed to
ctx->in_reg = 0;
ctx->initialized = 1; /* Default is initialized. */
+ if (ctx->recursion_depth > ctx->max_recursion_depth)
+ error (_("DWARF-2 expression error: Loop detected (%d)."),
+ ctx->recursion_depth);
+ ctx->recursion_depth++;
+
while (op_ptr < op_end)
{
enum dwarf_location_atom op = *op_ptr++;
dwarf_expr_push (ctx, result);
no_push:;
}
+
+ ctx->recursion_depth--;
+ gdb_assert (ctx->recursion_depth >= 0);
}