Discussion:
[ddbg] Debuggin DLL with Code::Blocks
Matthew Allen
2008-03-11 19:07:45 UTC
Permalink
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\
Ddbg 0.11.3 beta - D Debugger
Copyright (c) 2007 Jascha Wetzel
see http://ddbg.mainia.de/doc.html for documentation
Loading symbols from ../../_bin/saWorkspace.exe
(gdb) >>>>>>cb_gdb:
...
directory C:/SoftAutomationD/0_Workspace/saWorkspaceUtils/
directory C:/SoftAutomationD/
directory C:/SoftAutomationD/0_Base/saCollections/
directory C:/SoftAutomationD/0_Workspace/saWorkspace/
break "C:/SoftAutomationD/0_Workspace/saWorkspace/saWorkspace.d:190"
Breakpoint 0 at 0x00402197
break "C:/SoftAutomationD/0_Workspace/saWorkspace/saWorkspace.d:187"
Breakpoint 1 at 0x00402183
break "C:/SoftAutomationD/0_Base/saCollections/Variant.d:30"
Source file "C:\SoftAutomationD\0_Base\saCollections\Variant.d" not found
Breakpoint 2 at 0x00000000
break "C:/SoftAutomationD/0_Base/saCollections/saCollections.d:57"
Source file "C:\SoftAutomationD\0_Base\saCollections\saCollections.d" not found
Breakpoint 2 at 0x00000000
run
Jascha Wetzel
2008-03-12 10:57:50 UTC
Permalink
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.
Post by Matthew Allen
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\
Ddbg 0.11.3 beta - D Debugger
Copyright (c) 2007 Jascha Wetzel
see http://ddbg.mainia.de/doc.html for documentation
Loading symbols from ../../_bin/saWorkspace.exe
...
directory C:/SoftAutomationD/0_Workspace/saWorkspaceUtils/
directory C:/SoftAutomationD/
directory C:/SoftAutomationD/0_Base/saCollections/
directory C:/SoftAutomationD/0_Workspace/saWorkspace/
break "C:/SoftAutomationD/0_Workspace/saWorkspace/saWorkspace.d:190"
Breakpoint 0 at 0x00402197
break "C:/SoftAutomationD/0_Workspace/saWorkspace/saWorkspace.d:187"
Breakpoint 1 at 0x00402183
break "C:/SoftAutomationD/0_Base/saCollections/Variant.d:30"
Source file "C:\SoftAutomationD\0_Base\saCollections\Variant.d" not found
Breakpoint 2 at 0x00000000
break "C:/SoftAutomationD/0_Base/saCollections/saCollections.d:57"
Source file "C:\SoftAutomationD\0_Base\saCollections\saCollections.d" not found
Breakpoint 2 at 0x00000000
run
Matthew Allen
2008-03-12 14:53:41 UTC
Permalink
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.
Post by Jascha Wetzel
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
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.
Post by Matthew Allen
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\
Ddbg 0.11.3 beta - D Debugger
Copyright (c) 2007 Jascha Wetzel
see http://ddbg.mainia.de/doc.html for documentation
Loading symbols from ../../_bin/saWorkspace.exe
...
directory C:/SoftAutomationD/0_Workspace/saWorkspaceUtils/
directory C:/SoftAutomationD/
directory C:/SoftAutomationD/0_Base/saCollections/
directory C:/SoftAutomationD/0_Workspace/saWorkspace/
break "C:/SoftAutomationD/0_Workspace/saWorkspace/saWorkspace.d:190"
Breakpoint 0 at 0x00402197
break "C:/SoftAutomationD/0_Workspace/saWorkspace/saWorkspace.d:187"
Breakpoint 1 at 0x00402183
break "C:/SoftAutomationD/0_Base/saCollections/Variant.d:30"
Source file "C:\SoftAutomationD\0_Base\saCollections\Variant.d" not found
Breakpoint 2 at 0x00000000
break "C:/SoftAutomationD/0_Base/saCollections/saCollections.d:57"
Source file "C:\SoftAutomationD\0_Base\saCollections\saCollections.d" not found
Breakpoint 2 at 0x00000000
run
Jascha Wetzel
2008-03-13 08:17:42 UTC
Permalink
Post by Matthew Allen
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
Post by Matthew Allen
bp mySourceFileContainingMain.d:123
r
when the breakpoint is hit, lsm will list the modules.
Post by Matthew Allen
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.
Post by Matthew Allen
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.

Loading...