Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Expose Frame Type and Stop Reason in python Unwinder API
@ 2024-08-22  2:28 Andrew Wock via Gdb
  2024-08-22 13:09 ` Paul Koning via Gdb
  2024-08-26 13:56 ` John Baldwin via Gdb
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Wock via Gdb @ 2024-08-22  2:28 UTC (permalink / raw)
  To: gdb

Hello,

Recently I wrote a kernel trapframe unwinder using the python API, and
I was able to successfully extract the registers from the trapframe.
However, sometimes gdb would throw the "previous frame inner to this
frame" error on me.  This is because unwinding a trapframe sometimes
results in unwinding to a different stack.

The way this is fixed in the internal unwinder API is that there are
special frame types such as SIGTRAMP_FRAME which don't get checked for
that error.

Additionally, some trapframes unwind into userspace.  In those cases
I'd like to be able to stop the backtrace by setting a stop reason.
More broadly this would be useful for any case where a user wants to
stop the stacktrace at a certain point for whatever their use case is.

I'm interested in moving forward and writing a patch for this.

One implementation detail I noticed that complicates this
implementation is that all python unwinders are internally modeled as
a single C unwinder in py-unwind.c:974.  I believe that in order to
support a frame type feature, each unwinder will need to be modeled as
an independent C unwinder.

I am proposing this here to get community feedback on whether this
feature should be supported.

Thanks,
Andrew Wock

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

* Re: Expose Frame Type and Stop Reason in python Unwinder API
  2024-08-22  2:28 Expose Frame Type and Stop Reason in python Unwinder API Andrew Wock via Gdb
@ 2024-08-22 13:09 ` Paul Koning via Gdb
  2024-08-26 13:56 ` John Baldwin via Gdb
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Koning via Gdb @ 2024-08-22 13:09 UTC (permalink / raw)
  To: Andrew Wock; +Cc: gdb



> On Aug 21, 2024, at 10:28 PM, Andrew Wock via Gdb <gdb@sourceware.org> wrote:
> 
> Hello,
> 
> Recently I wrote a kernel trapframe unwinder using the python API, and
> I was able to successfully extract the registers from the trapframe.
> However, sometimes gdb would throw the "previous frame inner to this
> frame" error on me.  This is because unwinding a trapframe sometimes
> results in unwinding to a different stack.
> 
> The way this is fixed in the internal unwinder API is that there are
> special frame types such as SIGTRAMP_FRAME which don't get checked for
> that error.
> 
> Additionally, some trapframes unwind into userspace.  In those cases
> I'd like to be able to stop the backtrace by setting a stop reason.

For that case, stopping should be an option.  In the past I have found it very useful to be able to continue from kernel to user, in certain situations.

	paul



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

* Re: Expose Frame Type and Stop Reason in python Unwinder API
  2024-08-22  2:28 Expose Frame Type and Stop Reason in python Unwinder API Andrew Wock via Gdb
  2024-08-22 13:09 ` Paul Koning via Gdb
@ 2024-08-26 13:56 ` John Baldwin via Gdb
  1 sibling, 0 replies; 3+ messages in thread
From: John Baldwin via Gdb @ 2024-08-26 13:56 UTC (permalink / raw)
  To: Andrew Wock, gdb

On 8/21/24 22:28, Andrew Wock via Gdb wrote:
> Hello,
> 
> Recently I wrote a kernel trapframe unwinder using the python API, and
> I was able to successfully extract the registers from the trapframe.
> However, sometimes gdb would throw the "previous frame inner to this
> frame" error on me.  This is because unwinding a trapframe sometimes
> results in unwinding to a different stack.
> 
> The way this is fixed in the internal unwinder API is that there are
> special frame types such as SIGTRAMP_FRAME which don't get checked for
> that error.
> 
> Additionally, some trapframes unwind into userspace.  In those cases
> I'd like to be able to stop the backtrace by setting a stop reason.
> More broadly this would be useful for any case where a user wants to
> stop the stacktrace at a certain point for whatever their use case is.
> 
> I'm interested in moving forward and writing a patch for this.
> 
> One implementation detail I noticed that complicates this
> implementation is that all python unwinders are internally modeled as
> a single C unwinder in py-unwind.c:974.  I believe that in order to
> support a frame type feature, each unwinder will need to be modeled as
> an independent C unwinder.

Yes, I think that's true, or you'd need to have one unwinder per frame
type that you tie all the related unwinders to?

> I am proposing this here to get community feedback on whether this
> feature should be supported.

The other check I've run into is when you have a NULL function pointer
that raises a fault.  There is a check that aborts unwinding unless the
frame type is SIGTRAMP_FRAME IIRC.  I use custom unwinders in C++ for
FreeBSD's kgdb so that they can use SIGTRAMP_FRAME to get around that
limitation.

-- 
John Baldwin


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

end of thread, other threads:[~2024-08-26 13:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-22  2:28 Expose Frame Type and Stop Reason in python Unwinder API Andrew Wock via Gdb
2024-08-22 13:09 ` Paul Koning via Gdb
2024-08-26 13:56 ` John Baldwin via Gdb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox