[lldb-dev] Type information (methods, parameters etc.)

Greg Clayton gclayton at apple.com
Mon May 7 10:48:19 PDT 2012


Yes it does. First create a debugger, then a target, then grab the types:


using namespace lldb;

int
main (int argc, char const *argv[])
{
    SBDebugger::Initialize();
    SBDebugger debugger (SBDebugger::Create());
    
    if (debugger.IsValid())
    {
        // Create a target using the executable.
        SBTarget target (debugger.CreateTargetWithFileAndArch (exe_file_path, "x86_64-apple-macosx"));
        if (target.IsValid())
        {
            SBTypeList type_list (target.FindTypes("MyClass"));
            const uint32_t num_matches = type_list.GetSize();
            for (uint32_t i=0; i<num_matches; ++i)
            {
                SBType type (type_list.GetTypeAtIndex(i));
                //....
            }
        }
    }   
    SBDebugger::Terminate();
}


Then at the "...." you can use the SBType interface:

    size_t
    SBType::GetByteSize();

    const char*
    SBType::GetName();
    
    lldb::TypeClass
    SBType::GetTypeClass ();


You can also see your fields, and base classes with:

    uint32_t
    GetNumberOfFields ();
    
    uint32_t
    GetNumberOfDirectBaseClasses ();

    uint32_t
    GetNumberOfVirtualBaseClasses ();
    
    lldb::SBTypeMember
    GetFieldAtIndex (uint32_t idx);
    
    lldb::SBTypeMember
    GetDirectBaseClassAtIndex (uint32_t idx);

    lldb::SBTypeMember
    GetVirtualBaseClassAtIndex (uint32_t idx);

    uint32_t
    GetNumberOfTemplateArguments ();
    
    lldb::SBType
    GetTemplateArgumentType (uint32_t idx);

    lldb::TemplateArgumentKind
    GetTemplateArgumentKind (uint32_t idx);




On May 5, 2012, at 10:25 AM, Magnus Holm wrote:

> Hey folks,
> 
> I'm wondering if LLDB makes type information (class definitions,
> methods, parameters etc.) available in the API. I guess you could just
> parse the supported files using libclang, but LLDB might already be
> doing something similar already?
> 
> // Magnus Holm
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev




More information about the lldb-dev mailing list