Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 7/9] Throw exception in amd64 unwinders
Date: Mon, 31 Jul 2017 22:22:00 -0000	[thread overview]
Message-ID: <1501539715-8049-8-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1501539715-8049-1-git-send-email-yao.qi@linaro.org>

This patch changes amd64 unwinders not to throw exceptions.

gdb:

2017-07-31  Yao Qi  <yao.qi@linaro.org>

	* amd64-tdep.c (amd64_frame_cache) <base_p>: Remove.
	(amd64_init_frame_cache): Update.
	(amd64_frame_cache_1): Update.
	(amd64_frame_unwind_stop_reason): Don't check cache->base_p.
	(amd64_frame_this_id): Likewise.
	(amd64_sigtramp_frame_cache): Don't catch exception.
	(amd64_sigtramp_frame_unwind_stop_reason): Don't check
	cache->base_p.
	(amd64_sigtramp_frame_this_id): Likewise.
	(amd64_epilogue_frame_cache): Don't catch exception.
	(amd64_epilogue_frame_unwind_stop_reason): Don't check
	cache->base_p.
	(amd64_epilogue_frame_this_id): Likewise.
---
 gdb/amd64-tdep.c | 95 +++++++++++++-------------------------------------------
 1 file changed, 22 insertions(+), 73 deletions(-)

diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index f647402..256147b 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -1876,7 +1876,6 @@ struct amd64_frame_cache
 {
   /* Base address.  */
   CORE_ADDR base;
-  int base_p;
   CORE_ADDR sp_offset;
   CORE_ADDR pc;
 
@@ -1898,7 +1897,6 @@ amd64_init_frame_cache (struct amd64_frame_cache *cache)
 
   /* Base address.  */
   cache->base = 0;
-  cache->base_p = 0;
   cache->sp_offset = -8;
   cache->pc = 0;
 
@@ -2531,8 +2529,6 @@ amd64_frame_cache_1 (struct frame_info *this_frame,
   for (i = 0; i < AMD64_NUM_SAVED_REGS; i++)
     if (cache->saved_regs[i] != -1)
       cache->saved_regs[i] += cache->base;
-
-  cache->base_p = 1;
 }
 
 static struct amd64_frame_cache *
@@ -2546,16 +2542,7 @@ amd64_frame_cache (struct frame_info *this_frame, void **this_cache)
   cache = amd64_alloc_frame_cache ();
   *this_cache = cache;
 
-  TRY
-    {
-      amd64_frame_cache_1 (this_frame, cache);
-    }
-  CATCH (ex, RETURN_MASK_ERROR)
-    {
-      if (ex.error != NOT_AVAILABLE_ERROR)
-	throw_exception (ex);
-    }
-  END_CATCH
+  amd64_frame_cache_1 (this_frame, cache);
 
   return cache;
 }
