[PATCH v2] libgcc: Expose the instruction pointer and stack pointer in SEH _Unwind_Backtrace

Jonathan Yong 10walls@gmail.com
Tue Nov 3 00:32:05 GMT 2020


On 9/8/20 12:21 PM, 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 and cfa pointers, which are used by _Unwind_GetIP
> and _Unwind_GetCFA, to allow using these functions from the
> callacb to inspect the state at each stack frame.
> 
> 2020-09-08  Martin Storsjö  <martin@martin.st>
> 
> libgcc/Changelog:
>          * unwind-seh.c (_Unwind_Backtrace): Set the ra and cfa pointers
>          before calling the callback.
> ---
>   libgcc/unwind-seh.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/libgcc/unwind-seh.c b/libgcc/unwind-seh.c
> index 1a70180cfaa..275d782903a 100644
> --- a/libgcc/unwind-seh.c
> +++ b/libgcc/unwind-seh.c
> @@ -466,6 +466,11 @@ _Unwind_Backtrace(_Unwind_Trace_Fn trace,
>   			    &gcc_context.disp->HandlerData,
>   			    &gcc_context.disp->EstablisherFrame, NULL);
>   
> +      /* Set values that the callback can inspect via _Unwind_GetIP
> +       * and _Unwind_GetCFA. */
> +      gcc_context.ra = ms_context.Rip;
> +      gcc_context.cfa = ms_context.Rsp;
> +
>         /* Call trace function.  */
>         if (trace (&gcc_context, trace_argument) != _URC_NO_REASON)
>   	return _URC_FATAL_PHASE1_ERROR;
> 

Pushed to master branch, thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x713B5FE29C145D45_and_old_rev.asc
Type: application/pgp-keys
Size: 7929 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201103/e9d11b85/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201103/e9d11b85/attachment-0001.sig>


More information about the Gcc-patches mailing list