public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libgcc: Expose the current instruction pointer in SEH _Unwind_Backtrace
@ 2020-09-01 13:01 Martin Storsjö
  2020-09-04 12:51 ` Martin Storsjö
  2020-09-08 12:21 ` [PATCH v2] libgcc: Expose the instruction pointer and stack " Martin Storsjö
  0 siblings, 2 replies; 8+ messages in thread
From: Martin Storsjö @ 2020-09-01 13:01 UTC (permalink / raw)
  To: gcc-patches

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;
-- 
2.17.1


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

* Re: [PATCH] libgcc: Expose the current instruction pointer in SEH _Unwind_Backtrace
  2020-09-01 13:01 [PATCH] libgcc: Expose the current instruction pointer in SEH _Unwind_Backtrace Martin Storsjö
@ 2020-09-04 12:51 ` Martin Storsjö
  2020-09-08 12:21 ` [PATCH v2] libgcc: Expose the instruction pointer and stack " Martin Storsjö
  1 sibling, 0 replies; 8+ messages in thread
From: Martin Storsjö @ 2020-09-04 12:51 UTC (permalink / raw)
  To: gcc-patches

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

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

* [PATCH v2] libgcc: Expose the instruction pointer and stack pointer in SEH _Unwind_Backtrace
  2020-09-01 13:01 [PATCH] libgcc: Expose the current instruction pointer in SEH _Unwind_Backtrace Martin Storsjö
  2020-09-04 12:51 ` Martin Storsjö
@ 2020-09-08 12:21 ` Martin Storsjö
  2020-11-02 12:05   ` Kai Tietz
                     ` (2 more replies)
  1 sibling, 3 replies; 8+ messages in thread
From: Martin Storsjö @ 2020-09-08 12:21 UTC (permalink / raw)
  To: gcc-patches

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;
-- 
2.17.1


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

* Re: [PATCH v2] libgcc: Expose the instruction pointer and stack pointer in SEH _Unwind_Backtrace
  2020-09-08 12:21 ` [PATCH v2] libgcc: Expose the instruction pointer and stack " Martin Storsjö
@ 2020-11-02 12:05   ` Kai Tietz
  2020-11-06  3:27     ` Jeff Law
  2020-11-03  0:32   ` Jonathan Yong
  2020-11-06  3:28   ` Jeff Law
  2 siblings, 1 reply; 8+ messages in thread
From: Kai Tietz @ 2020-11-02 12:05 UTC (permalink / raw)
  To: Martin Storsjö, JonY; +Cc: GCC Patches

Hello,

as noone seems to be able to review this patch, I will do so, even if
this is no longer a task of mine.
The patch itself is reasonable and seems to fix a pending issue we
have on CFA support.  I had already private discussion with Martin,
and I would have loved to see a test-case illustrating this fix.  But
as Martin explained to me, there is no trivial testcase for this, so I
would approve that patch.

Regards,
Kai


Am Di., 8. Sept. 2020 um 14:24 Uhr schrieb Martin Storsjö <martin@martin.st>:
>
> 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;
> --
> 2.17.1
>

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

* Re: [PATCH v2] libgcc: Expose the instruction pointer and stack pointer in SEH _Unwind_Backtrace
  2020-09-08 12:21 ` [PATCH v2] libgcc: Expose the instruction pointer and stack " Martin Storsjö
  2020-11-02 12:05   ` Kai Tietz
@ 2020-11-03  0:32   ` Jonathan Yong
  2020-11-06  3:28   ` Jeff Law
  2 siblings, 0 replies; 8+ messages in thread
From: Jonathan Yong @ 2020-11-03  0:32 UTC (permalink / raw)
  To: gcc-patches


[-- Attachment #1.1.1: Type: text/plain, Size: 1489 bytes --]

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.

[-- Attachment #1.1.2: OpenPGP_0x713B5FE29C145D45_and_old_rev.asc --]
[-- Type: application/pgp-keys, Size: 8035 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

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

* Re: [PATCH v2] libgcc: Expose the instruction pointer and stack pointer in SEH _Unwind_Backtrace
  2020-11-02 12:05   ` Kai Tietz
