[Lldb-commits] [PATCH] D44321: Support demangling for D symbols via dlopen

Johan Engelen via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sun Mar 11 05:20:17 PDT 2018


johanengelen added a comment.

In https://reviews.llvm.org/D44321#1034141, @timotheecour wrote:

> > It's a little more complicated for D because it's an out-of-tree compiler so it poses interesting challenges.
>
> the demangling itself is thoroughly tested in https://github.com/dlang/druntime/blob/master/src/core/demangle.d


It's not the correct demangling of strings that needs to be tested. What needs testing:

- recognising D language and D mangled name
- loading of dynamic lib (plus testing that when loading fails lldb doesn't crash/exit; note: errmsg can be improved to e.g. "Failed to load D language plugin...")
- test that indeed the demangling function of the dyn lib is called

To test this, I think you can make a mock dynamic lib that implements the required interface, but in C++. The mock demangler could be something like this or even simpler:

  extern "C" char* lldbd_demangle(size_t length, const char* mangled) {
     if (mangled == "_D3fooFZv") // pseudo code
         return "void foo()";
     else
         return mangled;
  }

Then build that library in the test, and test loading and use on a fabricated piece of code (probably easiest to use C code with this in it: `extern "C" _D3fooFZv() { trap(); }`.


https://reviews.llvm.org/D44321





More information about the lldb-commits mailing list