delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/02/06/08:51:59

X-Spam-Check-By: sourceware.org
Message-ID: <43E7546E.9C1AF962@dessent.net>
Date: Mon, 06 Feb 2006 05:51:42 -0800
From: Brian Dessent <brian AT dessent DOT net>
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: gdb hangs
References: <bd3af4750602060320o2c3abb80wb05ccd1a8e2febed AT mail DOT gmail 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-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
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id k16DpsVY031978

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/


- Raw text -


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