@ 2020-11-06  3:27     ` Jeff Law
  2020-11-06  6:44       ` Jonathan Yong
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff Law @ 2020-11-06  3:27 UTC (permalink / raw)
  To: Kai Tietz, Martin Storsjö, JonY; +Cc: GCC Patches


On 11/2/20 5:05 AM, Kai Tietz via Gcc-patches wrote:
> Hello,
>
> as noone seems to be able to review this patch, I will do so, even if
> this is no longer a task of mine.
> The patch itself is reasonable and seems to fix a pending issue we
> have on CFA support.  I had already private discussion with Martin,
> and I would have loved to see a test-case illustrating this fix.  But
> as Martin explained to me, there is no trivial testcase for this, so I
> would approve that patch.

Thanks Kai.  I'll get the bits installed momentarily.


jeff



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

* Re: [PATCH v2] libgcc: Expose the instruction pointer and stack pointer in SEH _Unwind_Backtrace
  2020-09-08 12:21 ` [PATCH v2] libgcc: Expose the instruction pointer and stack " Martin Storsjö
  2020-11-02 12:05   ` Kai Tietz
  2020-11-03  0:32   ` Jonathan Yong
@ 2020-11-06  3:28   ` Jeff Law
  2 siblings, 0 replies; 8+ messages in thread
From: Jeff Law @ 2020-11-06  3:28 UTC (permalink / raw)
  To: Martin Storsjö, gcc-patches


On 9/8/20 6:21 AM, 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.

Ah, it's already been committed.  Sorry for the delays and confusion.

jeff



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

* Re: [PATCH v2] libgcc: Expose the instruction pointer and stack pointer in SEH _Unwind_Backtrace
  2020-11-06  3:27     ` Jeff Law
@ 2020-11-06  6:44       ` Jonathan Yong
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Yong @ 2020-11-06  6:44 UTC (permalink / raw)
  To: Jeff Law, Kai Tietz, Martin Storsjö; +Cc: GCC Patches


[-- Attachment #1.1.1: Type: text/plain, Size: 774 bytes --]

On 11/6/20 3:27 AM, Jeff Law wrote:
> 
> On 11/2/20 5:05 AM, Kai Tietz via Gcc-patches wrote:
>> Hello,
>>
>> as noone seems to be able to review this patch, I will do so, even if
>> this is no longer a task of mine.
>> The patch itself is reasonable and seems to fix a pending issue we
>> have on CFA support.  I had already private discussion with Martin,
>> and I would have loved to see a test-case illustrating this fix.  But
>> as Martin explained to me, there is no trivial testcase for this, so I
>> would approve that patch.
> 
> Thanks Kai.  I'll get the bits installed momentarily.
> 

FYI I already pushed this recently to gcc master branch 
bd6ecbe48ada79bb14cbb30ef8318495b5237790, but did not reply earlier.

Sorry about the confusion.


[-- Attachment #1.1.2: OpenPGP_0x713B5FE29C145D45_and_old_rev.asc --]
[-- Type: application/pgp-keys, Size: 8035 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

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

end of thread, other threads:[~2020-11-06  6:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 13:01 [PATCH] libgcc: Expose the current instruction pointer in SEH _Unwind_Backtrace Martin Storsjö
2020-09-04 12:51 ` Martin Storsjö
2020-09-08 12:21 ` [PATCH v2] libgcc: Expose the instruction pointer and stack " Martin Storsjö
2020-11-02 12:05   ` Kai Tietz
2020-11-06  3:27     ` Jeff Law
2020-11-06  6:44       ` Jonathan Yong
2020-11-03  0:32   ` Jonathan Yong
2020-11-06  3:28   ` Jeff Law

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).