This is the mail archive of the cygwin@sourceware.cygnus.com 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]

Re: Debugging cygwin.dll with gdb & static libcygwin_g.a


The thing that has bugged me the most about gnu-cygwin32 ever since I 
started using it, is that you couldn't really see what was going on, your 
code gets to the dll, and it disappears, and writing in your own debugging 
messages via debug_printf, is a real pain in the tail, so I finally fixed it.

Attached are the necessary files, to make a static libcygwin_g.a, along 
with a specs file that allows you to link with it.

All you have to do to link with the static lib, is add -g to your link line.

I also added a utility stripdll, so that your production dll will be the usual 
size, ~320K and fixed the Makefile so it will strip the extra debugging 
information from libcygwin.a automatically so you (and I ;^) don't 
have to remember every time. and for those of you who already have 
the Micros*** SDK I included a better version of lib2def.

There are at least two problems with this, the debuggable executables, are 
huge, ~3M at least, so most people won't want to use this for installed stuff ;^)

The libcygwin_g.a is also huge ~11M, so I won't be posting it anywhere, 
if you're into debugging dll code, you're going to have to build the 
dll anyway ;^)

The other thing is that the by now famous win95 lseek() bug will 
catch you once in a while, at least I think that's what's happening
so if the new .exe will run, but gdb segfaults when loading it, just relink, 
and try again.

But I think that being able to debug the .dll code directly is well worth it ;^))))))).

I have built and run /bin/bash.exe linked to /bin/sh "static", 
~3M w/debug code, 520K after strip --strip-all and it seems to work fine,
with one exception, you can reinvoke sh as many times as you want,
but running shell scripts can lockup, I suspect that changes would 
need to be made to the fork() code, to make this a truly workable
alternative for people who want to just send out the executables,
without the dll.

If you need to make changes to dll startup code in either dcrt0.cc, or libccrt0.cc,
like Sergey's patch does, you will want to make those same changes in gcrt0.cc
to debug them.

WARNING compiling with -g on your link line WILL be seriously 
hazardous to your free disk space once you do this, 
YOU HAVE BEEN WARNED!! ;^)

If you haven't mounted your filsystems -b already, you really should.
the attached files are LF only. you may be able to get away with adding
--ignore-whitespace to the patch line below, I don't know.

To create libcygwin_g.a 
BACKUP YOUR SPECS FILE FIRST!!!!
replace your .../H-i386-cygwin32/lib/gcc-lib/i386-cygwin32/$VERSION/specs
with the attached one.
cd into the .../cdk/winsup/ directory, and type patch -p0 < static.dif
find -name \*.rej 		there better not be any.
find -name \*.orig or \*.~1~|xargs rm
#depending on if you have      export VERSION_CONTROL=numbered     in .bashrc
.cd into your .../obj dir, and configure and make as usual.
I didn't have the static lib install by default, because of it's size. so to get the static lib
made and installed you will need to do

make prefix=/your/inst/dir exec_prefix=/your/inst/dir/H-i386-cygwin32 install-static

or just 

make libcygwin_g.a

and copy it wherever you want.

All that being said, have FUN!!!
	Mikey

./*                            DECLARATION

I, Jeffrey DeBeer, grant to the public domain my entire right, title,
and interest (including all rights under copyright) in my changes and
enhancements to the Cygwin32 library. These changes and enhancements are
herein called the "Work". The Work granted to the public domain shall
also include any future revisions of these changes and enhancements
hereafter made by me.

I  represent and warrant that I am the sole author of the Work and that
I have the right and power to make this grant. I make no other express
or implied warranty (including without limitation, in this disclaimer of
warranty, any warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE).

Jeffrey DeBeer
12 June 1997
*/


On Sat, 7 Jun 1997 21:13:14 -0700 (PDT), you wrote:

>Chris Faylor wrote:
>[...]
>> I am at a loss, however, as to how to debug this.  I've built a cygwin.dll
>> from scratch with Sergey's patches, but then, how do I debug it?  Attempting
>> to invoke gdb remotely hangs due to the problem I mentioned above.
>[...]
>
>A future change that needs to be made is to always build cygwin.dll
>and libcygwin.a as well as (new) cygwindebug.dll and libcygwindebug.a.
>Everything other than gdb would get linked against cygwin.dll whereas
>gdb would be linked against cygwindebug.dll.
>
>So if you need to debug a non-functional cygwin.dll, you could use any
>previously working gdb since it would depend on a working cygwin.dll.
>Alternatively, we could somehow statically link the code inside the
>cygwin.dll inside gdb.
>
>-- 
>Geoffrey Noer
>noer@cygnus.com
>-
>For help on using this list (especially unsubscribing), send a message to
>"gnu-win32-request@cygnus.com" with one line of text: "help".
>

static.dif

specs


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