delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/08/01/19:32:16

X-Spam-Check-By: sourceware.org
Message-ID: <46B117E8.95E4D9E9@dessent.net>
Date: Wed, 01 Aug 2007 16:31:52 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Stack traces in own program in cygwin
References: <46B07604 DOT 9000605 AT odd-e DOT com> <46B0ABD2 DOT E4F926E9 AT dessent DOT net> <46B10CFE DOT 1040708 AT odd-e DOT com>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Bas Vodde wrote:

> Thanks for the reply. Where can I find the cygwin code that unwinds the
> stack? I might have a look at it anyway :)

Look at class stack_info in winsup/cygwin/exceptions.cc.  It's pretty
simplistic, and I'm pretty sure it will be rendered totally ineffective
by -fomit-frame-pointer.

> The problem I have with dbghelp is not whether the DLL is available, but
> whether the WinSDK is... It would require a header file (which is
> possible to fake) and a .lib. I'm not sure how to call the dbghelp calls
> without linking to the library. (though this should be possible, I just
> don't know how and where to find info about how to do it). If you for an
> idea about this, then that also could help me forward :)

You can use LoadLibrary/GetProcAddress, which removes the need for the
SDK and import lib/header at build time, assuming that you recreate the
appropriate types in one of your headers.  It also provides your program
an opportunity to do graceful degredation if something goes wrong, e.g.
the user is running 9x/ME, or they have a version of the dll that's too
old, or the library has been removed, or whatever.  The disadvantage
here is that for every function you use you first have to declare a
function pointer with the correct return type/signature/argument list,
then call GetProcAddress, then make all calls through that function
pointer.  There is a clever trick that the Cygwin DLL uses that reduces
this busywork -- look at autoload.cc for details.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019