This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: backtrace(3) in Cygwin?


On Mar 11 18:41, David Stacey wrote:
> On 11/03/15 17:22, Corinna Vinschen wrote:
> >On Mar 11 17:10, David Stacey wrote:
> >>Please could you tell me if Cygwin supports backtrace(3) and
> >>backtrace_symbols(3) [1]? I can't find the execinfo.h header file, but
> >>presumably Cygwin is capable of generating a backtrace because the 'bt'
> >>command works in gdb.
> >GDB's `bt' implementation has nothing to do with Cygwin's capability
> >to walk a stack.  Cygwin only has limited capabilities there which
> >are used to create the stackdump file, see the stack_walk class in
> >exceptions.cc:
> >https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob_plain;f=winsup/cygwin/exceptions.cc
> >
> >If you want to create a backtrace(3) function set for Cygwin, feel
> >free:https://cygwin.com/contrib.html
> >I'm certainly not averse to patches...
> 
> Thanks for your reply. It shouldn't be too hard to create implementations of
> backtrace(3) and backtrace_symbols(3) using CaptureStackBackTrace() [1] and
> SymFromAddr() [2]. There should be enough information in a SYMBOL_INFO
> structure to create strings in the same format as backtrace_symbols().
> 
> backtrace_symbols_fd(3) might be harder, because I'm not sure I can honour
> the promise not to use heap memory internally.

This is something we can analyze and discuss on the cygwin-developers
mailing list if you're really interested in implementing this stuff at
one point.

> Also, note that the Windows
> functions mentioned above are single-threaded, and therefore any
> implementation based on them will be single-threaded also.

What about StackWalk64?  And what about the existing implementation
in stack_info::walk using RtlLookupFunctionEntry and RtlVirtualUnwind
on x86_64?

Ideally we only have one stack walk implementation and use them in
both situations, implementing backtrace(3) and creating the stackdump.
The stack_info::walk code for 32 bit really needs a thorough revamp
anyway.

> Further, Windows
> XP is limited to 63 stack frames.

Meh.

> I'm rather busy at the moment, but if I have time then I'll have a go.

That would be cool.  I'm looking forward to this.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: pgpwHE670lTT0.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]