Recent

Author Topic: Debugging the Lazarus IDE on Mac  (Read 5472 times)

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Debugging the Lazarus IDE on Mac
« on: July 28, 2017, 10:48:54 pm »
Hello, is it possible to single step through the Lazarus IDE source code under Xcode/LLDB. There's a particular CodeTools feature that I want to investigate and I think single stepping with breakpoints is the way to go.

Presumably, I would need to run `makeproj` on one of the Lazarus `lpi` files, but I'm not sure if this can even be done. Any ideas?
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Debugging the Lazarus IDE on Mac
« Reply #1 on: July 28, 2017, 10:55:19 pm »
Hello, is it possible to single step through the Lazarus IDE source code under Xcode/LLDB. There's a particular CodeTools feature that I want to investigate and I think single stepping with breakpoints is the way to go.

Presumably, I would need to run `makeproj` on one of the Lazarus `lpi` files, but I'm not sure if this can even be done. Any ideas?

You could just debug from the command line:

lldb lazarus.app

I think when I tried bringing it into Xcode, there was an issue or two, but I don't recall what. You'll probably have to change the path to the Info.plist file since lazarus.app is one level up from lazarus.lpi, which is not the way project that Laz creates is normally set up.

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Re: Debugging the Lazarus IDE on Mac
« Reply #2 on: July 28, 2017, 11:11:16 pm »
Presumably, I would need to go to `Tools -> Configure "Build Lazarus"` and select the `Debug` option. If so, would I need to set any other options, and can I do it in such a way as to avoid affecting my existing Lazarus build?
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Re: Debugging the Lazarus IDE on Mac
« Reply #3 on: July 28, 2017, 11:55:11 pm »
I tried doing this and chose another folder for the newly compiled debug version of Lazarus. I then open it with LLDB but when I tried to set a breakpoint, it broke in a completely different part of the source code. I decided to beat a hasty retreat at this stage and recompiled a normal version of my IDE again.
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4468
  • I like bugs.
Re: Debugging the Lazarus IDE on Mac
« Reply #4 on: July 29, 2017, 12:28:10 pm »
Presumably, I would need to go to `Tools -> Configure "Build Lazarus"` and select the `Debug` option. If so, would I need to set any other options, and can I do it in such a way as to avoid affecting my existing Lazarus build?
I don't know about Mac but on Linux the debugging of Lazarus using another instance of Lazarus works well. Console gdb works, too.
Don't choose another folder. Just build the Debug IDE into the same directory. You can copy backup binaries as much as needed in the same or into another folder. A backup binary is recommended anyway in case you modify the IDE's code so it crashes. Then just start the other binary and continue.
To debug with another instance of Lazarus, open project "lazarus.lpi" and press F9.
"lazarus.lpi" cannot be used for building the IDE because it not yet a "normal" project, but it is good for debugging.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Re: Debugging the Lazarus IDE on Mac
« Reply #5 on: July 29, 2017, 02:54:05 pm »
Presumably, I would need to go to `Tools -> Configure "Build Lazarus"` and select the `Debug` option. If so, would I need to set any other options, and can I do it in such a way as to avoid affecting my existing Lazarus build?
I don't know about Mac but on Linux the debugging of Lazarus using another instance of Lazarus works well. Console gdb works, too.
Don't choose another folder. Just build the Debug IDE into the same directory. You can copy backup binaries as much as needed in the same or into another folder. A backup binary is recommended anyway in case you modify the IDE's code so it crashes. Then just start the other binary and continue.
To debug with another instance of Lazarus, open project "lazarus.lpi" and press F9.
"lazarus.lpi" cannot be used for building the IDE because it not yet a "normal" project, but it is good for debugging.

Hi, Juha, unfortunately, it's complicated by the fact that on the macOS 10.12 Sierra version of the Mac's OS, GDB doesn't really work very well. Generally, the solution is to use Phil's project for reading the Lazarus project into Xcode and then debug under LLDB there. I tried to do this on the Lazarus files but I only got so far, and I'm just hoping that Phil might be able to shed some light on this problem. The debugging problem on the Mac is a bit of a pain because in all other respects, using Lazarus on the Mac is an absolute joy!
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Re: Debugging the Lazarus IDE on Mac
« Reply #6 on: July 29, 2017, 03:07:13 pm »
Hello again, Juha, you have actually indirectly helped me out. When you spoke about how easy it was to achieve on Linux, I was thinking what a shame that option isn't available to me. Then I realised that of course, it is available to me! I already have Lazarus 1.6.4 installed on a Windows 10 virtual machine under Parallels, and of course, there's nothing to stop me installing Lazarus on one of my Linux VM's.

I guess I had become blinkered thinking about Lazarus on the Mac, and it took a mental prod from you to jolt me out of that. Thanks very much!

Cheers,
Carl
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

 

TinyPortal © 2005-2018