* * *

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

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4886
    • wiki
New debugger for Mac based on lldb (Call for testers)
« on: October 14, 2018, 09:05:00 pm »
With the Lazarus Release Candidate 1 for 2.0 a new debugger for Mac users has been shipped.
It is based on LLDB, which is provided by apple and is ready to use. So there should no longer be a need to build and codesign gdb.

As the LLDB integration is all new, it needs a lot of testing. So this is a ...

call to all Mac users:
Please test the new LLDB based Lazarus debugger.

To test the new debugger, please download the Lazarus 2.0RC1.

- Open the IDE and install the package "LazDebuggerFpLLdb".
  It should be in the list of available packages, but if not it is in components/lazdebuggers/lazdebuggerfplldb
  Make sure to use the one with "Fp" in the name. (There also is LazDebuggerLLdb, but it is not as good.)
  Restart the IDE.

- Go to Tools > Options > Debugger
  In the "debugger type" dropdown, you should find and select "LLDB debugger (with fpdebug)"
  The edit below this (where you normally have the path to gdb), should be changed to the path of lldb.
  (lldb comes with the tools from Apple; and as such it is already codesigned by Apple).


To report any problems:
Start Lazarus from a shell with the following command line (replace pathes according to your installation):

You may need to use startlazarus, or specify the re-build lazarus which may be in your home folder / pcp.

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
  2.  

Attach the log file after reproducing the error.

--------------------
EDIT:
If you have a lot of units with debug info (eg all of LCL with debug info) you may have to increase ulimit.
https://bugs.freepascal.org/view.php?id=34467
« Last Edit: November 11, 2018, 09:59:16 pm by Martin_fr »

dbannon

  • Sr. Member
  • ****
  • Posts: 328
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #1 on: October 15, 2018, 03:10:30 am »
Martin, forgive my ignorance, I am unsure of how gdb / LLdb interact with heaptrc.

Specifically about memory leaks, will using LLdb give me the same sort of info on the Mac I am used to getting on Linux ?

Even if not, this is an astounding step forward. We loose so many potential Mac user who just read through those code signing instructions and shake their heads sadly...

Davo
Lazarus 1.8, Linux (and reluctantly Win10, OSX)

Cyrax

  • Hero Member
  • *****
  • Posts: 615
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #2 on: October 15, 2018, 12:19:58 pm »
GDB/lldb have nothing to do with heaptrc functionality. Heaptrc uses compiler generated debug info to display the lines and their numbers where the leak happened.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4886
    • wiki
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #3 on: October 15, 2018, 01:08:09 pm »
Heaptrc, works without the debugger.

GDB/LLDB is for setting breakpoints, single stepping, inspecting variables.

The LLDB based does not yet have all the features. E.G. "step to cursor" does not yet work. And the disassembler may not always work.

As for properties (with getter function): They can not be watched, same as under gdb.

josh

  • Hero Member
  • *****
  • Posts: 636
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #4 on: October 15, 2018, 02:30:36 pm »
Hi

Had a quick look and did not see a folder for mac osx x86_64 to test? Just OSXi386

Am I missing something?
Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4886
    • wiki
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #5 on: October 15, 2018, 03:25:16 pm »
Had a quick look and did not see a folder for mac osx x86_64 to test? Just OSXi386

Am I missing something?

Not really related to the debugger, you may want to follow this up on the RC announcment. http://forum.lazarus-ide.org/index.php/topic,42868.0.html

Afaik currently only carbon is pre-build. cocoa (64bit) is still alpha/beta.
But I believe (not sure) that the fpc package installs both, 64 and 32 bit. Then you can rebuild the IDE for 64 bit.

The debugger should work for both 64 and 32 bit. (As long as Apple does not remove 32bit support from lldb)

jwdietrich

  • Hero Member
  • *****
  • Posts: 980
    • formatio reticularis
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #6 on: October 18, 2018, 08:35:44 pm »
Sorry, but I can't find the package, see screenshot in the attachment. Did I overlook anything?
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 1.8.4 | FPC 3.0.4 | PPC, Intel, ARM | macOS, Windows, Linux

Cyrax

  • Hero Member
  • *****
  • Posts: 615
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #7 on: October 18, 2018, 08:58:02 pm »
Sorry, but I can't find the package, see screenshot in the attachment. Did I overlook anything?

Are you using the Lazarus Release Candidate 1 for 2.0? I don't think that OPM have it. You need to install it standard/old way (Package->Install/Uninstall Packages), not via OPM.
« Last Edit: October 18, 2018, 09:00:09 pm by Cyrax »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4886
    • wiki
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #8 on: October 18, 2018, 10:16:14 pm »
It is not it OPM.

The installer for 2.0RC1 contains the files, and they will be on your disk.

jwdietrich

  • Hero Member
  • *****
  • Posts: 980
    • formatio reticularis
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #9 on: October 19, 2018, 10:23:48 pm »
Thanks, it woks now.

In Lazarus 2.0RC1 the package is in /Developer/lazarus/components/lazdebuggers/lazdebuggerfplldb/. The path to the debugger can easily be found by typing which lldb in the terminal.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 1.8.4 | FPC 3.0.4 | PPC, Intel, ARM | macOS, Windows, Linux

jwdietrich

  • Hero Member
  • *****
  • Posts: 980
    • formatio reticularis
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #10 on: October 20, 2018, 03:38:30 pm »
My first impressions are:
  • It works quite well
  • Program execution is rather slow, especially at startup.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 1.8.4 | FPC 3.0.4 | PPC, Intel, ARM | macOS, Windows, Linux

ChrisR

  • Jr. Member
  • **
  • Posts: 73
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #11 on: October 22, 2018, 08:23:50 pm »
  • Works for me too
  • A bit of delay at launch and when opening dialogs, but fully useable

I realize that the debugger and heaptrc are separate, but having the combination of a simple-to-install debugger and a heaptrc that provides line numbers would be a terrific advance for Lazarus. Here is a simple project that shows that heaptrc is able to report leaks, but on the Mac you do not get the line numbers seen when run on Linux or Windows:
http://forum.lazarus.freepascal.org/index.php/topic,42755.0.html

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4886
    • wiki
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #12 on: October 28, 2018, 01:06:05 pm »
About HeapTrc
but on the Mac you do not get the line numbers seen when run on Linux or Windows:
If that is the case, and if the settings are correct (e.g the debugger gets line info, but the heaptrc does not), then this is an issue in fpc (and may need reporting there)

HeapTrc is entirely part of fpc.

There are several possible issues though:
1) It may affect dwarf only (or be limited to certain versions of it), or stabs only.
2) It may be broken only for external / none-external debug info.

Additionally the stacktrace dumping code in fpc has a safety feature, that can have "side effects".
If an address in the trace can not be resolved, the code will disable address resolving for all further addresses. This is, in case there was an error, which could lead to the error dumping another trace, ending in endless recursion. But this also happens, if there just is no data for that one address. (At least that is what it used to be, may have changed).

So if your top address, is not resolvable....
You can try (not tested myself on Mac), to load/paste the trace into the IDE's "Leaks and traces", then click resolve. In the following open dialog, select the application executable.

dbannon

  • Sr. Member
  • ****
  • Posts: 328
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #13 on: October 28, 2018, 11:28:30 pm »
Said Martin_Fr :
Quote
About HeapTrc
Quote from: ChrisR on October 23, 2018, 04:23:50 am

    but on the Mac you do not get the line numbers seen when run on Linux or Windows:

If that is the case, and if the settings are correct (e.g the debugger gets line info, but the heaptrc does not), then this is an issue in fpc (and may need reporting there)

Has been reported -
https://bugs.freepascal.org/view.php?id=32775

The mytest.pas demo pasted there is just fpc, no lazarus component. On Linux shows a line number, actually the number of the line where  BadProcedure() is called from rather than the new() statement but thats still enough to track leaks down. On mac, no line number or unit name.
Lazarus 1.8, Linux (and reluctantly Win10, OSX)

ChrisR

  • Jr. Member
  • **
  • Posts: 73
Re: New debugger for Mac based on lldb (Call for testers)
« Reply #14 on: October 29, 2018, 03:18:53 am »
@dbannon Thanks for issue 32775, a very elegant bug report, as you note, shows this is a fpc issue, not Lazarus. Thanks.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus