Cannot debug a dll (Windows x86) lazarus / 12-Debugger ---------------------------------------------------------------------- dmitry · 2010-01-16 20:27 I am probably missing something obvious here, but how do you debug a dll using pdb from within Lazarus? I turned on all the debug options in the Compiler options (no optimization, -g, -gl, -gw, -Xg), but sill no luck. I have a COM library that can be hosted by an external app. The simplest test would be to run the dll under regsvr32.exe. The working directory is set to where the dll resides. I tried copying the exe to the same directory, still no luck. Does the debugger only look for the debug symbolx for the host process (regsvr32.exe), but not for the hosted dll to be debugged? Looks like the debugger just does nto see the the DBG file or does nto know that which one needs to be loaded.: <-break-insert uSession.pas:6680> &"No source file named uSession.pas in loaded symbols.\n" ^error,msg="No source file named uSession.pas in loaded symbols." DBG file Full debugger output is below. Thanks! <-file-exec-and-symbols "C:/ProgrammingProjects/Redemption/fpc/compiled/regsvr32.exe"> ~"(no debugging symbols found)\n" ^done (gdb) <-environment-cd .> ^done (gdb) <-environment-cd "C:/ProgrammingProjects/Redemption/fpc/compiled/"> ^done (gdb) <-data-evaluate-expression FPC_THREADVAR_RELOCATE_PROC> &"No symbol table is loaded.  Use the \"file\" command.\n" ^error,msg="No symbol table is loaded.  Use the \"file\" command." (gdb) &"info functions FPC_CPUINIT\n" ~"All functions matching regular expression \"FPC_CPUINIT\":\n" ^done (gdb) &"info functions $$_RUNERROR$\n" ~"All functions matching regular expression \"$$_RUNERROR$\":\n" ^done (gdb) <-exec-arguments c:\ProgrammingProjects\Redemption\fpc\compiled\Redemption.dll> ^done (gdb) <-gdb-set language pascal> ^done (gdb) &"info address main\n" &"No symbol \"main\" in current context.\n" ^error,msg="No symbol \"main\" in current context." (gdb) <-break-insert -t main> &"Function \"main\" not defined in loaded symbols.\n" ^error,msg="Function \"main\" not defined in loaded symbols." (gdb) <-break-insert FPC_RAISEEXCEPTION> &"Function \"FPC_RAISEEXCEPTION\" not defined in loaded symbols.\n" ^error,msg="Function \"FPC_RAISEEXCEPTION\" not defined in loaded symbols." (gdb) <-break-insert FPC_BREAK_ERROR> &"Function \"FPC_BREAK_ERROR\" not defined in loaded symbols.\n" ^error,msg="Function \"FPC_BREAK_ERROR\" not defined in loaded symbols." (gdb) <-break-insert FPC_RUNERROR> &"Function \"FPC_RUNERROR\" not defined in loaded symbols.\n" ^error,msg="Function \"FPC_RUNERROR\" not defined in loaded symbols." (gdb) &"info file\n" ~"Symbols from \"C:/ProgrammingProjects/Redemption/fpc/compiled/regsvr32.exe\".\n" ~"Local exec file:\n" ~"\t`C:/ProgrammingProjects/Redemption/fpc/compiled/regsvr32.exe', \n" ~"        file type pei-i386.\n" ~"\tEntry point: 0x1002327\t0x01001000 - 0x01002ad8 is .text\n" ~"\t0x01003000 - 0x01003200 is .data\n" ~"\t0x01004000 - 0x01004ad8 is .rsrc\n" ^done (gdb) <-break-insert -t *16786215> ^done,bkpt={number="5",type="breakpoint",disp="del",enabled="y",addr=" 0x01002327",at="",times="0"} (gdb) <-exec-run> ^running (gdb) ~"[New thread 10100.0x11e0]\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" ~"(no debugging symbols found)\n" *stopped,thread-id="1",frame={addr="0x01002327",func="??",args=[]} (gdb) &"info program\n" ~"\tUsing the running image of child thread 10100.0x11e0.\n" ~"Program stopped at 0x1002327.\n" ~"It stopped at a breakpoint that has since been deleted.\n" ~"Type \"info stack\" or \"info registers\" for more information.\n" ^done (gdb) <-break-insert uSession.pas:6680> &"No source file named uSession.pas in loaded symbols.\n" ^error,msg="No source file named uSession.pas in loaded symbols." (gdb) <-break-insert uSession.pas:41554> &"No source file named uSession.pas in loaded symbols.\n" ^error,msg="No source file named uSession.pas in loaded symbols." (gdb) <-exec-continue> ^running (gdb) ~"[New thread 10100.0x1f90]\n" ~"[Switching to thread 10100.0x1f90]\n" *stopped,reason="signal-received",signal-name="SIGTRAP",signal- meaning="Trace/breakpoint trap",thread-id="2",frame={addr="0x7c90120f" ,func="ntdll!DbgUiConnectToDbg",args=[],from="C:\\WINDOWS\\system32\\n tdll.dll"} (gdb) &"info program\n" ~"\tUsing the running image of child thread 10100.0x1f90.\n" ~"Program stopped at 0x7c90120f.\n" ~"It stopped with signal SIGTRAP, Trace/breakpoint trap.\n" ~"Type \"info stack\" or \"info registers\" for more information.\n" ^done (gdb) <-symbol-list-lines C:\ProgrammingProjects\Redemption\Redemption.lpr> &"mi_cmd_symbol_list_lines: Unknown source file name.\n" ^error,msg="mi_cmd_symbol_list_lines: Unknown source file name." (gdb) <-symbol-list-lines Redemption.lpr> &"mi_cmd_symbol_list_lines: Unknown source file name.\n" ^error,msg="mi_cmd_symbol_list_lines: Unknown source file name." (gdb) <-exec-continue> ^running (gdb) ~"(no debugging symbols found)\n" ~"[New thread 10100.0x270c]\n" &"warning: Lowest section in C:\\WINDOWS\\system32\\xpsp2res.dll is .rsrc at 00011000\n" ~"[New thread 10100.0x2004]\n" ~"[New thread 10100.0xbc8]\n" *stopped,reason="exited-normally" (gdb) <-break-delete 0> &"warning: bad breakpoint number at or near '0'\n" ^done (gdb) <-break-delete 0> &"warning: bad breakpoint number at or near '0'\n" ^done (gdb) <-break-delete 0> &"warning: bad breakpoint number at or near '0'\n" ^done (gdb) <-file-exec-and-symbols > ^done (gdb) ---------------------------------------------------------------------- Marc · 2010-01-17 13:11 Sorry, this is not yet possible. The debugger sets all breakpoints on application start, not on dll load (what you need) For now, the only option I see for you is using gdb itself. ---------------------------------------------------------------------- dmitry · 2010-01-18 16:38 Are there any plans to support dynamically loaded dls? As more people jump the Delphi ship in favor of FPC, this would probably become more important: the reason for the jump is the Delphi inability to compile 64 bit dlls that people use for the shell extensions (must be 64 bit on 64 bit version of Windows), Office add- ins (Office 2010 64 bit) and 64 bit COM libraries used in IE, IIS, etc. Thanks! ---------------------------------------------------------------------- Marc · 2010-01-19 09:13 it will be supported someday. I simply didn't think of it yet. ---------------------------------------------------------------------- dmitry · 2010-01-26 17:25 Also, would it be possible to attach to a process? ---------------------------------------------------------------------- Marc · 2010-01-26 23:15 also some day, but not yet ---------------------------------------------------------------------- Marc · 2010-02-20 00:05 dmitry, can you check r23747 I've enabled setting pending breakpoints. This is only supported by "recent" (>= 6. versions of gdb. This might fix your debug dll issue