Wednesday, April 3, 2013

lldb for llvm-3.1


We had a cross-compiler tool-chain based on llvm-3.0. And we needed a debugger for the target. We chose lldb and we ported it for the target architecture. (Click here for somemore details). We used lldb svn trunk revision '142603'. We were able to integrate this revision of lldb into the llvm-3.0.

Recently the cross-compiler tool-chain has been upgraded to llvm-3.1. Since lldb depends on llvm, the lldb also has to be upgraded to a revision that would get build with llvm-3.1. (Note: The lldb svn trunk revision '142603' that we used with llvm-3.0 cannot be used with llvm-3.1. This is because lldb uses few modules of llvm for some functionalities such as expressions evaluation, disassembling. Hence changes in llvm would be reflected in lldb as it grows).

Till llvm-3.1, there is no sync between a llvm release and the lldb. And hence finding a right svn trunk revision of lldb that would work with llvm-3.1 is a little time-consuming task. The lldb trunk revisions are traversed to find the right revision that would work with llvm-3.1. And I found that lldb svn trunk revision 161210 works with llvm-3.1 after the following tweaks.

Change #1:
File: lldb/include/lldb/Expression/RecordingMemoryManager.h
Line: 284
Incorporated the changes from svn revision-164563 of this file. Added the following code:

    //------------------------------------------------------------------
    /// Passthrough interface stub
    //------------------------------------------------------------------
    virtual void *getPointerToNamedFunction(const std::string &Name,
                                            bool AbortOnFailure = true) {
        return m_default_mm_ap->getPointerToNamedFunction(Name, AbortOnFailure);
    }

Change #2:
File: lldb/lib/Makefile
Line: 60
Incorporated the changes from svn revision-164703 of this file. Removed the following line

      clangIndex.a \ 

Change #3:
File: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Line: 1519
Incorporated changes from svn revision-164563 of this file. Changed the following line

        case DW_TAG_APPLE_Property:
to
        case DW_TAG_APPLE_property:

Change #4:
File: lldb/source/Symbol/ClangASTContext.cpp
Line: 361
Incorporated the changes from svn revision-164563 of this file. Changed the following line

    Opts.NoInline = !Opt;
to
    Opts.NoInlineDefine = !Opt;

After the above mentioned tweaks, the lldb is successfully ported to our target.

No comments: