[lldb-dev] LLDB fails to load C++ Plugin (sharedlib) - error: this file does not represent a loadable dylib

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Fri Jun 8 09:29:59 PDT 2018

Comments inlined below.

> On Jun 8, 2018, at 2:52 AM, Bewoayia Kebianyor via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> Hello Everyone,
> I started looking into the LLDB with the intention of adding custom commands for my SW debugging purpose. For a better Understanding let me explain what I intend to do. I have an source file generated automatically from a Model with certain anotations added as comments in the code. This code will would be compiled and in error cases debugged. When debugging I may have to set breakpoints at certain statements in the code based on the anotations incerted by the code generator. This is done by specifying the source file and the line number. I Use CLANG to get the line number and source file for the comments. 

Did you know we have the ability to set breakpoints using source regular expression?

(lldb) breakpoint set --source-pattern-regexp "// breakpoint [0-9]+" --file /path/to/foo.cpp

This will use a regular expression to search the source file for the regular expression you specify and have one breakpoint that has multiple locations.

> I would like to have custom commands for this and internally map the to already existing commands  e.g. "breakpoint set -f -l". I found some examples for python, and for c++ I only found the example "lldb/examples/plugins/commands/fooplugin.cpp" for writing C++ plugin (dynLib) shipped with the LLDB source. In this example adding a new commands was straight forward and in the DoExecute function, I call the interpreter to handle a breakpoint command. I intend to use C++ rather than Python.

Do you even need this custom command given what I said above?
> This works fine for a simple shared lib (Simple modification of the Example provided in LLDB. In Do execute call interpreter to handle a breakpoint command). However if I add other C++ sources which does XML parsing, CLANG RecursiveASTVisitor etc to the Library, creating the shared library with eclipse is sucessful. I can link the created library to an application and it works well. However when I load this in lldb with the command ==> plugin load  "/home/bkebianyor/eclipse-workspace/Model_LLDB_Debugger/Debug/libModel_LLDB_Debugger.so", I get the error message: "error: this file does not represent a loadable dylib".
> #Loading the shared lib that is linked just to the liblldb.so - SUCESSFUL
> (lldb) 
> (lldb) plugin load  /home/bkebianyor/eclipse-workspace/DynLib/Debug/libDynLib.so
> (lldb)
> #Loading the shared lib that is linked just to the liblldb.so + libxerces-c-3.2.so - FAILS
> (lldb) plugin load  "/home/bkebianyor/eclipse-workspace/Model_LLDB_Debugger/Debug/libModel_LLDB_Debugger.so"
> error: this file does not represent a loadable dylib
> I have searched for this error on google, but could not find out how to resolve this error. Most answers pointed to a mismatch of the lldb version in the shared lib to be loaded and that linked to lldb, but that is not my case. I am using lldb-5.0.2 and LLVM/CLANG 5.0.2 toolcahin on Linux 16.04.1-Ubuntu and Eclipse IDE. LLVM was built with SHARED_LIBS set to ON.

I am guessing that maybe your libModel_LLDB_Debugger.so shared library can't find all the dependencies it requires when being loaded. Try making a small a.out file that links against this library and try to run your a.out program. See if you see any errors when the a.out tries to launch.


> Would be grateful for an answer.
> Thanks and Regards,
> Bewoayia

> ------------- 
> Dipl.- Ing. Bewoayia Kebianyor
> Researcher - Hardware/Software Design Methodology Group
> OFFIS e.V. - Institut für Informatik
> FuE Bereich Verkehr | R&D Division Transportation
> Escherweg 2 - 26121 Oldenburg - Germany
> Phone/Fax.: +49 441 9722 237/-278
> E-Mail: bewoayia.kebianyor at offis.de
> URL: http://www.offis.de <http://www.offis.de/>
> Registergericht: Amtsgericht Oldenburg VR 1956
> Vorstand: Prof. Dr.-Ing. Wolfgang H. Nebel (Vorsitzender), Prof. Dr. techn. Susanne Boll-Westermann, Prof. Dr. Werner Damm, Prof. Dr.-Ing. Axel Hahn, Prof. Dr.-Ing. Andreas Hein, Prof. Dr. Sebastian Lehnhoff
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20180608/7efda26f/attachment.html>

More information about the lldb-dev mailing list