This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB 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/780: Problem to debug a DLL


>Number:         780
>Category:       gdb
>Synopsis:       Problem to debug a DLL
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 02 11:48:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     obry@gnat.com
>Release:        GDB 4.x and 5.x
>Organization:
>Environment:
Windows GDB MingW or Cygwin based
>Description:
If the main application has no debug symbol or is built with MS tools it
is not possible to debug a DLL built with the GNU toolset.

(see How-To-Repeat section for the procedure)

Note that I have been able to reproduce this problem with:
   Cygwin GDB : GNU gdb 2002-07-19-cvs (cygwin-special)
   MingW GDB 5.0
   MingW GDB 5.1.1
   Snapshot GDB : GNU gdb 20021001
   MingW based GDB 4.17

Note also that it used to be possible to debug a DLL with:

   $ gdb -nw code.dll
   (gdb) break indll
   (gdb) exec-file main.exe
   (gdb) run
   Starting program: main.exe 

   Breakpoint 1, indll (x=12) at code.c:5
   5	  return x + 2;

This is working fine with GDB 4.17 for example. With GNAT 5.x the program is
not stopped at the breakpoint... Output from latest snapshot:

  $ gdb -nw code.dll
  GNU gdb 20021001
  Copyright 2002 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) break indll
  Breakpoint 1 at 0x11001087: file code.c, line 5.
  (gdb) exec-file main.exe
  (gdb) run
  Starting program: /home/obry/dev-gnat/bugs/B930-020/bug.report/main.exe 
  indll = 14

  Program exited normally.


Please, let me know if you need more information.

>How-To-Repeat:
To reproduce the problem:

Build the DLL

code.c:
<<
int
indll (int x)
{
  return x + 2;
}
> >

code.def:
<<
EXPORTS
	indll
> >

   $ gcc -c -g code.c
   $ gcc -mdll -o code.jnk -Wl,--base-file,code.base code.o -g
   $ dlltool --def code.def --dllname code.dll --output-exp code.exp \
	--base-file code.base
   $ gcc -mdll -o code.jnk -Wl,--base-file,code.base code.exp code.o -g
   $ dlltool --def code.def --dllname code.dll --output-lib libcode.a \
	--output-exp code.exp --base-file code.base
   $ gcc -mdll -o code.dll code.exp code.o -Wl,--image-base=0x11000000 -g

main.c:
<<
#include <stdio.h>

extern int indll (int);

int
main (void)
{
  printf ("indll = %d\n", indll (12));
  exit (0);
}
> >

   $ gcc -o main.exe main.c -L. -lcode -s


Then, let's debug the DLL:

   $ gdb -nw main.exe
   (gdb) dll-symbols code.dll
   (gdb) break indll
   Cannot access memory at address 0x11001084

Here GDB crash ! But it is possile to break at this location using the
reported address:

   (gdb) break *0x11001084
   Breakpoint 1 at 0x11001084: file code.c, line 4.
   (gdb) run
   Starting program: main.exe 

   Breakpoint 1, indll (x=1) at code.c:4
   4	{

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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