Recent

Author Topic: New debugger for Mac based on lldb (Call for testers)  (Read 9026 times)

baldzhang

  • New member
  • *
  • Posts: 24
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #15 on: November 02, 2018, 02:40:00 pm »
testing passed.

macos: 10.13.6
lazarus: trunk
fpc: 3.0.4
widgets: cocoa

will this merge to 2.0 ?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4949
    • wiki
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #16 on: November 02, 2018, 03:34:19 pm »
This is already present in the 2.0 branch. So yes, it will be part of 2.0

RayoGlauco

  • Jr. Member
  • **
  • Posts: 84
  • Beers: 1567
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #17 on: November 03, 2018, 12:26:01 pm »
I am using High Sierra on VirtualBox and Windows 10.
LLDB works well, and setup is easy in Lazarus.
Maybe a bit slow, but it's VirtualBox and my computer is not quite fast.
To err is human, but to really mess things up, you need a computer.

Akira1364

  • Sr. Member
  • ****
  • Posts: 382
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #18 on: November 03, 2018, 07:30:36 pm »
I've mentioned this before, but it's worth noting that this debugger does also work fine (and quite well) on Windows (and should technically work on any platform that can run LLDB, which is all desktop platforms for the most part.)
« Last Edit: November 03, 2018, 08:17:06 pm by Akira1364 »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4949
    • wiki
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #19 on: November 03, 2018, 09:19:35 pm »
On Windows you should get a much better experience with the gdb based debugger. Or if you want: fpdebug (which is used if the FpLldb debugger). If you want fpdebug (on win/linux) you can choose between pure fpdebug, or gdb+fpdebug.

Akira1364

  • Sr. Member
  • ****
  • Posts: 382
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #20 on: November 05, 2018, 12:54:45 am »
On Windows you should get a much better experience with the gdb based debugger. Or if you want: fpdebug (which is used if the FpLldb debugger). If you want fpdebug (on win/linux) you can choose between pure fpdebug, or gdb+fpdebug.

I'm aware the GDB debugger is currently more feature-complete in Lazarus. I just meant that LLDB is not in any way only a "Mac" thing, and that generally speaking it's a better debugger than GDB (as all LLVM/Clang tools are compared to their GNU equivalents.)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4949
    • wiki
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #21 on: November 05, 2018, 10:27:54 am »
I'm aware the GDB debugger is currently more feature-complete in Lazarus. I just meant that LLDB is not in any way only a "Mac" thing, and that generally speaking it's a better debugger than GDB (as all LLVM/Clang tools are compared to their GNU equivalents.)
That comparison is currently hard to make...
First of all, lldb (6.0.1 on win) still prints a lot of warnings about dwarf tags that it does not know (If you watch variables without fpdebug). That may depend on the exact version of lldb, and for different OS, it is not always easy to get the latest version. (On fedora the only version I could get (6.0.1) crashed in my tests)

Also (and that may just be me), I could not get the "MI" interface to run on windows. That made lldb much harder to use, because there is no common way to detect when the output of a command finished. (The prompt is not printed in time, if using a pipe).

