From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20925 invoked by alias); 6 Aug 2012 15:31:20 -0000 Received: (qmail 20910 invoked by uid 22791); 6 Aug 2012 15:31:19 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Aug 2012 15:31:02 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q76FV1h6002463 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 6 Aug 2012 11:31:01 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q76FV02i028065 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 6 Aug 2012 11:31:00 -0400 From: Tom Tromey To: Jan Kratochvil Cc: gdb-patches@sourceware.org Subject: Re: RFC: one approach to fixing PR 14100 References: <87r4rpqnng.fsf@fleche.redhat.com> <877gtgneto.fsf@fleche.redhat.com> <20120803210203.GA21083@host2.jankratochvil.net> <87k3xfl8oj.fsf@fleche.redhat.com> Date: Mon, 06 Aug 2012 15:31:00 -0000 In-Reply-To: <87k3xfl8oj.fsf@fleche.redhat.com> (Tom Tromey's message of "Fri, 03 Aug 2012 19:58:36 -0600") Message-ID: <87vcgwjavg.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00180.txt.bz2 >>>>> "Tom" == Tom Tromey writes: Tom> Then we need a cleanup instead. Tom> I'll look at it on Monday. Here it is. I regression-tested it on x86-64 Fedora 16. Tom * dwarf2-frame.c (clear_pointer_cleanup): New function. (dwarf2_frame_cache): Use it. * frame-unwind.h (frame_sniffer_ftype): Document prologue cache initialization constraint. diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c index 741a103..986aaea 100644 --- a/gdb/dwarf2-frame.c +++ b/gdb/dwarf2-frame.c @@ -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; } diff --git a/gdb/frame-unwind.h b/gdb/frame-unwind.h index f82d763..aa58640 100644 --- a/gdb/frame-unwind.h +++ b/gdb/frame-unwind.h @@ -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,