diff mbox series

libgcc: Expose the current instruction pointer in SEH _Unwind_Backtrace

Message ID 20200901130126.6266-1-martin@martin.st
State New
Headers show
Series libgcc: Expose the current instruction pointer in SEH _Unwind_Backtrace | expand

Commit Message

Martin Storsjo Sept. 1, 2020, 1:01 p.m. UTC
Previously, the SEH version of _Unwind_Backtrace did unwind
the stack and call the provided callback function as intended,
but there was little the caller could do within the callback to
actually get any info about that particular level in the unwind.

Set the ra pointer, which is used by _Unwind_GetIP, to allow
using this function to inspect the state within the callback,
before calling the callback function.

2020-09-01  Martin Storsjö  <martin@martin.st>

libgcc/Changelog:
        * unwind-seh.c (_Unwind_Backtrace): Set the ra pointer before
        calling the callback.
---
 libgcc/unwind-seh.c | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.17.1

Comments

Martin Storsjo Sept. 4, 2020, 12:51 p.m. UTC | #1
On Tue, 1 Sep 2020, Martin Storsjö wrote:

> Previously, the SEH version of _Unwind_Backtrace did unwind

> the stack and call the provided callback function as intended,

> but there was little the caller could do within the callback to

> actually get any info about that particular level in the unwind.

>

> Set the ra pointer, which is used by _Unwind_GetIP, to allow

> using this function to inspect the state within the callback,

> before calling the callback function.

>

> 2020-09-01  Martin Storsjö  <martin@martin.st>

>

> libgcc/Changelog:

>        * unwind-seh.c (_Unwind_Backtrace): Set the ra pointer before

>        calling the callback.

> ---

> libgcc/unwind-seh.c | 2 ++

> 1 file changed, 2 insertions(+)

>

> diff --git a/libgcc/unwind-seh.c b/libgcc/unwind-seh.c

> index 1a70180cfaa..72473135862 100644

> --- a/libgcc/unwind-seh.c

> +++ b/libgcc/unwind-seh.c

> @@ -466,6 +466,8 @@ _Unwind_Backtrace(_Unwind_Trace_Fn trace,

> 			    &gcc_context.disp->HandlerData,

> 			    &gcc_context.disp->EstablisherFrame, NULL);

>

> +      gcc_context.ra = ms_context.Rip;

> +

>       /* Call trace function.  */

>       if (trace (&gcc_context, trace_argument) != _URC_NO_REASON)

> 	return _URC_FATAL_PHASE1_ERROR;


Ping - any comments on this one?

// Martin
diff mbox series

Patch

diff --git a/libgcc/unwind-seh.c b/libgcc/unwind-seh.c
index 1a70180cfaa..72473135862 100644
--- a/libgcc/unwind-seh.c
+++ b/libgcc/unwind-seh.c
@@ -466,6 +466,8 @@  _Unwind_Backtrace(_Unwind_Trace_Fn trace,
 			    &gcc_context.disp->HandlerData,
 			    &gcc_context.disp->EstablisherFrame, NULL);
 
+      gcc_context.ra = ms_context.Rip;
+
       /* Call trace function.  */
       if (trace (&gcc_context, trace_argument) != _URC_NO_REASON)
 	return _URC_FATAL_PHASE1_ERROR;