[lldb-dev] Search C++ "virtual" objects

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Wed Aug 17 16:31:39 PDT 2016


You should add it to both SBModule and SBTarget.

To add new APIs you need to:

- add function prototype to include/lldb/API/SBModule.h and include/lldb/API/SBTarget.h
- add function body to source/API/SBModule.cpp and source/API/SBTarget.cpp
- add function prototype to Swig interface files scripts/interface/SBModule.i and scripts/interface/SBTarget.h
- add test that tests both new interfaces in the "packages/Python/lldbsuite/test/python_api" directory by creating a new directory named something appropriate. You can start by copying the "event" directory in there to "symbol_regex" and then rename the test python file to SymbolRegex.py. And add a test the compiles a C++ file with a few virtual classes and then search use your new APIs and make sure they work as expected.

The function prototypes will be:

    lldb::SBSymbolContextList
    SBModule::FindSymbolsByRegex (const char *regex, lldb::SymbolType type = eSymbolTypeAny);

And

    lldb::SBSymbolContextList
    SBTarget::FindSymbolsByRegex (const char *regex, lldb::SymbolType type = eSymbolTypeAny);

The module version will search the module in the SBModule object only, and the SBTarget version will use the module list found in the target object.

Greg


> On Aug 17, 2016, at 12:24 AM, Lei Kong <leikong at msn.com> wrote:
> 
> I’d like to add FindSymbolsByRegex, please let me know what I need to do.
> Thanks.
>  
> Sent from Mail for Windows 10
>  
> From: Greg Clayton
> Sent: Tuesday, August 16, 2016 11:42 AM
> To: Lei Kong
> Cc: Lei Kong via lldb-dev
> Subject: Re: [lldb-dev] Search C++ "virtual" objects
>  
> 
> > On Aug 15, 2016, at 4:59 PM, Lei Kong <leikong at msn.com> wrote:
> > 
> > Should I use lldb::SBTarget::GetModuleAtIndex() to get all modules and then lldb::SBModule::GetSymbolAtIndex() to go through all symbols?
> > Thanks.
> 
> This is the only way right now as we don't have a SBModule::FindSymbols that takes a regular expression. We only currently have:
> 
>     lldb::SBSymbolContextList
>     FindSymbols (const char *name,
>                  lldb::SymbolType type = eSymbolTypeAny);
> 
> 
> If you want to, you can add a:
> 
> 
>     lldb::SBSymbolContextList
>     FindSymbolsByRegex (const char *regex, lldb::SymbolType type = eSymbolTypeAny);
> 
> 
> Then you could call this:
> 
> 
> SBModule module = ...;
> lldb::SBSymbolContextList symbols = module.FindSymbolsByRegex("^vtable for ");
> 
> 
> You can then also add this to SBTarget. Let me know if you are interested in adding this and I can help you do it.
> 
> Greg Clayton



More information about the lldb-dev mailing list