[lldb-dev] enumerating the SBTypes from an SBModule

Greg Clayton gclayton at apple.com
Mon Jun 17 11:16:49 PDT 2013


Types are parsed lazily in modules so you will only get what types have been parsed up to the time you make the function call. My issue with trying to enumerate types in a module are:
1 - it isn't always easy to ask a large DWARF object "get me the number of unique types you contain". Often DWARF has duplicate type info that we realize can be coalesced when we parse a type.
2 - it is hard to force each symbol file parser to support "get type at index"

The best we can probably do is to add a

SBTypeList
SBModule::GetAllTypes()

Then lldb_private::SymbolVendor and lldb_private::SymboFile would need to have a new virtual functions added to them:


virtual size_t
lldb_private::SymbolVendor::GetAllTypes(lldb_private::TypeList &type_list);

virtual size_t
lldb_private::SymboFile::GetAllTypes(lldb_private::TypeList &type_list);


Then each symbol file parser would be responsible for parsing all types and returning a uniqued type list.

As for the performance issue you solved with your std::vector, I would change this patch to do the following:

1 - modify lldb_private::TypeListImpl to have a new Append function that takes a "const lldb_private::TypeList &type_list". You then might need to add a function to lldb_private::TypeList like:

void
lldb_private::TypeList (std::function <bool(lldb::TypeSP &type_sp)> const &callback);

We use this trick in the "BreakpointSiteList::ForEach" to provide an efficient way to iterate over a collection. An example of using a lambda function to iterate over the breakpoint site list can be seen in Process::DisableAllBreakpointSites(). The bool return value for the callback function indicates whether to continue iterating over the list.

The trickiest part of this will be the SymbolFileDWARF::GetAllTypes(). If you need help with this let me know.

Greg Clayton


On Jun 17, 2013, at 6:56 AM, Sebastien Metrot <meeloo at gmail.com> wrote:

> I have investigated a bit and added a hack to SBModule::FindTypes(..) to get all the types when the requested type name is null. (I have also changed lldb_private::TypeList in order to fetch all its contents in a std::vector in one go instead of calling GetTypeAtIndex which is way to slow when the list grows big).
> 
> I works in a strange way: the first time I call it I only get about 10 types, but each time I request the list the number of type gets bigger (much bigger, after about 10 call I reach a maximum of ~64K types). My guess is that it's due to lazy evaluation/parsing. I tried to understand the type parsing code but it's fairly complex and I don't really want to break anything with my little experiments.
> 
> I have attached a patch showing the changes I did.
> 
> I would welcome any help, thanks in advance,
> 
> S.
> 
> <GetAllTypes.diff>
> -- 
> Sebastien Metrot
> 
> 
> On Jun 17, 2013, at 12:32 , Sebastien Metrot <meeloo at gmail.com> wrote:
> 
>> Hi,
>> 
>> Is there a way to enumerate all the SBTypes that are defined inside an SBModule? I see that lldb_private::Module has a method TypeList* GetTypeList(); but it is not exposed by the official API. Is there a workaround or did I miss something? (I have tried using SBModule::FindTypes with "*", "" or NULL but it doesn't work that way apparently as it strictly searches for an explicit type name).
>> 
>> Cheers,
>> 
>> S.
>> 
>> -- 
>> Sebastien Metrot
>> 
>> _______________________________________________
>> lldb-dev mailing list
>> lldb-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
> 
> _______________________________________________
> 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