Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Gordon Prieur <Gordon.Prieur@Sun.COM>
To: gdb@sourceware.org
Subject: Re: stop-on-solib-events and Cygwin (or MinGW)
Date: Thu, 14 Feb 2008 18:58:00 -0000	[thread overview]
Message-ID: <47B48F3A.7070002@sun.com> (raw)
In-Reply-To: <20080214181353.GA7518@caradoc.them.org>

[-- Attachment #1: Type: text/plain, Size: 2909 bytes --]


Daniel Jacobowitz wrote:
> On Thu, Feb 14, 2008 at 09:41:15AM -0800, Gordon Prieur wrote:
>   
>> Its customer driven. In NetBeans, breakpoints persist outside of a gdb  
>> session.
>> The simplified scenario I'm using in my test cases contains 2 files,  
>> main.c and
>> shared.c (shared.c builds into a dll). If I link main.c with the shared  
>> library then
>> when I start debugging main, all breakpoints in shared.c are active.
>>
>> If I don't link the dll into main but explicitly dlopen it, the  
>> breakpoints aren't
>> active unless I set them after the dlopen.
>>     
>
> That sounds like a bug in GDB.  We need a test case.  Actually, it
> sounds like win32/2369.  Anyway, there is no reason this should not
> work from GDB without your having to do anything special.
>   

Its similar to 2369 but there are several differences. First off, I'm 
running  in mi mode
and I don't really expect it to handle breakpoints in unloaded dlls. In 
command line, it
asks if it should be left "pending on future shared library load".

But I also tried it from the command line (w/o mi) and it still failed. 
But that scenario
isn't identical to the one in 2369. In 2369, gdb tells you the bp fails 
to get set. In my
case (using Cygwin gdb 6.5.50)  I get a message "Pending breakpoint 
\"shared.c:5\"
resolved" but it gets ignored. I reran with a breakpoint in my main 
program (before
the call to the bp in my dll) and both worked.

I've attached my sources. Since I built from NetBeans projects I'm not 
including any
Makefiles. Build shared.c into a dll and reference it from app.c. Since 
I didn't want
to muck with dlopen finding the dll, I hardcoded the path in app.c. 
You'll need to
change it to point to the location you put libshared.dll.


>> Will this be part of gbd 6.8?
>>     
>
> Yes.
>
>   
>> From my point of view, its only fixed when  
>> I can
>> recommend a specific version of Cygwin and/or MinGW to my customers. Even
>> then, I'll need to support legacy versions without this feature. So even  
>> if its
>> fixed, I think I'll need to maintain my alternate Windows implementation for
>> a while.
>>     
>
> If you don't want to ship your own GDB, or require a new release,
> then we can't help you with GDB bugs - if you find a time machine
> sitting around somewhere, do let me know :-)
>   

We're considering bundling compilers, gdb, and make with NetBeans. In 
the mean time,
I have a time machine called patience:-)

Incidentally, my alternate Windows implementation seems to work. I set a 
bp in dlopen,
call "finish", and reset all failed NetBeans breakpoints . Note that 
"NetBeans breakpoints"
are different than gdb breakpoints. When I start gdb I attempt to create 
a gdb breakpoint
for each NetBeans breakpoint. The failed ones are the ones I'll retry 
after the dlopen. In
most cases, the failure is because the bp is in code not compiled into 
the app.

Gordon


[-- Attachment #2: app.c --]
[-- Type: text/x-csrc, Size: 574 bytes --]

#include <stdio.h>
#include <dlfcn.h>

int main(int argc, char **argv) {
	void *handle;
	int (*square)(int);
	const char *error;
	handle = dlopen ("C:/Documents and Settings/gordonp/My Documents/NetBeansProjects/DlopenTest_1/shared/dist/Debug/Cygwin-Windows/libshared.dll", RTLD_LAZY);
	if (!handle) {
		fputs (dlerror(), stderr);
		exit(1);
	}

	square = dlsym(handle, "square");
	if ((error = dlerror()) != NULL)  {
		fputs(error, stderr);
		exit(1);
	}

	printf ("%d\n", (*square)(1));
	printf ("%d\n", (*square)(2));
	printf ("%d\n", (*square)(3));
	dlclose(handle);
}


[-- Attachment #3: shared.c --]
[-- Type: text/x-csrc, Size: 66 bytes --]

#include <stdio.h>

int square(int arg)
{
    return (arg*arg);
}

  reply	other threads:[~2008-02-14 18:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-14 17:02 Gordon Prieur
2008-02-14 17:09 ` Daniel Jacobowitz
2008-02-14 17:41   ` Gordon Prieur
2008-02-14 18:14     ` Daniel Jacobowitz
2008-02-14 18:58       ` Gordon Prieur [this message]
2008-02-14 19:05         ` Daniel Jacobowitz
2008-02-14 19:18           ` Vladimir Prus
2008-02-14 19:43             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47B48F3A.7070002@sun.com \
    --to=gordon.prieur@sun.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox