Thread overview
Can't seem to debug D apps on Mac OS Mojave
June 08
Hi,

I'm trying out using LLDB with both the shipped version on Mac OS Mojave (lldb-1001.0.13.3), and also the one provided by Homebrew (lldb version 8.0.0), however I have issues:

I can't seem to print out any variables. It works for C++ apps built with -g, but not for D apps, e.g.:

Code:

-----
~/dev/d master * $ cat test.d
module test;
void main ( )
{
    int x = 1;

    int y = 2;

    int z = x + y;
}

$ /dev/d master * $ dmd --version
DMD64 D Compiler v2.086.0

$ dmd -g test.d -oftest
-----

With built-in LLDB:

-----
$ ~/dev/d master * $ lldb --version
lldb-1001.0.13.3

$ ~/dev/d master * $ lldb ./test

(lldb) target create "./test"
Current executable set to './test' (x86_64).

(lldb) b test.d : 7
Breakpoint 1: where = test`_Dmain + 24, address = 0x0000000100000e90

(lldb) r
Process 19968 launched: '/Users/andrejmitrovic/dev/d/test' (x86_64)
Process 19968 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100000e90 test`_Dmain at test.d:8
   5
   6   	    int y = 2;
   7
-> 8   	    int z = x + y;
   9   	}
Target 0: (test) stopped.

(lldb) p x
error: use of undeclared identifier 'x'

(lldb) p y
error: use of undeclared identifier 'y'

(lldb) frame variable
(lldb)
-----

With the one provided by homebrew:

-----
$ export PATH="/usr/local/opt/llvm/bin:$PATH"

$ lldb --version
lldb version 8.0.0

~/dev/d master * $ lldb ./test

(lldb) target create "./test"
Current executable set to './test' (x86_64).

(lldb) b test.d : 7
Breakpoint 1: where = test`_Dmain + 24, address = 0x0000000100000e90

(lldb) r
Process 20098 launched: '/Users/andrejmitrovic/dev/d/test' (x86_64)
Process 20098 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100000e90 test`_Dmain at test.d:8
   5
   6   	    int y = 2;
   7
-> 8   	    int z = x + y;
   9   	}

(lldb) p x
error: use of undeclared identifier 'x'

(lldb) p y
error: use of undeclared identifier 'y'

(lldb) frame variable
(lldb)
-----

Is there some extra step that's needed to get it working on Mac OS? I'm having the same issue trying to use GDB (after going through all the certificate stuff..)
June 08
On Saturday, 8 June 2019 at 10:15:23 UTC, Andrej Mitrovic wrote:
> Hi

Also this might not be the best place to post this since it's not that relevant to LDC itself, but maybe someone knows something more here since it's LLVM-related.
June 08
On Saturday, 8 June 2019 at 10:16:31 UTC, Andrej Mitrovic wrote:
> On Saturday, 8 June 2019 at 10:15:23 UTC, Andrej Mitrovic wrote:
>> Hi
>
> Also this might not be the best place to post this since it's not that relevant to LDC itself, but maybe someone knows something more here since it's LLVM-related.

I'll repost it to D.learn later unless someone posts a working solution. :)
June 08
On Saturday, 8 June 2019 at 10:15:23 UTC, Andrej Mitrovic wrote:
> Hi,

Sorry guys, it looks like using LLDB with a binary built with LDC works fine. It's trying to use it with a dmd-built binary that it fails. So I'll post about that somewhere else.


June 09
On 2019-06-08 12:28, Andrej Mitrovic wrote:
> On Saturday, 8 June 2019 at 10:15:23 UTC, Andrej Mitrovic wrote:
>> Hi,
> 
> Sorry guys, it looks like using LLDB with a binary built with LDC works fine. It's trying to use it with a dmd-built binary that it fails. So I'll post about that somewhere else.

https://issues.dlang.org/show_bug.cgi?id=18527

-- 
/Jacob Carlborg