]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* dwarf2-frame.c (clear_pointer_cleanup): New function.
authorTom Tromey <tromey@redhat.com>
Mon, 6 Aug 2012 19:20:43 +0000 (19:20 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 6 Aug 2012 19:20:43 +0000 (19:20 +0000)
(dwarf2_frame_cache): Use it.
* frame-unwind.h (frame_sniffer_ftype): Document prologue
cache initialization constraint.

gdb/ChangeLog
gdb/dwarf2-frame.c
gdb/frame-unwind.h

index e2ff0a9b73f9e016417a1214a0b022f4637555e3..c300886c6fda4698a9340b8e499eb4046ebba1a4 100644 (file)
@@ -1,3 +1,10 @@
+2012-08-06  Tom Tromey  <tromey@redhat.com>
+
+       * dwarf2-frame.c (clear_pointer_cleanup): New function.
+       (dwarf2_frame_cache): Use it.
+       * frame-unwind.h (frame_sniffer_ftype): Document prologue
+       cache initialization constraint.
+
 2012-08-06  Tom Tromey  <tromey@redhat.com>
 
        PR python/14386:
index 741a10333e36915d1d5f31bff31b5f32c7e13ed7..986aaea2335e59f3fded32c487e337495c4cc014 100644 (file)
@@ -994,10 +994,20 @@ struct dwarf2_frame_cache
   void *tailcall_cache;
 };
 
+/* A cleanup that sets a pointer to NULL.  */
+
+static void
+clear_pointer_cleanup (void *arg)
+{
+  void **ptr = arg;
+
+  *ptr = NULL;
+}
+
 static struct dwarf2_frame_cache *
 dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
-  struct cleanup *old_chain;
+  struct cleanup *reset_cache_cleanup, *old_chain;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   const int num_regs = gdbarch_num_regs (gdbarch)
                       + gdbarch_num_pseudo_regs (gdbarch);
@@ -1017,6 +1027,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
   cache = FRAME_OBSTACK_ZALLOC (struct dwarf2_frame_cache);
   cache->reg = FRAME_OBSTACK_CALLOC (num_regs, struct dwarf2_frame_state_reg);
   *this_cache = cache;
+  reset_cache_cleanup = make_cleanup (clear_pointer_cleanup, this_cache);
 
   /* Allocate and initialize the frame state.  */
   fs = XZALLOC (struct dwarf2_frame_state);
@@ -1111,6 +1122,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
        {
          cache->unavailable_retaddr = 1;
          do_cleanups (old_chain);
+         discard_cleanups (reset_cache_cleanup);
          return cache;
        }
 
@@ -1226,6 +1238,7 @@ incomplete CFI data; unspecified registers (e.g., %s) at %s"),
                                 (entry_cfa_sp_offset_p
                                  ? &entry_cfa_sp_offset : NULL));
 
+  discard_cleanups (reset_cache_cleanup);
   return cache;
 }
 
index f82d76366bb26c8ad088728bdf305b6ded60723a..aa5864078584ab474a34fd9fddce4aa852308e40 100644 (file)
@@ -44,7 +44,9 @@ struct value;
 
 /* Given THIS frame, take a whiff of its registers (namely
    the PC and attributes) and if SELF is the applicable unwinder,
-   return non-zero.  Possibly also initialize THIS_PROLOGUE_CACHE.  */
+   return non-zero.  Possibly also initialize THIS_PROLOGUE_CACHE; but
+   only if returning 1.  Initializing THIS_PROLOGUE_CACHE in other
+   cases (0 return, or exception) is invalid.  */
 
 typedef int (frame_sniffer_ftype) (const struct frame_unwind *self,
                                   struct frame_info *this_frame,