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: gdb hangs


Vitaly Provodin wrote:

> I am trying to debug Win32 dll.
> Actually, I exercised setting breakpoint in dynamically loaded libraries and
> used the pending breakpoints feature of gdb. It properly works on Linux but
> on Windows I get the promising start message "Starting program:?" and
> gdb successfully hangs.

Hmm, interesting.  Gdb is not actually hung -- it has encoutered an
error and has prompted the user "Do you wish to continue, y/n" but you
don't see that because output at that point is temporarily redirected to
/dev/null.  But if you press y<enter> it will try to continue, but it
hits the same snag again, and things just go downhill from there.  You
can see this illustrated much more clearly if you use insight, as the
prompts are properly displayed.

The actual source of the problem is the SECT_OFF_DATA macro around line
910 in coffread.c.  I'm not sure exactly what's broken here, but it
seems like it might be related to the fact that (at least on my system)
the DLL gets assigned the default image base and has to be relocated and
ends up loading very low in memory at 0x003f0000.  If you enable auto
image basing (add -Wl,--enable-auto-image-base to the link line) you get
a DLL that loads much higher and doesn't require relocation, and
everything works fine.

You might want to take this up on the gdb list, although since both
Corinna and cgf read both lists this is probably not necessary.

By the way, this is pretty bad C:

>     *(void**)(&helloworld_func) = dlsym(handle, "helloworld");

This will give you a warning at -O2 because it violates the language's
aliasing rules.  That kind of thing can really bite you later.  I think
you really ought to use something like:

   helloworld_func = (void (*)()) dlsym(handle, "helloworld");

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/


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