[lldb-dev] enumerating the SBTypes from an SBModule

Sebastien Metrot meeloo at gmail.com
Tue Jun 18 16:54:17 PDT 2013


Excellent! This is exactly what I needed and the addition of the class mask fits my needs perfectly!

Thanks so much Greg!

S.

On Jun 19, 2013, at 00:55 , Greg Clayton <gclayton at apple.com> wrote:

> I added the ability to get a list of types from a SBModule or SBCompileUnit. 
> 
> % svn commit
> Sending        include/lldb/API/SBCompileUnit.h
> Sending        include/lldb/API/SBModule.h
> Sending        include/lldb/API/SBType.h
> Sending        include/lldb/Core/MappedHash.h
> Sending        include/lldb/Core/UniqueCStringMap.h
> Sending        include/lldb/Symbol/SymbolFile.h
> Sending        include/lldb/Symbol/SymbolVendor.h
> Sending        include/lldb/Symbol/Type.h
> Sending        include/lldb/Symbol/TypeList.h
> Sending        include/lldb/lldb-enumerations.h
> Sending        scripts/Python/interface/SBCompileUnit.i
> Sending        scripts/Python/interface/SBModule.i
> Sending        source/API/SBCompileUnit.cpp
> Sending        source/API/SBModule.cpp
> Sending        source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
> Sending        source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
> Sending        source/Plugins/SymbolFile/DWARF/NameToDIE.h
> Sending        source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
> Sending        source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
> Sending        source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
> Sending        source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
> Sending        source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
> Sending        source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
> Sending        source/Symbol/SymbolVendor.cpp
> Sending        source/Symbol/Type.cpp
> Sending        source/Symbol/TypeList.cpp
> Transmitting file data ..........................
> Committed revision 184251.
> 
> 
> The new functions are:
> 
> //------------------------------------------------------------------
> /// Get all types matching \a type_mask from debug info in this
> /// module.
> ///
> /// @param[in] type_mask
> ///     A bitfield that consists of one or more bits logically OR'ed
> ///     together from the lldb::TypeClass enumeration. This allows
> ///     you to request only structure types, or only class, struct
> ///     and union types. Passing in lldb::eTypeClassAny will return
> ///     all types found in the debug information for this module.
> ///
> /// @return
> ///     A list of types in this module that match \a type_mask
> //------------------------------------------------------------------
> lldb::SBTypeList
> SBModule::GetTypes (uint32_t type_mask)
> 
> 
> //------------------------------------------------------------------
> /// Get all types matching \a type_mask from debug info in this
> /// compile unit.
> ///
> /// @param[in] type_mask
> ///    A bitfield that consists of one or more bits logically OR'ed
> ///    together from the lldb::TypeClass enumeration. This allows
> ///    you to request only structure types, or only class, struct
> ///    and union types. Passing in lldb::eTypeClassAny will return
> ///    all types found in the debug information for this compile
> ///    unit.
> ///
> /// @return
> ///    A list of types in this compile unit that match \a type_mask
> //------------------------------------------------------------------
> lldb::SBTypeList
> SBCompileUnit::GetTypes (uint32_t type_mask = lldb::eTypeClassAny);
> 
> This lets you request types by filling out a mask that contains one or more bits from the lldb::TypeClass enumerations, so you can only get the types you really want.
> 
> 
> Now you can do things like:
> 
> (lldb) script
> module = lldb.target.module['a.out']
> types = module.GetTypes()
> for t in types:
>  print t
> 
> Or you can iterate through the compile units and get the types for each individual compile unit:
> 
> (lldb) script
> module = lldb.target.module['a.out']
> for i in range(module.GetNumCompileUnits()):
>  cu = module.GetCompileUnitAtIndex(i)
>  types = cu.GetTypes()
>  for t in types:
>    print t
> 
> 
> 
> On Jun 17, 2013, at 6:21 PM, Sebastien Metrot <meeloo at gmail.com> wrote:
> 
>> Awesome, here is my tentative patch:
>> 
>> <GetAllTypes.diff>
>> 
>> Thanks!
>> 
>> S.
>> 
>> 
>> On Jun 18, 2013, at 03:14 , Greg Clayton <gclayton at apple.com> wrote:
>>> 
>>> Send a patch with this function hollowed out and I will fill it in for you.
>> 
>> _______________________________________________
>> 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