debugging FCL modules lazarus / 12-Debugger ---------------------------------------------------------------------- dmitryb · 2014-04-20 22:13 How to debug debug FCL components. I want to go through TDataset and other components when I debug my app. I read about it here: http://wiki.lazarus.freepascal.org/Lazarus_Faq#How_can_I_debug_FCL_com ponents_from_packages_with_Lazarus so I recompiled FCL package with checkbox - (-gl) (look at the screenshot) and recompiled my app but still the debuger (F7) skip TDataset methods. ---------------------------------------------------------------------- Martin_fr · 2014-04-20 22:33 TDAtaSet itself is in   FPC\packages\fcl-db\src\base\db.pas That would mean, you must recompile FPC. That is not possible with the fpc that comes with Lazarus as it does not contain the makefiles, you nee to download a full Version with Makefiles. BUT there is another way. First: Do NOT / NEVER make changes inside the fpc folder, that comes with Lazarus 1) Make a copy of the folder  FPC\packages\fcl-db\ 2) Remove ppu and o files from this folder (from the copy) 3) either create a package for this folder, or add the sources ( \packages\fcl-db\src\ and sub folders) to your project. Easiest is to just add the source containing folders to your project unit search path. [1] 4) Rename, or move the original folder, so it will not be found (yes that is an exception to the "never" rule above). After the debug session you need to restore it, so other projects will have it. Now if you build your project, it should use the copied sources. And you can debug them. --- [1] Maybe you have to add it to the unit search path of the FCL package instead ---------------------------------------------------------------------- Leledumbo · 2014-04-20 23:48 QuoteThat would mean, you must recompile FPC. That is not possible with the fpc that comes with Lazarus as it does not contain the makefiles, you nee to download a full Version with Makefiles.Actually, the Makefiles in packages still exist. So one just need to go inside respective package folder (or top level packages if all packages are going to be recompiled) and make from there. ---------------------------------------------------------------------- dmitryb · 2014-04-21 09:15 QuoteThat would mean, you must recompile FPC. Yes, I think I want to recompile the whole FPC. I want to have a possibility to debug db.pas and other FCL modules from all applications. How can I do it? If I need to download a full Version where can I get it? There are no something about full version on the official download page: http://www.lazarus.freepascal.org/index.php?page=downloads I noticed an interesting thing. with code Code: [Select]procedure TForm1.Button1Click(Sender: TObject); begin   Dbf1.Open; end; procedure TForm1.Button2Click(Sender: TObject); begin   Button1.Caption := 'Button1New'; end; Using (F7), I can go into SetText method for "Button1.Caption" but I can't go into TDataSet.Open. So it means that LCL is compiled with Debug Info and FCL without. Why did they do so? Why they build Lazarus installer that only a part of the code can be debugged. ---------------------------------------------------------------------- Leledumbo · 2014-04-21 14:55 QuoteHow can I do it? If I need to download a full Version where can I get it?http://sourceforge.net/projects/freepascal/files/Source/ QuoteWhy did they do so? Why they build Lazarus installer that only a part of the code can be debugged.Because only LCL belongs to Lazarus. FCL is part of FPC. Lazarus can only control LCL (though FCL is registered as built-in package in Lazarus). ---------------------------------------------------------------------- Martin_fr · 2014-04-21 15:45 Actually, the contained FPC is build from sources for the installer. But those packages being part of FPC, does explain why they are not individual Lazarus packages, that can be rebuild from within the IDE, like the LCL. Adding debug info there too, would massively increase the size of the installer, and very few people will need it. In fact adding debug info there would annoy most people. If you build the entire FCL and RTL with debug info, and you step your app, then you also step into AnsiStringIncRef/DeRef and other helpers. SomeString := SomeFunc(OtherString); Stepping with F7, will not (immediately) enter SomeFunc, but go into AnsiStringIncRef first. Then you must use F7 at the end of AnsiStringIncRef to step to SomeFunc. If you use F8 at the end of AnsiStringIncRef you will never step to SomeFunc. So an RTL with debug info, would annoy 99% of the users. The line needs to be drawn somewhere, FCL could be either way. But RTL and FCL ace build together, with one call to "make". Splitting this up would be a lot of work. There are tools like fpup (or fpcup?), that can help maintain your self build copies of fpc and Lazarus. (search forum and wiki) ---------------------------------------------------------------------- dmitryb · 2014-04-22 10:22 Ok. I will try to install the whole FPC. But now I would like to check the second method of debuging some of FPC files. Method of copying files in the project directory. I have a run time error "EReadError" in the method procedure TReader.ReadListEnd; So I copied files From C:\Lazarus\fpc\2.6.2\source\rtl\objpas\classes\ action.inc bits.inc classes.inc classesh.inc collect.inc compon.inc constsg.inc constss.inc cregist.inc dm.inc filer.inc intf.inc lists.inc parser.inc persist.inc reader.inc resref.inc sllist.inc streams.inc stringl.inc tthread.inc twriter.inc util.inc writer.inc From C:\Lazarus\fpc\2.6.2\source\rtl\win32\ classes.pp to the directory of my project and tried to compile it: I got compilation error: FclSrc\classes.pp(80,1) Fatal: Selected assembler reader not supported on the line Code: [Select]function TrampolineWndProc(Window: HWND; Message, WParam: WPARAM;LParam: LPARAM): HRESULT; stdcall; assembler; asm how to fix it? Chaning Assembler style to Intel or AT&T in the project Options doesn't help. ---------------------------------------------------------------------- marcov · 2014-04-22 10:55 Quote from: Martin_fr on April 21, 2014, 05:45:24 pmStepping with F7, will not (immediately) enter SomeFunc, but go into AnsiStringIncRef first. Then you must use F7 at the end of AnsiStringIncRef to step to SomeFunc. If you use F8 at the end of AnsiStringIncRef you will never step to SomeFunc. So an RTL with debug info, would annoy 99% of the users. The line needs to be drawn somewhere, FCL could be either way. But RTL and FCL ace build together, with one call to "make". Splitting this up would be a lot of work. On targets where debug symbols are weakly linked, building the snapshot with debuginfo, backing up the .o's of system, objpas, sysutils and optionally classes and then stripping those .o's is a good remedy for that. ---------------------------------------------------------------------- dmitryb · 2014-04-22 11:50 QuoteIn fact adding debug info there would annoy most people. If you build the entire FCL and RTL with debug info, and you step your app, then you also step into AnsiStringIncRef/DeRef and other helpers. Yes, I don't need this low level debugging But such classes as TDataSet, TStream, TFiler, TReader, TWriter, TComponent are classes where I constantly work when debugging. ---------------------------------------------------------------------- skalogryz · 2014-04-22 12:10 Delphi actually has (had?) {$D} switch. It allows to disable debugging information per unit. I don't think the switch is supported by FPC currently. I presume the behavior of the switch could be handled on the debugger level. So it could skip stepping through lines of a unit "excluded" from the debugging. Implementation of "exclusion" list at the debugger level provides more flexibility, since a compiled unit could still maintain the debugging information. Something similar is actually happening right now, when a debugger doesn't have a source for a module ---------------------------------------------------------------------- Leledumbo · 2014-04-22 15:30 Quote from: dmitryb on April 22, 2014, 12:22:12 pmOk. I will try to install the whole FPC. But now I would like to check the second method of debuging some of FPC files. Method of copying files in the project directory. to the directory of my project and tried to compile it: I got compilation error: FclSrc\classes.pp(80,1) Fatal: Selected assembler reader not supported on the line Code: [Select]function TrampolineWndProc(Window: HWND; Message, WParam: WPARAM;LParam: LPARAM): HRESULT; stdcall; assembler; asm how to fix it? Chaning Assembler style to Intel or AT&T in the project Options doesn't help. Short answer: it's not that easy, copying to project directory doesn't always work, especially for rtl units. If you've ever tried the Makefile, and watch it as the compilation goes on, you'll notice the script passes several options to the compiler while compiling. ---------------------------------------------------------------------- Martin_fr · 2014-04-22 17:00 Newer GDB have a command, that allows to specify functions that are ignored when stepping in. But IDE support is yet missing.