Recent

Author Topic: Debugging Lazarus in Lazarus  (Read 262 times)

dbannon

  • Hero Member
  • *****
  • Posts: 3297
    • tomboy-ng, a rewrite of the classic Tomboy
Debugging Lazarus in Lazarus
« on: February 18, 2025, 07:08:50 am »
In another post, an Mac Arm user needs help to debug lazarus RC2 startup.

Just the normal log does not show anything interesting so, I assume we need to run Lazarus RC2 under a debugger and fortunately 4.0RC1 is working OK

A long time since I did this, so, better I test it first.

But I am find I am unable to build 4.0RC2 in RC1 on my Linux laptop. The 4.0RC2 tree builds nicely with a make clean bigide. Given the errors I see, I have to assume I am doing it wrong !

Because of the changes around IDEPackager, seems must be RC1 running RC2 ? So I build a clean 4.0RC1 and opened the lazarus.lpi in my 4.0RC2 source tree.

Things I noted -

No compiler set in project, need to set Project->ProjectOptions->CompilerOptions->Compiler
No boxes ticked, need to tick all three. Easy.

Missing Symbols (eg) - KeyAndShiftStateToEditorKeyString seems to have moved to components/ideintf/idecommands.pas so I added that path to -Fu

And a few more. All up I ended adding
Code: Pascal  [Select][+][-]
  1. ./components/ideintf;packages/ideproject;packages/idedebugger;../components/lazcontrols

to the -Fu line. 

But then, I get treefilteredit.pas(469,3) Error: Identifier not found "fAlreadyFiltered"
Code: Pascal  [Select][+][-]
  1. $> grep -niR "fAlreadyFiltered" *
  2. ...
  3. lcl/editbtn.pas:244:    fAlreadyFiltered: Boolean;

So, declared in editbtn.pas ?  I need to add editbtn to the uses line ??  No, I am clearly on the wrong train. Help please !

Davo


Ref :  https://forum.lazarus.freepascal.org/index.php/topic,70214.0/topicseen.html

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10920
  • Debugger - SynEdit - and more
    • wiki
Re: Debugging Lazarus in Lazarus
« Reply #1 on: February 18, 2025, 10:13:42 am »
No compiler set in project, need to set Project->ProjectOptions->CompilerOptions->Compiler
No boxes ticked, need to tick all three. Easy.
That is intentional. (for lazarus.lpi)

The IDE can currently not be build using the normal project build system (not sure why / just from what I have once been told).

To debug the IDE, you build it via:  Tools > Configure Build Lazarus
If you debug a different IDE version, then you build it before hand, from within that version - or via make.

When you press run to debug, and files where changed (I think in packages), you may see those packages being compiled. But they won't be linked into an exe. After all the IDE is not going to be rebuild.



Not sure on the other errors, but likely a consequence of trying to compile from within the project.

dbannon

  • Hero Member
  • *****
  • Posts: 3297
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Debugging Lazarus in Lazarus
« Reply #2 on: February 18, 2025, 11:21:59 am »
Thanks Martin, I guess that all makes sense. I initially had a debug version ready to run (I thought) but IDE wanted to rebuild it. I'll try your approach a bit more carefully.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10920
  • Debugger - SynEdit - and more
    • wiki
Re: Debugging Lazarus in Lazarus
« Reply #3 on: February 18, 2025, 12:06:56 pm »
If you are debugging between 2 Lazarus installations...

I haven't tested if opening the lazarus.lpi from the other install, will also run the lazarus executable from that other installs folder. (It might, but I don't know).

But you always can ensure this by using: Run > Run params
and set the "host application"


The other way is to just do everything in the folder of the install that you want to debug.

Copy the "good" lazarus executable into that folder (but under a new name lazarus_1), then start this, and it will run using the folder that you want to debug. Then you can debug the exe in that folder.



Be aware, if you have a normal install, so the install is in /usr/ and not writeable to you, then your lazarus executable (if you installed package or did rebuild) is not in the install folder, it is somewhere inside the PCP (usually ~/.lazarus) / not sure where exactly).

startlazarus would start this, but you can't use that in the debugger, as the debugger would not follow the launch of the process for lazarus.

So you need to copy that rebuild lazarus, or you need to use "run param"

dbannon

  • Hero Member
  • *****
  • Posts: 3297
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Debugging Lazarus in Lazarus
« Reply #4 on: February 18, 2025, 12:26:41 pm »
We are all good Martin. I cleaned out the RC2 dir, put in a fresh source tree, make clean bigide.

Then started the RC1 ide, pointed to the RC2 lazarus.lpi, project opened, click Run (not Build!).  And the RC1 ide/debugger ran my RC2 binary without problems.

Lets hope Jim, the Mac user (who also has RC1 and RC2 source builds) can do the same and pin point the problem.

Davo

(don't we have a cool built in debugger these days ?)

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018