aboutsummaryrefslogtreecommitdiffstats
path: root/source/Target/Target.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Target/Target.cpp')
-rw-r--r--source/Target/Target.cpp1127
1 files changed, 500 insertions, 627 deletions
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 4941cb585c55..4b9a1b77ad16 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -71,7 +71,7 @@ Target::Arch::Arch(const ArchSpec &spec)
: m_spec(spec),
m_plugin_up(PluginManager::CreateArchitectureInstance(spec)) {}
-const Target::Arch& Target::Arch::operator=(const ArchSpec &spec) {
+const Target::Arch &Target::Arch::operator=(const ArchSpec &spec) {
m_spec = spec;
m_plugin_up = PluginManager::CreateArchitectureInstance(spec);
return *this;
@@ -106,21 +106,19 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch,
CheckInWithManager();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p Target::Target()", static_cast<void *>(this));
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT),
+ "{0} Target::Target()", static_cast<void *>(this));
if (target_arch.IsValid()) {
- LogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET,
- "Target::Target created with architecture %s (%s)",
- target_arch.GetArchitectureName(),
- target_arch.GetTriple().getTriple().c_str());
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET),
+ "Target::Target created with architecture {0} ({1})",
+ target_arch.GetArchitectureName(),
+ target_arch.GetTriple().getTriple().c_str());
}
}
Target::~Target() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p Target::~Target()", static_cast<void *>(this));
+ LLDB_LOG(log, "{0} Target::~Target()", static_cast<void *>(this));
DeleteCurrentProcess();
}
@@ -137,10 +135,9 @@ void Target::PrimeFromDummyTarget(Target *target) {
BreakpointSP new_bp(new Breakpoint(*this, *breakpoint_sp.get()));
AddBreakpoint(new_bp, false);
}
-
- for (auto bp_name_entry : target->m_breakpoint_names)
- {
-
+
+ for (auto bp_name_entry : target->m_breakpoint_names) {
+
BreakpointName *new_bp_name = new BreakpointName(*bp_name_entry.second);
AddBreakpointName(new_bp_name);
}
@@ -209,13 +206,11 @@ const lldb::ProcessSP &Target::GetProcessSP() const { return m_process_sp; }
lldb::REPLSP Target::GetREPL(Status &err, lldb::LanguageType language,
const char *repl_options, bool can_create) {
if (language == eLanguageTypeUnknown) {
- std::set<LanguageType> repl_languages;
+ LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs();
- Language::GetLanguagesSupportingREPLs(repl_languages);
-
- if (repl_languages.size() == 1) {
- language = *repl_languages.begin();
- } else if (repl_languages.size() == 0) {
+ if (auto single_lang = repl_languages.GetSingularLanguage()) {
+ language = *single_lang;
+ } else if (repl_languages.Empty()) {
err.SetErrorStringWithFormat(
"LLDB isn't configured with REPL support for any languages.");
return REPLSP();
@@ -310,14 +305,14 @@ BreakpointSP Target::CreateSourceRegexBreakpoint(
const FileSpecList *containingModules,
const FileSpecList *source_file_spec_list,
const std::unordered_set<std::string> &function_names,
- RegularExpression &source_regex, bool internal, bool hardware,
+ RegularExpression source_regex, bool internal, bool hardware,
LazyBool move_to_nearest_code) {
SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList(
containingModules, source_file_spec_list));
if (move_to_nearest_code == eLazyBoolCalculate)
move_to_nearest_code = GetMoveToNearestCode() ? eLazyBoolYes : eLazyBoolNo;
BreakpointResolverSP resolver_sp(new BreakpointResolverFileRegex(
- nullptr, source_regex, function_names,
+ nullptr, std::move(source_regex), function_names,
!static_cast<bool>(move_to_nearest_code)));
return CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
@@ -552,7 +547,7 @@ SearchFilterSP Target::GetSearchFilterForModuleAndCUList(
BreakpointSP Target::CreateFuncRegexBreakpoint(
const FileSpecList *containingModules,
- const FileSpecList *containingSourceFiles, RegularExpression &func_regex,
+ const FileSpecList *containingSourceFiles, RegularExpression func_regex,
lldb::LanguageType requested_language, LazyBool skip_prologue,
bool internal, bool hardware) {
SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList(
@@ -561,7 +556,7 @@ BreakpointSP Target::CreateFuncRegexBreakpoint(
? GetSkipPrologue()
: static_cast<bool>(skip_prologue);
BreakpointResolverSP resolver_sp(new BreakpointResolverName(
- nullptr, func_regex, requested_language, 0, skip));
+ nullptr, std::move(func_regex), requested_language, 0, skip));
return CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
}
@@ -584,46 +579,40 @@ Target::CreateExceptionBreakpoint(enum lldb::LanguageType language,
return exc_bkpt_sp;
}
-lldb::BreakpointSP
-Target::CreateScriptedBreakpoint(const llvm::StringRef class_name,
- const FileSpecList *containingModules,
- const FileSpecList *containingSourceFiles,
- bool internal,
- bool request_hardware,
- StructuredData::ObjectSP extra_args_sp,
- Status *creation_error)
-{
+lldb::BreakpointSP Target::CreateScriptedBreakpoint(
+ const llvm::StringRef class_name, const FileSpecList *containingModules,
+ const FileSpecList *containingSourceFiles, bool internal,
+ bool request_hardware, StructuredData::ObjectSP extra_args_sp,
+ Status *creation_error) {
SearchFilterSP filter_sp;
-
+
lldb::SearchDepth depth = lldb::eSearchDepthTarget;
- bool has_files = containingSourceFiles && containingSourceFiles->GetSize() > 0;
+ bool has_files =
+ containingSourceFiles && containingSourceFiles->GetSize() > 0;
bool has_modules = containingModules && containingModules->GetSize() > 0;
-
+
if (has_files && has_modules) {
- filter_sp = GetSearchFilterForModuleAndCUList(
- containingModules, containingSourceFiles);
+ filter_sp = GetSearchFilterForModuleAndCUList(containingModules,
+ containingSourceFiles);
} else if (has_files) {
- filter_sp = GetSearchFilterForModuleAndCUList(
- nullptr, containingSourceFiles);
+ filter_sp =
+ GetSearchFilterForModuleAndCUList(nullptr, containingSourceFiles);
} else if (has_modules) {
filter_sp = GetSearchFilterForModuleList(containingModules);
} else {
filter_sp = std::make_shared<SearchFilterForUnconstrainedSearches>(
shared_from_this());
}
-
+
StructuredDataImpl *extra_args_impl = new StructuredDataImpl();
if (extra_args_sp)
extra_args_impl->SetObjectSP(extra_args_sp);
BreakpointResolverSP resolver_sp(new BreakpointResolverScripted(
- nullptr, class_name, depth, extra_args_impl,
- *GetDebugger().GetScriptInterpreter()));
+ nullptr, class_name, depth, extra_args_impl));
return CreateBreakpoint(filter_sp, resolver_sp, internal, false, true);
-
}
-
BreakpointSP Target::CreateBreakpoint(SearchFilterSP &filter_sp,
BreakpointResolverSP &resolver_sp,
bool internal, bool request_hardware,
@@ -651,8 +640,8 @@ void Target::AddBreakpoint(lldb::BreakpointSP bp_sp, bool internal) {
if (log) {
StreamString s;
bp_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
- log->Printf("Target::%s (internal = %s) => break_id = %s\n", __FUNCTION__,
- bp_sp->IsInternal() ? "yes" : "no", s.GetData());
+ LLDB_LOGF(log, "Target::%s (internal = %s) => break_id = %s\n",
+ __FUNCTION__, bp_sp->IsInternal() ? "yes" : "no", s.GetData());
}
bp_sp->ResolveBreakpoint();
@@ -662,71 +651,61 @@ void Target::AddBreakpoint(lldb::BreakpointSP bp_sp, bool internal) {
}
}
-void Target::AddNameToBreakpoint(BreakpointID &id,
- const char *name,
- Status &error)
- {
- BreakpointSP bp_sp
- = m_breakpoint_list.FindBreakpointByID(id.GetBreakpointID());
- if (!bp_sp)
- {
- StreamString s;
- id.GetDescription(&s, eDescriptionLevelBrief);
- error.SetErrorStringWithFormat("Could not find breakpoint %s",
- s.GetData());
- return;
- }
- AddNameToBreakpoint(bp_sp, name, error);
- }
-
-void Target::AddNameToBreakpoint(BreakpointSP &bp_sp,
- const char *name,
- Status &error)
- {
- if (!bp_sp)
- return;
-
- BreakpointName *bp_name = FindBreakpointName(ConstString(name), true, error);
- if (!bp_name)
- return;
-
- bp_name->ConfigureBreakpoint(bp_sp);
- bp_sp->AddName(name);
- }
+void Target::AddNameToBreakpoint(BreakpointID &id, const char *name,
+ Status &error) {
+ BreakpointSP bp_sp =
+ m_breakpoint_list.FindBreakpointByID(id.GetBreakpointID());
+ if (!bp_sp) {
+ StreamString s;
+ id.GetDescription(&s, eDescriptionLevelBrief);
+ error.SetErrorStringWithFormat("Could not find breakpoint %s", s.GetData());
+ return;
+ }
+ AddNameToBreakpoint(bp_sp, name, error);
+}
+
+void Target::AddNameToBreakpoint(BreakpointSP &bp_sp, const char *name,
+ Status &error) {
+ if (!bp_sp)
+ return;
+
+ BreakpointName *bp_name = FindBreakpointName(ConstString(name), true, error);
+ if (!bp_name)
+ return;
+
+ bp_name->ConfigureBreakpoint(bp_sp);
+ bp_sp->AddName(name);
+}
void Target::AddBreakpointName(BreakpointName *bp_name) {
m_breakpoint_names.insert(std::make_pair(bp_name->GetName(), bp_name));
}
-BreakpointName *Target::FindBreakpointName(ConstString name,
- bool can_create,
- Status &error)
-{
+BreakpointName *Target::FindBreakpointName(ConstString name, bool can_create,
+ Status &error) {
BreakpointID::StringIsBreakpointName(name.GetStringRef(), error);
if (!error.Success())
return nullptr;
BreakpointNameList::iterator iter = m_breakpoint_names.find(name);
if (iter == m_breakpoint_names.end()) {
- if (!can_create)
- {
+ if (!can_create) {
error.SetErrorStringWithFormat("Breakpoint name \"%s\" doesn't exist and "
- "can_create is false.", name.AsCString());
+ "can_create is false.",
+ name.AsCString());
return nullptr;
}
- iter = m_breakpoint_names.insert(std::make_pair(name,
- new BreakpointName(name)))
- .first;
+ iter = m_breakpoint_names
+ .insert(std::make_pair(name, new BreakpointName(name)))
+ .first;
}
return (iter->second);
}
-void
-Target::DeleteBreakpointName(ConstString name)
-{
+void Target::DeleteBreakpointName(ConstString name) {
BreakpointNameList::iterator iter = m_breakpoint_names.find(name);
-
+
if (iter != m_breakpoint_names.end()) {
const char *name_cstr = name.AsCString();
m_breakpoint_names.erase(iter);
@@ -736,15 +715,13 @@ Target::DeleteBreakpointName(ConstString name)
}
void Target::RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp,
- ConstString name)
-{
+ ConstString name) {
bp_sp->RemoveName(name.AsCString());
}
-void Target::ConfigureBreakpointName(BreakpointName &bp_name,
- const BreakpointOptions &new_options,
- const BreakpointName::Permissions &new_permissions)
-{
+void Target::ConfigureBreakpointName(
+ BreakpointName &bp_name, const BreakpointOptions &new_options,
+ const BreakpointName::Permissions &new_permissions) {
bp_name.GetOptions().CopyOverSetOptions(new_options);
bp_name.GetPermissions().MergeInto(new_permissions);
ApplyNameToBreakpoints(bp_name);
@@ -752,15 +729,14 @@ void Target::ConfigureBreakpointName(BreakpointName &bp_name,
void Target::ApplyNameToBreakpoints(BreakpointName &bp_name) {
BreakpointList bkpts_with_name(false);
- m_breakpoint_list.FindBreakpointsByName(bp_name.GetName().AsCString(),
+ m_breakpoint_list.FindBreakpointsByName(bp_name.GetName().AsCString(),
bkpts_with_name);
for (auto bp_sp : bkpts_with_name.Breakpoints())
bp_name.ConfigureBreakpoint(bp_sp);
}
-void Target::GetBreakpointNames(std::vector<std::string> &names)
-{
+void Target::GetBreakpointNames(std::vector<std::string> &names) {
names.clear();
for (auto bp_name : m_breakpoint_names) {
names.push_back(bp_name.first.AsCString());
@@ -797,10 +773,10 @@ WatchpointSP Target::CreateWatchpoint(lldb::addr_t addr, size_t size,
const CompilerType *type, uint32_t kind,
Status &error) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("Target::%s (addr = 0x%8.8" PRIx64 " size = %" PRIu64
- " type = %u)\n",
- __FUNCTION__, addr, (uint64_t)size, kind);
+ LLDB_LOGF(log,
+ "Target::%s (addr = 0x%8.8" PRIx64 " size = %" PRIu64
+ " type = %u)\n",
+ __FUNCTION__, addr, (uint64_t)size, kind);
WatchpointSP wp_sp;
if (!ProcessIsValid()) {
@@ -855,10 +831,9 @@ WatchpointSP Target::CreateWatchpoint(lldb::addr_t addr, size_t size,
}
error = m_process_sp->EnableWatchpoint(wp_sp.get(), notify);
- if (log)
- log->Printf("Target::%s (creation of watchpoint %s with id = %u)\n",
- __FUNCTION__, error.Success() ? "succeeded" : "failed",
- wp_sp->GetID());
+ LLDB_LOGF(log, "Target::%s (creation of watchpoint %s with id = %u)\n",
+ __FUNCTION__, error.Success() ? "succeeded" : "failed",
+ wp_sp->GetID());
if (error.Fail()) {
// Enabling the watchpoint on the device side failed. Remove the said
@@ -875,22 +850,19 @@ WatchpointSP Target::CreateWatchpoint(lldb::addr_t addr, size_t size,
return wp_sp;
}
-void Target::RemoveAllowedBreakpoints ()
-{
+void Target::RemoveAllowedBreakpoints() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("Target::%s \n", __FUNCTION__);
+ LLDB_LOGF(log, "Target::%s \n", __FUNCTION__);
m_breakpoint_list.RemoveAllowed(true);
-
+
m_last_created_breakpoint.reset();
}
void Target::RemoveAllBreakpoints(bool internal_also) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("Target::%s (internal_also = %s)\n", __FUNCTION__,
- internal_also ? "yes" : "no");
+ LLDB_LOGF(log, "Target::%s (internal_also = %s)\n", __FUNCTION__,
+ internal_also ? "yes" : "no");
m_breakpoint_list.RemoveAll(true);
if (internal_also)
@@ -901,9 +873,8 @@ void Target::RemoveAllBreakpoints(bool internal_also) {
void Target::DisableAllBreakpoints(bool internal_also) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("Target::%s (internal_also = %s)\n", __FUNCTION__,
- internal_also ? "yes" : "no");
+ LLDB_LOGF(log, "Target::%s (internal_also = %s)\n", __FUNCTION__,
+ internal_also ? "yes" : "no");
m_breakpoint_list.SetEnabledAll(false);
if (internal_also)
@@ -912,17 +883,15 @@ void Target::DisableAllBreakpoints(bool internal_also) {
void Target::DisableAllowedBreakpoints() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("Target::%s", __FUNCTION__);
+ LLDB_LOGF(log, "Target::%s", __FUNCTION__);
m_breakpoint_list.SetEnabledAllowed(false);
}
void Target::EnableAllBreakpoints(bool internal_also) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("Target::%s (internal_also = %s)\n", __FUNCTION__,
- internal_also ? "yes" : "no");
+ LLDB_LOGF(log, "Target::%s (internal_also = %s)\n", __FUNCTION__,
+ internal_also ? "yes" : "no");
m_breakpoint_list.SetEnabledAll(true);
if (internal_also)
@@ -931,17 +900,15 @@ void Target::EnableAllBreakpoints(bool internal_also) {
void Target::EnableAllowedBreakpoints() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("Target::%s", __FUNCTION__);
+ LLDB_LOGF(log, "Target::%s", __FUNCTION__);
m_breakpoint_list.SetEnabledAllowed(true);
}
bool Target::RemoveBreakpointByID(break_id_t break_id) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
- break_id, LLDB_BREAK_ID_IS_INTERNAL(break_id) ? "yes" : "no");
+ LLDB_LOGF(log, "Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
+ break_id, LLDB_BREAK_ID_IS_INTERNAL(break_id) ? "yes" : "no");
if (DisableBreakpointByID(break_id)) {
if (LLDB_BREAK_ID_IS_INTERNAL(break_id))
@@ -960,9 +927,8 @@ bool Target::RemoveBreakpointByID(break_id_t break_id) {
bool Target::DisableBreakpointByID(break_id_t break_id) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
- break_id, LLDB_BREAK_ID_IS_INTERNAL(break_id) ? "yes" : "no");
+ LLDB_LOGF(log, "Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
+ break_id, LLDB_BREAK_ID_IS_INTERNAL(break_id) ? "yes" : "no");
BreakpointSP bp_sp;
@@ -979,9 +945,8 @@ bool Target::DisableBreakpointByID(break_id_t break_id) {
bool Target::EnableBreakpointByID(break_id_t break_id) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
- break_id, LLDB_BREAK_ID_IS_INTERNAL(break_id) ? "yes" : "no");
+ LLDB_LOGF(log, "Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
+ break_id, LLDB_BREAK_ID_IS_INTERNAL(break_id) ? "yes" : "no");
BreakpointSP bp_sp;
@@ -1031,10 +996,9 @@ Status Target::SerializeBreakpointsToFile(const FileSpec &file,
}
StreamFile out_file(path.c_str(),
- File::OpenOptions::eOpenOptionTruncate |
- File::OpenOptions::eOpenOptionWrite |
- File::OpenOptions::eOpenOptionCanCreate |
- File::OpenOptions::eOpenOptionCloseOnExec,
+ File::eOpenOptionTruncate | File::eOpenOptionWrite |
+ File::eOpenOptionCanCreate |
+ File::eOpenOptionCloseOnExec,
lldb::eFilePermissionsFileDefault);
if (!out_file.GetFile().IsValid()) {
error.SetErrorStringWithFormat("Unable to open output file: %s.",
@@ -1159,8 +1123,7 @@ Status Target::CreateBreakpointsFromFile(const FileSpec &file,
// to end operations.
bool Target::RemoveAllWatchpoints(bool end_to_end) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("Target::%s\n", __FUNCTION__);
+ LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
if (!end_to_end) {
m_watchpoint_list.RemoveAll(true);
@@ -1191,8 +1154,7 @@ bool Target::RemoveAllWatchpoints(bool end_to_end) {
// to end operations.
bool Target::DisableAllWatchpoints(bool end_to_end) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("Target::%s\n", __FUNCTION__);
+ LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
if (!end_to_end) {
m_watchpoint_list.SetEnabledAll(false);
@@ -1221,8 +1183,7 @@ bool Target::DisableAllWatchpoints(bool end_to_end) {
// to end operations.
bool Target::EnableAllWatchpoints(bool end_to_end) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("Target::%s\n", __FUNCTION__);
+ LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
if (!end_to_end) {
m_watchpoint_list.SetEnabledAll(true);
@@ -1250,8 +1211,7 @@ bool Target::EnableAllWatchpoints(bool end_to_end) {
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
bool Target::ClearAllWatchpointHitCounts() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("Target::%s\n", __FUNCTION__);
+ LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
size_t num_watchpoints = m_watchpoint_list.GetSize();
for (size_t i = 0; i < num_watchpoints; ++i) {
@@ -1267,8 +1227,7 @@ bool Target::ClearAllWatchpointHitCounts() {
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
bool Target::ClearAllWatchpointHistoricValues() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("Target::%s\n", __FUNCTION__);
+ LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
size_t num_watchpoints = m_watchpoint_list.GetSize();
for (size_t i = 0; i < num_watchpoints; ++i) {
@@ -1285,8 +1244,7 @@ bool Target::ClearAllWatchpointHistoricValues() {
// these operations.
bool Target::IgnoreAllWatchpoints(uint32_t ignore_count) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("Target::%s\n", __FUNCTION__);
+ LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
if (!ProcessIsValid())
return false;
@@ -1305,8 +1263,7 @@ bool Target::IgnoreAllWatchpoints(uint32_t ignore_count) {
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
bool Target::DisableWatchpointByID(lldb::watch_id_t watch_id) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
+ LLDB_LOGF(log, "Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
if (!ProcessIsValid())
return false;
@@ -1325,8 +1282,7 @@ bool Target::DisableWatchpointByID(lldb::watch_id_t watch_id) {
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
bool Target::EnableWatchpointByID(lldb::watch_id_t watch_id) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
+ LLDB_LOGF(log, "Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
if (!ProcessIsValid())
return false;
@@ -1345,8 +1301,7 @@ bool Target::EnableWatchpointByID(lldb::watch_id_t watch_id) {
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
bool Target::RemoveWatchpointByID(lldb::watch_id_t watch_id) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
+ LLDB_LOGF(log, "Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
WatchpointSP watch_to_remove_sp = m_watchpoint_list.FindByID(watch_id);
if (watch_to_remove_sp == m_last_created_watchpoint)
@@ -1363,8 +1318,7 @@ bool Target::RemoveWatchpointByID(lldb::watch_id_t watch_id) {
bool Target::IgnoreWatchpointByID(lldb::watch_id_t watch_id,
uint32_t ignore_count) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
+ LLDB_LOGF(log, "Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
if (!ProcessIsValid())
return false;
@@ -1399,19 +1353,18 @@ static void LoadScriptingResourceForModule(const ModuleSP &module_sp,
Target *target) {
Status error;
StreamString feedback_stream;
- if (module_sp &&
- !module_sp->LoadScriptingResourceInTarget(target, error,
- &feedback_stream)) {
+ if (module_sp && !module_sp->LoadScriptingResourceInTarget(
+ target, error, &feedback_stream)) {
if (error.AsCString())
- target->GetDebugger().GetErrorFile()->Printf(
+ target->GetDebugger().GetErrorStream().Printf(
"unable to load scripting data for module %s - error reported was "
"%s\n",
module_sp->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
error.AsCString());
}
if (feedback_stream.GetSize())
- target->GetDebugger().GetErrorFile()->Printf("%s\n",
- feedback_stream.GetData());
+ target->GetDebugger().GetErrorStream().Printf("%s\n",
+ feedback_stream.GetData());
}
void Target::ClearModules(bool delete_locations) {
@@ -1440,7 +1393,8 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
executable_sp->GetFileSpec().GetPath().c_str());
const bool notify = true;
- m_images.Append(executable_sp, notify); // The first image is our executable file
+ m_images.Append(executable_sp,
+ notify); // The first image is our executable file
// If we haven't set an architecture yet, reset our architecture based on
// what we found in the executable module.
@@ -1481,10 +1435,10 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
platform_dependent_file_spec = dependent_file_spec;
ModuleSpec module_spec(platform_dependent_file_spec, m_arch.GetSpec());
- ModuleSP image_module_sp(GetOrCreateModule(module_spec,
- false /* notify */));
+ ModuleSP image_module_sp(
+ GetOrCreateModule(module_spec, false /* notify */));
if (image_module_sp) {
- added_modules.AppendIfNeeded (image_module_sp, false);
+ added_modules.AppendIfNeeded(image_module_sp, false);
ObjectFile *objfile = image_module_sp->GetObjectFile();
if (objfile)
objfile->GetDependentModules(dependent_files);
@@ -1531,8 +1485,9 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, bool set_platform) {
bool arch_changed, vendor_changed, os_changed, os_ver_changed,
env_changed;
- m_arch.GetSpec().PiecewiseTripleCompare(other, arch_changed, vendor_changed,
- os_changed, os_ver_changed, env_changed);
+ m_arch.GetSpec().PiecewiseTripleCompare(other, arch_changed,
+ vendor_changed, os_changed,
+ os_ver_changed, env_changed);
if (!arch_changed && !vendor_changed && !os_changed && !env_changed)
replace_local_arch = false;
@@ -1554,10 +1509,9 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, bool set_platform) {
// If we have an executable file, try to reset the executable to the desired
// architecture
- if (log)
- log->Printf("Target::SetArchitecture changing architecture to %s (%s)",
- arch_spec.GetArchitectureName(),
- arch_spec.GetTriple().getTriple().c_str());
+ LLDB_LOGF(log, "Target::SetArchitecture changing architecture to %s (%s)",
+ arch_spec.GetArchitectureName(),
+ arch_spec.GetTriple().getTriple().c_str());
m_arch = other;
ModuleSP executable_sp = GetExecutableModule();
@@ -1565,16 +1519,15 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, bool set_platform) {
// Need to do something about unsetting breakpoints.
if (executable_sp) {
- if (log)
- log->Printf("Target::SetArchitecture Trying to select executable file "
- "architecture %s (%s)",
- arch_spec.GetArchitectureName(),
- arch_spec.GetTriple().getTriple().c_str());
+ LLDB_LOGF(log,
+ "Target::SetArchitecture Trying to select executable file "
+ "architecture %s (%s)",
+ arch_spec.GetArchitectureName(),
+ arch_spec.GetTriple().getTriple().c_str());
ModuleSpec module_spec(executable_sp->GetFileSpec(), other);
FileSpecList search_paths = GetExecutableSearchPaths();
Status error = ModuleList::GetSharedModule(module_spec, executable_sp,
- &search_paths,
- nullptr, nullptr);
+ &search_paths, nullptr, nullptr);
if (!error.Fail() && executable_sp) {
SetExecutableModule(executable_sp, eLoadDependentsYes);
@@ -1591,11 +1544,11 @@ bool Target::MergeArchitecture(const ArchSpec &arch_spec) {
// The current target arch is compatible with "arch_spec", see if we can
// improve our current architecture using bits from "arch_spec"
- if (log)
- log->Printf("Target::MergeArchitecture target has arch %s, merging with "
- "arch %s",
- m_arch.GetSpec().GetTriple().getTriple().c_str(),
- arch_spec.GetTriple().getTriple().c_str());
+ LLDB_LOGF(log,
+ "Target::MergeArchitecture target has arch %s, merging with "
+ "arch %s",
+ m_arch.GetSpec().GetTriple().getTriple().c_str(),
+ arch_spec.GetTriple().getTriple().c_str());
// Merge bits from arch_spec into "merged_arch" and set our architecture
ArchSpec merged_arch(m_arch.GetSpec());
@@ -1612,7 +1565,7 @@ bool Target::MergeArchitecture(const ArchSpec &arch_spec) {
void Target::NotifyWillClearList(const ModuleList &module_list) {}
void Target::NotifyModuleAdded(const ModuleList &module_list,
- const ModuleSP &module_sp) {
+ const ModuleSP &module_sp) {
// A module is being added to this target for the first time
if (m_valid) {
ModuleList my_module_list;
@@ -1622,7 +1575,7 @@ void Target::NotifyModuleAdded(const ModuleList &module_list,
}
void Target::NotifyModuleRemoved(const ModuleList &module_list,
- const ModuleSP &module_sp) {
+ const ModuleSP &module_sp) {
// A module is being removed from this target.
if (m_valid) {
ModuleList my_module_list;
@@ -1632,8 +1585,8 @@ void Target::NotifyModuleRemoved(const ModuleList &module_list,
}
void Target::NotifyModuleUpdated(const ModuleList &module_list,
- const ModuleSP &old_module_sp,
- const ModuleSP &new_module_sp) {
+ const ModuleSP &old_module_sp,
+ const ModuleSP &new_module_sp) {
// A module is replacing an already added module
if (m_valid) {
m_breakpoint_list.UpdateBreakpointsWhenModuleIsReplaced(old_module_sp,
@@ -1644,10 +1597,9 @@ void Target::NotifyModuleUpdated(const ModuleList &module_list,
}
void Target::NotifyModulesRemoved(lldb_private::ModuleList &module_list) {
- ModulesDidUnload (module_list, false);
+ ModulesDidUnload(module_list, false);
}
-
void Target::ModulesDidLoad(ModuleList &module_list) {
const size_t num_images = module_list.GetSize();
if (m_valid && num_images) {
@@ -1696,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(
@@ -1967,8 +1919,8 @@ bool Target::ReadPointerFromMemory(const Address &addr, bool prefer_file_cache,
Status &error, Address &pointer_addr) {
Scalar scalar;
if (ReadScalarIntegerFromMemory(addr, prefer_file_cache,
- m_arch.GetSpec().GetAddressByteSize(), false, scalar,
- error)) {
+ m_arch.GetSpec().GetAddressByteSize(), false,
+ scalar, error)) {
addr_t pointer_vm_addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
if (pointer_vm_addr != LLDB_INVALID_ADDRESS) {
SectionLoadList &section_load_list = GetSectionLoadList();
@@ -2021,8 +1973,8 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
transformed_spec.GetFileSpec().GetFilename() =
module_spec.GetFileSpec().GetFilename();
error = ModuleList::GetSharedModule(transformed_spec, module_sp,
- &search_paths,
- &old_module_sp, &did_create_module);
+ &search_paths, &old_module_sp,
+ &did_create_module);
}
}
@@ -2037,9 +1989,9 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
// cache.
if (module_spec.GetUUID().IsValid()) {
// We have a UUID, it is OK to check the global module list...
- error = ModuleList::GetSharedModule(module_spec, module_sp,
- &search_paths,
- &old_module_sp, &did_create_module);
+ error =
+ ModuleList::GetSharedModule(module_spec, module_sp, &search_paths,
+ &old_module_sp, &did_create_module);
}
if (!module_sp) {
@@ -2047,8 +1999,8 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
// module in the shared module cache.
if (m_platform_sp) {
error = m_platform_sp->GetSharedModule(
- module_spec, m_process_sp.get(), module_sp,
- &search_paths, &old_module_sp, &did_create_module);
+ module_spec, m_process_sp.get(), module_sp, &search_paths,
+ &old_module_sp, &did_create_module);
} else {
error.SetErrorString("no platform is currently set");
}
@@ -2107,11 +2059,9 @@ 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) {
+ m_images.FindModules(module_spec_copy, found_modules);
+ if (found_modules.GetSize() == 1)
old_module_sp = found_modules.GetModuleAtIndex(0);
- }
}
}
@@ -2120,9 +2070,8 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
if (GetPreloadSymbols())
module_sp->PreloadSymbols();
- if (old_module_sp &&
- m_images.GetIndexForModule(old_module_sp.get()) !=
- LLDB_INVALID_INDEX32) {
+ if (old_module_sp && m_images.GetIndexForModule(old_module_sp.get()) !=
+ LLDB_INVALID_INDEX32) {
m_images.ReplaceModule(old_module_sp, module_sp);
Module *old_module_ptr = old_module_sp.get();
old_module_sp.reset();
@@ -2164,34 +2113,28 @@ void Target::ImageSearchPathsChanged(const PathMappingList &path_list,
target->SetExecutableModule(exe_module_sp, eLoadDependentsYes);
}
-TypeSystem *Target::GetScratchTypeSystemForLanguage(Status *error,
- lldb::LanguageType language,
- bool create_on_demand) {
+llvm::Expected<TypeSystem &>
+Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
+ bool create_on_demand) {
if (!m_valid)
- return nullptr;
-
- if (error) {
- error->Clear();
- }
+ return llvm::make_error<llvm::StringError>("Invalid Target",
+ llvm::inconvertibleErrorCode());
if (language == eLanguageTypeMipsAssembler // GNU AS and LLVM use it for all
// assembly code
|| language == eLanguageTypeUnknown) {
- std::set<lldb::LanguageType> languages_for_types;
- std::set<lldb::LanguageType> languages_for_expressions;
+ LanguageSet languages_for_expressions =
+ Language::GetLanguagesSupportingTypeSystemsForExpressions();
- Language::GetLanguagesSupportingTypeSystems(languages_for_types,
- languages_for_expressions);
-
- if (languages_for_expressions.count(eLanguageTypeC)) {
+ if (languages_for_expressions[eLanguageTypeC]) {
language = eLanguageTypeC; // LLDB's default. Override by setting the
// target language.
} else {
- if (languages_for_expressions.empty()) {
- return nullptr;
- } else {
- language = *languages_for_expressions.begin();
- }
+ if (languages_for_expressions.Empty())
+ return llvm::make_error<llvm::StringError>(
+ "No expression support for any languages",
+ llvm::inconvertibleErrorCode());
+ language = (LanguageType)languages_for_expressions.bitvector.find_first();
}
}
@@ -2199,39 +2142,63 @@ TypeSystem *Target::GetScratchTypeSystemForLanguage(Status *error,
create_on_demand);
}
+std::vector<TypeSystem *> Target::GetScratchTypeSystems(bool create_on_demand) {
+ if (!m_valid)
+ return {};
+
+ std::vector<TypeSystem *> scratch_type_systems;
+
+ LanguageSet languages_for_expressions =
+ Language::GetLanguagesSupportingTypeSystemsForExpressions();
+
+ for (auto bit : languages_for_expressions.bitvector.set_bits()) {
+ auto language = (LanguageType)bit;
+ auto type_system_or_err =
+ GetScratchTypeSystemForLanguage(language, create_on_demand);
+ if (!type_system_or_err)
+ LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
+ type_system_or_err.takeError(),
+ "Language '{}' has expression support but no scratch type "
+ "system available",
+ Language::GetNameForLanguageType(language));
+ else
+ scratch_type_systems.emplace_back(&type_system_or_err.get());
+ }
+
+ return scratch_type_systems;
+}
+
PersistentExpressionState *
Target::GetPersistentExpressionStateForLanguage(lldb::LanguageType language) {
- TypeSystem *type_system =
- GetScratchTypeSystemForLanguage(nullptr, language, true);
+ auto type_system_or_err = GetScratchTypeSystemForLanguage(language, true);
- if (type_system) {
- return type_system->GetPersistentExpressionState();
- } else {
+ if (auto err = type_system_or_err.takeError()) {
+ LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
+ std::move(err),
+ "Unable to get persistent expression state for language {}",
+ Language::GetNameForLanguageType(language));
return nullptr;
}
+
+ return type_system_or_err->GetPersistentExpressionState();
}
UserExpression *Target::GetUserExpressionForLanguage(
llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
Expression::ResultType desired_type,
- const EvaluateExpressionOptions &options,
- ValueObject *ctx_obj, Status &error) {
- Status type_system_error;
-
- TypeSystem *type_system =
- GetScratchTypeSystemForLanguage(&type_system_error, language);
- UserExpression *user_expr = nullptr;
-
- if (!type_system) {
+ const EvaluateExpressionOptions &options, ValueObject *ctx_obj,
+ Status &error) {
+ auto type_system_or_err = GetScratchTypeSystemForLanguage(language);
+ if (auto err = type_system_or_err.takeError()) {
error.SetErrorStringWithFormat(
"Could not find type system for language %s: %s",
Language::GetNameForLanguageType(language),
- type_system_error.AsCString());
+ llvm::toString(std::move(err)).c_str());
return nullptr;
}
- user_expr = type_system->GetUserExpression(expr, prefix, language,
- desired_type, options, ctx_obj);
+ auto *user_expr = type_system_or_err->GetUserExpression(
+ expr, prefix, language, desired_type, options, ctx_obj);
if (!user_expr)
error.SetErrorStringWithFormat(
"Could not create an expression for language %s",
@@ -2244,21 +2211,17 @@ FunctionCaller *Target::GetFunctionCallerForLanguage(
lldb::LanguageType language, const CompilerType &return_type,
const Address &function_address, const ValueList &arg_value_list,
const char *name, Status &error) {
- Status type_system_error;
- TypeSystem *type_system =
- GetScratchTypeSystemForLanguage(&type_system_error, language);
- FunctionCaller *persistent_fn = nullptr;
-
- if (!type_system) {
+ auto type_system_or_err = GetScratchTypeSystemForLanguage(language);
+ if (auto err = type_system_or_err.takeError()) {
error.SetErrorStringWithFormat(
"Could not find type system for language %s: %s",
Language::GetNameForLanguageType(language),
- type_system_error.AsCString());
- return persistent_fn;
+ llvm::toString(std::move(err)).c_str());
+ return nullptr;
}
- persistent_fn = type_system->GetFunctionCaller(return_type, function_address,
- arg_value_list, name);
+ auto *persistent_fn = type_system_or_err->GetFunctionCaller(
+ return_type, function_address, arg_value_list, name);
if (!persistent_fn)
error.SetErrorStringWithFormat(
"Could not create an expression for language %s",
@@ -2271,20 +2234,17 @@ UtilityFunction *
Target::GetUtilityFunctionForLanguage(const char *text,
lldb::LanguageType language,
const char *name, Status &error) {
- Status type_system_error;
- TypeSystem *type_system =
- GetScratchTypeSystemForLanguage(&type_system_error, language);
- UtilityFunction *utility_fn = nullptr;
+ auto type_system_or_err = GetScratchTypeSystemForLanguage(language);
- if (!type_system) {
+ if (auto err = type_system_or_err.takeError()) {
error.SetErrorStringWithFormat(
"Could not find type system for language %s: %s",
Language::GetNameForLanguageType(language),
- type_system_error.AsCString());
- return utility_fn;
+ llvm::toString(std::move(err)).c_str());
+ return nullptr;
}
- utility_fn = type_system->GetUtilityFunction(text, name);
+ auto *utility_fn = type_system_or_err->GetUtilityFunction(text, name);
if (!utility_fn)
error.SetErrorStringWithFormat(
"Could not create an expression for language %s",
@@ -2294,12 +2254,17 @@ Target::GetUtilityFunctionForLanguage(const char *text,
}
ClangASTContext *Target::GetScratchClangASTContext(bool create_on_demand) {
- if (m_valid) {
- if (TypeSystem *type_system = GetScratchTypeSystemForLanguage(
- nullptr, eLanguageTypeC, create_on_demand))
- return llvm::dyn_cast<ClangASTContext>(type_system);
+ if (!m_valid)
+ return nullptr;
+
+ auto type_system_or_err =
+ GetScratchTypeSystemForLanguage(eLanguageTypeC, create_on_demand);
+ if (auto err = type_system_or_err.takeError()) {
+ LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
+ std::move(err), "Couldn't get scratch ClangASTContext");
+ return nullptr;
}
- return nullptr;
+ return llvm::dyn_cast<ClangASTContext>(&type_system_or_err.get());
}
ClangASTImporterSP Target::GetClangASTImporter() {
@@ -2340,10 +2305,10 @@ ArchSpec Target::GetDefaultArchitecture() {
void Target::SetDefaultArchitecture(const ArchSpec &arch) {
TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
if (properties_sp) {
- LogIfAnyCategoriesSet(
- LIBLLDB_LOG_TARGET, "Target::SetDefaultArchitecture setting target's "
- "default architecture to %s (%s)",
- arch.GetArchitectureName(), arch.GetTriple().getTriple().c_str());
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET),
+ "Target::SetDefaultArchitecture setting target's "
+ "default architecture to {0} ({1})",
+ arch.GetArchitectureName(), arch.GetTriple().getTriple());
return properties_sp->SetDefaultArchitecture(arch);
}
}
@@ -2378,7 +2343,8 @@ ExpressionResults Target::EvaluateExpression(
bool old_suppress_value = m_suppress_stop_hooks;
m_suppress_stop_hooks = true;
auto on_exit = llvm::make_scope_exit([this, old_suppress_value]() {
- m_suppress_stop_hooks = old_suppress_value; });
+ m_suppress_stop_hooks = old_suppress_value;
+ });
ExecutionContext exe_ctx;
@@ -2392,13 +2358,19 @@ ExpressionResults Target::EvaluateExpression(
// Make sure we aren't just trying to see the value of a persistent variable
// (something like "$0")
- lldb::ExpressionVariableSP persistent_var_sp;
// Only check for persistent variables the expression starts with a '$'
- if (expr[0] == '$')
- persistent_var_sp = GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC)
- ->GetPersistentExpressionState()
- ->GetVariable(expr);
-
+ lldb::ExpressionVariableSP persistent_var_sp;
+ if (expr[0] == '$') {
+ auto type_system_or_err =
+ GetScratchTypeSystemForLanguage(eLanguageTypeC);
+ if (auto err = type_system_or_err.takeError()) {
+ LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
+ std::move(err), "Unable to get scratch type system");
+ } else {
+ persistent_var_sp =
+ type_system_or_err->GetPersistentExpressionState()->GetVariable(expr);
+ }
+ }
if (persistent_var_sp) {
result_valobj_sp = persistent_var_sp->GetValueObject();
execution_results = eExpressionCompleted;
@@ -2415,8 +2387,7 @@ ExpressionResults Target::EvaluateExpression(
return execution_results;
}
-lldb::ExpressionVariableSP
-Target::GetPersistentVariable(ConstString name) {
+lldb::ExpressionVariableSP Target::GetPersistentVariable(ConstString name) {
lldb::ExpressionVariableSP variable_sp;
m_scratch_type_system_map.ForEach(
[name, &variable_sp](TypeSystem *type_system) -> bool {
@@ -2448,24 +2419,61 @@ lldb::addr_t Target::GetPersistentSymbol(ConstString name) {
return address;
}
+llvm::Expected<lldb_private::Address> Target::GetEntryPointAddress() {
+ Module *exe_module = GetExecutableModulePointer();
+ llvm::Error error = llvm::Error::success();
+ assert(!error); // Check the success value when assertions are enabled.
+
+ if (!exe_module || !exe_module->GetObjectFile()) {
+ error = llvm::make_error<llvm::StringError>("No primary executable found",
+ llvm::inconvertibleErrorCode());
+ } else {
+ Address entry_addr = exe_module->GetObjectFile()->GetEntryPointAddress();
+ if (entry_addr.IsValid())
+ return entry_addr;
+
+ error = llvm::make_error<llvm::StringError>(
+ "Could not find entry point address for executable module \"" +
+ exe_module->GetFileSpec().GetFilename().GetStringRef() + "\"",
+ llvm::inconvertibleErrorCode());
+ }
+
+ const ModuleList &modules = GetImages();
+ const size_t num_images = modules.GetSize();
+ for (size_t idx = 0; idx < num_images; ++idx) {
+ ModuleSP module_sp(modules.GetModuleAtIndex(idx));
+ if (!module_sp || !module_sp->GetObjectFile())
+ continue;
+
+ Address entry_addr = module_sp->GetObjectFile()->GetEntryPointAddress();
+ if (entry_addr.IsValid()) {
+ // Discard the error.
+ llvm::consumeError(std::move(error));
+ return entry_addr;
+ }
+ }
+
+ return std::move(error);
+}
+
lldb::addr_t Target::GetCallableLoadAddress(lldb::addr_t load_addr,
AddressClass addr_class) const {
auto arch_plugin = GetArchitecturePlugin();
- return arch_plugin ?
- arch_plugin->GetCallableLoadAddress(load_addr, addr_class) : load_addr;
+ return arch_plugin
+ ? arch_plugin->GetCallableLoadAddress(load_addr, addr_class)
+ : load_addr;
}
lldb::addr_t Target::GetOpcodeLoadAddress(lldb::addr_t load_addr,
AddressClass addr_class) const {
auto arch_plugin = GetArchitecturePlugin();
- return arch_plugin ?
- arch_plugin->GetOpcodeLoadAddress(load_addr, addr_class) : load_addr;
+ return arch_plugin ? arch_plugin->GetOpcodeLoadAddress(load_addr, addr_class)
+ : load_addr;
}
lldb::addr_t Target::GetBreakableLoadAddress(lldb::addr_t addr) {
auto arch_plugin = GetArchitecturePlugin();
- return arch_plugin ?
- arch_plugin->GetBreakableLoadAddress(addr, *this) : addr;
+ return arch_plugin ? arch_plugin->GetBreakableLoadAddress(addr, *this) : addr;
}
SourceManager &Target::GetSourceManager() {
@@ -2539,7 +2547,7 @@ void Target::RunStopHooks() {
if (!m_process_sp)
return;
-
+
// Somebody might have restarted the process:
if (m_process_sp->GetState() != eStateStopped)
return;
@@ -2658,11 +2666,12 @@ void Target::RunStopHooks() {
// But only complain if there were more stop hooks to do:
StopHookCollection::iterator tmp = pos;
if (++tmp != end)
- result.AppendMessageWithFormat("\nAborting stop hooks, hook %" PRIu64
- " set the program running.\n"
- " Consider using '-G true' to make "
- "stop hooks auto-continue.\n",
- cur_hook_sp->GetID());
+ result.AppendMessageWithFormat(
+ "\nAborting stop hooks, hook %" PRIu64
+ " set the program running.\n"
+ " Consider using '-G true' to make "
+ "stop hooks auto-continue.\n",
+ cur_hook_sp->GetID());
keep_going = false;
did_restart = true;
}
@@ -2820,9 +2829,8 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
Status error;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET));
- if (log)
- log->Printf("Target::%s() called for %s", __FUNCTION__,
- launch_info.GetExecutableFile().GetPath().c_str());
+ LLDB_LOGF(log, "Target::%s() called for %s", __FUNCTION__,
+ launch_info.GetExecutableFile().GetPath().c_str());
StateType state = eStateInvalid;
@@ -2834,14 +2842,12 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
if (process_sp) {
state = process_sp->GetState();
- if (log)
- log->Printf(
- "Target::%s the process exists, and its current state is %s",
- __FUNCTION__, StateAsCString(state));
+ LLDB_LOGF(log,
+ "Target::%s the process exists, and its current state is %s",
+ __FUNCTION__, StateAsCString(state));
} else {
- if (log)
- log->Printf("Target::%s the process instance doesn't currently exist.",
- __FUNCTION__);
+ LLDB_LOGF(log, "Target::%s the process instance doesn't currently exist.",
+ __FUNCTION__);
}
}
@@ -2873,24 +2879,23 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
// that can launch a process for debugging, go ahead and do that here.
if (state != eStateConnected && platform_sp &&
platform_sp->CanDebugProcess()) {
- if (log)
- log->Printf("Target::%s asking the platform to debug the process",
- __FUNCTION__);
+ LLDB_LOGF(log, "Target::%s asking the platform to debug the process",
+ __FUNCTION__);
// If there was a previous process, delete it before we make the new one.
// One subtle point, we delete the process before we release the reference
// to m_process_sp. That way even if we are the last owner, the process
// will get Finalized before it gets destroyed.
DeleteCurrentProcess();
-
+
m_process_sp =
GetPlatform()->DebugProcess(launch_info, debugger, this, error);
} else {
- if (log)
- log->Printf("Target::%s the platform doesn't know how to debug a "
- "process, getting a process plugin to do this for us.",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "Target::%s the platform doesn't know how to debug a "
+ "process, getting a process plugin to do this for us.",
+ __FUNCTION__);
if (state == eStateConnected) {
assert(m_process_sp);
@@ -2928,9 +2933,9 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
if (state == eStateStopped) {
if (!launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) {
if (synchronous_execution) {
- // Now we have handled the stop-from-attach, and we are just switching
- // to a synchronous resume. So we should switch to the SyncResume
- // hijacker.
+ // Now we have handled the stop-from-attach, and we are just
+ // switching to a synchronous resume. So we should switch to the
+ // SyncResume hijacker.
m_process_sp->RestoreProcessEvents();
m_process_sp->ResumeSynchronous(stream);
} else {
@@ -3213,33 +3218,51 @@ void Target::StopHook::GetDescription(Stream *s,
s->SetIndentLevel(indent_level);
}
-// class TargetProperties
-
-// clang-format off
static constexpr OptionEnumValueElement g_dynamic_value_types[] = {
- {eNoDynamicValues, "no-dynamic-values",
- "Don't calculate the dynamic type of values"},
- {eDynamicCanRunTarget, "run-target", "Calculate the dynamic type of values "
- "even if you have to run the target."},
- {eDynamicDontRunTarget, "no-run-target",
- "Calculate the dynamic type of values, but don't run the target."} };
+ {
+ eNoDynamicValues,
+ "no-dynamic-values",
+ "Don't calculate the dynamic type of values",
+ },
+ {
+ eDynamicCanRunTarget,
+ "run-target",
+ "Calculate the dynamic type of values "
+ "even if you have to run the target.",
+ },
+ {
+ eDynamicDontRunTarget,
+ "no-run-target",
+ "Calculate the dynamic type of values, but don't run the target.",
+ },
+};
OptionEnumValues lldb_private::GetDynamicValueTypes() {
return OptionEnumValues(g_dynamic_value_types);
}
static constexpr OptionEnumValueElement g_inline_breakpoint_enums[] = {
- {eInlineBreakpointsNever, "never", "Never look for inline breakpoint "
- "locations (fastest). This setting "
- "should only be used if you know that "
- "no inlining occurs in your programs."},
- {eInlineBreakpointsHeaders, "headers",
- "Only check for inline breakpoint locations when setting breakpoints in "
- "header files, but not when setting breakpoint in implementation source "
- "files (default)."},
- {eInlineBreakpointsAlways, "always",
- "Always look for inline breakpoint locations when setting file and line "
- "breakpoints (slower but most accurate)."} };
+ {
+ eInlineBreakpointsNever,
+ "never",
+ "Never look for inline breakpoint locations (fastest). This setting "
+ "should only be used if you know that no inlining occurs in your"
+ "programs.",
+ },
+ {
+ eInlineBreakpointsHeaders,
+ "headers",
+ "Only check for inline breakpoint locations when setting breakpoints "
+ "in header files, but not when setting breakpoint in implementation "
+ "source files (default).",
+ },
+ {
+ eInlineBreakpointsAlways,
+ "always",
+ "Always look for inline breakpoint locations when setting file and "
+ "line breakpoints (slower but most accurate).",
+ },
+};
enum x86DisassemblyFlavor {
eX86DisFlavorDefault,
@@ -3248,258 +3271,99 @@ enum x86DisassemblyFlavor {
};
static constexpr OptionEnumValueElement g_x86_dis_flavor_value_types[] = {
- {eX86DisFlavorDefault, "default", "Disassembler default (currently att)."},
- {eX86DisFlavorIntel, "intel", "Intel disassembler flavor."},
- {eX86DisFlavorATT, "att", "AT&T disassembler flavor."} };
+ {
+ eX86DisFlavorDefault,
+ "default",
+ "Disassembler default (currently att).",
+ },
+ {
+ eX86DisFlavorIntel,
+ "intel",
+ "Intel disassembler flavor.",
+ },
+ {
+ eX86DisFlavorATT,
+ "att",
+ "AT&T disassembler flavor.",
+ },
+};
static constexpr OptionEnumValueElement g_hex_immediate_style_values[] = {
- {Disassembler::eHexStyleC, "c", "C-style (0xffff)."},
- {Disassembler::eHexStyleAsm, "asm", "Asm-style (0ffffh)."} };
+ {
+ Disassembler::eHexStyleC,
+ "c",
+ "C-style (0xffff).",
+ },
+ {
+ Disassembler::eHexStyleAsm,
+ "asm",
+ "Asm-style (0ffffh).",
+ },
+};
static constexpr OptionEnumValueElement g_load_script_from_sym_file_values[] = {
- {eLoadScriptFromSymFileTrue, "true",
- "Load debug scripts inside symbol files"},
- {eLoadScriptFromSymFileFalse, "false",
- "Do not load debug scripts inside symbol files."},
- {eLoadScriptFromSymFileWarn, "warn",
- "Warn about debug scripts inside symbol files but do not load them."} };
-
-static constexpr
-OptionEnumValueElement g_load_current_working_dir_lldbinit_values[] = {
- {eLoadCWDlldbinitTrue, "true",
- "Load .lldbinit files from current directory"},
- {eLoadCWDlldbinitFalse, "false",
- "Do not load .lldbinit files from current directory"},
- {eLoadCWDlldbinitWarn, "warn",
- "Warn about loading .lldbinit files from current directory"} };
+ {
+ eLoadScriptFromSymFileTrue,
+ "true",
+ "Load debug scripts inside symbol files",
+ },
+ {
+ eLoadScriptFromSymFileFalse,
+ "false",
+ "Do not load debug scripts inside symbol files.",
+ },
+ {
+ eLoadScriptFromSymFileWarn,
+ "warn",
+ "Warn about debug scripts inside symbol files but do not load them.",
+ },
+};
+
+static constexpr OptionEnumValueElement g_load_cwd_lldbinit_values[] = {
+ {
+ eLoadCWDlldbinitTrue,
+ "true",
+ "Load .lldbinit files from current directory",
+ },
+ {
+ eLoadCWDlldbinitFalse,
+ "false",
+ "Do not load .lldbinit files from current directory",
+ },
+ {
+ eLoadCWDlldbinitWarn,
+ "warn",
+ "Warn about loading .lldbinit files from current directory",
+ },
+};
static constexpr OptionEnumValueElement g_memory_module_load_level_values[] = {
- {eMemoryModuleLoadLevelMinimal, "minimal",
- "Load minimal information when loading modules from memory. Currently "
- "this setting loads sections only."},
- {eMemoryModuleLoadLevelPartial, "partial",
- "Load partial information when loading modules from memory. Currently "
- "this setting loads sections and function bounds."},
- {eMemoryModuleLoadLevelComplete, "complete",
- "Load complete information when loading modules from memory. Currently "
- "this setting loads sections and all symbols."} };
-
-static constexpr PropertyDefinition g_properties[] = {
- {"default-arch", OptionValue::eTypeArch, true, 0, nullptr, {},
- "Default architecture to choose, when there's a choice."},
- {"move-to-nearest-code", OptionValue::eTypeBoolean, false, true, nullptr,
- {}, "Move breakpoints to nearest code."},
- {"language", OptionValue::eTypeLanguage, false, eLanguageTypeUnknown,
- nullptr, {},
- "The language to use when interpreting expressions entered in commands."},
- {"expr-prefix", OptionValue::eTypeFileSpec, false, 0, nullptr, {},
- "Path to a file containing expressions to be prepended to all "
- "expressions."},
- {"prefer-dynamic-value", OptionValue::eTypeEnum, false,
- eDynamicDontRunTarget, nullptr, OptionEnumValues(g_dynamic_value_types),
- "Should printed values be shown as their dynamic value."},
- {"enable-synthetic-value", OptionValue::eTypeBoolean, false, true, nullptr,
- {}, "Should synthetic values be used by default whenever available."},
- {"skip-prologue", OptionValue::eTypeBoolean, false, true, nullptr, {},
- "Skip function prologues when setting breakpoints by name."},
- {"source-map", OptionValue::eTypePathMap, false, 0, nullptr, {},
- "Source path remappings are used to track the change of location between "
- "a source file when built, and "
- "where it exists on the current system. It consists of an array of "
- "duples, the first element of each duple is "
- "some part (starting at the root) of the path to the file when it was "
- "built, "
- "and the second is where the remainder of the original build hierarchy is "
- "rooted on the local system. "
- "Each element of the array is checked in order and the first one that "
- "results in a match wins."},
- {"exec-search-paths", OptionValue::eTypeFileSpecList, false, 0, nullptr,
- {}, "Executable search paths to use when locating executable files "
- "whose paths don't match the local file system."},
- {"debug-file-search-paths", OptionValue::eTypeFileSpecList, false, 0,
- nullptr, {},
- "List of directories to be searched when locating debug symbol files. "
- "See also symbols.enable-external-lookup."},
- {"clang-module-search-paths", OptionValue::eTypeFileSpecList, false, 0,
- nullptr, {},
- "List of directories to be searched when locating modules for Clang."},
- {"auto-import-clang-modules", OptionValue::eTypeBoolean, false, true,
- nullptr, {},
- "Automatically load Clang modules referred to by the program."},
- {"import-std-module", OptionValue::eTypeBoolean, false, false,
- nullptr, {},
- "Import the C++ std module to improve debugging STL containers."},
- {"auto-apply-fixits", OptionValue::eTypeBoolean, false, true, nullptr,
- {}, "Automatically apply fix-it hints to expressions."},
- {"notify-about-fixits", OptionValue::eTypeBoolean, false, true, nullptr,
- {}, "Print the fixed expression text."},
- {"save-jit-objects", OptionValue::eTypeBoolean, false, false, nullptr,
- {}, "Save intermediate object files generated by the LLVM JIT"},
- {"max-children-count", OptionValue::eTypeSInt64, false, 256, nullptr,
- {}, "Maximum number of children to expand in any level of depth."},
- {"max-string-summary-length", OptionValue::eTypeSInt64, false, 1024,
- nullptr, {},
- "Maximum number of characters to show when using %s in summary strings."},
- {"max-memory-read-size", OptionValue::eTypeSInt64, false, 1024, nullptr,
- {}, "Maximum number of bytes that 'memory read' will fetch before "
- "--force must be specified."},
- {"breakpoints-use-platform-avoid-list", OptionValue::eTypeBoolean, false,
- true, nullptr, {}, "Consult the platform module avoid list when "
- "setting non-module specific breakpoints."},
- {"arg0", OptionValue::eTypeString, false, 0, nullptr, {},
- "The first argument passed to the program in the argument array which can "
- "be different from the executable itself."},
- {"run-args", OptionValue::eTypeArgs, false, 0, nullptr, {},
- "A list containing all the arguments to be passed to the executable when "
- "it is run. Note that this does NOT include the argv[0] which is in "
- "target.arg0."},
- {"env-vars", OptionValue::eTypeDictionary, false, OptionValue::eTypeString,
- nullptr, {}, "A list of all the environment variables to be passed "
- "to the executable's environment, and their values."},
- {"inherit-env", OptionValue::eTypeBoolean, false, true, nullptr, {},
- "Inherit the environment from the process that is running LLDB."},
- {"input-path", OptionValue::eTypeFileSpec, false, 0, nullptr, {},
- "The file/path to be used by the executable program for reading its "
- "standard input."},
- {"output-path", OptionValue::eTypeFileSpec, false, 0, nullptr, {},
- "The file/path to be used by the executable program for writing its "
- "standard output."},
- {"error-path", OptionValue::eTypeFileSpec, false, 0, nullptr, {},
- "The file/path to be used by the executable program for writing its "
- "standard error."},
- {"detach-on-error", OptionValue::eTypeBoolean, false, true, nullptr,
- {}, "debugserver will detach (rather than killing) a process if it "
- "loses connection with lldb."},
- {"preload-symbols", OptionValue::eTypeBoolean, false, true, nullptr, {},
- "Enable loading of symbol tables before they are needed."},
- {"disable-aslr", OptionValue::eTypeBoolean, false, true, nullptr, {},
- "Disable Address Space Layout Randomization (ASLR)"},
- {"disable-stdio", OptionValue::eTypeBoolean, false, false, nullptr, {},
- "Disable stdin/stdout for process (e.g. for a GUI application)"},
- {"inline-breakpoint-strategy", OptionValue::eTypeEnum, false,
- eInlineBreakpointsAlways, nullptr,
- OptionEnumValues(g_inline_breakpoint_enums),
- "The strategy to use when settings breakpoints by file and line. "
- "Breakpoint locations can end up being inlined by the compiler, so that a "
- "compile unit 'a.c' might contain an inlined function from another source "
- "file. "
- "Usually this is limited to breakpoint locations from inlined functions "
- "from header or other include files, or more accurately "
- "non-implementation source files. "
- "Sometimes code might #include implementation files and cause inlined "
- "breakpoint locations in inlined implementation files. "
- "Always checking for inlined breakpoint locations can be expensive "
- "(memory and time), so if you have a project with many headers "
- "and find that setting breakpoints is slow, then you can change this "
- "setting to headers. "
- "This setting allows you to control exactly which strategy is used when "
- "setting "
- "file and line breakpoints."},
- // FIXME: This is the wrong way to do per-architecture settings, but we
- // don't have a general per architecture settings system in place yet.
- {"x86-disassembly-flavor", OptionValue::eTypeEnum, false,
- eX86DisFlavorDefault, nullptr,
- OptionEnumValues(g_x86_dis_flavor_value_types),
- "The default disassembly flavor to use for x86 or x86-64 targets."},
- {"use-hex-immediates", OptionValue::eTypeBoolean, false, true, nullptr,
- {}, "Show immediates in disassembly as hexadecimal."},
- {"hex-immediate-style", OptionValue::eTypeEnum, false,
- Disassembler::eHexStyleC, nullptr,
- OptionEnumValues(g_hex_immediate_style_values),
- "Which style to use for printing hexadecimal disassembly values."},
- {"use-fast-stepping", OptionValue::eTypeBoolean, false, true, nullptr,
- {}, "Use a fast stepping algorithm based on running from branch to "
- "branch rather than instruction single-stepping."},
- {"load-script-from-symbol-file", OptionValue::eTypeEnum, false,
- eLoadScriptFromSymFileWarn, nullptr,
- OptionEnumValues(g_load_script_from_sym_file_values),
- "Allow LLDB to load scripting resources embedded in symbol files when "
- "available."},
- {"load-cwd-lldbinit", OptionValue::eTypeEnum, false, eLoadCWDlldbinitWarn,
- nullptr, OptionEnumValues(g_load_current_working_dir_lldbinit_values),
- "Allow LLDB to .lldbinit files from the current directory automatically."},
- {"memory-module-load-level", OptionValue::eTypeEnum, false,
- eMemoryModuleLoadLevelComplete, nullptr,
- OptionEnumValues(g_memory_module_load_level_values),
- "Loading modules from memory can be slow as reading the symbol tables and "
- "other data can take a long time depending on your connection to the "
- "debug target. "
- "This setting helps users control how much information gets loaded when "
- "loading modules from memory."
- "'complete' is the default value for this setting which will load all "
- "sections and symbols by reading them from memory (slowest, most "
- "accurate). "
- "'partial' will load sections and attempt to find function bounds without "
- "downloading the symbol table (faster, still accurate, missing symbol "
- "names). "
- "'minimal' is the fastest setting and will load section data with no "
- "symbols, but should rarely be used as stack frames in these memory "
- "regions will be inaccurate and not provide any context (fastest). "},
- {"display-expression-in-crashlogs", OptionValue::eTypeBoolean, false, false,
- nullptr, {}, "Expressions that crash will show up in crash logs if "
- "the host system supports executable specific crash log "
- "strings and this setting is set to true."},
- {"trap-handler-names", OptionValue::eTypeArray, true,
- OptionValue::eTypeString, nullptr, {},
- "A list of trap handler function names, e.g. a common Unix user process "
- "one is _sigtramp."},
- {"display-runtime-support-values", OptionValue::eTypeBoolean, false, false,
- nullptr, {}, "If true, LLDB will show variables that are meant to "
- "support the operation of a language's runtime support."},
- {"display-recognized-arguments", OptionValue::eTypeBoolean, false, false,
- nullptr, {}, "Show recognized arguments in variable listings by default."},
- {"non-stop-mode", OptionValue::eTypeBoolean, false, 0, nullptr, {},
- "Disable lock-step debugging, instead control threads independently."},
- {"require-hardware-breakpoint", OptionValue::eTypeBoolean, false, 0,
- nullptr, {}, "Require all breakpoints to be hardware breakpoints."}};
-// clang-format on
+ {
+ eMemoryModuleLoadLevelMinimal,
+ "minimal",
+ "Load minimal information when loading modules from memory. Currently "
+ "this setting loads sections only.",
+ },
+ {
+ eMemoryModuleLoadLevelPartial,
+ "partial",
+ "Load partial information when loading modules from memory. Currently "
+ "this setting loads sections and function bounds.",
+ },
+ {
+ eMemoryModuleLoadLevelComplete,
+ "complete",
+ "Load complete information when loading modules from memory. Currently "
+ "this setting loads sections and all symbols.",
+ },
+};
+
+#define LLDB_PROPERTIES_target
+#include "TargetProperties.inc"
enum {
- ePropertyDefaultArch,
- ePropertyMoveToNearestCode,
- ePropertyLanguage,
- ePropertyExprPrefix,
- ePropertyPreferDynamic,
- ePropertyEnableSynthetic,
- ePropertySkipPrologue,
- ePropertySourceMap,
- ePropertyExecutableSearchPaths,
- ePropertyDebugFileSearchPaths,
- ePropertyClangModuleSearchPaths,
- ePropertyAutoImportClangModules,
- ePropertyImportStdModule,
- ePropertyAutoApplyFixIts,
- ePropertyNotifyAboutFixIts,
- ePropertySaveObjects,
- ePropertyMaxChildrenCount,
- ePropertyMaxSummaryLength,
- ePropertyMaxMemReadSize,
- ePropertyBreakpointUseAvoidList,
- ePropertyArg0,
- ePropertyRunArgs,
- ePropertyEnvVars,
- ePropertyInheritEnv,
- ePropertyInputPath,
- ePropertyOutputPath,
- ePropertyErrorPath,
- ePropertyDetachOnError,
- ePropertyPreloadSymbols,
- ePropertyDisableASLR,
- ePropertyDisableSTDIO,
- ePropertyInlineStrategy,
- ePropertyDisassemblyFlavor,
- ePropertyUseHexImmediates,
- ePropertyHexImmediateStyle,
- ePropertyUseFastStepping,
- ePropertyLoadScriptFromSymbolFile,
- ePropertyLoadCWDlldbinitFile,
- ePropertyMemoryModuleLoadLevel,
- ePropertyDisplayExpressionsInCrashlogs,
- ePropertyTrapHandlerNames,
- ePropertyDisplayRuntimeSupportValues,
- ePropertyDisplayRecognizedArguments,
- ePropertyNonStopModeEnabled,
- ePropertyRequireHardwareBreakpoints,
+#define LLDB_PROPERTIES_target
+#include "TargetPropertiesEnum.inc"
ePropertyExperimental,
};
@@ -3547,7 +3411,7 @@ protected:
m_got_host_env = true;
const uint32_t idx = ePropertyInheritEnv;
if (GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0)) {
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0)) {
PlatformSP platform_sp(m_target->GetPlatform());
if (platform_sp) {
Environment env = platform_sp->GetEnvironment();
@@ -3575,17 +3439,13 @@ protected:
};
// TargetProperties
-static constexpr PropertyDefinition g_experimental_properties[]{
- {"inject-local-vars", OptionValue::eTypeBoolean, true, true, nullptr,
- {},
- "If true, inject local variables explicitly into the expression text. "
- "This will fix symbol resolution when there are name collisions between "
- "ivars and local variables. "
- "But it can make expressions run much more slowly."},
- {"use-modern-type-lookup", OptionValue::eTypeBoolean, true, false, nullptr,
- {}, "If true, use Clang's modern type lookup infrastructure."}};
-
-enum { ePropertyInjectLocalVars = 0, ePropertyUseModernTypeLookup };
+#define LLDB_PROPERTIES_experimental
+#include "TargetProperties.inc"
+
+enum {
+#define LLDB_PROPERTIES_experimental
+#include "TargetPropertiesEnum.inc"
+};
class TargetExperimentalOptionValueProperties : public OptionValueProperties {
public:
@@ -3655,7 +3515,7 @@ TargetProperties::TargetProperties(Target *target)
} else {
m_collection_sp =
std::make_shared<TargetOptionValueProperties>(ConstString("target"));
- m_collection_sp->Initialize(g_properties);
+ m_collection_sp->Initialize(g_target_properties);
m_experimental_properties_up.reset(new TargetExperimentalProperties());
m_collection_sp->AppendProperty(
ConstString(Properties::GetExperimentalSettingsName()),
@@ -3724,14 +3584,14 @@ void TargetProperties::SetDefaultArchitecture(const ArchSpec &arch) {
bool TargetProperties::GetMoveToNearestCode() const {
const uint32_t idx = ePropertyMoveToNearestCode;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
lldb::DynamicValueType TargetProperties::GetPreferDynamicValue() const {
const uint32_t idx = ePropertyPreferDynamic;
return (lldb::DynamicValueType)
m_collection_sp->GetPropertyAtIndexAsEnumeration(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_target_properties[idx].default_uint_value);
}
bool TargetProperties::SetPreferDynamicValue(lldb::DynamicValueType d) {
@@ -3742,7 +3602,7 @@ bool TargetProperties::SetPreferDynamicValue(lldb::DynamicValueType d) {
bool TargetProperties::GetPreloadSymbols() const {
const uint32_t idx = ePropertyPreloadSymbols;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
void TargetProperties::SetPreloadSymbols(bool b) {
@@ -3753,7 +3613,7 @@ void TargetProperties::SetPreloadSymbols(bool b) {
bool TargetProperties::GetDisableASLR() const {
const uint32_t idx = ePropertyDisableASLR;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
void TargetProperties::SetDisableASLR(bool b) {
@@ -3764,7 +3624,7 @@ void TargetProperties::SetDisableASLR(bool b) {
bool TargetProperties::GetDetachOnError() const {
const uint32_t idx = ePropertyDetachOnError;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
void TargetProperties::SetDetachOnError(bool b) {
@@ -3775,7 +3635,7 @@ void TargetProperties::SetDetachOnError(bool b) {
bool TargetProperties::GetDisableSTDIO() const {
const uint32_t idx = ePropertyDisableSTDIO;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
void TargetProperties::SetDisableSTDIO(bool b) {
@@ -3789,7 +3649,7 @@ const char *TargetProperties::GetDisassemblyFlavor() const {
x86DisassemblyFlavor flavor_value =
(x86DisassemblyFlavor)m_collection_sp->GetPropertyAtIndexAsEnumeration(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_target_properties[idx].default_uint_value);
return_value = g_x86_dis_flavor_value_types[flavor_value].string_value;
return return_value;
}
@@ -3797,18 +3657,18 @@ const char *TargetProperties::GetDisassemblyFlavor() const {
InlineStrategy TargetProperties::GetInlineStrategy() const {
const uint32_t idx = ePropertyInlineStrategy;
return (InlineStrategy)m_collection_sp->GetPropertyAtIndexAsEnumeration(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_target_properties[idx].default_uint_value);
}
llvm::StringRef TargetProperties::GetArg0() const {
const uint32_t idx = ePropertyArg0;
- return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, llvm::StringRef());
+ return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx,
+ llvm::StringRef());
}
void TargetProperties::SetArg0(llvm::StringRef arg) {
const uint32_t idx = ePropertyArg0;
- m_collection_sp->SetPropertyAtIndexAsString(
- nullptr, idx, arg);
+ m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, arg);
m_launch_info.SetArg0(arg);
}
@@ -3841,7 +3701,7 @@ void TargetProperties::SetEnvironment(Environment env) {
bool TargetProperties::GetSkipPrologue() const {
const uint32_t idx = ePropertySkipPrologue;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
PathMappingList &TargetProperties::GetSourcePathMap() const {
@@ -3853,7 +3713,7 @@ PathMappingList &TargetProperties::GetSourcePathMap() const {
return option_value->GetCurrentValue();
}
-void TargetProperties::AppendExecutableSearchPaths(const FileSpec& dir) {
+void TargetProperties::AppendExecutableSearchPaths(const FileSpec &dir) {
const uint32_t idx = ePropertyExecutableSearchPaths;
OptionValueFileSpecList *option_value =
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
@@ -3892,55 +3752,61 @@ FileSpecList TargetProperties::GetClangModuleSearchPaths() {
bool TargetProperties::GetEnableAutoImportClangModules() const {
const uint32_t idx = ePropertyAutoImportClangModules;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
bool TargetProperties::GetEnableImportStdModule() const {
const uint32_t idx = ePropertyImportStdModule;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
bool TargetProperties::GetEnableAutoApplyFixIts() const {
const uint32_t idx = ePropertyAutoApplyFixIts;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
bool TargetProperties::GetEnableNotifyAboutFixIts() const {
const uint32_t idx = ePropertyNotifyAboutFixIts;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
bool TargetProperties::GetEnableSaveObjects() const {
const uint32_t idx = ePropertySaveObjects;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
bool TargetProperties::GetEnableSyntheticValue() const {
const uint32_t idx = ePropertyEnableSynthetic;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
+}
+
+uint32_t TargetProperties::GetMaxZeroPaddingInFloatFormat() const {
+ const uint32_t idx = ePropertyMaxZeroPaddingInFloatFormat;
+ return m_collection_sp->GetPropertyAtIndexAsUInt64(
+ nullptr, idx, g_target_properties[idx].default_uint_value);
}
uint32_t TargetProperties::GetMaximumNumberOfChildrenToDisplay() const {
const uint32_t idx = ePropertyMaxChildrenCount;
return m_collection_sp->GetPropertyAtIndexAsSInt64(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_target_properties[idx].default_uint_value);
}
uint32_t TargetProperties::GetMaximumSizeOfStringSummary() const {
const uint32_t idx = ePropertyMaxSummaryLength;
return m_collection_sp->GetPropertyAtIndexAsSInt64(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_target_properties[idx].default_uint_value);
}
uint32_t TargetProperties::GetMaximumMemReadSize() const {
const uint32_t idx = ePropertyMaxMemReadSize;
return m_collection_sp->GetPropertyAtIndexAsSInt64(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_target_properties[idx].default_uint_value);
}
FileSpec TargetProperties::GetStandardInputPath() const {
@@ -4000,52 +3866,52 @@ llvm::StringRef TargetProperties::GetExpressionPrefixContents() {
bool TargetProperties::GetBreakpointsConsultPlatformAvoidList() {
const uint32_t idx = ePropertyBreakpointUseAvoidList;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
bool TargetProperties::GetUseHexImmediates() const {
const uint32_t idx = ePropertyUseHexImmediates;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
bool TargetProperties::GetUseFastStepping() const {
const uint32_t idx = ePropertyUseFastStepping;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
bool TargetProperties::GetDisplayExpressionsInCrashlogs() const {
const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
LoadScriptFromSymFile TargetProperties::GetLoadScriptFromSymbolFile() const {
const uint32_t idx = ePropertyLoadScriptFromSymbolFile;
return (LoadScriptFromSymFile)
m_collection_sp->GetPropertyAtIndexAsEnumeration(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_target_properties[idx].default_uint_value);
}
LoadCWDlldbinitFile TargetProperties::GetLoadCWDlldbinitFile() const {
const uint32_t idx = ePropertyLoadCWDlldbinitFile;
return (LoadCWDlldbinitFile)m_collection_sp->GetPropertyAtIndexAsEnumeration(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_target_properties[idx].default_uint_value);
}
Disassembler::HexImmediateStyle TargetProperties::GetHexImmediateStyle() const {
const uint32_t idx = ePropertyHexImmediateStyle;
return (Disassembler::HexImmediateStyle)
m_collection_sp->GetPropertyAtIndexAsEnumeration(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_target_properties[idx].default_uint_value);
}
MemoryModuleLoadLevel TargetProperties::GetMemoryModuleLoadLevel() const {
const uint32_t idx = ePropertyMemoryModuleLoadLevel;
return (MemoryModuleLoadLevel)
m_collection_sp->GetPropertyAtIndexAsEnumeration(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_target_properties[idx].default_uint_value);
}
bool TargetProperties::GetUserSpecifiedTrapHandlerNames(Args &args) const {
@@ -4122,7 +3988,7 @@ void TargetProperties::SetProcessLaunchInfo(
bool TargetProperties::GetRequireHardwareBreakpoints() const {
const uint32_t idx = ePropertyRequireHardwareBreakpoints;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
void TargetProperties::SetRequireHardwareBreakpoints(bool b) {
@@ -4259,3 +4125,10 @@ Target::TargetEventData::GetModuleListFromEvent(const Event *event_ptr) {
module_list = event_data->m_module_list;
return module_list;
}
+
+std::recursive_mutex &Target::GetAPIMutex() {
+ if (GetProcessSP() && GetProcessSP()->CurrentThreadIsPrivateStateThread())
+ return m_private_mutex;
+ else
+ return m_mutex;
+}