* dwarf2loc.c (dwarf2_evaluate_loc_desc): Make a cleanup.
authorTom Tromey <tromey@redhat.com>
Tue, 11 Aug 2009 20:36:49 +0000 (20:36 +0000)
committerTom Tromey <tromey@redhat.com>
Tue, 11 Aug 2009 20:36:49 +0000 (20:36 +0000)
(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.

gdb/ChangeLog
gdb/dwarf2-frame.c
gdb/dwarf2expr.c
gdb/dwarf2expr.h
gdb/dwarf2loc.c

index 6355f7bec63c767627c0655850ba00531cd34f2c..c81b7f5758c4e50a634591b53a3a3ff587d2e902 100644 (file)
@@ -1,3 +1,12 @@
+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.
index 0f6da4052b47c23de035eb09fec5517c17c71ea5..427f58f5cd4fa9136498615da7f8c3a97680401d 100644 (file)
@@ -352,8 +352,11 @@ execute_stack_op (gdb_byte *exp, ULONGEST len, int addr_size,
 {
   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;
@@ -369,7 +372,7 @@ execute_stack_op (gdb_byte *exp, ULONGEST len, int addr_size,
   if (ctx->in_reg)
     result = read_reg (this_frame, result);
 
-  free_dwarf_expr_context (ctx);
+  do_cleanups (old_chain);
 
   return result;
 }
index 8dbf97694b671b9db391a2b95a544cf102b86aa2..2721065b307535692b453744bd05dede9d503fa2 100644 (file)
@@ -61,6 +61,22 @@ free_dwarf_expr_context (struct dwarf_expr_context *ctx)
   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.  */
 
index 70479221d749f97e0fbf42c0651cf65d9ecc76e1..2306e490348e2ab5acc2f313d4c28215ac9146b2 100644 (file)
@@ -131,6 +131,8 @@ struct dwarf_expr_piece
 
 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);
index 071b5ac14a6525a0f14b89246a381175793b24ad..1df6a9f05c4ce6646115b2816bf6803f1b1138ef 100644 (file)
@@ -215,6 +215,7 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
   struct value *retval;
   struct dwarf_expr_baton baton;
   struct dwarf_expr_context *ctx;
+  struct cleanup *old_chain;
 
   if (size == 0)
     {
@@ -228,6 +229,8 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
   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;
@@ -282,7 +285,7 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
 
   set_value_initialized (retval, ctx->initialized);
 
-  free_dwarf_expr_context (ctx);
+  do_cleanups (old_chain);
 
   return retval;
 }
@@ -346,10 +349,13 @@ dwarf2_loc_desc_needs_frame (gdb_byte *data, unsigned short size,
   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;
@@ -373,7 +379,7 @@ dwarf2_loc_desc_needs_frame (gdb_byte *data, unsigned short size,
           in_reg = 1;
     }
 
-  free_dwarf_expr_context (ctx);
+  do_cleanups (old_chain);
 
   return baton.needs_frame || in_reg;
 }
This page took 0.031623 seconds and 4 git commands to generate.