From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12551 invoked by alias); 14 Jun 2011 11:53:49 -0000 Received: (qmail 12541 invoked by uid 22791); 14 Jun 2011 11:53:48 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Jun 2011 11:53:33 +0000 Received: (qmail 26709 invoked from network); 14 Jun 2011 11:53:32 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 14 Jun 2011 11:53:32 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [RFC] i386 PLT stub unwinder Date: Tue, 14 Jun 2011 11:53:00 -0000 User-Agent: KMail/1.13.6 (Linux/2.6.38-8-generic; KDE/4.6.2; x86_64; ; ) Cc: Mark Kettenis References: <201106131555.p5DFtucc019690@glazunov.sibelius.xs4all.nl> <201106141249.28010.pedro@codesourcery.com> In-Reply-To: <201106141249.28010.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201106141252.56583.pedro@codesourcery.com> X-IsSubscribed: yes 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: 2011-06/txt/msg00189.txt.bz2 On Tuesday 14 June 2011 12:49:27, Pedro Alves wrote: > Might as well write that in patch form. See below. You > can merge it into yours, or have me apply it when yours goes > in, as you prefer. Sorry, forgot to quilt refresh. This is right patch. -- Pedro Alves --- gdb/i386-tdep.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) Index: src/gdb/i386-tdep.c =================================================================== --- src.orig/gdb/i386-tdep.c 2011-06-14 12:05:30.000000000 +0100 +++ src/gdb/i386-tdep.c 2011-06-14 12:42:41.286489839 +0100 @@ -2125,6 +2125,7 @@ struct i386_insn i386_pic_plt_stub_insns static struct i386_frame_cache * i386_plt_stub_frame_cache (struct frame_info *this_frame, void **this_cache) { + volatile struct gdb_exception ex; struct i386_frame_cache *cache; struct i386_insn *insn; LONGEST sp_offset = -4; @@ -2205,15 +2206,33 @@ i386_plt_stub_frame_cache (struct frame_ cache->pc = pc; - sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM); - cache->base = sp + cache->sp_offset; - cache->saved_sp = cache->base + 8; - cache->saved_regs[I386_EIP_REGNUM] = cache->base + 4; + TRY_CATCH (ex, RETURN_MASK_ERROR) + { + sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM); + cache->base = sp + cache->sp_offset; + cache->saved_sp = cache->base + 8; + cache->saved_regs[I386_EIP_REGNUM] = cache->base + 4; + cache->base_p = 1; + } + if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR) + throw_exception (ex); - cache->base_p = 1; return cache; } +static enum unwind_stop_reason +i386_plt_stub_frame_unwind_stop_reason (struct frame_info *this_frame, + void **this_cache) +{ + struct i386_frame_cache *cache = + i386_plt_stub_frame_cache (this_frame, this_cache); + + if (!cache->base_p) + return UNWIND_UNAVAILABLE; + + return UNWIND_NO_REASON; +} + static void i386_plt_stub_frame_this_id (struct frame_info *this_frame, void **this_cache, struct frame_id *this_id) @@ -2221,6 +2240,9 @@ i386_plt_stub_frame_this_id (struct fram struct i386_frame_cache *cache = i386_plt_stub_frame_cache (this_frame, this_cache); + if (!cache->base_p) + return; + /* See the end of i386_push_dummy_call. */ (*this_id) = frame_id_build (cache->base + 8, cache->pc); } @@ -2256,7 +2278,7 @@ i386_plt_stub_frame_sniffer (const struc static const struct frame_unwind i386_plt_stub_frame_unwind = { NORMAL_FRAME, - default_frame_unwind_stop_reason, + i386_plt_stub_frame_unwind_stop_reason, i386_plt_stub_frame_this_id, i386_plt_stub_frame_prev_register,