aboutsummaryrefslogtreecommitdiffstats
path: root/source/API/SBTarget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/API/SBTarget.cpp')
-rw-r--r--source/API/SBTarget.cpp103
1 files changed, 46 insertions, 57 deletions
diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp
index 5e87eb6273b3..1d13087eef69 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -44,11 +44,11 @@
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Host/Host.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/DeclVendor.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/Language.h"
@@ -218,7 +218,7 @@ SBStructuredData SBTarget::GetStatistics() {
if (!target_sp)
return LLDB_RECORD_RESULT(data);
- auto stats_up = llvm::make_unique<StructuredData::Dictionary>();
+ auto stats_up = std::make_unique<StructuredData::Dictionary>();
int i = 0;
for (auto &Entry : target_sp->GetStatistics()) {
std::string Desc = lldb_private::GetStatDescription(
@@ -960,8 +960,8 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(
const LazyBool skip_prologue = eLazyBoolCalculate;
sb_bp = target_sp->CreateFuncRegexBreakpoint(
- module_list.get(), comp_unit_list.get(), regexp, symbol_language,
- skip_prologue, internal, hardware);
+ module_list.get(), comp_unit_list.get(), std::move(regexp),
+ symbol_language, skip_prologue, internal, hardware);
}
return LLDB_RECORD_RESULT(sb_bp);
@@ -1061,8 +1061,8 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
}
sb_bp = target_sp->CreateSourceRegexBreakpoint(
- module_list.get(), source_file_list.get(), func_names_set, regexp,
- false, hardware, move_to_nearest_code);
+ module_list.get(), source_file_list.get(), func_names_set,
+ std::move(regexp), false, hardware, move_to_nearest_code);
}
return LLDB_RECORD_RESULT(sb_bp);
@@ -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;
}
}
@@ -1858,11 +1853,11 @@ lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
}
// No matches, search for basic typename matches
- ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
- if (clang_ast)
- return LLDB_RECORD_RESULT(SBType(ClangASTContext::GetBasicType(
- clang_ast->getASTContext(), const_typename)));
+ for (auto *type_system : target_sp->GetScratchTypeSystems())
+ if (auto type = type_system->GetBuiltinTypeByName(const_typename))
+ return LLDB_RECORD_RESULT(SBType(type));
}
+
return LLDB_RECORD_RESULT(SBType());
}
@@ -1872,10 +1867,9 @@ SBType SBTarget::GetBasicType(lldb::BasicType type) {
TargetSP target_sp(GetSP());
if (target_sp) {
- ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
- if (clang_ast)
- return LLDB_RECORD_RESULT(SBType(
- ClangASTContext::GetBasicType(clang_ast->getASTContext(), type)));
+ for (auto *type_system : target_sp->GetScratchTypeSystems())
+ if (auto compiler_type = type_system->GetBasicTypeFromAST(type))
+ return LLDB_RECORD_RESULT(SBType(compiler_type));
}
return LLDB_RECORD_RESULT(SBType());
}
@@ -1892,16 +1886,13 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
bool exact_match = false;
TypeList type_list;
llvm::DenseSet<SymbolFile *> searched_symbol_files;
- uint32_t num_matches =
- images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX,
- searched_symbol_files, type_list);
+ images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX,
+ searched_symbol_files, type_list);
- if (num_matches > 0) {
- for (size_t idx = 0; idx < num_matches; idx++) {
- TypeSP type_sp(type_list.GetTypeAtIndex(idx));
- if (type_sp)
- sb_type_list.Append(SBType(type_sp));
- }
+ for (size_t idx = 0; idx < type_list.GetSize(); idx++) {
+ TypeSP type_sp(type_list.GetTypeAtIndex(idx));
+ if (type_sp)
+ sb_type_list.Append(SBType(type_sp));
}
// Try the loaded language runtimes
@@ -1918,10 +1909,10 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
if (sb_type_list.GetSize() == 0) {
// No matches, search for basic typename matches
- ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
- if (clang_ast)
- sb_type_list.Append(SBType(ClangASTContext::GetBasicType(
- clang_ast->getASTContext(), const_typename)));
+ for (auto *type_system : target_sp->GetScratchTypeSystems())
+ if (auto compiler_type =
+ type_system->GetBuiltinTypeByName(const_typename))
+ sb_type_list.Append(SBType(compiler_type));
}
}
return LLDB_RECORD_RESULT(sb_type_list);
@@ -1937,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)
@@ -1974,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)
@@ -2291,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);
}
@@ -2355,10 +2344,10 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr,
expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
}
}
- if (expr_log)
- expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is "
- "%s, summary %s **",
- expr_result.GetValue(), expr_result.GetSummary());
+ LLDB_LOGF(expr_log,
+ "** [SBTarget::EvaluateExpression] Expression result is "
+ "%s, summary %s **",
+ expr_result.GetValue(), expr_result.GetSummary());
return LLDB_RECORD_RESULT(expr_result);
}