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]

Dlls and debugging


Gcc is not the only one to have trouble with dlls and that uninformative:
'Application failed to initialize properly' message. 
Lcc too has its problems... and I spent the whole day debugging a problem
of a dll that calls another dll and doesn't 'initialize properly'... damm!

I posted before a method for debugging dll initialization: it consisted in
planting an interrupt three (debugger interrupt) at the start of a dll's
LibMain to see if the loading of the dll goes as far as to actually call the 
LibMain, and force the debugger into foreground.
You just write
LibMain(... etc)
{
	asm("int $3");
}
I have discovered ANOTHER method, that could complement that one, and I
think it could be of general interest. If you are not interested in this
kind of esoteric details just skip this message.

'Algorithm':
A)
Install all the debugging symbols for the system dlls.
B)
Start the MSVC debugger (new version >4.x)
C)
Put a breakpoint at _LdrpRunInitializeRoutines@4:
This is where all the LibMains are called by the system. This should probably 
be at 0x77f632bc or near it.
D)
look several lines (assembly lines) below and you will notice a variable
called '_ShowSnaps' at 0x77fa4a38. 
E)
SET THAT VARIABLE TO ONE!
The way of doing it is to start the quick watch window, make a cast of
that address to int * and set it to one.

This will have a magic effect in the system! It will display all it is doing,
which dlls are being loaded, which routines are being called, which load
suceeded etc.

I am sure you can do this in gdb too. The crucial point is to find out the
address of that variable in your system.

Have fun!

-- 
Jacob Navia	Logiciels/Informatique
41 rue Maurice Ravel			Tel 01 48.23.51.44
93430 Villetaneuse 			Fax 01 48.23.95.39
France
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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