Recent

Author Topic: Cannot debug a dll (Windows x86)  (Read 15486 times)

dmitry

  • New Member
  • *
  • Posts: 32
    • Outlook Developer Tools
Cannot debug a dll (Windows x86)
« on: January 16, 2010, 09:27:59 pm »
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>
&"info functions FPC_CPUINIT\n"

~"All functions matching regular expression \"FPC_CPUINIT\":\n"

^done

(gdb)

<info functions $$_RUNERROR$>
&"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>
&"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>
&"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>
&"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\\ntdll.dll"}

(gdb)

<info program>
&"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)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2706
Re: Cannot debug a dll (Windows x86)
« Reply #1 on: January 17, 2010, 02:11:10 pm »
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.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

dmitry

  • New Member
  • *
  • Posts: 32
    • Outlook Developer Tools
Re: Cannot debug a dll (Windows x86)
« Reply #2 on: January 18, 2010, 05:38:54 pm »
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!
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2706
Re: Cannot debug a dll (Windows x86)
« Reply #3 on: January 19, 2010, 10:13:37 am »
it will be supported someday. I simply didn't think of it yet.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

dmitry

  • New Member
  • *
  • Posts: 32
    • Outlook Developer Tools
Re: Cannot debug a dll (Windows x86)
« Reply #4 on: January 26, 2010, 06:25:13 pm »
Also, would it be possible to attach to a process?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2706
Re: Cannot debug a dll (Windows x86)
« Reply #5 on: January 27, 2010, 12:15:52 am »
also some day, but not yet
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2706
Re: Cannot debug a dll (Windows x86)
« Reply #6 on: February 20, 2010, 01:05:41 am »
dmitry, can you check r23747
I've enabled setting pending breakpoints. This is only supported by "recent" (>= 6.8) versions of gdb.
This might fix your debug dll issue
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

 

TinyPortal © 2005-2018