public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* Re: [PATCH 2/4] libdwfl: make the unwinder aware of the backend defined ra_offset.
@ 2016-01-03 11:23 Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2016-01-03 11:23 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 597 bytes --]

On Tue, Dec 08, 2015 at 07:10:41PM +0100, Jose E. Marchesi wrote:
> Ebl backends can define an offset that must be applied to the value of
> the "return address register" defined in the CFI ABI information.
> This patch makes the unwinder to use that offset when reading the RA
> CFI register.

Looks good. Pushed to master.

Thanks for convincing me on irc that adjusting the return address is
the way to go to make this consistent with other arches instead of
trying to add even more magic to the return address -> calling address
code (as was my first suggestion).

Cheers,

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/4] libdwfl: make the unwinder aware of the backend defined ra_offset.
@ 2015-12-08 18:10 Jose E. Marchesi
  0 siblings, 0 replies; 2+ messages in thread
From: Jose E. Marchesi @ 2015-12-08 18:10 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 2242 bytes --]

Ebl backends can define an offset that must be applied to the value of
the "return address register" defined in the CFI ABI information.
This patch makes the unwinder to use that offset when reading the RA
CFI register.

Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
---
 libdwfl/ChangeLog      | 7 +++++++
 libdwfl/dwfl_frame.c   | 2 +-
 libdwfl/frame_unwind.c | 9 ++++++++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 3c48b5e..88a4f2c 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,10 @@
+2015-12-08  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+	* dwfl_frame.c (state_fetch_pc): Add a backend-defined offset to
+	the value of the return address register as defined by the CFI
+	abi.
+	* frame_unwind.c (handle_cfi): Likewise.
+
 2015-11-19  Mark Wielaard  <mjw@redhat.com>
 
 	* dwfl_module.c (__libdwfl_module_free): Remove Dwfl_Module Ebl from
diff --git a/libdwfl/dwfl_frame.c b/libdwfl/dwfl_frame.c
index a91a1d6..d639939 100644
--- a/libdwfl/dwfl_frame.c
+++ b/libdwfl/dwfl_frame.c
@@ -57,7 +57,7 @@ state_fetch_pc (Dwfl_Frame *state)
 	    __libdwfl_seterrno (DWFL_E_LIBEBL_BAD);
 	    return false;
 	  }
-	state->pc = state->regs[ra];
+	state->pc = state->regs[ra] + ebl_ra_offset (ebl);
 	state->pc_state = DWFL_FRAME_STATE_PC_SET;
       }
       return true;
diff --git a/libdwfl/frame_unwind.c b/libdwfl/frame_unwind.c
index 39509b7..0e470b9 100644
--- a/libdwfl/frame_unwind.c
+++ b/libdwfl/frame_unwind.c
@@ -637,7 +637,14 @@ handle_cfi (Dwfl_Frame *state, Dwarf_Addr pc, Dwarf_CFI *cfi, Dwarf_Addr bias)
       if (unwound->pc == 0)
 	unwound->pc_state = DWFL_FRAME_STATE_PC_UNDEFINED;
       else
-	unwound->pc_state = DWFL_FRAME_STATE_PC_SET;
+        {
+          unwound->pc_state = DWFL_FRAME_STATE_PC_SET;
+          /* In SPARC the return address register actually contains
+             the address of the call instruction instead of the return
+             address.  Therefore we add here an offset defined by the
+             backend.  Most likely 0.  */
+          unwound->pc += ebl_ra_offset (ebl);
+        }
     }
   free (frame);
 }
-- 
2.3.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-03 11:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-03 11:23 [PATCH 2/4] libdwfl: make the unwinder aware of the backend defined ra_offset Mark Wielaard
  -- strict thread matches above, loose matches on Subject: below --
2015-12-08 18:10 Jose E. Marchesi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).