Hi
I'm writing a DLL to be run by host application R (ver 2.11.1), using this Lazarus version:
Lazarus 0.9.28.2 r22279 FPC 2.2.4 i386-win32-win32/win64
under Window XP x64 Service Pack 2. Everything is 32bit except my computer (and the Windows version). I can do rudimentary debugging *without* dwarf. But when I tried to use dwarf (ticking "Generate dwarf debug information (-gw)" in Project/Compiler_options), debugging just didn't work. Well, I can't set a breakpoint, anyway. Even with dwarf not working, the DLL runs OK inside R though (except for the bugs I am trying to debug...).
I have "Run/Run_parameters/Host_application" and "Run/Run_parameters/Command_line_parameters" set, but not "R/R_p/Launching application" etc.
Below is (most) of the debug output from the with/without dwarf runs. Even without dwarf, there are lots of errors messages, but it still works (sort-of; at any rate, I can set breakpoints and inspect simple variables).
The messages suggest to me that the dwarf version is not finding the source. The DLL and its source are in different directories, the former set by "Project/Project_options/Application/Target_file_name". I've tried setting "extra" paths to my source code and DLL directory (which are different), to no effect. EG in "Project/Compiler_options/Debugger_path_addition" (and when I add the source path there, it resets it to "."), and in "Environment/Options/Debugger/General/Additional_search_path".
There are countless other places in Lazarus where various paths are set; I have little idea what most of them do, and have not included them here (but will happily do so, if anyone thinks they might matter).
Any help much appreciated!
Mark Bravington
mark.bravington@csiro.au
BTW #1: though I know quite a lot about R, Pascal, and DLLs under R, I know nothing about gdb and scary linuxy stuff like that; for better or (probably) worse, I live in the candyfloss castle that is Windows.
BTW #2: while trying dwarf, I also tried ticking the "Use external gdb symbols file (-Xg)" box in Project/Compiler_options, and got this error at the end of building:
srw_raneff3.lpr(307,1) Fatal: Internal error 200602251
library srw_raneff3;
{$mode delphi}{$H+}
{$define REML}
uses
Classes, Useful, Maths32,
{$IFNDEF AD} D_Tuseful_obj_unit, {$ENDIF}{AD}
tuseful_obj_unit, domin
{$IFDEF REML}
, Tsrw_raneff3_obj_unit
, d_tsrw_raneff3_obj_unit
, Tsrw_raneff3_reml_obj_unit, D_TSRW_RANEFF3_REML_OBJ_UNIT
, tw_d_tsrw_raneff3_reml_obj_unit
{$ENDIF}
;
**************** DEBUG OUTPUT WITH DWARF ******************
(gdb)
<-gdb-set confirm off>
^done
(gdb)
<-gdb-set new-console off>
^done
(gdb)
<-gdb-version>
~"GNU gdb 6.8\n"
~"Copyright (C) 2008 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n"
~"This is free software: you are free to change and redistribute it.\n"
~"There is NO WARRANTY, to the extent permitted by law. Type \"show copying\"\n"
~"and \"show warranty\" for details.\n"
~"This GDB was configured as \"i686-pc-mingw32\".\n"
^done
(gdb)
<-gdb-set env AD=d:\r2.0\ad\work>
^done
<<SNIPPED-- LOTS OF ENV VARS GET SET HERE>>
(gdb)
<-file-exec-and-symbols "c:/r/r-2.11.1pat/bin/rgui.exe">
~"(no debugging symbols found)\n"
^done
(gdb)
<-environment-cd .>
^done
(gdb)
<-environment-cd "C:/r/r-2.11.1pat/bin/">
^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 R_PROFILE=D:\R2.0\.R_PROFILE R_USER=D:\R2.0>
^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:/r/r-2.11.1pat/bin/rgui.exe\".\n"
~"Local exec file:\n"
~"\t`c:/r/r-2.11.1pat/bin/rgui.exe', file type pei-i386.\n"
~"\tEntry point: 0x4012a0\t0x00401000 - 0x00405948 is .text\n"
~"\t0x00406000 - 0x00406084 is .data\n"
~"\t0x00407000 - 0x004073f4 is .rdata\n"
~"\t0x00408000 - 0x00408a10 is .bss\n"
~"\t0x00409000 - 0x004094e8 is .idata\n"
~"\t0x0040a000 - 0x0040b078 is .rsrc\n"
^done
(gdb)
<-break-insert -t *4199072>
^done,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x004012a0",at="",times="0"}
(gdb)
<-exec-run>
^running
(gdb)
~"[New thread 293960.0x47c4c]\n"
&"Error: dll starting at 0x77d40000 not found.\n"
&"Error while mapping shared library sections:\n"
&"NOT_AN_IMAGE: No such file or directory.\n"
&"Error while mapping shared library sections:\n"
&"C:\\WINDOWS\\SysWOW64\\ntdll32.dll: No such file or directory.\n"
&"Error: dll starting at 0x77d40000 not found.\n"
&"Error: dll starting at 0x77c20000 not 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="0x004012a0",func="??",args=[]}
(gdb)
<info program>
&"info program\n"
~"\tUsing the running image of child thread 293960.0x47c4c.\n"
~"Program stopped at 0x4012a0.\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 srw_raneff3.lpr:243>
&"No source file named srw_raneff3.lpr in loaded symbols.\n"
^error,msg="No source file named srw_raneff3.lpr in loaded symbols."
(gdb)
<-break-insert tsrw_raneff3_reml_obj_unit.pas:358>
&"No source file named tsrw_raneff3_reml_obj_unit.pas in loaded symbols.\n"
^error,msg="No source file named tsrw_raneff3_reml_obj_unit.pas in loaded symbols."
(gdb)
<-break-insert tsrw_raneff3_obj_unit.pas:678>
&"No source file named tsrw_raneff3_obj_unit.pas in loaded symbols.\n"
^error,msg="No source file named tsrw_raneff3_obj_unit.pas in loaded symbols."
(gdb)
<-break-insert srw_raneff3.lpr:33>
&"No source file named srw_raneff3.lpr in loaded symbols.\n"
^error,msg="No source file named srw_raneff3.lpr in loaded symbols."
(gdb)
<-exec-continue>
^running
(gdb)
~"[New thread 293960.0x47c50]\n"
~"[New thread 293960.0x47c54]\n"
~"[Switching to thread 293960.0x47c54]\n"
*stopped,reason="signal-received",signal-name="SIGTRAP",signal-meaning="Trace/breakpoint trap",thread-id="3",frame={addr="0x7d61002e",func="??",args=[]}
(gdb)
<info program>
&"info program\n"
~"\tUsing the running image of child thread 293960.0x47c54.\n"
~"Program stopped at 0x7d61002e.\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 D:\r2.0\srw\inst\pascal3\srw_raneff3.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 srw_raneff3.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)
~"[New thread 293960.0x47c58]\n"
~"[New thread 293960.0x47c60]\n"
~"[New thread 293960.0x47c5c]\n"
&"Error while reading shared library symbols:\n"
&"Dwarf Error: Could not find abbrev number 12975 [in module d:\\rpackages\\r2.10.0\\srw\\libs\\srw_raneff3.dll]\n"
<<SNIPPED-- SAME ERROR MESSAGE MANY TIMES>>
*************************** DEBUG OUTPUT WITHOUT DWARF ***************************************
<-file-exec-and-symbols "c:/r/r-2.11.1pat/bin/rgui.exe">
~"(no debugging symbols found)\n"
^done
(gdb)
<-environment-cd .>
^done
(gdb)
<-environment-cd "C:/r/r-2.11.1pat/bin/">
^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 R_PROFILE=D:\R2.0\.R_PROFILE R_USER=D:\R2.0>
^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:/r/r-2.11.1pat/bin/rgui.exe\".\n"
~"Local exec file:\n"
~"\t`c:/r/r-2.11.1pat/bin/rgui.exe', file type pei-i386.\n"
~"\tEntry point: 0x4012a0\t0x00401000 - 0x00405948 is .text\n"
~"\t0x00406000 - 0x00406084 is .data\n"
~"\t0x00407000 - 0x004073f4 is .rdata\n"
~"\t0x00408000 - 0x00408a10 is .bss\n"
~"\t0x00409000 - 0x004094e8 is .idata\n"
~"\t0x0040a000 - 0x0040b078 is .rsrc\n"
^done
(gdb)
<-break-insert -t *4199072>
^done,bkpt={number="2",type="breakpoint",disp="del",enabled="y",addr="0x004012a0",at="",times="0"}
(gdb)
<-exec-run>
^running
(gdb)
~"[New thread 294592.0x47e9c]\n"
&"Error: dll starting at 0x77d40000 not found.\n"
&"Error while mapping shared library sections:\n"
&"NOT_AN_IMAGE: No such file or directory.\n"
&"Error while mapping shared library sections:\n"
&"C:\\WINDOWS\\SysWOW64\\ntdll32.dll: No such file or directory.\n"
&"Error: dll starting at 0x77d40000 not found.\n"
&"Error: dll starting at 0x77c20000 not 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="0x004012a0",func="??",args=[]}
(gdb)
<info program>
&"info program\n"
~"\tUsing the running image of child thread 294592.0x47e9c.\n"
~"Program stopped at 0x4012a0.\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 srw_raneff3.lpr:243>
&"No source file named srw_raneff3.lpr in loaded symbols.\n"
^error,msg="No source file named srw_raneff3.lpr in loaded symbols."
(gdb)
<-break-insert tsrw_raneff3_reml_obj_unit.pas:358>
&"No source file named tsrw_raneff3_reml_obj_unit.pas in loaded symbols.\n"
^error,msg="No source file named tsrw_raneff3_reml_obj_unit.pas in loaded symbols."
(gdb)
<-break-insert tsrw_raneff3_obj_unit.pas:678>
&"No source file named tsrw_raneff3_obj_unit.pas in loaded symbols.\n"
^error,msg="No source file named tsrw_raneff3_obj_unit.pas in loaded symbols."
(gdb)
<-break-insert srw_raneff3.lpr:33>
&"No source file named srw_raneff3.lpr in loaded symbols.\n"
^error,msg="No source file named srw_raneff3.lpr in loaded symbols."
(gdb)
<-exec-continue>
^running
(gdb)
~"[New thread 294592.0x47e8c]\n"
~"[New thread 294592.0x47eac]\n"
~"[Switching to thread 294592.0x47eac]\n"
*stopped,reason="signal-received",signal-name="SIGTRAP",signal-meaning="Trace/breakpoint trap",thread-id="3",frame={addr="0x7d61002e",func="??",args=[]}
(gdb)
<info program>
&"info program\n"
~"\tUsing the running image of child thread 294592.0x47eac.\n"
~"Program stopped at 0x7d61002e.\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 D:\r2.0\srw\inst\pascal3\srw_raneff3.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 srw_raneff3.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)
~"[New thread 294592.0x47e94]\n"
~"[New thread 294592.0x47eb4]\n"
~"[New thread 294592.0x47ea4]\n"
~"[New thread 294592.0x47f28]\n"
~"[Switching to thread 294592.0x47f28]\n"
*stopped,reason="signal-received",signal-name="SIGTRAP",signal-meaning="Trace/breakpoint trap",thread-id="7",frame={addr="0x7d61002e",func="??",args=[]}
(gdb)
<info program>
&"info program\n"
~"\tUsing the running image of child thread 294592.0x47f28.\n"
~"Program stopped at 0x7d61002e.\n"
~"It stopped with signal SIGTRAP, Trace/breakpoint trap.\n"
~"Type \"info stack\" or \"info registers\" for more information.\n"
^done
(gdb)
<-break-insert srw_raneff3.lpr:243>
^done,bkpt={number="3",type="breakpoint",disp="keep",enabled="y",addr="0x06c41b15",func="R_SRW3_GET_DPROBS",file="srw_raneff3.lpr",line="243",times="0"}
(gdb)
<-break-enable 3>
^done
(gdb)
<-exec-continue>
^running
(gdb)