www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.debugger - [ddbg] Debuggin DLL with Code::Blocks

reply Matthew Allen <mallen creativelifestyles.removeme.com> writes:
I am trying to debug a DLL with the latest release of DDBG (0.11.3) using
CodeBlocks 8.02 release. 

CodeBlocks does not allow you to directly debug a DLL so I select a host exe
and set my breakpoints. The Debugger log window however shows errors on trying
to set the breakpoints in the DLL's. The DLL's are loaded and the path to the
sourcecode is added to the debugger but it DDBG complains that it cannot find
the source file. Has anyone successfully debugged a DLL with CodeBlocks? Is
there some additional setup I need to do in order to get this to work? Any help
is much appreciated. Log is below.

Command-line: C:\DMCompilers\Debugger\ddbg_gdb.bat -nx -fullname  -quiet -args
../../_bin/saWorkspace.exe
Working dir : C:\SoftAutomationD\0_Workspace\saWorkspace\
 set prompt >>>>>>cb_gdb:

Copyright (c) 2007 Jascha Wetzel see http://ddbg.mainia.de/doc.html for documentation Loading symbols from ../../_bin/saWorkspace.exe (gdb) >>>>>>cb_gdb: ...
cb_gdb:





cb_gdb:





cb_gdb:





cb_gdb:





cb_gdb:






cb_gdb:






cb_gdb:






Breakpoint 2 at 0x00000000
cb_gdb:






Breakpoint 2 at 0x00000000
cb_gdb:






Mar 11 2008
parent reply Jascha Wetzel <firstname mainia.de> writes:
the debug info in the executable usually hold the source filenames as 
relative paths just like they were used during compilation.
in order for the debugger to find the files, it needs to reconstruct the 
absolute paths using the search paths that are set with the directory 
command (or 'sp' when in ddbg command line mode).

so my guess is that you are missing a directory for the search path. you 
can find out what the source files are called in the debug info by using 
ddbg from the command line. the following commands should do that for 
your project:

cd C:\SoftAutomationD\0_Workspace\saWorkspace\
ddbg ..\..\_bin\saWorkspace.exe
lsm

if that lists too much, you can try
lsm Variant
instead.

you might get something like
saCollections/Variant.d
in which case you'd need to add
C:/SoftAutomationD/0_Base/
to the search paths.


Matthew Allen wrote:
 I am trying to debug a DLL with the latest release of DDBG (0.11.3) using
CodeBlocks 8.02 release. 
 
 CodeBlocks does not allow you to directly debug a DLL so I select a host exe
and set my breakpoints. The Debugger log window however shows errors on trying
to set the breakpoints in the DLL's. The DLL's are loaded and the path to the
sourcecode is added to the debugger but it DDBG complains that it cannot find
the source file. Has anyone successfully debugged a DLL with CodeBlocks? Is
there some additional setup I need to do in order to get this to work? Any help
is much appreciated. Log is below.
 
 Command-line: C:\DMCompilers\Debugger\ddbg_gdb.bat -nx -fullname  -quiet -args
../../_bin/saWorkspace.exe
 Working dir : C:\SoftAutomationD\0_Workspace\saWorkspace\
 set prompt >>>>>>cb_gdb:

Copyright (c) 2007 Jascha Wetzel see http://ddbg.mainia.de/doc.html for documentation Loading symbols from ../../_bin/saWorkspace.exe (gdb) >>>>>>cb_gdb: ...
 cb_gdb:





 cb_gdb:





 cb_gdb:





 cb_gdb:





 cb_gdb:






 cb_gdb:






 cb_gdb:






Breakpoint 2 at 0x00000000
 cb_gdb:






Breakpoint 2 at 0x00000000
 cb_gdb:







Mar 12 2008
parent reply Matthew Allen <mallen creativelifestyles.removeme.com> writes:
Sorry to be a pain. I am linking my DLL to the exe statically. The variant.d
file is in the DLL sourcecode. When I load the symbols from saWorkspace.exe it
does not know about variant at that point.

CodeBlocks sets the breakpoints before running and so the symbols for the
saCollections.dll have not been loaded before the breakpoint is set.

Am I doing something wrong. Sorry for my ignorance. I have tried looking at the
command line for ddbg and gdb to see if I can add the DLL on the command line
so it get's loaded right away. Is this possible? I did not see an option for
that.

Thanks for your help.

Jascha Wetzel Wrote:

 the debug info in the executable usually hold the source filenames as 
 relative paths just like they were used during compilation.
 in order for the debugger to find the files, it needs to reconstruct the 
 absolute paths using the search paths that are set with the directory 
 command (or 'sp' when in ddbg command line mode).
 
 so my guess is that you are missing a directory for the search path. you 
 can find out what the source files are called in the debug info by using 
 ddbg from the command line. the following commands should do that for 
 your project:
 
 cd C:\SoftAutomationD\0_Workspace\saWorkspace\
 ddbg ..\..\_bin\saWorkspace.exe
 lsm
 
 if that lists too much, you can try
 lsm Variant
 instead.
 
 you might get something like
 saCollections/Variant.d
 in which case you'd need to add
 C:/SoftAutomationD/0_Base/
 to the search paths.
 
 
 Matthew Allen wrote:
 I am trying to debug a DLL with the latest release of DDBG (0.11.3) using
CodeBlocks 8.02 release. 
 
 CodeBlocks does not allow you to directly debug a DLL so I select a host exe
and set my breakpoints. The Debugger log window however shows errors on trying
to set the breakpoints in the DLL's. The DLL's are loaded and the path to the
sourcecode is added to the debugger but it DDBG complains that it cannot find
the source file. Has anyone successfully debugged a DLL with CodeBlocks? Is
there some additional setup I need to do in order to get this to work? Any help
is much appreciated. Log is below.
 
 Command-line: C:\DMCompilers\Debugger\ddbg_gdb.bat -nx -fullname  -quiet -args
../../_bin/saWorkspace.exe
 Working dir : C:\SoftAutomationD\0_Workspace\saWorkspace\
 set prompt >>>>>>cb_gdb:

Copyright (c) 2007 Jascha Wetzel see http://ddbg.mainia.de/doc.html for documentation Loading symbols from ../../_bin/saWorkspace.exe (gdb) >>>>>>cb_gdb: ...
 cb_gdb:





 cb_gdb:





 cb_gdb:





 cb_gdb:





 cb_gdb:






 cb_gdb:






 cb_gdb:






Breakpoint 2 at 0x00000000
 cb_gdb:






Breakpoint 2 at 0x00000000
 cb_gdb:








Mar 12 2008
parent Jascha Wetzel <firstname mainia.de> writes:
Matthew Allen wrote:
 Sorry to be a pain. I am linking my DLL to the exe statically. The variant.d
file is in the DLL sourcecode. When I load the symbols from saWorkspace.exe it
does not know about variant at that point.

oh right, you need to execute the program in the debugger until the point where the DLL has been loaded (ddbg will log that). you can for example set a breakpoint in main() and run the debuggee with something like this:
 bp mySourceFileContainingMain.d:123
 r

when the breakpoint is hit, lsm will list the modules.
 CodeBlocks sets the breakpoints before running and so the symbols for the
saCollections.dll have not been loaded before the breakpoint is set.

that is not a problem. those breakpoints will stay inactive until the appropriate module are loaded.
 I have tried looking at the command line for ddbg and gdb to see if I can add
the DLL on the command line so it get's loaded right away. Is this possible? I
did not see an option for that.

that's not possible. you'll have to make the program load the DLL as described above.
Mar 13 2008