You should see the blue dots in the editor-gutter, to indicate that there is debug info.
I don't see any “blue dots” in the editor;
the breakpoints are red, if that's what you mean.
Once the debugger is running there should be
- little blue dots, one for each line that has source code
- the breakpoints should be red, with a "checkmark" ("V") symbol on them
But, that is once the debugger is running.
You are trying to debug the package within the IDE? (As opposed to having your own project using the package)?
Yes, I am trying to debug the installed package with the currently running IDE.
Is that correct?
2) Open ide/lazarus.lpi
Why should I debug the IDE?
I just want to debug the package.
Do I have to open ide/lazarus.lpi to debug the package?
A package on its own doesn't "run". Its not an application, there is no standalone *.exe for the package.
For projecttemplates the executable is the IDE.
So, yes, you need to debug the IDE.
You don't have to step through the IDE, or anything. You can (should be able to) set breakpoint directly in the code of the package.
Of course, what the package does will depend on what the IDE is calling on the package. So you may end up needing to look at that. (but that is maybe, maybe not).
Well, in theory, but I don't think its the way to go, you can write your own project, and simulate the IDE, and call the package yourself. But that isn't going to be practical. That would be a massive undertaking (since I expect projecttemplates wants to use the IDEINTF, and to simulate that, you need to write a huge amount of code) => So, opening lazarus.lpi it is.
If you compiled all of it correctly, then when you press F9 on the lazarus.lpi, and when the 2nd IDE opens, and you go back to the first IDE => then the blue dots should be there. And your breakpoints should show the "V" indicating they are active.
Should I change the profile to Debug IDE under Tools -> Configure Build Lazarus... -> Profile?
It is set currently to Normal IDE?
Yes, that will be the easiest.
Otherwise edit the custom options, and make sure they have at least
-gw3
Or better
-gw3 -O-1
IIRC the debug profile will also add range checks etc -Cr or -Criot or something like that. Ok to have, not making a difference for your case.
I open projtemplates.lpk(currently installed package) -> package -> open lpk file -> open in files tree -> projecttemplates.pp
The code is now displayed in Lazarus.
I set a breakpoint -> what now?
Do I have to recompile the entire IDE so that the breakpoint is used in the package?
You have to recompile the entire IDE when/if
- you change any options (in the package, or in other packages, or in the IDE, or in the Tools menu), e.g. optimization level, or debug info settings -O -gw .....
- If you changed any code (e.g. to test what the change will do)
And if you recompiled, check it replaced the lazarus.exe (timestamp should be updated to "now" / time of compilation), there should not be a lazarus.new.exe
Once you recompiled for the above, then you do
not need to recompile for
- changing (setting, unsetting, properties) breakpoints
Can you explain to me in simple steps how to debug installed packages?
I assume I'm doing something fundamentally wrong.
First of all => I will assume you installed to C:\lazarus or to some folder that your user account has write access to.
1)
If you installed lazarus as admin, into c:\programs or into some folder that you don't have write access with your normal user account => then it becomes a bit more complicated.
2)
- set debug info in the packag
- chose debug profiles in tools > config build laz
3)
Open ide/lazarus.lpi
4)
Recompile the IDE from the tools menu.
Check the lazarus.exe was updated => If it was, then you do *not* need to restart (you can if you want)
(more see below)
5)
run / F9
-----------------------
You may want to run the original Lazarus.exe as the one that acts as debugger.
E.g. if you make changes to the code, and you don't know they work, then you only want those changes in the "running IN debugger" lazarus IDE.
But you don't want the "running AS debugger" IDE to be affected.
In that case make a copy of lazarus.exe (e.g. lazarus-orig.exe).
Run lazarus-orig.exe (and ignore the "changed file name stuff" that comes up (if you need it open there is an option / cfg file / but I need to search...).
Then when you rebuild the IDE, it will change the lazarus.exe and when you debug it will run the lazarus.exe IN the debugger.