@@ -2567,9 +2554,6 @@ amd64_frame_unwind_stop_reason (struct frame_info *this_frame,
   struct amd64_frame_cache *cache =
     amd64_frame_cache (this_frame, this_cache);
 
-  if (!cache->base_p)
-    return UNWIND_UNAVAILABLE;
-
   /* This marks the outermost frame.  */
   if (cache->base == 0)
     return UNWIND_OUTERMOST;
@@ -2584,9 +2568,7 @@ amd64_frame_this_id (struct frame_info *this_frame, void **this_cache,
   struct amd64_frame_cache *cache =
     amd64_frame_cache (this_frame, this_cache);
 
-  if (!cache->base_p)
-    (*this_id) = frame_id_build_unavailable_stack (cache->pc);
-  else if (cache->base == 0)
+  if (cache->base == 0)
     {
       /* This marks the outermost frame.  */
       return;
@@ -2664,26 +2646,15 @@ amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
 
   cache = amd64_alloc_frame_cache ();
 
-  TRY
-    {
-      get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
-      cache->base = extract_unsigned_integer (buf, 8, byte_order) - 8;
-
-      addr = tdep->sigcontext_addr (this_frame);
-      gdb_assert (tdep->sc_reg_offset);
-      gdb_assert (tdep->sc_num_regs <= AMD64_NUM_SAVED_REGS);
-      for (i = 0; i < tdep->sc_num_regs; i++)
-	if (tdep->sc_reg_offset[i] != -1)
-	  cache->saved_regs[i] = addr + tdep->sc_reg_offset[i];
+  get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
+  cache->base = extract_unsigned_integer (buf, 8, byte_order) - 8;
 
-      cache->base_p = 1;
-    }
-  CATCH (ex, RETURN_MASK_ERROR)
-    {
-      if (ex.error != NOT_AVAILABLE_ERROR)
-	throw_exception (ex);
-    }
-  END_CATCH
+  addr = tdep->sigcontext_addr (this_frame);
+  gdb_assert (tdep->sc_reg_offset);
+  gdb_assert (tdep->sc_num_regs <= AMD64_NUM_SAVED_REGS);
+  for (i = 0; i < tdep->sc_num_regs; i++)
+    if (tdep->sc_reg_offset[i] != -1)
+      cache->saved_regs[i] = addr + tdep->sc_reg_offset[i];
 
   *this_cache = cache;
   return cache;
@@ -2696,9 +2667,6 @@ amd64_sigtramp_frame_unwind_stop_reason (struct frame_info *this_frame,
   struct amd64_frame_cache *cache =
     amd64_sigtramp_frame_cache (this_frame, this_cache);
 
-  if (!cache->base_p)
-    return UNWIND_UNAVAILABLE;
-
   return UNWIND_NO_REASON;
 }
 
@@ -2709,9 +2677,7 @@ amd64_sigtramp_frame_this_id (struct frame_info *this_frame,
   struct amd64_frame_cache *cache =
     amd64_sigtramp_frame_cache (this_frame, this_cache);
 
-  if (!cache->base_p)
-    (*this_id) = frame_id_build_unavailable_stack (get_frame_pc (this_frame));
-  else if (cache->base == 0)
+  if (cache->base == 0)
     {
       /* This marks the outermost frame.  */
       return;
@@ -2841,30 +2807,19 @@ amd64_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache)
   cache = amd64_alloc_frame_cache ();
   *this_cache = cache;
 
-  TRY
-    {
-      /* Cache base will be %esp plus cache->sp_offset (-8).  */
-      get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
-      cache->base = extract_unsigned_integer (buf, 8,
-					      byte_order) + cache->sp_offset;
+  /* Cache base will be %esp plus cache->sp_offset (-8).  */
+  get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
+  cache->base = extract_unsigned_integer (buf, 8,
+					  byte_order) + cache->sp_offset;
 
-      /* Cache pc will be the frame func.  */
-      cache->pc = get_frame_pc (this_frame);
+  /* Cache pc will be the frame func.  */
+  cache->pc = get_frame_pc (this_frame);
 
-      /* The saved %esp will be at cache->base plus 16.  */
-      cache->saved_sp = cache->base + 16;
+  /* The saved %esp will be at cache->base plus 16.  */
+  cache->saved_sp = cache->base + 16;
 
-      /* The saved %eip will be at cache->base plus 8.  */
-      cache->saved_regs[AMD64_RIP_REGNUM] = cache->base + 8;
-
-      cache->base_p = 1;
-    }
-  CATCH (ex, RETURN_MASK_ERROR)
-    {
-      if (ex.error != NOT_AVAILABLE_ERROR)
-	throw_exception (ex);
-    }
-  END_CATCH
+  /* The saved %eip will be at cache->base plus 8.  */
+  cache->saved_regs[AMD64_RIP_REGNUM] = cache->base + 8;
 
   return cache;
 }
@@ -2876,9 +2831,6 @@ amd64_epilogue_frame_unwind_stop_reason (struct frame_info *this_frame,
   struct amd64_frame_cache *cache
     = amd64_epilogue_frame_cache (this_frame, this_cache);
 
-  if (!cache->base_p)
-    return UNWIND_UNAVAILABLE;
-
   return UNWIND_NO_REASON;
 }
 
@@ -2890,10 +2842,7 @@ amd64_epilogue_frame_this_id (struct frame_info *this_frame,
   struct amd64_frame_cache *cache = amd64_epilogue_frame_cache (this_frame,
 							       this_cache);
 
-  if (!cache->base_p)
-    (*this_id) = frame_id_build_unavailable_stack (cache->pc);
-  else
-    (*this_id) = frame_id_build (cache->base + 8, cache->pc);
+  (*this_id) = frame_id_build (cache->base + 8, cache->pc);
 }
 
 static const struct frame_unwind amd64_epilogue_frame_unwind =
-- 
1.9.1


  reply	other threads:[~2017-07-31 22:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-31 22:22 [PATCH 0/9] Centralize unwinder api exceptions handling Yao Qi
2017-07-31 22:22 ` Yao Qi [this message]
2017-07-31 22:22 ` [PATCH 4/9] Reset *THIS_CACHE in frame_unwind_try_unwinder in case of exception Yao Qi
2017-08-11 16:47   ` Pedro Alves
2017-08-17 15:27     ` Yao Qi
2017-07-31 22:22 ` [PATCH 2/9] Class-fy dwarf2_frame_state Yao Qi
2017-07-31 22:22 ` [PATCH 8/9] Throw exception in i386 unwinders Yao Qi
2017-07-31 22:22 ` [PATCH 6/9] Throw exception in dwarf2 unwinders Yao Qi
2017-07-31 22:22 ` [PATCH 1/9] Move dwarf2_frame_state_reg.exp_len to union .loc Yao Qi
2017-07-31 22:22 ` [PATCH 3/9] Class-fy dwarf2_frame_state_reg_info Yao Qi
2017-07-31 22:22 ` [PATCH 5/9] Handle unwinding exceptions Yao Qi
2017-07-31 22:22 ` [PATCH 9/9] Throw exception in aarch64 unwinder Yao Qi
2017-08-11  8:35 ` [PATCH 0/9] Centralize unwinder api exceptions handling Yao Qi

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=1501539715-8049-8-git-send-email-yao.qi@linaro.org \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /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