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]

gdb hangs


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.

Here is a log of gdb session:
-----------------8<-----------------
$ gdb dlcheck.exe
GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-cygwin"...
(gdb) r
Starting program: /cygdrive/c/dllcheck/dlcheck.exe
-----------------8<-----------------

It could be interrupted only by killing the gdb process.

Here is the source file of the application (dlcheck.c)
=======================
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>

int main(int argc, char **argv) {
    void *handle;
    void (*helloworld_func)();
    char *error;

    handle = dlopen("./helloworld.dll", RTLD_NOW);
    if (!handle) {
        fprintf(stderr, "%s\n", dlerror());
        exit(1);
    }

    dlerror();  /*Clear any existing errors */
    *(void**)(&helloworld_func) = dlsym(handle, "helloworld");
    if ((error = dlerror()) != NULL) {
        fprintf(stderr, "%s\n", error);
        exit(1);
    }

    (*helloworld_func)();
    dlclose(handle);
    return 0;
}
=======================

Here is the source file of the dll (helloworld.c)
=======================
#include <stdio.h>

void helloworld(void) {
    printf("Hello, world!\n");
}
=======================

Here is make file
=======================
all: dlcheck.exe helloworld.dll

dlcheck.exe: dlcheck.o
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C Linker'
	gcc  -odlcheck.exe dlcheck.o
	@echo 'Finished building target: $@'
	@echo ' '

dlcheck.o:	dlcheck.c
	@echo 'Invoking: GCC Compiler'
	gcc  -g -c dlcheck.c
	@echo 'Finished building target: $@'
	@echo ' '

helloworld.dll: helloworld.o
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C Linker'
	gcc  -shared -ohelloworld.dll helloworld.o helloworld.def
	@echo 'Finished building target: $@'
	@echo ' '

helloworld.o:	helloworld.c
	@echo 'Invoking: GCC Compiler'
	gcc  -g -c helloworld.c
	@echo 'Finished building target: $@'
	@echo ' '

clean:
	rm -rf dlcheck.exe dlcheck.o helloworld.dll helloworld.o
	-@echo ' '
=======================

Thanks in advance,
Vitaly Provodin

Attachment: cygchek.out
Description: Text document

--
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]