Further LLDB (unlike GDB) only understands c-based syntax. GDB has a (very) limited pascal understanding.
This means to get a pointer deref in lldb you have to write "*foo".
The reason you can do Pascal style in the IDE is that there is "lldb (with fpdebug)": fpdebug is a separate debugger, that handles the pascal syntax. It has its own dwarf reader, and uses lldb, to dump raw memory (watch the console, or "ide internals > debug output)

For many other things I dont have a comparison. And also I did not spent that much time on lldb, to really judge it. So I cant fully compare the two.

Igor Kokarev

  • Jr. Member
  • **
  • Posts: 50
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #22 on: November 13, 2018, 10:47:20 am »
Thanks for the new lldb debugger! It works fine in macOS High Sierra.

I only noticed that starting of an app with LLDB debugger takes more time (4-6 seconds longer).

Also lldb can't show values for WideString variables.

One problem. I can't install lazdebuggerfplldb on macOS Mojave 10.14. Please include pre-built lldb debuger for Lazarus 2.0 RC2.

Because I can't compile any carbon or 32-bit app on macOS Mojave 10.14 in Lazarus, I get linking error. Only 64-bit / cocoa apps can be compiled and works fine.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4949
    • wiki
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #23 on: November 13, 2018, 12:55:00 pm »
I only noticed that starting of an app with LLDB debugger takes more time (4-6 seconds longer).
Sorry about the slow down There is probably not much that can be done right now.
You can try the package LazDebuggerLLdb (without the FP). But that is pure lldb, no support for pascal style. All watches need to be specified in c syntax (*form1 or form1->FFooBar), and everything displays in c syntax. If that is slow too, then it is lldb itself (and nothing can be done at all, but hoping that lldb improves).
Also this may not support all datatypes. Or it may support more. Its not tested for that. (hence Alpha / also its more a proof of concept, so it will not get much fixes in that area)

Quote
Also lldb can't show values for WideString variables.
For LazDebuggerFpLLdb, (the "with fpdebug")  version, I added a workaround for widestring. They *should* work in the next version. WideChar is still broken (including SomeWideString[n]). Will have to see if it can be fixed in time.

Quote
One problem. I can't install lazdebuggerfplldb on macOS Mojave 10.14. Please include pre-built lldb debuger for Lazarus 2.0 RC2.
Because I can't compile any carbon or 32-bit app on macOS Mojave 10.14 in Lazarus, I get linking error. Only 64-bit / cocoa apps can be compiled and works fine.

Already committed for RC3, the IDE will have lazdebuggerfplldb pre-installed. (Only lazdebuggerfplldb, only the one with fpdebug).

EDIT:
widechar should also work

EDIT:
Quote
Also lldb can't show values for WideString variables.
Just for info/background: That is actually fpdebug. (Not tested if lldb itself can). The IDE bypasses lldb for all work on pascal related data. lldb just provides the memory dump (raw bytes)
But that is internal info...
« Last Edit: November 13, 2018, 01:22:19 pm by Martin_fr »

Igor Kokarev

  • Jr. Member
  • **
  • Posts: 50
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #24 on: November 13, 2018, 02:41:21 pm »
Martin,

Many thanks for your quick reply and for all your efforts to improve LLDB debugger in Lazarus! I will try RC3 version once it ready.

kcandrews

  • New member
  • *
  • Posts: 5
Re: New debugger for Mac based on lldb - "ignore exceptions" ineffective
« Reply #25 on: November 27, 2018, 06:39:59 pm »
Quick test with High Sierra OSX 10.13.6, Lazarus 2.0.0RC2, FPC 3.04, i386-darwin-carbon:  I don't yet have time to come up with test projects to prove this (in a simple way), but my big project consistently had troubles when debugging with lldb (fplldb) -- always stopping on every raised exception -- even when the exceptions were set to be ignored.  This made debugging totally impractical (and requires sticking with gdb for now).  I also had regular crashes when viewing objects/variables during debug breakpoints.  Do know that really I greatly appreciate the effort being made to move away from gdb on the mac since it is so messy to fool with codesigning, crsutil non-standard settings, etc.
« Last Edit: November 27, 2018, 06:45:37 pm by kcandrews »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4949
    • wiki
Re: New debugger for Mac based on lldb - "ignore exceptions" ineffective
« Reply #26 on: November 27, 2018, 07:49:37 pm »
always stopping on every raised exception -- even when the exceptions were set to be ignored.

Thanks for pointing out. That was a simple oversight when putting the new debugger together. The code for this is identical with what all other debuggers do.
I fixed this, and it will be in RC3.

Also fixed incorrect classnames for exceptions (the 2 digits at the start).
And fixed a mem leak.

Quote
I also had regular crashes when viewing objects/variables during debug breakpoints. 
Crashes in the IDE, or crashes of lldb itself (is lldb still in the task list?)

If it is not to much trouble, run the logfile
Code: Pascal  [Select]
  1.     /path/to/lazarus/lazarus.app/Contents/MacOS/lazarus --debug-log=/path/to/yourfiles/laz.log --debug-enable=DBG_CMD_ECHO,DBG_STATE,DBG_DATA_MONITORS,DBGMI_QUEUE_DEBUG,FPDBG_DWARF_ERRORS,FPDBG_DWARF_WARNINGS,FPDBG_DWARF_VERBOSE_LOAD,FPDBG_DWARF_DATA_WARNINGS,DBG_VERBOSE,DBG_WARNINGS,DBG_STATE,DBG_EVENTS,DBG_THREAD_AND_FRAME

You can do that always, but then I suggest to start the IDE from a script, that will first delete the old log. Or it will grow really big).
Then when the crash happens, attach or send the file.
(If you did inspect watches with sensitive data, or do not whish to reveal library names, or procedure names, that may be part of debugging, you can edit the file. You can also sent it in private)

There also already are various fixes (including some crashes) that will be in RC3. (fixes made after RC2)

Quote
Do know that really I greatly appreciate the effort being made to move away from gdb on the mac since it is so messy to fool with codesigning, crsutil non-standard settings, etc.
Thanks.

kcandrews

  • New member
  • *
  • Posts: 5
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #27 on: November 28, 2018, 02:44:12 am »
Martin,
Thanks so much for your response!  Great to know these things are already addressed.
I'll plan to do this again with logfile output sometime in the next few days and send it along!  I know how important getting the specifics on bugs can be (long time software architect/consultant/programmer, now retired mostly).
Keith

VTwin

  • Hero Member
  • *****
  • Posts: 504
  • Former Turbo Pascal 3 user
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #28 on: November 28, 2018, 03:50:34 pm »
Martin,

Thanks, this is fantastic news! I just set up lldb with the latest Cocoa trunk. Installation went smoothly following your directions. So far so good, I'll try to run it through all of my projects and report back any issues.

Cheers,
VTwin
“Talk is cheap. Show me the code.” Linus Torvalds

Lazarus 2.1 svn trunk 59794: macOS 10.11.6 (64 bit Cocoa)
Lazarus 1.8.4: Win 7 (64 bit) & Ubuntu 16.04.3 (64 bit) on VBox

Trenatos

  • Sr. Member
  • ****
  • Posts: 454
  • Software developer - Open source contributor
    • MarcusFernstrom.com
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #29 on: November 28, 2018, 05:10:10 pm »
Fantastic news, much appreciated!

Will give lldb a go very soon, would be nice to have a debugger working on my Mac!