Oh, by the way: you must install your code into the IDE.
If you write a normal project and use the package the LazarusIDE is nil. That is normal.
Once you added your package to the IDE, then in that package you can use LazarusIDE.
To debug the code, you must debug the entire IDE.
- Open ide/lazarus.lpi as project.
- If needed compile via tools menu. You must do that every time you made changes to your code. F9 will NOT recompile the IDE
(no need to restart the IDE [1] / you can turn that off under "configure build ide" in Tools menu)
- Run the code in the debugger by using F9
Make a backup of your Lazarus.exe
In case it no longer starts with your code installed.
[1]
Normally building the IDE ends with "linking lazarus.exe"
At least on windows it is possible (though rare), that if the IDE crashed in the debugger, it locks the lazarus.exe. Then it will do "linking lazarus.new.exe".
In that case you still debug the old lazarus, without the latest changes to your code.
You can try to fix this by "run > reset debugger" and rebuild again.
You can check in the install folder if the lazarus.exe is new (look at the date). Also there should be no lazarus.new.exe (but there will be lazarus.old.exe)