[lldb-dev] lldb support for D programming language

a a thelastmammoth at gmail.com
Sun Jul 8 05:28:41 PDT 2012

Hi (apologies if this is not the right place to ask)

Is there any plan to support the D programming language in lldb?

gdb already supports it (but only on linux, not OSX), but it would be nice
to have support in lldb.
The D patch for gdb is actually pretty small, just a few minor edits
scattered throughout.

Currently, if I compile a main.d file with dmd (dmd -g main.d), lldb will
not see any variables with fr v.
It works better with ldc2 though: ldc2 -g main.d followed by lldb main does
show variable with frv, however it (obviously) doesn't understand D name

(lldb) fr select 5
frame #5: 0x0000000100000d3f main`_Dmain + 79 at main.d:39
   37   int main(string[]args){
   38   int x=std.conv.to!int(args[1]);
-> 39   return fun1(x);
   40   }

(lldb) fr v
(<anonymous struct>) args = {
  length = 2
  ptr = 0x0000000100200990
(int) x = 11

(lldb) bt
* thread #1: tid = 0x1f03, 0x0000000100000c11 main`cfun1 + 33 at main.d:15,
stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000100000c11 main`cfun1 + 33 at main.d:15
    frame #1: 0x0000000100000c99 main`_D4main4fun4FiZi + 25 at main.d:27
    frame #2: 0x0000000100000c70 main`_D4main4fun3FiZi + 16 at main.d:24
    frame #3: 0x0000000100000c50 main`_D4main4fun2FiZi + 16 at main.d:21
    frame #4: 0x0000000100000c30 main`_D4main4fun1FiZi + 16 at main.d:18
    frame #5: 0x0000000100000d3f main`_Dmain + 79 at main.d:39
    frame #6: 0x000000010004cf0f main`_D2rt6dmain24mainUiPPaZi7runMainMFZv
+ 31 at dmain2.d:530
    frame #7: 0x000000010004ce9a
main`_D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv + 42 at dmain2.d:505
    frame #8: 0x000000010004cf64 main`_D2rt6dmain24mainUiPPaZi6runAllMFZv +
68 at dmain2.d:540
    frame #9: 0x000000010004ce9a
main`_D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv + 42 at dmain2.d:505
    frame #10: 0x000000010004ce06 main`main + 406 at .:550
    frame #11: 0x0000000100000b94 main`start + 52

What needs to be changed to allow for the following (in order of priority):
1) detect language (command-line option? from mangled name signature?)
2) display correctly demangled D symbols (we can use dmd's
std.core.demangle as a library function)
3) write expressions in unmangled form, eg:
      expr (void)_D4main4dispFiZi(100) //currently works
      expr (int) main.disp(100) // desired (or even expr disp(100))

3) D-aware command completion
4) support for printing basic D types: arrays, associative arrays, structs

The mangling seems to be in
lldb/llvm/tools/clang/include/clang/AST/Mangle.h but that's not very
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20120708/54246d02/attachment.html>

More information about the lldb-dev mailing list