Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Mark Kettenis <mark.kettenis@xs4all.nl>
Subject: Re: [RFC] i386 PLT stub unwinder
Date: Tue, 14 Jun 2011 11:53:00 -0000	[thread overview]
Message-ID: <201106141252.56583.pedro@codesourcery.com> (raw)
In-Reply-To: <201106141249.28010.pedro@codesourcery.com>

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,


      reply	other threads:[~2011-06-14 11:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-13 15:56 Mark Kettenis
2011-06-13 16:14 ` Jan Kratochvil
2011-06-13 16:32   ` Joel Brobecker
2011-06-13 16:43   ` Tom Tromey
2011-06-13 19:15     ` Mark Kettenis
2011-06-14 11:49 ` Pedro Alves
2011-06-14 11:53   ` Pedro Alves [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201106141252.56583.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox