Recent

Author Topic: lldb on windows?  (Read 2283 times)

r2r3

  • New member
  • *
  • Posts: 45
lldb on windows?
« on: January 02, 2019, 08:21:25 pm »
Lazarus suppots lldb on Windows? Because i saw binaries for codetyphon..

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5163
    • wiki
Re: lldb on windows?
« Reply #1 on: January 02, 2019, 08:43:25 pm »
Yes it does. (Lazarus 2.0RC and up)

You do need to download a working copy of lldb yourself (from the llvm project, or any source of your trust).
The lldb you use, must support the correct bitness (32/64).

However may I ask which problem you try to solve? What do you try to gain?
The lldb based debugger has less features, than the gdb based one. And probably is no more stable... (I doubt that differs for codetyphon, how long ago did they add it? We developed our lldb supporting code last autumn)
Though of course it may be possible that a very particular bug, is not present in lldb, while it exists in all versions of gdb... / In most cases there is a version of gdb that will do better.

Depending on what you want to achieve, there are more options:
- gdb with fpdebug
- fpDebug
« Last Edit: January 02, 2019, 09:19:27 pm by Martin_fr »

r2r3

  • New member
  • *
  • Posts: 45
Re: lldb on windows?
« Reply #2 on: January 02, 2019, 09:00:42 pm »
Can you explain how to set it up on windows? Would appreciate.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5163
    • wiki
Re: lldb on windows?
« Reply #3 on: January 02, 2019, 09:18:03 pm »
Same as explained here for Mac.

You need at least a current 2.0 RC of Lazarus (or svn trunk or fixes2.0 branch).

In older RC versions you need to install the package (Package menu) LazDebuggerFpLldb

You need lldb.exe (probably install a full llvm)
Do NOT use the snapshots, they do not always contain lldb.
This *should* work (IIRC) http://releases.llvm.org/download.html#7.0.1
Actually I tested with 6.0.1 sofar. But I guess 7.0.1 should be fine too.

In 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 (where ever you saved yours)

If you run into issues please describe which step, and what issue.

---
Edit
- gdb with fpdebug
- fpDebug
- lldb WITHOUT fpdebug (NOT advised)

are all available by installing the correct packages:
LazDebugger....

On Windows FpDebug is really worth a try....

Edit2
Note that our source page also offers "Alternative GDB" in the Windows32 / Windows 64 sections.
So if the default version of gdb does not work well for you, you can try newer versions.
« Last Edit: January 02, 2019, 09:40:29 pm by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5163
    • wiki
Re: lldb on windows?
« Reply #4 on: January 02, 2019, 09:39:52 pm »
Lazarus suppots lldb on Windows? Because i saw binaries for codetyphon..
According to their screenshots, it seems code typhon uses the "without fpdebug" version of lldb-based debugger.

This version is pure lldb. Meaning all watches input and output require c style syntax.

Background:
LLDB does not understand Pascal. So afaik it expects "Objcet->field". And it prints stuff in c-style too.

Lazarus has a debugger that combines lldb with the abilities of fpdebug. So you get all the pascal syntax.

r2r3

  • New member
  • *
  • Posts: 45
Re: lldb on windows?
« Reply #5 on: January 02, 2019, 09:40:41 pm »
Excellent. Will test!

r2r3

  • New member
  • *
  • Posts: 45
Re: lldb on windows?
« Reply #6 on: January 02, 2019, 10:37:07 pm »
Seems to work! Also its much faster than GDB.
However there is some problem with this demo.
It will just debug ASM after first dll call.


Code: Pascal  [Select]
  1. program Project1;
  2.  
  3. {$mode delphi}
  4.  
  5. uses Windows;
  6.  
  7. type
  8.   int = longint;
  9.   bool = boolean;
  10.  
  11.   function printf(const format: pchar): int; cdecl; varargs; external 'msvcrt.dll';
  12.   procedure getch(); external 'msvcrt.dll' name '_getch';
  13.  
  14. begin
  15.   printf('two numbers %d', 3);
  16.   printf('two numbers %d', 3);
  17. end.
         

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5163
    • wiki
Re: lldb on windows?
« Reply #7 on: January 02, 2019, 11:03:14 pm »
Seems to work! Also its much faster than GDB.

Which lldb are you using? with/without fpdebug?

If you want speed, use pure FpDebug (package LazDebuggerFp).
(no cross debug though)

You can also use "gdb with fpdebug" LazDebuggerFpGdbmi.
It's fast on windows, if you compile with
Code: [Select]
-dWithWinMemReader
Quote
However there is some problem with this demo.
It will just debug ASM after first dll call.
You mean inside the dll, or when stepping over the 2nd "printf" in your own unit?

Stepping depends purely on what lldb supports.

Btw: make sure you use "dwarf" (default for 64 bits, but not 32bits)
« Last Edit: January 02, 2019, 11:07:55 pm by Martin_fr »

r2r3

  • New member
  • *
  • Posts: 45
Re: lldb on windows?
« Reply #8 on: January 02, 2019, 11:34:10 pm »
Yes instead of going over the function it just starts debuging ASM on both x64 and x86..
I use fpdebug LLDB..

Seems to happen only with dll's !
« Last Edit: January 02, 2019, 11:37:24 pm by r2r3 »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5163
    • wiki
Re: lldb on windows?
« Reply #9 on: January 02, 2019, 11:47:39 pm »
Yes instead of going over the function it just starts debuging ASM on both x64 and x86..
I use fpdebug LLDB..

Seems to happen only with dll's !

Can you try getting a log? (edit the windows shortcut to lazarus)
Code: [Select]
lazarus.exe --debug-log=C:\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
 

There is a (un)known issue with current fpc (3.0.4, afaik 3.2 fixes and afaik trunk) where both gdb and lldb appear to sometimes do weird stepping.
IIRC this was not present in earlier fpc (not sure about 3.0.2).
https://bugs.freepascal.org/view.php?id=34159

r2r3

  • New member
  • *
  • Posts: 45
Re: lldb on windows?
« Reply #10 on: January 02, 2019, 11:54:13 pm »
Is it possible to speed up GDB on Windows?
--disable-nls seems to help a bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5163
    • wiki
Re: lldb on windows?
« Reply #11 on: January 03, 2019, 12:37:55 am »
Depends on which part you want to speed up?

Start up?
- A tiny bit by "DisableLoadSymbolsForLibraries"
- Make sure "reset debugger after each run" is NOT checked

Evaluation of watches?
- Set all Memory limits to the same value
- Ensure any package you do not debug, is compiled without debug info
=> Use gdb with fpdebug, and compile the IDE with  -dWithWinMemReader

Stepping?
- Not really (Note you can continue stepping before watches are done).


You can use the power off button in most debug windows, to prevent them from updating.
If you also "power off" the debug history window, then the IDE will not ask gdb for any data it does not need.
This may in some case improve stepping.
If you continue stepping, the IDE will stop asking gdb for locals/watches etc. But it still has to wait for the one that is already requested from gdb.
If you power off the windows, and the IDE does not request anything, then there is not even the wait for the current requested....
But in most cases this will be hardly noticeable.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5163
    • wiki
Re: lldb on windows?
« Reply #12 on: January 03, 2019, 12:39:56 am »
Did you try pure FpDebug? This is the fastest you can get!

r2r3

  • New member
  • *
  • Posts: 45
Re: lldb on windows?
« Reply #13 on: January 03, 2019, 10:21:15 am »
fpDebug seems to crash for me.

LLDB seems to work fine it just doesn't skip over dll calls.. and goes directly in to ASM.
« Last Edit: January 03, 2019, 10:24:46 am by r2r3 »

Igor Kokarev

  • Jr. Member
  • **
  • Posts: 75
Re: lldb on windows?
« Reply #14 on: January 03, 2019, 01:26:14 pm »
Seems to work! Also its much faster than GDB.

I noticed that GDB in 64-bit Lazarus works much FASTER than GDB in 32-bit Lazarus. My app is also works faster and more responsive. The difference is very big. So now I debug all my projects only in 64-bit Lazarus.