Modernize the rest of the Find.* API (NFC)

This patch removes the size_t return value and the append parameter
from the remainder of the Find.* functions in LLDB's internal API. As
in the previous patches, this is motivated by the fact that these
parameters aren't really used, and in the case of the append parameter
were frequently implemented incorrectly.

Differential Revision: https://reviews.llvm.org/D69119

llvm-svn: 375160
This commit is contained in:
Adrian Prantl 2019-10-17 19:56:40 +00:00
parent e3905dee00
commit 1ad655e255
52 changed files with 482 additions and 705 deletions

View File

@ -246,11 +246,11 @@ public:
ConstString name,
lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
size_t FindSymbolsWithNameAndType(ConstString name,
void FindSymbolsWithNameAndType(ConstString name,
lldb::SymbolType symbol_type,
SymbolContextList &sc_list);
size_t FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
void FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
lldb::SymbolType symbol_type,
SymbolContextList &sc_list);
@ -266,10 +266,7 @@ public:
///
/// \param[out] sc_list
/// A list to append any matching symbol contexts to.
///
/// \return
/// The number of symbol contexts that were added to \a sc_list
size_t FindFunctionSymbols(ConstString name, uint32_t name_type_mask,
void FindFunctionSymbols(ConstString name, uint32_t name_type_mask,
SymbolContextList &sc_list);
/// Find compile units by partial or full path.
@ -280,19 +277,10 @@ public:
/// \param[in] path
/// The name of the function we are looking for.
///
/// \param[in] append
/// If \b true, then append any compile units that were found
/// to \a sc_list. If \b false, then the \a sc_list is cleared
/// and the contents of \a sc_list are replaced.
///
/// \param[out] sc_list
/// A symbol context list that gets filled in with all of the
/// matches.
///
/// \return
/// The number of matches added to \a sc_list.
size_t FindCompileUnits(const FileSpec &path, bool append,
SymbolContextList &sc_list);
void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list);
/// Find functions by name.
///
@ -312,21 +300,13 @@ public:
/// names, base names, C++ methods, or ObjC selectors.
/// See FunctionNameType for more details.
///
/// \param[in] append
/// If \b true, any matches will be appended to \a sc_list, else
/// matches replace the contents of \a sc_list.
///
/// \param[out] sc_list
/// A symbol context list that gets filled in with all of the
/// matches.
///
/// \return
/// The number of matches added to \a sc_list.
size_t FindFunctions(ConstString name,
void FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask, bool symbols_ok,
bool inlines_ok, bool append,
SymbolContextList &sc_list);
bool inlines_ok, SymbolContextList &sc_list);
/// Find functions by name.
///
@ -344,12 +324,8 @@ public:
/// \param[out] sc_list
/// A symbol context list that gets filled in with all of the
/// matches.
///
/// \return
/// The number of matches added to \a sc_list.
size_t FindFunctions(const RegularExpression &regex, bool symbols_ok,
bool inlines_ok, bool append,
SymbolContextList &sc_list);
void FindFunctions(const RegularExpression &regex, bool symbols_ok,
bool inlines_ok, SymbolContextList &sc_list);
/// Find addresses by file/line
///
@ -394,9 +370,7 @@ public:
/// \param[in] variable_list
/// A list of variables that gets the matches appended to.
///
/// \return
/// The number of matches added to \a variable_list.
size_t FindGlobalVariables(ConstString name,
void FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
size_t max_matches, VariableList &variable_list);
@ -412,9 +386,7 @@ public:
/// \param[in] variable_list
/// A list of variables that gets the matches appended to.
///
/// \return
/// The number of matches added to \a variable_list.
size_t FindGlobalVariables(const RegularExpression &regex, size_t max_matches,
void FindGlobalVariables(const RegularExpression &regex, size_t max_matches,
VariableList &variable_list);
/// Find types by name.

View File

@ -247,35 +247,24 @@ public:
/// \param[in] path
/// The name of the compile unit we are looking for.
///
/// \param[in] append
/// If \b true, then append any compile units that were found
/// to \a sc_list. If \b false, then the \a sc_list is cleared
/// and the contents of \a sc_list are replaced.
///
/// \param[out] sc_list
/// A symbol context list that gets filled in with all of the
/// matches.
///
/// \return
/// The number of matches added to \a sc_list.
size_t FindCompileUnits(const FileSpec &path, bool append,
SymbolContextList &sc_list) const;
void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list) const;
/// \see Module::FindFunctions ()
size_t FindFunctions(ConstString name,
lldb::FunctionNameType name_type_mask,
bool include_symbols, bool include_inlines, bool append,
void FindFunctions(ConstString name, lldb::FunctionNameType name_type_mask,
bool include_symbols, bool include_inlines,
SymbolContextList &sc_list) const;
/// \see Module::FindFunctionSymbols ()
size_t FindFunctionSymbols(ConstString name,
void FindFunctionSymbols(ConstString name,
lldb::FunctionNameType name_type_mask,
SymbolContextList &sc_list);
/// \see Module::FindFunctions ()
size_t FindFunctions(const RegularExpression &name, bool include_symbols,
bool include_inlines, bool append,
SymbolContextList &sc_list);
void FindFunctions(const RegularExpression &name, bool include_symbols,
bool include_inlines, SymbolContextList &sc_list);
/// Find global and static variables by name.
///
@ -289,10 +278,7 @@ public:
///
/// \param[in] variable_list
/// A list of variables that gets the matches appended to.
///
/// \return
/// The number of matches added to \a variable_list.
size_t FindGlobalVariables(ConstString name, size_t max_matches,
void FindGlobalVariables(ConstString name, size_t max_matches,
VariableList &variable_list) const;
/// Find global and static variables by regular expression.
@ -306,10 +292,7 @@ public:
///
/// \param[in] variable_list
/// A list of variables that gets the matches appended to.
///
/// \return
/// The number of matches added to \a variable_list.
size_t FindGlobalVariables(const RegularExpression &regex, size_t max_matches,
void FindGlobalVariables(const RegularExpression &regex, size_t max_matches,
VariableList &variable_list) const;
/// Finds the first module whose file specification matches \a file_spec.
@ -337,10 +320,7 @@ public:
/// \param[out] matching_module_list
/// A module list that gets filled in with any modules that
/// match the search criteria.
///
/// \return
/// The number of matching modules found by the search.
size_t FindModules(const ModuleSpec &module_spec,
void FindModules(const ModuleSpec &module_spec,
ModuleList &matching_module_list) const;
lldb::ModuleSP FindModule(const Module *module_ptr) const;
@ -354,15 +334,13 @@ public:
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const;
size_t FindSymbolsWithNameAndType(ConstString name,
void FindSymbolsWithNameAndType(ConstString name,
lldb::SymbolType symbol_type,
SymbolContextList &sc_list,
bool append = false) const;
SymbolContextList &sc_list) const;
size_t FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
void FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
lldb::SymbolType symbol_type,
SymbolContextList &sc_list,
bool append = false) const;
SymbolContextList &sc_list) const;
/// Find types by name.
///
@ -474,6 +452,7 @@ public:
/// \return
/// The number of modules in the module list.
size_t GetSize() const;
bool IsEmpty() const { return !GetSize(); }
bool LoadScriptingResourcesInTarget(Target *target, std::list<Status> &errors,
Stream *feedback_stream = nullptr,
@ -492,7 +471,7 @@ public:
static bool RemoveSharedModule(lldb::ModuleSP &module_sp);
static size_t FindSharedModules(const ModuleSpec &module_spec,
static void FindSharedModules(const ModuleSpec &module_spec,
ModuleList &matching_module_list);
static size_t RemoveOrphanSharedModules(bool mandatory);

View File

@ -380,7 +380,7 @@ public:
return false;
}
size_t FindMatchingModuleSpecs(const ModuleSpec &module_spec,
void FindMatchingModuleSpecs(const ModuleSpec &module_spec,
ModuleSpecList &matching_list) const {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
bool exact_arch_match = true;
@ -400,7 +400,6 @@ public:
matching_list.Append(spec);
}
}
return matching_list.GetSize() - initial_match_count;
}
void Dump(Stream &strm) {

View File

@ -173,21 +173,19 @@ public:
SymbolContextList &sc_list);
virtual void DumpClangAST(Stream &s) {}
virtual uint32_t
virtual void
FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, VariableList &variables);
virtual uint32_t FindGlobalVariables(const RegularExpression &regex,
virtual void FindGlobalVariables(const RegularExpression &regex,
uint32_t max_matches,
VariableList &variables);
virtual uint32_t FindFunctions(ConstString name,
virtual void FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, bool append,
SymbolContextList &sc_list);
virtual uint32_t FindFunctions(const RegularExpression &regex,
bool include_inlines, bool append,
SymbolContextList &sc_list);
bool include_inlines, SymbolContextList &sc_list);
virtual void FindFunctions(const RegularExpression &regex,
bool include_inlines, SymbolContextList &sc_list);
virtual void
FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,

View File

@ -92,15 +92,15 @@ public:
const RegularExpression &regex, lldb::SymbolType symbol_type,
Debug symbol_debug_type, Visibility symbol_visibility,
std::vector<uint32_t> &indexes);
size_t FindAllSymbolsWithNameAndType(ConstString name,
void FindAllSymbolsWithNameAndType(ConstString name,
lldb::SymbolType symbol_type,
std::vector<uint32_t> &symbol_indexes);
size_t FindAllSymbolsWithNameAndType(ConstString name,
void FindAllSymbolsWithNameAndType(ConstString name,
lldb::SymbolType symbol_type,
Debug symbol_debug_type,
Visibility symbol_visibility,
std::vector<uint32_t> &symbol_indexes);
size_t FindAllSymbolsMatchingRexExAndType(
void FindAllSymbolsMatchingRexExAndType(
const RegularExpression &regex, lldb::SymbolType symbol_type,
Debug symbol_debug_type, Visibility symbol_visibility,
std::vector<uint32_t> &symbol_indexes);
@ -112,7 +112,7 @@ public:
Symbol *FindSymbolContainingFileAddress(lldb::addr_t file_addr);
void ForEachSymbolContainingFileAddress(
lldb::addr_t file_addr, std::function<bool(Symbol *)> const &callback);
size_t FindFunctionSymbols(ConstString name, uint32_t name_type_mask,
void FindFunctionSymbols(ConstString name, uint32_t name_type_mask,
SymbolContextList &sc_list);
void CalculateSymbolSizes();

View File

@ -148,13 +148,9 @@ public:
/// The equivalent symbol list - any equivalent symbols found are appended
/// to this list.
///
/// \return
/// Number of equivalent symbols found.
virtual size_t FindEquivalentSymbols(Symbol *original_symbol,
virtual void FindEquivalentSymbols(Symbol *original_symbol,
ModuleList &module_list,
SymbolContextList &equivalent_symbols) {
return 0;
}
SymbolContextList &equivalent_symbols) {}
/// Ask if it is ok to try and load or unload an shared library (image).
///

View File

@ -282,8 +282,7 @@ SBSymbolContextList SBModule::FindCompileUnits(const SBFileSpec &sb_file_spec) {
SBSymbolContextList sb_sc_list;
const ModuleSP module_sp(GetSP());
if (sb_file_spec.IsValid() && module_sp) {
const bool append = true;
module_sp->FindCompileUnits(*sb_file_spec, append, *sb_sc_list);
module_sp->FindCompileUnits(*sb_file_spec, *sb_sc_list);
}
return LLDB_RECORD_RESULT(sb_sc_list);
}
@ -342,8 +341,9 @@ lldb::SBSymbolContextList SBModule::FindSymbols(const char *name,
Symtab *symtab = GetUnifiedSymbolTable(module_sp);
if (symtab) {
std::vector<uint32_t> matching_symbol_indexes;
const size_t num_matches = symtab->FindAllSymbolsWithNameAndType(
ConstString(name), symbol_type, matching_symbol_indexes);
symtab->FindAllSymbolsWithNameAndType(ConstString(name), symbol_type,
matching_symbol_indexes);
const size_t num_matches = matching_symbol_indexes.size();
if (num_matches) {
SymbolContext sc;
sc.module_sp = module_sp;
@ -398,12 +398,11 @@ lldb::SBSymbolContextList SBModule::FindFunctions(const char *name,
lldb::SBSymbolContextList sb_sc_list;
ModuleSP module_sp(GetSP());
if (name && module_sp) {
const bool append = true;
const bool symbols_ok = true;
const bool inlines_ok = true;
FunctionNameType type = static_cast<FunctionNameType>(name_type_mask);
module_sp->FindFunctions(ConstString(name), nullptr, type, symbols_ok,
inlines_ok, append, *sb_sc_list);
inlines_ok, *sb_sc_list);
}
return LLDB_RECORD_RESULT(sb_sc_list);
}
@ -418,9 +417,9 @@ SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name,
ModuleSP module_sp(GetSP());
if (name && module_sp) {
VariableList variable_list;
const uint32_t match_count = module_sp->FindGlobalVariables(
ConstString(name), nullptr, max_matches, variable_list);
module_sp->FindGlobalVariables(ConstString(name), nullptr, max_matches,
variable_list);
const uint32_t match_count = variable_list.GetSize();
if (match_count > 0) {
for (uint32_t i = 0; i < match_count; ++i) {
lldb::ValueObjectSP valobj_sp;

View File

@ -1653,11 +1653,8 @@ SBSymbolContextList SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) {
SBSymbolContextList sb_sc_list;
const TargetSP target_sp(GetSP());
if (target_sp && sb_file_spec.IsValid()) {
const bool append = true;
target_sp->GetImages().FindCompileUnits(*sb_file_spec,
append, *sb_sc_list);
}
if (target_sp && sb_file_spec.IsValid())
target_sp->GetImages().FindCompileUnits(*sb_file_spec, *sb_sc_list);
return LLDB_RECORD_RESULT(sb_sc_list);
}
@ -1783,10 +1780,9 @@ lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name,
const bool symbols_ok = true;
const bool inlines_ok = true;
const bool append = true;
FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
target_sp->GetImages().FindFunctions(ConstString(name), mask, symbols_ok,
inlines_ok, append, *sb_sc_list);
inlines_ok, *sb_sc_list);
return LLDB_RECORD_RESULT(sb_sc_list);
}
@ -1806,17 +1802,16 @@ lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name,
switch (matchtype) {
case eMatchTypeRegex:
target_sp->GetImages().FindFunctions(RegularExpression(name_ref), true,
true, true, *sb_sc_list);
true, *sb_sc_list);
break;
case eMatchTypeStartsWith:
regexstr = llvm::Regex::escape(name) + ".*";
target_sp->GetImages().FindFunctions(RegularExpression(regexstr), true,
true, true, *sb_sc_list);
true, *sb_sc_list);
break;
default:
target_sp->GetImages().FindFunctions(ConstString(name),
eFunctionNameTypeAny, true, true,
true, *sb_sc_list);
target_sp->GetImages().FindFunctions(
ConstString(name), eFunctionNameTypeAny, true, true, *sb_sc_list);
break;
}
}
@ -1933,9 +1928,9 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
TargetSP target_sp(GetSP());
if (name && target_sp) {
VariableList variable_list;
const uint32_t match_count = target_sp->GetImages().FindGlobalVariables(
ConstString(name), max_matches, variable_list);
target_sp->GetImages().FindGlobalVariables(ConstString(name), max_matches,
variable_list);
const uint32_t match_count = variable_list.GetSize();
if (match_count > 0) {
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
if (exe_scope == nullptr)
@ -1970,20 +1965,20 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
uint32_t match_count;
switch (matchtype) {
case eMatchTypeNormal:
match_count = target_sp->GetImages().FindGlobalVariables(
ConstString(name), max_matches, variable_list);
target_sp->GetImages().FindGlobalVariables(ConstString(name), max_matches,
variable_list);
break;
case eMatchTypeRegex:
match_count = target_sp->GetImages().FindGlobalVariables(
RegularExpression(name_ref), max_matches, variable_list);
target_sp->GetImages().FindGlobalVariables(RegularExpression(name_ref),
max_matches, variable_list);
break;
case eMatchTypeStartsWith:
regexstr = llvm::Regex::escape(name) + ".*";
match_count = target_sp->GetImages().FindGlobalVariables(
RegularExpression(regexstr), max_matches, variable_list);
target_sp->GetImages().FindGlobalVariables(RegularExpression(regexstr),
max_matches, variable_list);
break;
}
match_count = variable_list.GetSize();
if (match_count > 0) {
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
if (exe_scope == nullptr)
@ -2287,11 +2282,9 @@ lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name,
SBSymbolContextList sb_sc_list;
if (name && name[0]) {
TargetSP target_sp(GetSP());
if (target_sp) {
bool append = true;
if (target_sp)
target_sp->GetImages().FindSymbolsWithNameAndType(
ConstString(name), symbol_type, *sb_sc_list, append);
}
ConstString(name), symbol_type, *sb_sc_list);
}
return LLDB_RECORD_RESULT(sb_sc_list);
}

View File

@ -271,7 +271,6 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter,
bool filter_by_language = (m_language != eLanguageTypeUnknown);
const bool include_symbols = !filter_by_cu;
const bool include_inlines = true;
const bool append = true;
switch (m_match_type) {
case Breakpoint::Exact:
@ -280,7 +279,7 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter,
const size_t start_func_idx = func_list.GetSize();
context.module_sp->FindFunctions(
lookup.GetLookupName(), nullptr, lookup.GetNameTypeMask(),
include_symbols, include_inlines, append, func_list);
include_symbols, include_inlines, func_list);
const size_t end_func_idx = func_list.GetSize();
@ -294,7 +293,7 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter,
context.module_sp->FindFunctions(
m_regex,
!filter_by_cu, // include symbols only if we aren't filtering by CU
include_inlines, append, func_list);
include_inlines, func_list);
}
break;
case Breakpoint::Glob:

View File

@ -447,9 +447,8 @@ Searcher::CallbackReturn CommandCompletions::SymbolCompleter::SearchCallback(
SymbolContextList sc_list;
const bool include_symbols = true;
const bool include_inlines = true;
const bool append = true;
context.module_sp->FindFunctions(m_regex, include_symbols, include_inlines,
append, sc_list);
sc_list);
SymbolContext sc;
// Now add the functions & symbols to the list - only add if unique:

View File

@ -392,17 +392,18 @@ protected:
// const.
ModuleList module_list =
(m_module_list.GetSize() > 0) ? m_module_list : target->GetImages();
size_t num_matches =
module_list.FindFunctions(name, eFunctionNameTypeAuto,
/*include_symbols=*/false,
/*include_inlines=*/true,
/*append=*/true, sc_list_funcs);
/*include_inlines=*/true, sc_list_funcs);
size_t num_matches = sc_list_funcs.GetSize();
if (!num_matches) {
// If we didn't find any functions with that name, try searching for
// symbols that line up exactly with function addresses.
SymbolContextList sc_list_symbols;
size_t num_symbol_matches = module_list.FindFunctionSymbols(
module_list.FindFunctionSymbols(
name, eFunctionNameTypeAuto, sc_list_symbols);
size_t num_symbol_matches = sc_list_symbols.GetSize();
for (size_t i = 0; i < num_symbol_matches; i++) {
SymbolContext sc;
sc_list_symbols.GetContextAtIndex(i, sc);
@ -580,7 +581,8 @@ protected:
FileSpec module_file_spec(m_options.modules[i]);
if (module_file_spec) {
ModuleSpec module_spec(module_file_spec);
if (target->GetImages().FindModules(module_spec, m_module_list) == 0)
target->GetImages().FindModules(module_spec, m_module_list);
if (m_module_list.IsEmpty())
result.AppendWarningWithFormat("No module found for '%s'.\n",
m_options.modules[i].c_str());
}
@ -872,13 +874,11 @@ protected:
// these somewhere, there should probably be a module-filter-list that can be
// passed to the various ModuleList::Find* calls, which would either be a
// vector of string names or a ModuleSpecList.
size_t FindMatchingFunctions(Target *target, ConstString name,
void FindMatchingFunctions(Target *target, ConstString name,
SymbolContextList &sc_list) {
// Displaying the source for a symbol:
bool include_inlines = true;
bool append = true;
bool include_symbols = false;
size_t num_matches = 0;
if (m_options.num_lines == 0)
m_options.num_lines = 10;
@ -892,22 +892,20 @@ protected:
ModuleSpec module_spec(module_file_spec);
matching_modules.Clear();
target->GetImages().FindModules(module_spec, matching_modules);
num_matches += matching_modules.FindFunctions(
matching_modules.FindFunctions(
name, eFunctionNameTypeAuto, include_symbols, include_inlines,
append, sc_list);
sc_list);
}
}
} else {
num_matches = target->GetImages().FindFunctions(
name, eFunctionNameTypeAuto, include_symbols, include_inlines, append,
target->GetImages().FindFunctions(name, eFunctionNameTypeAuto,
include_symbols, include_inlines,
sc_list);
}
return num_matches;
}
size_t FindMatchingFunctionSymbols(Target *target, ConstString name,
void FindMatchingFunctionSymbols(Target *target, ConstString name,
SymbolContextList &sc_list) {
size_t num_matches = 0;
const size_t num_modules = m_options.modules.size();
if (num_modules > 0) {
ModuleList matching_modules;
@ -917,15 +915,14 @@ protected:
ModuleSpec module_spec(module_file_spec);
matching_modules.Clear();
target->GetImages().FindModules(module_spec, matching_modules);
num_matches += matching_modules.FindFunctionSymbols(
name, eFunctionNameTypeAuto, sc_list);
matching_modules.FindFunctionSymbols(name, eFunctionNameTypeAuto,
sc_list);
}
}
} else {
num_matches = target->GetImages().FindFunctionSymbols(
name, eFunctionNameTypeAuto, sc_list);
target->GetImages().FindFunctionSymbols(name, eFunctionNameTypeAuto,
sc_list);
}
return num_matches;
}
bool DoExecute(Args &command, CommandReturnObject &result) override {
@ -945,13 +942,15 @@ protected:
ConstString name(m_options.symbol_name.c_str());
// Displaying the source for a symbol. Search for function named name.
size_t num_matches = FindMatchingFunctions(target, name, sc_list);
FindMatchingFunctions(target, name, sc_list);
size_t num_matches = sc_list.GetSize();
if (!num_matches) {
// If we didn't find any functions with that name, try searching for
// symbols that line up exactly with function addresses.
SymbolContextList sc_list_symbols;
size_t num_symbol_matches =
FindMatchingFunctionSymbols(target, name, sc_list_symbols);
size_t num_symbol_matches =sc_list_symbols.GetSize();
for (size_t i = 0; i < num_symbol_matches; i++) {
SymbolContext sc;
sc_list_symbols.GetContextAtIndex(i, sc);

View File

@ -798,12 +798,12 @@ public:
static size_t GetVariableCallback(void *baton, const char *name,
VariableList &variable_list) {
size_t old_size = variable_list.GetSize();
Target *target = static_cast<Target *>(baton);
if (target) {
return target->GetImages().FindGlobalVariables(ConstString(name),
UINT32_MAX, variable_list);
}
return 0;
if (target)
target->GetImages().FindGlobalVariables(ConstString(name), UINT32_MAX,
variable_list);
return variable_list.GetSize() - old_size;
}
Options *GetOptions() override { return &m_option_group; }
@ -866,8 +866,9 @@ protected:
return false;
}
use_var_name = true;
matches = target->GetImages().FindGlobalVariables(regex, UINT32_MAX,
target->GetImages().FindGlobalVariables(regex, UINT32_MAX,
variable_list);
matches = variable_list.GetSize();
} else {
Status error(Variable::GetValuesForVariableExpressionPath(
arg, m_exe_ctx.GetBestExecutionContextScope(),
@ -942,7 +943,6 @@ protected:
}
} else {
SymbolContextList sc_list;
const bool append = true;
// We have one or more compile unit or shlib
if (num_shlibs > 0) {
for (size_t shlib_idx = 0; shlib_idx < num_shlibs; ++shlib_idx) {
@ -955,8 +955,7 @@ protected:
if (num_compile_units > 0) {
for (size_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
module_sp->FindCompileUnits(
compile_units.GetFileSpecAtIndex(cu_idx), append,
sc_list);
compile_units.GetFileSpecAtIndex(cu_idx), sc_list);
} else {
SymbolContext sc;
sc.module_sp = module_sp;
@ -974,7 +973,7 @@ protected:
// units files that were specified
for (size_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
target->GetImages().FindCompileUnits(
compile_units.GetFileSpecAtIndex(cu_idx), append, sc_list);
compile_units.GetFileSpecAtIndex(cu_idx), sc_list);
}
const uint32_t num_scs = sc_list.GetSize();
@ -1598,19 +1597,17 @@ static size_t LookupFunctionInModule(CommandInterpreter &interpreter,
bool verbose) {
if (module && name && name[0]) {
SymbolContextList sc_list;
const bool append = true;
size_t num_matches = 0;
if (name_is_regex) {
RegularExpression function_name_regex((llvm::StringRef(name)));
num_matches = module->FindFunctions(function_name_regex, include_symbols,
include_inlines, append, sc_list);
module->FindFunctions(function_name_regex, include_symbols,
include_inlines, sc_list);
} else {
ConstString function_name(name);
num_matches = module->FindFunctions(
function_name, nullptr, eFunctionNameTypeAuto, include_symbols,
include_inlines, append, sc_list);
module->FindFunctions(function_name, nullptr, eFunctionNameTypeAuto,
include_symbols, include_inlines, sc_list);
}
num_matches = sc_list.GetSize();
if (num_matches) {
strm.Indent();
strm.Printf("%" PRIu64 " match%s found in ", (uint64_t)num_matches,
@ -1770,8 +1767,8 @@ static size_t FindModulesByName(Target *target, const char *module_name,
}
} else {
if (target) {
const size_t num_matches =
target->GetImages().FindModules(module_spec, module_list);
const size_t num_matches = module_list.GetSize();
// Not found in our module list for our target, check the main shared
// module list in case it is a extra file used somewhere else
@ -2695,8 +2692,8 @@ protected:
if (search_using_module_spec) {
ModuleList matching_modules;
const size_t num_matches =
target->GetImages().FindModules(module_spec, matching_modules);
const size_t num_matches = matching_modules.GetSize();
char path[PATH_MAX];
if (num_matches == 1) {
@ -3352,7 +3349,7 @@ protected:
if (m_options.m_type == eLookupTypeFunctionOrSymbol) {
ConstString function_name(m_options.m_str.c_str());
target->GetImages().FindFunctions(function_name, eFunctionNameTypeAuto,
true, false, true, sc_list);
true, false, sc_list);
} else if (m_options.m_type == eLookupTypeAddress && target) {
Address addr;
if (target->GetSectionLoadList().ResolveLoadAddress(m_options.m_addr,
@ -4067,8 +4064,9 @@ protected:
// It has a UUID, look for this UUID in the target modules
ModuleSpec symfile_uuid_module_spec;
symfile_uuid_module_spec.GetUUID() = symfile_module_spec.GetUUID();
num_matches = target->GetImages().FindModules(
symfile_uuid_module_spec, matching_module_list);
target->GetImages().FindModules(symfile_uuid_module_spec,
matching_module_list);
num_matches = matching_module_list.GetSize();
}
}
@ -4086,8 +4084,9 @@ protected:
ModuleSpec symfile_uuid_module_spec;
symfile_uuid_module_spec.GetUUID() =
symfile_module_spec.GetUUID();
num_matches = target->GetImages().FindModules(
symfile_uuid_module_spec, matching_module_list);
target->GetImages().FindModules(symfile_uuid_module_spec,
matching_module_list);
num_matches = matching_module_list.GetSize();
}
}
}
@ -4096,9 +4095,10 @@ protected:
// Just try to match up the file by basename if we have no matches at
// this point
if (num_matches == 0)
num_matches =
if (num_matches == 0) {
target->GetImages().FindModules(module_spec, matching_module_list);
num_matches = matching_module_list.GetSize();
}
while (num_matches == 0) {
ConstString filename_no_extension(
@ -4115,8 +4115,8 @@ protected:
// Replace basename with one less extension
module_spec.GetFileSpec().GetFilename() = filename_no_extension;
num_matches =
target->GetImages().FindModules(module_spec, matching_module_list);
num_matches = matching_module_list.GetSize();
}
if (num_matches > 1) {

View File

@ -785,12 +785,12 @@ corresponding to the byte size of the data type.");
protected:
static size_t GetVariableCallback(void *baton, const char *name,
VariableList &variable_list) {
size_t old_size = variable_list.GetSize();
Target *target = static_cast<Target *>(baton);
if (target) {
return target->GetImages().FindGlobalVariables(ConstString(name),
UINT32_MAX, variable_list);
}
return 0;
if (target)
target->GetImages().FindGlobalVariables(ConstString(name), UINT32_MAX,
variable_list);
return variable_list.GetSize() - old_size;
}
bool DoExecute(Args &command, CommandReturnObject &result) override {

View File

@ -86,7 +86,6 @@ AddressResolverName::SearchCallback(SearchFilter &filter,
const bool include_symbols = false;
const bool include_inlines = true;
const bool append = false;
switch (m_match_type) {
case AddressResolver::Exact:
if (context.module_sp) {
@ -94,7 +93,7 @@ AddressResolverName::SearchCallback(SearchFilter &filter,
eSymbolTypeCode, sym_list);
context.module_sp->FindFunctions(m_func_name, nullptr,
eFunctionNameTypeAuto, include_symbols,
include_inlines, append, func_list);
include_inlines, func_list);
}
break;
@ -103,7 +102,7 @@ AddressResolverName::SearchCallback(SearchFilter &filter,
context.module_sp->FindSymbolsMatchingRegExAndType(
m_regex, eSymbolTypeCode, sym_list);
context.module_sp->FindFunctions(m_regex, include_symbols,
include_inlines, append, func_list);
include_inlines, func_list);
}
break;

View File

@ -174,11 +174,10 @@ bool Disassembler::Disassemble(
SymbolContextList sc_list;
if (module) {
module->FindFunctions(name, nullptr, eFunctionNameTypeAuto, include_symbols,
include_inlines, true, sc_list);
include_inlines, sc_list);
} else if (exe_ctx.GetTargetPtr()) {
exe_ctx.GetTargetPtr()->GetImages().FindFunctions(
name, eFunctionNameTypeAuto, include_symbols, include_inlines, false,
sc_list);
name, eFunctionNameTypeAuto, include_symbols, include_inlines, sc_list);
}
// If no functions were found there's nothing to disassemble.

View File

@ -594,31 +594,22 @@ uint32_t Module::ResolveSymbolContextsForFileSpec(
return sc_list.GetSize() - initial_count;
}
size_t Module::FindGlobalVariables(ConstString name,
void Module::FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
size_t max_matches,
VariableList &variables) {
size_t max_matches, VariableList &variables) {
if (SymbolFile *symbols = GetSymbolFile())
return symbols->FindGlobalVariables(name, parent_decl_ctx, max_matches,
variables);
return 0;
symbols->FindGlobalVariables(name, parent_decl_ctx, max_matches, variables);
}
size_t Module::FindGlobalVariables(const RegularExpression &regex,
size_t max_matches,
VariableList &variables) {
void Module::FindGlobalVariables(const RegularExpression &regex,
size_t max_matches, VariableList &variables) {
SymbolFile *symbols = GetSymbolFile();
if (symbols)
return symbols->FindGlobalVariables(regex, max_matches, variables);
return 0;
symbols->FindGlobalVariables(regex, max_matches, variables);
}
size_t Module::FindCompileUnits(const FileSpec &path, bool append,
void Module::FindCompileUnits(const FileSpec &path,
SymbolContextList &sc_list) {
if (!append)
sc_list.Clear();
const size_t start_size = sc_list.GetSize();
const size_t num_compile_units = GetNumCompileUnits();
SymbolContext sc;
sc.module_sp = shared_from_this();
@ -630,7 +621,6 @@ size_t Module::FindCompileUnits(const FileSpec &path, bool append,
sc_list.Append(sc);
}
}
return sc_list.GetSize() - start_size;
}
Module::LookupInfo::LookupInfo(ConstString name,
@ -793,14 +783,11 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
}
}
size_t Module::FindFunctions(ConstString name,
void Module::FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask,
bool include_symbols, bool include_inlines,
bool append, SymbolContextList &sc_list) {
if (!append)
sc_list.Clear();
SymbolContextList &sc_list) {
const size_t old_size = sc_list.GetSize();
// Find all the functions (not symbols, but debug information functions...
@ -812,7 +799,7 @@ size_t Module::FindFunctions(ConstString name,
if (symbols) {
symbols->FindFunctions(lookup_info.GetLookupName(), parent_decl_ctx,
lookup_info.GetNameTypeMask(), include_inlines,
append, sc_list);
sc_list);
// Now check our symbol table for symbols that are code symbols if
// requested
@ -831,7 +818,7 @@ size_t Module::FindFunctions(ConstString name,
} else {
if (symbols) {
symbols->FindFunctions(name, parent_decl_ctx, name_type_mask,
include_inlines, append, sc_list);
include_inlines, sc_list);
// Now check our symbol table for symbols that are code symbols if
// requested
@ -842,20 +829,15 @@ size_t Module::FindFunctions(ConstString name,
}
}
}
return sc_list.GetSize() - old_size;
}
size_t Module::FindFunctions(const RegularExpression &regex,
bool include_symbols, bool include_inlines,
bool append, SymbolContextList &sc_list) {
if (!append)
sc_list.Clear();
void Module::FindFunctions(const RegularExpression &regex, bool include_symbols,
bool include_inlines,
SymbolContextList &sc_list) {
const size_t start_size = sc_list.GetSize();
if (SymbolFile *symbols = GetSymbolFile()) {
symbols->FindFunctions(regex, include_inlines, append, sc_list);
symbols->FindFunctions(regex, include_inlines, sc_list);
// Now check our symbol table for symbols that are code symbols if
// requested
@ -917,7 +899,6 @@ size_t Module::FindFunctions(const RegularExpression &regex,
}
}
}
return sc_list.GetSize() - start_size;
}
void Module::FindAddressesForLine(const lldb::TargetSP target_sp,
@ -1326,7 +1307,7 @@ void Module::SymbolIndicesToSymbolContextList(
}
}
size_t Module::FindFunctionSymbols(ConstString name,
void Module::FindFunctionSymbols(ConstString name,
uint32_t name_type_mask,
SymbolContextList &sc_list) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
@ -1334,11 +1315,10 @@ size_t Module::FindFunctionSymbols(ConstString name,
"Module::FindSymbolsFunctions (name = %s, mask = 0x%8.8x)",
name.AsCString(), name_type_mask);
if (Symtab *symtab = GetSymtab())
return symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
return 0;
symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
}
size_t Module::FindSymbolsWithNameAndType(ConstString name,
void Module::FindSymbolsWithNameAndType(ConstString name,
SymbolType symbol_type,
SymbolContextList &sc_list) {
// No need to protect this call using m_mutex all other method calls are
@ -1348,16 +1328,14 @@ size_t Module::FindSymbolsWithNameAndType(ConstString name,
Timer scoped_timer(
func_cat, "Module::FindSymbolsWithNameAndType (name = %s, type = %i)",
name.AsCString(), symbol_type);
const size_t initial_size = sc_list.GetSize();
if (Symtab *symtab = GetSymtab()) {
std::vector<uint32_t> symbol_indexes;
symtab->FindAllSymbolsWithNameAndType(name, symbol_type, symbol_indexes);
SymbolIndicesToSymbolContextList(symtab, symbol_indexes, sc_list);
}
return sc_list.GetSize() - initial_size;
}
size_t Module::FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
void Module::FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
SymbolType symbol_type,
SymbolContextList &sc_list) {
// No need to protect this call using m_mutex all other method calls are
@ -1368,7 +1346,6 @@ size_t Module::FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
func_cat,
"Module::FindSymbolsMatchingRegExAndType (regex = %s, type = %i)",
regex.GetText().str().c_str(), symbol_type);
const size_t initial_size = sc_list.GetSize();
if (Symtab *symtab = GetSymtab()) {
std::vector<uint32_t> symbol_indexes;
symtab->FindAllSymbolsMatchingRexExAndType(
@ -1376,7 +1353,6 @@ size_t Module::FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
symbol_indexes);
SymbolIndicesToSymbolContextList(symtab, symbol_indexes, sc_list);
}
return sc_list.GetSize() - initial_size;
}
void Module::PreloadSymbols() {

View File

@ -326,14 +326,10 @@ ModuleSP ModuleList::GetModuleAtIndexUnlocked(size_t idx) const {
return module_sp;
}
size_t ModuleList::FindFunctions(ConstString name,
void ModuleList::FindFunctions(ConstString name,
FunctionNameType name_type_mask,
bool include_symbols, bool include_inlines,
bool append,
SymbolContextList &sc_list) const {
if (!append)
sc_list.Clear();
const size_t old_size = sc_list.GetSize();
if (name_type_mask & eFunctionNameTypeAuto) {
@ -344,7 +340,7 @@ size_t ModuleList::FindFunctions(ConstString name,
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindFunctions(lookup_info.GetLookupName(), nullptr,
lookup_info.GetNameTypeMask(), include_symbols,
include_inlines, true, sc_list);
include_inlines, sc_list);
}
const size_t new_size = sc_list.GetSize();
@ -356,13 +352,12 @@ size_t ModuleList::FindFunctions(ConstString name,
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindFunctions(name, nullptr, name_type_mask, include_symbols,
include_inlines, true, sc_list);
include_inlines, sc_list);
}
}
return sc_list.GetSize() - old_size;
}
size_t ModuleList::FindFunctionSymbols(ConstString name,
void ModuleList::FindFunctionSymbols(ConstString name,
lldb::FunctionNameType name_type_mask,
SymbolContextList &sc_list) {
const size_t old_size = sc_list.GetSize();
@ -388,96 +383,66 @@ size_t ModuleList::FindFunctionSymbols(ConstString name,
(*pos)->FindFunctionSymbols(name, name_type_mask, sc_list);
}
}
return sc_list.GetSize() - old_size;
}
size_t ModuleList::FindFunctions(const RegularExpression &name,
void ModuleList::FindFunctions(const RegularExpression &name,
bool include_symbols, bool include_inlines,
bool append, SymbolContextList &sc_list) {
const size_t old_size = sc_list.GetSize();
SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindFunctions(name, include_symbols, include_inlines, append,
sc_list);
(*pos)->FindFunctions(name, include_symbols, include_inlines, sc_list);
}
}
return sc_list.GetSize() - old_size;
}
size_t ModuleList::FindCompileUnits(const FileSpec &path, bool append,
void ModuleList::FindCompileUnits(const FileSpec &path,
SymbolContextList &sc_list) const {
if (!append)
sc_list.Clear();
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindCompileUnits(path, true, sc_list);
(*pos)->FindCompileUnits(path, sc_list);
}
}
return sc_list.GetSize();
}
size_t ModuleList::FindGlobalVariables(ConstString name,
size_t max_matches,
void ModuleList::FindGlobalVariables(ConstString name, size_t max_matches,
VariableList &variable_list) const {
size_t initial_size = variable_list.GetSize();
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindGlobalVariables(name, nullptr, max_matches, variable_list);
}
return variable_list.GetSize() - initial_size;
}
size_t ModuleList::FindGlobalVariables(const RegularExpression &regex,
void ModuleList::FindGlobalVariables(const RegularExpression &regex,
size_t max_matches,
VariableList &variable_list) const {
size_t initial_size = variable_list.GetSize();
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindGlobalVariables(regex, max_matches, variable_list);
}
return variable_list.GetSize() - initial_size;
}
size_t ModuleList::FindSymbolsWithNameAndType(ConstString name,
void ModuleList::FindSymbolsWithNameAndType(ConstString name,
SymbolType symbol_type,
SymbolContextList &sc_list,
bool append) const {
SymbolContextList &sc_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
if (!append)
sc_list.Clear();
size_t initial_size = sc_list.GetSize();
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
(*pos)->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
return sc_list.GetSize() - initial_size;
}
size_t ModuleList::FindSymbolsMatchingRegExAndType(
void ModuleList::FindSymbolsMatchingRegExAndType(
const RegularExpression &regex, lldb::SymbolType symbol_type,
SymbolContextList &sc_list, bool append) const {
SymbolContextList &sc_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
if (!append)
sc_list.Clear();
size_t initial_size = sc_list.GetSize();
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
(*pos)->FindSymbolsMatchingRegExAndType(regex, symbol_type, sc_list);
return sc_list.GetSize() - initial_size;
}
size_t ModuleList::FindModules(const ModuleSpec &module_spec,
void ModuleList::FindModules(const ModuleSpec &module_spec,
ModuleList &matching_module_list) const {
size_t existing_matches = matching_module_list.GetSize();
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
@ -485,7 +450,6 @@ size_t ModuleList::FindModules(const ModuleSpec &module_spec,
if (module_sp->MatchesModuleSpec(module_spec))
matching_module_list.Append(module_sp);
}
return matching_module_list.GetSize() - existing_matches;
}
ModuleSP ModuleList::FindModule(const Module *module_ptr) const {
@ -736,9 +700,9 @@ bool ModuleList::ModuleIsInCache(const Module *module_ptr) {
return false;
}
size_t ModuleList::FindSharedModules(const ModuleSpec &module_spec,
void ModuleList::FindSharedModules(const ModuleSpec &module_spec,
ModuleList &matching_module_list) {
return GetSharedModuleList().FindModules(module_spec, matching_module_list);
GetSharedModuleList().FindModules(module_spec, matching_module_list);
}
size_t ModuleList::RemoveOrphanSharedModules(bool mandatory) {
@ -773,8 +737,9 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
// mutex list.
if (!always_create) {
ModuleList matching_module_list;
const size_t num_matching_modules =
shared_module_list.FindModules(module_spec, matching_module_list);
const size_t num_matching_modules = matching_module_list.GetSize();
if (num_matching_modules > 0) {
for (size_t module_idx = 0; module_idx < num_matching_modules;
++module_idx) {
@ -925,8 +890,8 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
platform_module_spec.GetSymbolFileSpec() =
located_binary_modulespec.GetSymbolFileSpec();
ModuleList matching_module_list;
if (shared_module_list.FindModules(platform_module_spec,
matching_module_list) > 0) {
shared_module_list.FindModules(platform_module_spec, matching_module_list);
if (!matching_module_list.IsEmpty()) {
module_sp = matching_module_list.GetModuleAtIndex(0);
// If we didn't have a UUID in mind when looking for the object file,

View File

@ -324,10 +324,10 @@ bool SourceManager::GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line) {
ConstString main_name("main");
bool symbols_okay = false; // Force it to be a debug symbol.
bool inlines_okay = true;
bool append = false;
size_t num_matches = executable_ptr->FindFunctions(
main_name, nullptr, lldb::eFunctionNameTypeBase, inlines_okay,
symbols_okay, append, sc_list);
executable_ptr->FindFunctions(main_name, nullptr,
lldb::eFunctionNameTypeBase, inlines_okay,
symbols_okay, sc_list);
size_t num_matches = sc_list.GetSize();
for (size_t idx = 0; idx < num_matches; idx++) {
SymbolContext sc;
sc_list.GetContextAtIndex(idx, sc);

View File

@ -854,7 +854,6 @@ lldb::addr_t IRExecutionUnit::FindInSymbols(
sc.module_sp->FindFunctions(spec.name, nullptr, spec.mask,
true, // include_symbols
false, // include_inlines
true, // append
sc_list);
}
@ -870,7 +869,6 @@ lldb::addr_t IRExecutionUnit::FindInSymbols(
sc.target_sp->GetImages().FindFunctions(spec.name, spec.mask,
true, // include_symbols
false, // include_inlines
true, // append
sc_list);
}

View File

@ -290,8 +290,9 @@ bool HexagonDYLDRendezvous::FindMetadata(const char *name, PThreadField field,
Target &target = m_process->GetTarget();
SymbolContextList list;
if (!target.GetImages().FindSymbolsWithNameAndType(ConstString(name),
eSymbolTypeAny, list))
target.GetImages().FindSymbolsWithNameAndType(ConstString(name),
eSymbolTypeAny, list);
if (list.IsEmpty())
return false;
Address address = list[0].symbol->GetAddress();

View File

@ -977,15 +977,13 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread &thread,
return thread_plan_sp;
}
size_t DynamicLoaderDarwin::FindEquivalentSymbols(
void DynamicLoaderDarwin::FindEquivalentSymbols(
lldb_private::Symbol *original_symbol, lldb_private::ModuleList &images,
lldb_private::SymbolContextList &equivalent_symbols) {
ConstString trampoline_name = original_symbol->GetMangled().GetName(
original_symbol->GetLanguage(), Mangled::ePreferMangled);
if (!trampoline_name)
return 0;
size_t initial_size = equivalent_symbols.GetSize();
return;
static const char *resolver_name_regex = "(_gc|_non_gc|\\$[A-Za-z0-9\\$]+)$";
std::string equivalent_regex_buf("^");
@ -993,11 +991,9 @@ size_t DynamicLoaderDarwin::FindEquivalentSymbols(
equivalent_regex_buf.append(resolver_name_regex);
RegularExpression equivalent_name_regex(equivalent_regex_buf);
const bool append = true;
images.FindSymbolsMatchingRegExAndType(equivalent_name_regex, eSymbolTypeCode,
equivalent_symbols, append);
equivalent_symbols);
return equivalent_symbols.GetSize() - initial_size;
}
lldb::ModuleSP DynamicLoaderDarwin::GetPThreadLibraryModule() {
@ -1008,8 +1004,8 @@ lldb::ModuleSP DynamicLoaderDarwin::GetPThreadLibraryModule() {
module_spec.GetFileSpec().GetFilename().SetCString(
"libsystem_pthread.dylib");
ModuleList module_list;
if (m_process->GetTarget().GetImages().FindModules(module_spec,
module_list)) {
m_process->GetTarget().GetImages().FindModules(module_spec, module_list);
if (!module_list.IsEmpty()) {
if (module_list.GetSize() == 1) {
module_sp = module_list.GetModuleAtIndex(0);
if (module_sp)

View File

@ -41,7 +41,7 @@ public:
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread,
bool stop_others) override;
size_t FindEquivalentSymbols(
void FindEquivalentSymbols(
lldb_private::Symbol *original_symbol,
lldb_private::ModuleList &module_list,
lldb_private::SymbolContextList &equivalent_symbols) override;

View File

@ -558,8 +558,9 @@ bool DYLDRendezvous::FindMetadata(const char *name, PThreadField field,
Target &target = m_process->GetTarget();
SymbolContextList list;
if (!target.GetImages().FindSymbolsWithNameAndType(ConstString(name),
eSymbolTypeAny, list))
target.GetImages().FindSymbolsWithNameAndType(ConstString(name),
eSymbolTypeAny, list);
if (list.IsEmpty())
return false;
Address address = list[0].symbol->GetAddress();

View File

@ -1228,7 +1228,6 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
const bool include_symbols = false;
const bool include_inlines = false;
const bool append = false;
std::string interface_name = interface_decl->getNameAsString();
@ -1238,9 +1237,10 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
ms.Flush();
ConstString instance_method_name(ms.GetString());
sc_list.Clear();
m_target->GetImages().FindFunctions(
instance_method_name, lldb::eFunctionNameTypeFull, include_symbols,
include_inlines, append, sc_list);
include_inlines, sc_list);
if (sc_list.GetSize())
break;
@ -1250,9 +1250,10 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
ms.Flush();
ConstString class_method_name(ms.GetString());
sc_list.Clear();
m_target->GetImages().FindFunctions(
class_method_name, lldb::eFunctionNameTypeFull, include_symbols,
include_inlines, append, sc_list);
include_inlines, sc_list);
if (sc_list.GetSize())
break;
@ -1265,7 +1266,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
m_target->GetImages().FindFunctions(
selector_name, lldb::eFunctionNameTypeSelector, include_symbols,
include_inlines, append, candidate_sc_list);
include_inlines, candidate_sc_list);
for (uint32_t ci = 0, ce = candidate_sc_list.GetSize(); ci != ce; ++ci) {
SymbolContext candidate_sc;

View File

@ -1216,14 +1216,12 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
}
const bool include_inlines = false;
const bool append = false;
sc_list.Clear();
if (namespace_decl && module_sp) {
const bool include_symbols = false;
module_sp->FindFunctions(name, &namespace_decl, eFunctionNameTypeBase,
include_symbols, include_inlines, append,
sc_list);
include_symbols, include_inlines, sc_list);
} else if (target && !namespace_decl) {
const bool include_symbols = true;
@ -1232,7 +1230,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
target->GetImages().FindFunctions(name, eFunctionNameTypeFull,
include_symbols, include_inlines,
append, sc_list);
sc_list);
}
// If we found more than one function, see if we can use the frame's decl

View File

@ -458,8 +458,8 @@ addr_t JITLoaderGDB::GetSymbolAddress(ModuleList &module_list,
SymbolContextList target_symbols;
Target &target = m_process->GetTarget();
if (!module_list.FindSymbolsWithNameAndType(name, symbol_type,
target_symbols))
module_list.FindSymbolsWithNameAndType(name, symbol_type, target_symbols);
if (target_symbols.IsEmpty())
return LLDB_INVALID_ADDRESS;
SymbolContext sym_ctx;

View File

@ -231,7 +231,7 @@ CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo(
SymbolContextList scl;
target.GetImages().FindSymbolsMatchingRegExAndType(
RegularExpression{R"(^)" + func_to_match}, eSymbolTypeAny, scl, true);
RegularExpression{R"(^)" + func_to_match}, eSymbolTypeAny, scl);
// Case 1,2 or 3
if (scl.GetSize() >= 1) {

View File

@ -223,11 +223,14 @@ Address *AppleObjCRuntime::GetPrintForDebuggerAddr() {
SymbolContextList contexts;
SymbolContext context;
if ((!modules.FindSymbolsWithNameAndType(ConstString("_NSPrintForDebugger"),
eSymbolTypeCode, contexts)) &&
(!modules.FindSymbolsWithNameAndType(ConstString("_CFPrintForDebugger"),
eSymbolTypeCode, contexts)))
modules.FindSymbolsWithNameAndType(ConstString("_NSPrintForDebugger"),
eSymbolTypeCode, contexts);
if (contexts.IsEmpty()) {
modules.FindSymbolsWithNameAndType(ConstString("_CFPrintForDebugger"),
eSymbolTypeCode, contexts);
if (contexts.IsEmpty())
return nullptr;
}
contexts.GetContextAtIndex(0, context);
@ -444,10 +447,12 @@ bool AppleObjCRuntime::CalculateHasNewLiteralsAndIndexing() {
SymbolContextList sc_list;
return target.GetImages().FindSymbolsWithNameAndType(
s_method_signature, eSymbolTypeCode, sc_list) ||
target.GetImages().FindSymbolsWithNameAndType(
s_arclite_method_signature, eSymbolTypeCode, sc_list);
target.GetImages().FindSymbolsWithNameAndType(s_method_signature,
eSymbolTypeCode, sc_list);
if (sc_list.IsEmpty())
target.GetImages().FindSymbolsWithNameAndType(s_arclite_method_signature,
eSymbolTypeCode, sc_list);
return !sc_list.IsEmpty();
}
lldb::SearchFilterSP AppleObjCRuntime::CreateExceptionSearchFilter() {

View File

@ -2640,8 +2640,9 @@ bool AppleObjCRuntimeV2::GetCFBooleanValuesIfNeeded() {
std::function<lldb::addr_t(ConstString)> get_symbol =
[this](ConstString sym) -> lldb::addr_t {
SymbolContextList sc_list;
if (GetProcess()->GetTarget().GetImages().FindSymbolsWithNameAndType(
sym, lldb::eSymbolTypeData, sc_list) == 1) {
GetProcess()->GetTarget().GetImages().FindSymbolsWithNameAndType(
sym, lldb::eSymbolTypeData, sc_list);
if (sc_list.GetSize() == 1) {
SymbolContext sc;
sc_list.GetContextAtIndex(0, sc);
if (sc.symbol)

View File

@ -103,8 +103,8 @@ ObjCLanguageRuntime::LookupInCompleteClassCache(ConstString &name) {
const ModuleList &modules = m_process->GetTarget().GetImages();
SymbolContextList sc_list;
const size_t matching_symbols =
modules.FindSymbolsWithNameAndType(name, eSymbolTypeObjCClass, sc_list);
const size_t matching_symbols = sc_list.GetSize();
if (matching_symbols) {
SymbolContext sc;

View File

@ -5276,8 +5276,9 @@ lldb_private::Address ObjectFileMachO::GetEntryPointAddress() {
if (module_sp) {
SymbolContextList contexts;
SymbolContext context;
if (module_sp->FindSymbolsWithNameAndType(ConstString("start"),
eSymbolTypeCode, contexts)) {
module_sp->FindSymbolsWithNameAndType(ConstString("start"),
eSymbolTypeCode, contexts);
if (contexts.GetSize()) {
if (contexts.GetContextAtIndex(0, context))
m_entry_point_address = context.symbol->GetAddress();
}

View File

@ -364,9 +364,9 @@ PlatformAndroid::GetLibdlFunctionDeclarations(lldb_private::Process *process) {
const char *dl_open_name = nullptr;
Target &target = process->GetTarget();
for (auto name: dl_open_names) {
if (target.GetImages().FindFunctionSymbols(ConstString(name),
eFunctionNameTypeFull,
matching_symbols)) {
target.GetImages().FindFunctionSymbols(
ConstString(name), eFunctionNameTypeFull, matching_symbols);
if (matching_symbols.GetSize()) {
dl_open_name = name;
break;
}

View File

@ -41,13 +41,13 @@ bool lldb_private::InferiorCallMmap(Process *process, addr_t &allocated_addr,
if (thread == nullptr)
return false;
const bool append = true;
const bool include_symbols = true;
const bool include_inlines = false;
SymbolContextList sc_list;
const uint32_t count = process->GetTarget().GetImages().FindFunctions(
process->GetTarget().GetImages().FindFunctions(
ConstString("mmap"), eFunctionNameTypeFull, include_symbols,
include_inlines, append, sc_list);
include_inlines, sc_list);
const uint32_t count = sc_list.GetSize();
if (count > 0) {
SymbolContext sc;
if (sc_list.GetContextAtIndex(0, sc)) {
@ -135,13 +135,13 @@ bool lldb_private::InferiorCallMunmap(Process *process, addr_t addr,
if (thread == nullptr)
return false;
const bool append = true;
const bool include_symbols = true;
const bool include_inlines = false;
SymbolContextList sc_list;
const uint32_t count = process->GetTarget().GetImages().FindFunctions(
process->GetTarget().GetImages().FindFunctions(
ConstString("munmap"), eFunctionNameTypeFull, include_symbols,
include_inlines, append, sc_list);
include_inlines, sc_list);
const uint32_t count = sc_list.GetSize();
if (count > 0) {
SymbolContext sc;
if (sc_list.GetContextAtIndex(0, sc)) {

View File

@ -3834,8 +3834,9 @@ void GDBRemoteCommunicationClient::ServeSymbolLookups(
addr_t symbol_load_addr = LLDB_INVALID_ADDRESS;
lldb_private::SymbolContextList sc_list;
if (process->GetTarget().GetImages().FindSymbolsWithNameAndType(
ConstString(symbol_name), eSymbolTypeAny, sc_list)) {
process->GetTarget().GetImages().FindSymbolsWithNameAndType(
ConstString(symbol_name), eSymbolTypeAny, sc_list);
if (!sc_list.IsEmpty()) {
const size_t num_scs = sc_list.GetSize();
for (size_t sc_idx = 0;
sc_idx < num_scs &&

View File

@ -289,23 +289,17 @@ uint32_t SymbolFileBreakpad::ResolveSymbolContext(
return sc_list.GetSize() - old_size;
}
uint32_t SymbolFileBreakpad::FindFunctions(
void SymbolFileBreakpad::FindFunctions(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines, bool append,
FunctionNameType name_type_mask, bool include_inlines,
SymbolContextList &sc_list) {
// TODO
if (!append)
sc_list.Clear();
return sc_list.GetSize();
}
uint32_t SymbolFileBreakpad::FindFunctions(const RegularExpression &regex,
bool include_inlines, bool append,
void SymbolFileBreakpad::FindFunctions(const RegularExpression &regex,
bool include_inlines,
SymbolContextList &sc_list) {
// TODO
if (!append)
sc_list.Clear();
return sc_list.GetSize();
}
void SymbolFileBreakpad::FindTypes(

View File

@ -70,12 +70,10 @@ public:
size_t ParseBlocksRecursive(Function &func) override { return 0; }
uint32_t FindGlobalVariables(ConstString name,
void FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
VariableList &variables) override {
return 0;
}
VariableList &variables) override {}
size_t ParseVariablesForContext(const SymbolContext &sc) override {
return 0;
@ -100,14 +98,13 @@ public:
void GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask,
TypeList &type_list) override {}
uint32_t FindFunctions(ConstString name,
void FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, bool append,
SymbolContextList &sc_list) override;
bool include_inlines, SymbolContextList &sc_list) override;
uint32_t FindFunctions(const RegularExpression &regex, bool include_inlines,
bool append, SymbolContextList &sc_list) override;
void FindFunctions(const RegularExpression &regex, bool include_inlines,
SymbolContextList &sc_list) override;
void FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,

View File

@ -2005,7 +2005,7 @@ bool SymbolFileDWARF::DeclContextMatchesThisSymbolFile(
return false;
}
uint32_t SymbolFileDWARF::FindGlobalVariables(
void SymbolFileDWARF::FindGlobalVariables(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@ -2020,11 +2020,11 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(
max_matches);
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
return 0;
return;
DWARFDebugInfo *info = DebugInfo();
if (info == nullptr)
return 0;
if (!info)
return;
// Remember how many variables are in the list before we search.
const uint32_t original_size = variables.GetSize();
@ -2111,10 +2111,9 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(
name.GetCString(), static_cast<const void *>(parent_decl_ctx),
max_matches, num_matches);
}
return num_matches;
}
uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression &regex,
void SymbolFileDWARF::FindGlobalVariables(const RegularExpression &regex,
uint32_t max_matches,
VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@ -2129,8 +2128,8 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression &regex,
}
DWARFDebugInfo *info = DebugInfo();
if (info == nullptr)
return 0;
if (!info)
return;
// Remember how many variables are in the list before we search.
const uint32_t original_size = variables.GetSize();
@ -2163,9 +2162,6 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression &regex,
m_index->ReportInvalidDIERef(die_ref, regex.GetText());
}
}
// Return the number of variable that were appended to the list
return variables.GetSize() - original_size;
}
bool SymbolFileDWARF::ResolveFunction(const DWARFDIE &orig_die,
@ -2241,9 +2237,10 @@ bool SymbolFileDWARF::DIEInDeclContext(const CompilerDeclContext *decl_ctx,
return false;
}
uint32_t SymbolFileDWARF::FindFunctions(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines, bool append,
void SymbolFileDWARF::FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask,
bool include_inlines,
SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
@ -2259,21 +2256,16 @@ uint32_t SymbolFileDWARF::FindFunctions(
if (log) {
GetObjectFile()->GetModule()->LogMessage(
log,
"SymbolFileDWARF::FindFunctions (name=\"%s\", "
"name_type_mask=0x%x, append=%u, sc_list)",
name.GetCString(), name_type_mask, append);
"SymbolFileDWARF::FindFunctions (name=\"%s\", name_type_mask=0x%x, sc_list)",
name.GetCString(), name_type_mask);
}
// If we aren't appending the results to this list, then clear the list
if (!append)
sc_list.Clear();
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
return 0;
return;
// If name is empty then we won't find anything.
if (name.IsEmpty())
return 0;
return;
// Remember how many sc_list are in the list before we search in case we are
// appending the results to a variable list.
@ -2300,16 +2292,14 @@ uint32_t SymbolFileDWARF::FindFunctions(
GetObjectFile()->GetModule()->LogMessage(
log,
"SymbolFileDWARF::FindFunctions (name=\"%s\", "
"name_type_mask=0x%x, include_inlines=%d, append=%u, sc_list) => "
"%u",
name.GetCString(), name_type_mask, include_inlines, append,
"name_type_mask=0x%x, include_inlines=%d, sc_list) => %u",
name.GetCString(), name_type_mask, include_inlines,
num_matches);
}
return num_matches;
}
uint32_t SymbolFileDWARF::FindFunctions(const RegularExpression &regex,
bool include_inlines, bool append,
void SymbolFileDWARF::FindFunctions(const RegularExpression &regex,
bool include_inlines,
SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
@ -2320,22 +2310,13 @@ uint32_t SymbolFileDWARF::FindFunctions(const RegularExpression &regex,
if (log) {
GetObjectFile()->GetModule()->LogMessage(
log,
"SymbolFileDWARF::FindFunctions (regex=\"%s\", append=%u, sc_list)",
regex.GetText().str().c_str(), append);
log, "SymbolFileDWARF::FindFunctions (regex=\"%s\", sc_list)",
regex.GetText().str().c_str());
}
// If we aren't appending the results to this list, then clear the list
if (!append)
sc_list.Clear();
DWARFDebugInfo *info = DebugInfo();
if (!info)
return 0;
// Remember how many sc_list are in the list before we search in case we are
// appending the results to a variable list.
uint32_t original_size = sc_list.GetSize();
return;
DIEArray offsets;
m_index->GetFunctions(regex, offsets);
@ -2350,9 +2331,6 @@ uint32_t SymbolFileDWARF::FindFunctions(const RegularExpression &regex,
if (resolved_dies.insert(die.GetDIE()).second)
ResolveFunction(die, include_inlines, sc_list);
}
// Return the number of variable that were appended to the list
return sc_list.GetSize() - original_size;
}
void SymbolFileDWARF::GetMangledNamesForFunction(

View File

@ -157,24 +157,24 @@ public:
lldb::SymbolContextItem resolve_scope,
lldb_private::SymbolContextList &sc_list) override;
uint32_t
void
FindGlobalVariables(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
uint32_t FindGlobalVariables(const lldb_private::RegularExpression &regex,
void FindGlobalVariables(const lldb_private::RegularExpression &regex,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
uint32_t
FindFunctions(lldb_private::ConstString name,
void FindFunctions(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask, bool include_inlines,
bool append, lldb_private::SymbolContextList &sc_list) override;
lldb::FunctionNameType name_type_mask,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) override;
uint32_t FindFunctions(const lldb_private::RegularExpression &regex,
bool include_inlines, bool append,
void FindFunctions(const lldb_private::RegularExpression &regex,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) override;
void GetMangledNamesForFunction(

View File

@ -824,12 +824,11 @@ uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext(
return sc_list.GetSize() - initial;
}
uint32_t SymbolFileDWARFDebugMap::PrivateFindGlobalVariables(
void SymbolFileDWARFDebugMap::PrivateFindGlobalVariables(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
const std::vector<uint32_t>
&indexes, // Indexes into the symbol table that match "name"
uint32_t max_matches, VariableList &variables) {
const uint32_t original_size = variables.GetSize();
const size_t match_count = indexes.size();
for (size_t i = 0; i < match_count; ++i) {
uint32_t oso_idx;
@ -838,29 +837,26 @@ uint32_t SymbolFileDWARFDebugMap::PrivateFindGlobalVariables(
if (comp_unit_info) {
SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
if (oso_dwarf) {
if (oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches,
variables))
oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches,
variables);
if (variables.GetSize() > max_matches)
break;
}
}
}
return variables.GetSize() - original_size;
}
uint32_t SymbolFileDWARFDebugMap::FindGlobalVariables(
void SymbolFileDWARFDebugMap::FindGlobalVariables(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
// Remember how many variables are in the list before we search.
const uint32_t original_size = variables.GetSize();
uint32_t total_matches = 0;
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
const uint32_t oso_matches = oso_dwarf->FindGlobalVariables(
name, parent_decl_ctx, max_matches, variables);
const uint32_t old_size = variables.GetSize();
oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches,
variables);
const uint32_t oso_matches = variables.GetSize() - old_size;
if (oso_matches > 0) {
total_matches += oso_matches;
@ -879,23 +875,18 @@ uint32_t SymbolFileDWARFDebugMap::FindGlobalVariables(
return false;
});
// Return the number of variable that were appended to the list
return variables.GetSize() - original_size;
}
uint32_t
SymbolFileDWARFDebugMap::FindGlobalVariables(const RegularExpression &regex,
uint32_t max_matches,
void SymbolFileDWARFDebugMap::FindGlobalVariables(
const RegularExpression &regex, uint32_t max_matches,
VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
// Remember how many variables are in the list before we search.
const uint32_t original_size = variables.GetSize();
uint32_t total_matches = 0;
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
const uint32_t oso_matches =
const uint32_t old_size = variables.GetSize();
oso_dwarf->FindGlobalVariables(regex, max_matches, variables);
const uint32_t oso_matches = variables.GetSize() - old_size;
if (oso_matches > 0) {
total_matches += oso_matches;
@ -914,9 +905,6 @@ SymbolFileDWARFDebugMap::FindGlobalVariables(const RegularExpression &regex,
return false;
});
// Return the number of variable that were appended to the list
return variables.GetSize() - original_size;
}
int SymbolFileDWARFDebugMap::SymbolContainsSymbolWithIndex(
@ -1012,9 +1000,9 @@ static void RemoveFunctionsWithModuleNotEqualTo(const ModuleSP &module_sp,
}
}
uint32_t SymbolFileDWARFDebugMap::FindFunctions(
void SymbolFileDWARFDebugMap::FindFunctions(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines, bool append,
FunctionNameType name_type_mask, bool include_inlines,
SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
@ -1022,28 +1010,20 @@ uint32_t SymbolFileDWARFDebugMap::FindFunctions(
"SymbolFileDWARFDebugMap::FindFunctions (name = %s)",
name.GetCString());
uint32_t initial_size = 0;
if (append)
initial_size = sc_list.GetSize();
else
sc_list.Clear();
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
uint32_t sc_idx = sc_list.GetSize();
if (oso_dwarf->FindFunctions(name, parent_decl_ctx, name_type_mask,
include_inlines, true, sc_list)) {
oso_dwarf->FindFunctions(name, parent_decl_ctx, name_type_mask,
include_inlines, sc_list);
if (!sc_list.IsEmpty()) {
RemoveFunctionsWithModuleNotEqualTo(m_objfile_sp->GetModule(), sc_list,
sc_idx);
}
return false;
});
return sc_list.GetSize() - initial_size;
}
uint32_t SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression &regex,
void SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression &regex,
bool include_inlines,
bool append,
SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
@ -1051,23 +1031,16 @@ uint32_t SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression &regex,
"SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')",
regex.GetText().str().c_str());
uint32_t initial_size = 0;
if (append)
initial_size = sc_list.GetSize();
else
sc_list.Clear();
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
uint32_t sc_idx = sc_list.GetSize();
if (oso_dwarf->FindFunctions(regex, include_inlines, true, sc_list)) {
oso_dwarf->FindFunctions(regex, include_inlines, sc_list);
if (!sc_list.IsEmpty()) {
RemoveFunctionsWithModuleNotEqualTo(m_objfile_sp->GetModule(), sc_list,
sc_idx);
}
return false;
});
return sc_list.GetSize() - initial_size;
}
void SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope,

View File

@ -92,21 +92,21 @@ public:
bool check_inlines,
lldb::SymbolContextItem resolve_scope,
lldb_private::SymbolContextList &sc_list) override;
uint32_t
void
FindGlobalVariables(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
uint32_t FindGlobalVariables(const lldb_private::RegularExpression &regex,
void FindGlobalVariables(const lldb_private::RegularExpression &regex,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
uint32_t
FindFunctions(lldb_private::ConstString name,
void FindFunctions(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask, bool include_inlines,
bool append, lldb_private::SymbolContextList &sc_list) override;
uint32_t FindFunctions(const lldb_private::RegularExpression &regex,
bool include_inlines, bool append,
lldb::FunctionNameType name_type_mask,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) override;
void FindFunctions(const lldb_private::RegularExpression &regex,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) override;
void
FindTypes(lldb_private::ConstString name,
@ -236,7 +236,7 @@ protected:
static int SymbolContainsSymbolWithID(lldb::user_id_t *symbol_idx_ptr,
const CompileUnitInfo *comp_unit_info);
uint32_t PrivateFindGlobalVariables(
void PrivateFindGlobalVariables(
lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const std::vector<uint32_t> &name_symbol_indexes, uint32_t max_matches,

View File

@ -1179,7 +1179,7 @@ size_t SymbolFileNativePDB::ParseBlocksRecursive(Function &func) {
void SymbolFileNativePDB::DumpClangAST(Stream &s) { m_ast->Dump(s); }
uint32_t SymbolFileNativePDB::FindGlobalVariables(
void SymbolFileNativePDB::FindGlobalVariables(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@ -1204,17 +1204,16 @@ uint32_t SymbolFileNativePDB::FindGlobalVariables(
continue;
}
}
return variables.GetSize();
}
uint32_t SymbolFileNativePDB::FindFunctions(
void SymbolFileNativePDB::FindFunctions(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines, bool append,
FunctionNameType name_type_mask, bool include_inlines,
SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
// For now we only support lookup by method name.
if (!(name_type_mask & eFunctionNameTypeMethod))
return 0;
return;
using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
@ -1239,15 +1238,11 @@ uint32_t SymbolFileNativePDB::FindFunctions(
sc_list.Append(sc);
}
return sc_list.GetSize();
}
uint32_t SymbolFileNativePDB::FindFunctions(const RegularExpression &regex,
bool include_inlines, bool append,
SymbolContextList &sc_list) {
return 0;
}
void SymbolFileNativePDB::FindFunctions(const RegularExpression &regex,
bool include_inlines,
SymbolContextList &sc_list) {}
void SymbolFileNativePDB::FindTypes(
ConstString name, const CompilerDeclContext *parent_decl_ctx,

View File

@ -88,7 +88,7 @@ public:
size_t ParseBlocksRecursive(Function &func) override;
uint32_t FindGlobalVariables(ConstString name,
void FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
VariableList &variables) override;
@ -117,14 +117,13 @@ public:
void GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask,
TypeList &type_list) override;
uint32_t FindFunctions(ConstString name,
void FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, bool append,
SymbolContextList &sc_list) override;
bool include_inlines, SymbolContextList &sc_list) override;
uint32_t FindFunctions(const RegularExpression &regex, bool include_inlines,
bool append, SymbolContextList &sc_list) override;
void FindFunctions(const RegularExpression &regex, bool include_inlines,
SymbolContextList &sc_list) override;
void FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,

View File

@ -1097,19 +1097,19 @@ SymbolFilePDB::ParseVariables(const lldb_private::SymbolContext &sc,
return num_added;
}
uint32_t SymbolFilePDB::FindGlobalVariables(
void SymbolFilePDB::FindGlobalVariables(
lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, lldb_private::VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
return 0;
return;
if (name.IsEmpty())
return 0;
return;
auto results = m_global_scope_up->findAllChildren<PDBSymbolData>();
if (!results)
return 0;
return;
uint32_t matches = 0;
size_t old_size = variables.GetSize();
@ -1138,20 +1138,17 @@ uint32_t SymbolFilePDB::FindGlobalVariables(
ParseVariables(sc, *pdb_data, &variables);
matches = variables.GetSize() - old_size;
}
return matches;
}
uint32_t
SymbolFilePDB::FindGlobalVariables(const lldb_private::RegularExpression &regex,
uint32_t max_matches,
void SymbolFilePDB::FindGlobalVariables(
const lldb_private::RegularExpression &regex, uint32_t max_matches,
lldb_private::VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (!regex.IsValid())
return 0;
return;
auto results = m_global_scope_up->findAllChildren<PDBSymbolData>();
if (!results)
return 0;
return;
uint32_t matches = 0;
size_t old_size = variables.GetSize();
@ -1176,8 +1173,6 @@ SymbolFilePDB::FindGlobalVariables(const lldb_private::RegularExpression &regex,
ParseVariables(sc, *pdb_data, &variables);
matches = variables.GetSize() - old_size;
}
return matches;
}
bool SymbolFilePDB::ResolveFunction(const llvm::pdb::PDBSymbolFunc &pdb_func,
@ -1299,24 +1294,21 @@ void SymbolFilePDB::CacheFunctionNames() {
m_func_base_names.SizeToFit();
}
uint32_t SymbolFilePDB::FindFunctions(
void SymbolFilePDB::FindFunctions(
lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines, bool append,
FunctionNameType name_type_mask, bool include_inlines,
lldb_private::SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (!append)
sc_list.Clear();
lldbassert((name_type_mask & eFunctionNameTypeAuto) == 0);
if (name_type_mask == eFunctionNameTypeNone)
return 0;
return;
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
return 0;
return;
if (name.IsEmpty())
return 0;
return;
auto old_size = sc_list.GetSize();
if (name_type_mask & eFunctionNameTypeFull ||
name_type_mask & eFunctionNameTypeBase ||
name_type_mask & eFunctionNameTypeMethod) {
@ -1346,25 +1338,19 @@ uint32_t SymbolFilePDB::FindFunctions(
ResolveFn(m_func_base_names);
ResolveFn(m_func_method_names);
}
if (name_type_mask & eFunctionNameTypeBase) {
if (name_type_mask & eFunctionNameTypeBase)
ResolveFn(m_func_base_names);
}
if (name_type_mask & eFunctionNameTypeMethod) {
if (name_type_mask & eFunctionNameTypeMethod)
ResolveFn(m_func_method_names);
}
}
return sc_list.GetSize() - old_size;
}
uint32_t
SymbolFilePDB::FindFunctions(const lldb_private::RegularExpression &regex,
bool include_inlines, bool append,
void SymbolFilePDB::FindFunctions(const lldb_private::RegularExpression &regex,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (!append)
sc_list.Clear();
if (!regex.IsValid())
return 0;
return;
auto old_size = sc_list.GetSize();
CacheFunctionNames();
@ -1383,8 +1369,6 @@ SymbolFilePDB::FindFunctions(const lldb_private::RegularExpression &regex,
};
ResolveFn(m_func_full_names);
ResolveFn(m_func_base_names);
return sc_list.GetSize() - old_size;
}
void SymbolFilePDB::GetMangledNamesForFunction(

View File

@ -99,24 +99,24 @@ public:
lldb::SymbolContextItem resolve_scope,
lldb_private::SymbolContextList &sc_list) override;
uint32_t
void
FindGlobalVariables(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
uint32_t FindGlobalVariables(const lldb_private::RegularExpression &regex,
void FindGlobalVariables(const lldb_private::RegularExpression &regex,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
uint32_t
FindFunctions(lldb_private::ConstString name,
void FindFunctions(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask, bool include_inlines,
bool append, lldb_private::SymbolContextList &sc_list) override;
lldb::FunctionNameType name_type_mask,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) override;
uint32_t FindFunctions(const lldb_private::RegularExpression &regex,
bool include_inlines, bool append,
void FindFunctions(const lldb_private::RegularExpression &regex,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) override;
void GetMangledNamesForFunction(

View File

@ -579,9 +579,9 @@ bool SystemRuntimeMacOSX::BacktraceRecordingHeadersInitialized() {
static ConstString introspection_dispatch_queue_info_version(
"__introspection_dispatch_queue_info_version");
SymbolContextList sc_list;
if (m_process->GetTarget().GetImages().FindSymbolsWithNameAndType(
introspection_dispatch_queue_info_version, eSymbolTypeData, sc_list) >
0) {
m_process->GetTarget().GetImages().FindSymbolsWithNameAndType(
introspection_dispatch_queue_info_version, eSymbolTypeData, sc_list);
if (!sc_list.IsEmpty()) {
SymbolContext sc;
sc_list.GetContextAtIndex(0, sc);
AddressRange addr_range;
@ -593,9 +593,9 @@ bool SystemRuntimeMacOSX::BacktraceRecordingHeadersInitialized() {
static ConstString introspection_dispatch_queue_info_data_offset(
"__introspection_dispatch_queue_info_data_offset");
if (m_process->GetTarget().GetImages().FindSymbolsWithNameAndType(
introspection_dispatch_queue_info_data_offset, eSymbolTypeData,
sc_list) > 0) {
m_process->GetTarget().GetImages().FindSymbolsWithNameAndType(
introspection_dispatch_queue_info_data_offset, eSymbolTypeData, sc_list);
if (!sc_list.IsEmpty()) {
SymbolContext sc;
sc_list.GetContextAtIndex(0, sc);
AddressRange addr_range;
@ -607,9 +607,9 @@ bool SystemRuntimeMacOSX::BacktraceRecordingHeadersInitialized() {
static ConstString introspection_dispatch_item_info_version(
"__introspection_dispatch_item_info_version");
if (m_process->GetTarget().GetImages().FindSymbolsWithNameAndType(
introspection_dispatch_item_info_version, eSymbolTypeData, sc_list) >
0) {
m_process->GetTarget().GetImages().FindSymbolsWithNameAndType(
introspection_dispatch_item_info_version, eSymbolTypeData, sc_list);
if (!sc_list.IsEmpty()) {
SymbolContext sc;
sc_list.GetContextAtIndex(0, sc);
AddressRange addr_range;
@ -621,9 +621,9 @@ bool SystemRuntimeMacOSX::BacktraceRecordingHeadersInitialized() {
static ConstString introspection_dispatch_item_info_data_offset(
"__introspection_dispatch_item_info_data_offset");
if (m_process->GetTarget().GetImages().FindSymbolsWithNameAndType(
introspection_dispatch_item_info_data_offset, eSymbolTypeData,
sc_list) > 0) {
m_process->GetTarget().GetImages().FindSymbolsWithNameAndType(
introspection_dispatch_item_info_data_offset, eSymbolTypeData, sc_list);
if (!sc_list.IsEmpty()) {
SymbolContext sc;
sc_list.GetContextAtIndex(0, sc);
AddressRange addr_range;

View File

@ -149,8 +149,8 @@ void CallEdge::ParseSymbolFileAndResolve(ModuleList &images) {
auto resolve_lazy_callee = [&]() -> Function * {
ConstString callee_name{lazy_callee.symbol_name};
SymbolContextList sc_list;
size_t num_matches =
images.FindFunctionSymbols(callee_name, eFunctionNameTypeAuto, sc_list);
size_t num_matches = sc_list.GetSize();
if (num_matches == 0 || !sc_list[0].symbol) {
LLDB_LOG(log, "CallEdge: Found no symbols for {0}, cannot resolve it",
callee_name);

View File

@ -102,36 +102,24 @@ uint32_t SymbolFile::ResolveSymbolContext(const FileSpec &file_spec,
return 0;
}
uint32_t
SymbolFile::FindGlobalVariables(ConstString name,
void SymbolFile::FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
return 0;
}
uint32_t SymbolFile::FindGlobalVariables(const RegularExpression &regex,
uint32_t max_matches,
VariableList &variables) {
return 0;
}
VariableList &variables) {}
uint32_t SymbolFile::FindFunctions(ConstString name,
void SymbolFile::FindGlobalVariables(const RegularExpression &regex,
uint32_t max_matches,
VariableList &variables) {}
void SymbolFile::FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, bool append,
SymbolContextList &sc_list) {
if (!append)
sc_list.Clear();
return 0;
}
bool include_inlines,
SymbolContextList &sc_list) {}
uint32_t SymbolFile::FindFunctions(const RegularExpression &regex,
bool include_inlines, bool append,
SymbolContextList &sc_list) {
if (!append)
sc_list.Clear();
return 0;
}
void SymbolFile::FindFunctions(const RegularExpression &regex,
bool include_inlines,
SymbolContextList &sc_list) {}
void SymbolFile::GetMangledNamesForFunction(
const std::string &scope_qualified_name,

View File

@ -738,7 +738,7 @@ Symbol *Symtab::FindSymbolWithType(SymbolType symbol_type,
return nullptr;
}
size_t
void
Symtab::FindAllSymbolsWithNameAndType(ConstString name,
SymbolType symbol_type,
std::vector<uint32_t> &symbol_indexes) {
@ -756,10 +756,9 @@ Symtab::FindAllSymbolsWithNameAndType(ConstString name,
// the symbols and match the symbol_type if any was given.
AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_indexes);
}
return symbol_indexes.size();
}
size_t Symtab::FindAllSymbolsWithNameAndType(
void Symtab::FindAllSymbolsWithNameAndType(
ConstString name, SymbolType symbol_type, Debug symbol_debug_type,
Visibility symbol_visibility, std::vector<uint32_t> &symbol_indexes) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
@ -777,10 +776,9 @@ size_t Symtab::FindAllSymbolsWithNameAndType(
AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_debug_type,
symbol_visibility, symbol_indexes);
}
return symbol_indexes.size();
}
size_t Symtab::FindAllSymbolsMatchingRexExAndType(
void Symtab::FindAllSymbolsMatchingRexExAndType(
const RegularExpression &regex, SymbolType symbol_type,
Debug symbol_debug_type, Visibility symbol_visibility,
std::vector<uint32_t> &symbol_indexes) {
@ -788,7 +786,6 @@ size_t Symtab::FindAllSymbolsMatchingRexExAndType(
AppendSymbolIndexesMatchingRegExAndType(regex, symbol_type, symbol_debug_type,
symbol_visibility, symbol_indexes);
return symbol_indexes.size();
}
Symbol *Symtab::FindFirstSymbolWithNameAndType(ConstString name,
@ -1024,10 +1021,8 @@ void Symtab::SymbolIndicesToSymbolContextList(
}
}
size_t Symtab::FindFunctionSymbols(ConstString name,
uint32_t name_type_mask,
void Symtab::FindFunctionSymbols(ConstString name, uint32_t name_type_mask,
SymbolContextList &sc_list) {
size_t count = 0;
std::vector<uint32_t> symbol_indexes;
// eFunctionNameTypeAuto should be pre-resolved by a call to
@ -1108,11 +1103,8 @@ size_t Symtab::FindFunctionSymbols(ConstString name,
symbol_indexes.erase(
std::unique(symbol_indexes.begin(), symbol_indexes.end()),
symbol_indexes.end());
count = symbol_indexes.size();
SymbolIndicesToSymbolContextList(symbol_indexes, sc_list);
}
return count;
}
const Symbol *Symtab::GetParent(Symbol *child_symbol) const {

View File

@ -1648,11 +1648,11 @@ bool Target::ModuleIsExcludedForUnconstrainedSearches(
if (GetBreakpointsConsultPlatformAvoidList()) {
ModuleList matchingModules;
ModuleSpec module_spec(module_file_spec);
size_t num_modules = GetImages().FindModules(module_spec, matchingModules);
GetImages().FindModules(module_spec, matchingModules);
size_t num_modules = matchingModules.GetSize();
// If there is more than one module for this file spec, only return true if
// ALL the modules are on the
// black list.
// If there is more than one module for this file spec, only
// return true if ALL the modules are on the black list.
if (num_modules > 0) {
for (size_t i = 0; i < num_modules; i++) {
if (!ModuleIsExcludedForUnconstrainedSearches(
@ -2059,13 +2059,11 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
module_spec_copy.GetUUID().Clear();
ModuleList found_modules;
size_t num_found =
m_images.FindModules(module_spec_copy, found_modules);
if (num_found == 1) {
if (found_modules.GetSize() == 1)
old_module_sp = found_modules.GetModuleAtIndex(0);
}
}
}
// Preload symbols outside of any lock, so hopefully we can do this for
// each library in parallel.

View File

@ -436,7 +436,8 @@ Error opts::symbols::findFunctions(lldb_private::Module &Module) {
} else if (Regex) {
RegularExpression RE(Name);
assert(RE.IsValid());
Symfile.FindFunctions(RE, true, false, List);
List.Clear();
Symfile.FindFunctions(RE, true, List);
} else {
Expected<CompilerDeclContext> ContextOr = getDeclContext(Symfile);
if (!ContextOr)
@ -444,8 +445,9 @@ Error opts::symbols::findFunctions(lldb_private::Module &Module) {
CompilerDeclContext *ContextPtr =
ContextOr->IsValid() ? &*ContextOr : nullptr;
List.Clear();
Symfile.FindFunctions(ConstString(Name), ContextPtr, getFunctionNameFlags(),
true, false, List);
true, List);
}
outs() << formatv("Found {0} functions:\n", List.GetSize());
StreamString Stream;

View File

@ -163,7 +163,8 @@ Symbols:
auto Count = [M](const char *Name, FunctionNameType Type) -> int {
SymbolContextList SymList;
return M->FindFunctionSymbols(ConstString(Name), Type, SymList);
M->FindFunctionSymbols(ConstString(Name), Type, SymList);
return SymList.GetSize();
};
// Unmangled

View File

@ -129,8 +129,9 @@ void ModuleCacheTest::TryGetAndPut(const FileSpec &cache_dir,
ASSERT_TRUE(bool(module_sp));
SymbolContextList sc_list;
EXPECT_EQ(1u, module_sp->FindFunctionSymbols(ConstString("boom"),
eFunctionNameTypeFull, sc_list));
module_sp->FindFunctionSymbols(ConstString("boom"), eFunctionNameTypeFull,
sc_list);
EXPECT_EQ(1u, sc_list.GetSize());
EXPECT_STREQ(GetDummyRemotePath().GetCString(),
module_sp->GetPlatformFileSpec().GetCString());
EXPECT_STREQ(module_uuid, module_sp->GetUUID().GetAsString().c_str());