(dwarf2_loc_desc_needs_frame): Likewise.
* dwarf2expr.h (make_cleanup_free_dwarf_expr_context): Declare.
* dwarf2expr.c (free_dwarf_expr_context_cleanup): New function.
(make_cleanup_free_dwarf_expr_context): Likewise.
* dwarf2-frame.c (execute_stack_op): Make a cleanup.
+2009-08-11 Tom Tromey <tromey@redhat.com>
+
+ * dwarf2loc.c (dwarf2_evaluate_loc_desc): Make a cleanup.
+ (dwarf2_loc_desc_needs_frame): Likewise.
+ * dwarf2expr.h (make_cleanup_free_dwarf_expr_context): Declare.
+ * dwarf2expr.c (free_dwarf_expr_context_cleanup): New function.
+ (make_cleanup_free_dwarf_expr_context): Likewise.
+ * dwarf2-frame.c (execute_stack_op): Make a cleanup.
+
2009-08-10 Jan Kratochvil <jan.kratochvil@redhat.com>
* objfiles.c (gdb_bfd_unref): Use the bfd_usrdata accessor.
{
struct dwarf_expr_context *ctx;
CORE_ADDR result;
+ struct cleanup *old_chain;
ctx = new_dwarf_expr_context ();
+ old_chain = make_cleanup_free_dwarf_expr_context (ctx);
+
ctx->gdbarch = get_frame_arch (this_frame);
ctx->addr_size = addr_size;
ctx->baton = this_frame;
if (ctx->in_reg)
result = read_reg (this_frame, result);
- free_dwarf_expr_context (ctx);
+ do_cleanups (old_chain);
return result;
}
xfree (ctx);
}
+/* Helper for make_cleanup_free_dwarf_expr_context. */
+
+static void
+free_dwarf_expr_context_cleanup (void *arg)
+{
+ free_dwarf_expr_context (arg);
+}
+
+/* Return a cleanup that calls free_dwarf_expr_context. */
+
+struct cleanup *
+make_cleanup_free_dwarf_expr_context (struct dwarf_expr_context *ctx)
+{
+ return make_cleanup (free_dwarf_expr_context_cleanup, ctx);
+}
+
/* Expand the memory allocated to CTX's stack to contain at least
NEED more elements than are currently used. */
struct dwarf_expr_context *new_dwarf_expr_context (void);
void free_dwarf_expr_context (struct dwarf_expr_context *ctx);
+struct cleanup *
+ make_cleanup_free_dwarf_expr_context (struct dwarf_expr_context *ctx);
void dwarf_expr_push (struct dwarf_expr_context *ctx, CORE_ADDR value);
void dwarf_expr_pop (struct dwarf_expr_context *ctx);
struct value *retval;
struct dwarf_expr_baton baton;
struct dwarf_expr_context *ctx;
+ struct cleanup *old_chain;
if (size == 0)
{
baton.objfile = dwarf2_per_cu_objfile (per_cu);
ctx = new_dwarf_expr_context ();
+ old_chain = make_cleanup_free_dwarf_expr_context (ctx);
+
ctx->gdbarch = get_objfile_arch (baton.objfile);
ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
ctx->baton = &baton;
set_value_initialized (retval, ctx->initialized);
- free_dwarf_expr_context (ctx);
+ do_cleanups (old_chain);
return retval;
}
struct needs_frame_baton baton;
struct dwarf_expr_context *ctx;
int in_reg;
+ struct cleanup *old_chain;
baton.needs_frame = 0;
ctx = new_dwarf_expr_context ();
+ old_chain = make_cleanup_free_dwarf_expr_context (ctx);
+
ctx->gdbarch = get_objfile_arch (dwarf2_per_cu_objfile (per_cu));
ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
ctx->baton = &baton;
in_reg = 1;
}
- free_dwarf_expr_context (ctx);
+ do_cleanups (old_chain);
return baton.needs_frame || in_reg;
}