Recent

Author Topic: [Solved] How to trace \ debug a design-time package with Lazarus?  (Read 1707 times)

devEric69

  • Hero Member
  • *****
  • Posts: 648
Hello,

I'm reading the following code, used in a static package that has to be rebuilt to be integrated in the IDE...:

Code: Pascal  [Select][+][-]
  1. procedure TCodeFrm.SaveSettings;
  2. var
  3.   Config: TConfigStorage;
  4. begin
  5.   try
  6.     Config := GetIDEConfigStorage('codelib.xml', False);
  7.     try
  8.       Config.SetDeleteValue('CodeLib/DBPath/Value', DatabasePath, LazarusIDE.GetPrimaryConfigPath);  
  9.     ...\...
  10.  
...and I am trying to find out where 'codelib.xml' is located, but I don't see any 'codelib.xml' file in the displayed directory. But, I can't do it because I don't actually know how to debug a builded static package in Lazarus :-[ ( in fact, I'm currently displaying the result of  ShowMessage(LazarusIDE.GetPrimaryConfigPath);. But as said, there is no 'codelib.xml' found at this location???). Hence my first question: am I missing something obvious for not finding where codelib.xml is? In other words, finding codelib.xml should be easy?




And I have a second question. For information, in Delphi, I know how to debug a design-time package *.lpk. Globally, the principle in Delphi is to debug with a first instance of Delphi the design source code that we are manipulating live in a second instance of Delphi.

To do this, in Delphi, I can do like this:
a) check if the debugging of the package in question is possible: for that, open Delphi, and edit the package in design (the one with "usage option" = "design time only" i.e. open the package I would want to debug. Do a rebuild in order to see if everything is correct, if this package compiles, and then if it could be installed. Warning, this is only a pre-requisite check. It must be really not be installed in Delphi.
b) configure Delphi like this:
- set in the general tab of "Tools\options\debuggers", the option "Debug spawned processed" checked, in order to be able to debug the processes generated by the "Run\Run" action when we will define a target in "Host application".
- set in "Tools", "Debug source path", the access directory to the files used by the property editors and other units concerned by the design-time aspect of a design package (e.g.: 'C:\...\...\Delphi\Source\Property editors'). In this directory, we will find among others files, designide.lpk, designintf.pas, colnedit.pas, ...
- in the options of "Tools\options\debugger debugger", it's necessary to check "Integrated debugging"!
c) it is necessary to configure in "Run\Parameters", local tab, "Host application" the target to be launched, i.e. to indicate the location of delphi.exe (for ex.: 'C:\...\...\delphi\bin\delphi.exe').
d) do "Run\Run" in this first instance of Delphi, with the design package to track not installed, as mentioned above. If everything is well set up, "Run\Run" should automatically launch a second instance of Delphi which will be the one debugged when we'll interact with it, when we'll use it live.
e) if exceptions are raised at this moment of the launch - i.e. at the launch of the second instance of Delphi - and that this last one crashes, hangs up due to exceptions (EconvertError, ...), then it is possible to go in "Tools\Debugger options", then "Language exceptions", and to add them there in order to ignore them.
f) redo "Run\Run" (which will always restart a second instance of Delphi) until we succeed in launching this second instance in a clean, stable way.
g) now, in this second instance of stable and debuggable Delphi, it is obviously necessary to install the design package that we wish to debug (via the "Components\install packages..." menu). This loads the correct package which can now be debugged by the first instance of Delphi (through the correct *.bpl file, but it's a detail).
➔ Then, we can put breakpoints in the first instance of Delphi and trace i.e. we can debug where we are going, where we are actually interacting with the second instance...
note: watch out for typo errors in the package's register procedure ;) .

So, my second question is: can Lazarus do this? If so, is there any documentation that explains it?

Regards.
« Last Edit: April 30, 2021, 05:30:20 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

korba812

  • Sr. Member
  • ****
  • Posts: 390
Re: How to trace a design-time package with Lazarus?
« Reply #1 on: April 29, 2021, 12:58:52 pm »
In Lazarus it is quite similar. Just open the project "ide\lazarus.lpr", put your brakpoints and run with debugger.

https://wiki.freepascal.org/Extending_the_IDE#Debugging_the_IDE
« Last Edit: April 29, 2021, 01:07:20 pm by korba812 »

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: How to trace \ debug a design-time package with Lazarus?
« Reply #2 on: April 29, 2021, 03:26:52 pm »
Hello @korba812,

Thank you very much for your short answer which works (Cf. screenshots) :) .

« Last Edit: April 29, 2021, 03:32:37 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

 

TinyPortal © 2005-2018