Forum > General

[Solved] How to trace \ debug a design-time package with Lazarus?



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

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TCodeFrm.SaveSettings;var  Config: TConfigStorage;begin  try    Config := GetIDEConfigStorage('codelib.xml', False);    try      Config.SetDeleteValue('CodeLib/DBPath/Value', DatabasePath, LazarusIDE.GetPrimaryConfigPath);       ...\... ...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?


In Lazarus it is quite similar. Just open the project "ide\lazarus.lpr", put your brakpoints and run with debugger.

Hello @korba812,

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


[0] Message Index

Go to full version