aboutsummaryrefslogtreecommitdiffstats
path: root/source/Target
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
commitead246455adf1a215ec2715dad6533073a6beb4e (patch)
treef3f97a47d77053bf96fe74cdbd6fae74380e8a92 /source/Target
parentfdb00c4408990a0a63ef7f496d809ce59f263bc5 (diff)
downloadsrc-vendor/lldb.tar.gz
src-vendor/lldb.zip
Vendor import of stripped lldb trunk r375505, the last commit before thevendor/lldb/lldb-trunk-r375505vendor/lldb
upstream Subversion repository was made read-only, and the LLVM project migrated to GitHub: https://llvm.org/svn/llvm-project/lldb/trunk@375505
Notes
Notes: svn path=/vendor/lldb/dist/; revision=353952 svn path=/vendor/lldb/lldb-r375505/; revision=353953; tag=vendor/lldb/lldb-trunk-r375505
Diffstat (limited to 'source/Target')
-rw-r--r--source/Target/ABI.cpp19
-rw-r--r--source/Target/ExecutionContext.cpp4
-rw-r--r--source/Target/Language.cpp24
-rw-r--r--source/Target/LanguageRuntime.cpp7
-rw-r--r--source/Target/Memory.cpp28
-rw-r--r--source/Target/ModuleCache.cpp29
-rw-r--r--source/Target/Platform.cpp150
-rw-r--r--source/Target/Process.cpp837
-rw-r--r--source/Target/RegisterContext.cpp8
-rw-r--r--source/Target/RemoteAwarePlatform.cpp4
-rw-r--r--source/Target/SectionLoadList.cpp12
-rw-r--r--source/Target/StackFrame.cpp42
-rw-r--r--source/Target/StackFrameList.cpp78
-rw-r--r--source/Target/StopInfo.cpp117
-rw-r--r--source/Target/Target.cpp1127
-rw-r--r--source/Target/TargetProperties.td237
-rw-r--r--source/Target/Thread.cpp250
-rw-r--r--source/Target/ThreadList.cpp55
-rw-r--r--source/Target/ThreadPlan.cpp3
-rw-r--r--source/Target/ThreadPlanBase.cpp40
-rw-r--r--source/Target/ThreadPlanCallFunction.cpp132
-rw-r--r--source/Target/ThreadPlanCallUserExpression.cpp5
-rw-r--r--source/Target/ThreadPlanPython.cpp42
-rw-r--r--source/Target/ThreadPlanRunToAddress.cpp3
-rw-r--r--source/Target/ThreadPlanShouldStopHere.cpp17
-rw-r--r--source/Target/ThreadPlanStepInRange.cpp70
-rw-r--r--source/Target/ThreadPlanStepInstruction.cpp24
-rw-r--r--source/Target/ThreadPlanStepOut.cpp4
-rw-r--r--source/Target/ThreadPlanStepOverBreakpoint.cpp16
-rw-r--r--source/Target/ThreadPlanStepOverRange.cpp14
-rw-r--r--source/Target/ThreadPlanStepRange.cpp57
-rw-r--r--source/Target/ThreadPlanStepThrough.cpp16
-rw-r--r--source/Target/ThreadPlanStepUntil.cpp3
-rw-r--r--source/Target/ThreadPlanTracer.cpp21
34 files changed, 1773 insertions, 1722 deletions
diff --git a/source/Target/ABI.cpp b/source/Target/ABI.cpp
index 28cd9aec665c..005261e0ddee 100644
--- a/source/Target/ABI.cpp
+++ b/source/Target/ABI.cpp
@@ -15,6 +15,8 @@
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Log.h"
+#include "llvm/Support/TargetRegistry.h"
using namespace lldb;
using namespace lldb_private;
@@ -210,3 +212,20 @@ bool ABI::GetFallbackRegisterLocation(
return false;
}
+
+std::unique_ptr<llvm::MCRegisterInfo> ABI::MakeMCRegisterInfo(const ArchSpec &arch) {
+ std::string triple = arch.GetTriple().getTriple();
+ std::string lookup_error;
+ const llvm::Target *target =
+ llvm::TargetRegistry::lookupTarget(triple, lookup_error);
+ if (!target) {
+ LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS),
+ "Failed to create an llvm target for {0}: {1}", triple,
+ lookup_error);
+ return nullptr;
+ }
+ std::unique_ptr<llvm::MCRegisterInfo> info_up(
+ target->createMCRegInfo(triple));
+ assert(info_up);
+ return info_up;
+}
diff --git a/source/Target/ExecutionContext.cpp b/source/Target/ExecutionContext.cpp
index 77327372f88b..a24a098eb300 100644
--- a/source/Target/ExecutionContext.cpp
+++ b/source/Target/ExecutionContext.cpp
@@ -183,9 +183,9 @@ uint32_t ExecutionContext::GetAddressByteSize() const {
lldb::ByteOrder ExecutionContext::GetByteOrder() const {
if (m_target_sp && m_target_sp->GetArchitecture().IsValid())
- m_target_sp->GetArchitecture().GetByteOrder();
+ return m_target_sp->GetArchitecture().GetByteOrder();
if (m_process_sp)
- m_process_sp->GetByteOrder();
+ return m_process_sp->GetByteOrder();
return endian::InlHostByteOrder();
}
diff --git a/source/Target/Language.cpp b/source/Target/Language.cpp
index 3c3ef2841d44..43d0be0f737c 100644
--- a/source/Target/Language.cpp
+++ b/source/Target/Language.cpp
@@ -357,26 +357,16 @@ std::set<lldb::LanguageType> Language::GetSupportedLanguages() {
return supported_languages;
}
-void Language::GetLanguagesSupportingTypeSystems(
- std::set<lldb::LanguageType> &languages,
- std::set<lldb::LanguageType> &languages_for_expressions) {
- uint32_t idx = 0;
-
- while (TypeSystemEnumerateSupportedLanguages enumerate = PluginManager::
- GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(idx++)) {
- (*enumerate)(languages, languages_for_expressions);
- }
+LanguageSet Language::GetLanguagesSupportingTypeSystems() {
+ return PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
}
-void Language::GetLanguagesSupportingREPLs(
- std::set<lldb::LanguageType> &languages) {
- uint32_t idx = 0;
+LanguageSet Language::GetLanguagesSupportingTypeSystemsForExpressions() {
+ return PluginManager::GetAllTypeSystemSupportedLanguagesForExpressions();
+}
- while (REPLEnumerateSupportedLanguages enumerate =
- PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex(
- idx++)) {
- (*enumerate)(languages);
- }
+LanguageSet Language::GetLanguagesSupportingREPLs() {
+ return PluginManager::GetREPLAllTypeSystemSupportedLanguages();
}
std::unique_ptr<Language::TypeScavenger> Language::GetTypeScavenger() {
diff --git a/source/Target/LanguageRuntime.cpp b/source/Target/LanguageRuntime.cpp
index dd4415810613..999ac99e93c3 100644
--- a/source/Target/LanguageRuntime.cpp
+++ b/source/Target/LanguageRuntime.cpp
@@ -111,12 +111,11 @@ public:
~ExceptionBreakpointResolver() override = default;
Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
- SymbolContext &context, Address *addr,
- bool containing) override {
+ SymbolContext &context,
+ Address *addr) override {
if (SetActualResolver())
- return m_actual_resolver_sp->SearchCallback(filter, context, addr,
- containing);
+ return m_actual_resolver_sp->SearchCallback(filter, context, addr);
else
return eCallbackReturnStop;
}
diff --git a/source/Target/Memory.cpp b/source/Target/Memory.cpp
index 31a378069cec..7c77cc06eb03 100644
--- a/source/Target/Memory.cpp
+++ b/source/Target/Memory.cpp
@@ -348,10 +348,11 @@ AllocatedMemoryCache::AllocatePage(uint32_t byte_size, uint32_t permissions,
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
if (log) {
- log->Printf("Process::DoAllocateMemory (byte_size = 0x%8.8" PRIx32
- ", permissions = %s) => 0x%16.16" PRIx64,
- (uint32_t)page_byte_size, GetPermissionsAsCString(permissions),
- (uint64_t)addr);
+ LLDB_LOGF(log,
+ "Process::DoAllocateMemory (byte_size = 0x%8.8" PRIx32
+ ", permissions = %s) => 0x%16.16" PRIx64,
+ (uint32_t)page_byte_size, GetPermissionsAsCString(permissions),
+ (uint64_t)addr);
}
if (addr != LLDB_INVALID_ADDRESS) {
@@ -385,12 +386,11 @@ lldb::addr_t AllocatedMemoryCache::AllocateMemory(size_t byte_size,
addr = block_sp->ReserveBlock(byte_size);
}
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "AllocatedMemoryCache::AllocateMemory (byte_size = 0x%8.8" PRIx32
- ", permissions = %s) => 0x%16.16" PRIx64,
- (uint32_t)byte_size, GetPermissionsAsCString(permissions),
- (uint64_t)addr);
+ LLDB_LOGF(log,
+ "AllocatedMemoryCache::AllocateMemory (byte_size = 0x%8.8" PRIx32
+ ", permissions = %s) => 0x%16.16" PRIx64,
+ (uint32_t)byte_size, GetPermissionsAsCString(permissions),
+ (uint64_t)addr);
return addr;
}
@@ -406,9 +406,9 @@ bool AllocatedMemoryCache::DeallocateMemory(lldb::addr_t addr) {
}
}
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("AllocatedMemoryCache::DeallocateMemory (addr = 0x%16.16" PRIx64
- ") => %i",
- (uint64_t)addr, success);
+ LLDB_LOGF(log,
+ "AllocatedMemoryCache::DeallocateMemory (addr = 0x%16.16" PRIx64
+ ") => %i",
+ (uint64_t)addr, success);
return success;
}
diff --git a/source/Target/ModuleCache.cpp b/source/Target/ModuleCache.cpp
index 444c9806f98b..124cdacfb4d2 100644
--- a/source/Target/ModuleCache.cpp
+++ b/source/Target/ModuleCache.cpp
@@ -48,7 +48,7 @@ std::string GetEscapedHostname(const char *hostname) {
class ModuleLock {
private:
- File m_file;
+ FileUP m_file_up;
std::unique_ptr<lldb_private::LockFile> m_lock;
FileSpec m_file_spec;
@@ -94,9 +94,8 @@ void DeleteExistingModule(const FileSpec &root_dir_spec,
Status error;
ModuleLock lock(root_dir_spec, module_uuid, error);
if (error.Fail()) {
- if (log)
- log->Printf("Failed to lock module %s: %s",
- module_uuid.GetAsString().c_str(), error.AsCString());
+ LLDB_LOGF(log, "Failed to lock module %s: %s",
+ module_uuid.GetAsString().c_str(), error.AsCString());
}
namespace fs = llvm::sys::fs;
@@ -158,16 +157,19 @@ ModuleLock::ModuleLock(const FileSpec &root_dir_spec, const UUID &uuid,
return;
m_file_spec = JoinPath(lock_dir_spec, uuid.GetAsString().c_str());
- FileSystem::Instance().Open(m_file, m_file_spec,
- File::eOpenOptionWrite |
- File::eOpenOptionCanCreate |
- File::eOpenOptionCloseOnExec);
- if (!m_file) {
- error.SetErrorToErrno();
+
+ auto file = FileSystem::Instance().Open(
+ m_file_spec, File::eOpenOptionWrite | File::eOpenOptionCanCreate |
+ File::eOpenOptionCloseOnExec);
+ if (file)
+ m_file_up = std::move(file.get());
+ else {
+ m_file_up.reset();
+ error = Status(file.takeError());
return;
}
- m_lock.reset(new lldb_private::LockFile(m_file.GetDescriptor()));
+ m_lock.reset(new lldb_private::LockFile(m_file_up->GetDescriptor()));
error = m_lock->WriteLock(0, 1);
if (error.Fail())
error.SetErrorStringWithFormat("Failed to lock file: %s",
@@ -175,10 +177,11 @@ ModuleLock::ModuleLock(const FileSpec &root_dir_spec, const UUID &uuid,
}
void ModuleLock::Delete() {
- if (!m_file)
+ if (!m_file_up)
return;
- m_file.Close();
+ m_file_up->Close();
+ m_file_up.reset();
llvm::sys::fs::remove(m_file_spec.GetPath());
}
diff --git a/source/Target/Platform.cpp b/source/Target/Platform.cpp
index 710f82eaefa9..c9849a9e5f09 100644
--- a/source/Target/Platform.cpp
+++ b/source/Target/Platform.cpp
@@ -63,13 +63,13 @@ const char *Platform::GetHostPlatformName() { return "host"; }
namespace {
-static constexpr PropertyDefinition g_properties[] = {
- {"use-module-cache", OptionValue::eTypeBoolean, true, true, nullptr,
- {}, "Use module cache."},
- {"module-cache-directory", OptionValue::eTypeFileSpec, true, 0, nullptr,
- {}, "Root directory for cached modules."}};
+#define LLDB_PROPERTIES_platform
+#include "TargetProperties.inc"
-enum { ePropertyUseModuleCache, ePropertyModuleCacheDirectory };
+enum {
+#define LLDB_PROPERTIES_platform
+#include "TargetPropertiesEnum.inc"
+};
} // namespace
@@ -80,7 +80,7 @@ ConstString PlatformProperties::GetSettingName() {
PlatformProperties::PlatformProperties() {
m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
- m_collection_sp->Initialize(g_properties);
+ m_collection_sp->Initialize(g_platform_properties);
auto module_cache_dir = GetModuleCacheDirectory();
if (module_cache_dir)
@@ -99,7 +99,7 @@ PlatformProperties::PlatformProperties() {
bool PlatformProperties::GetUseModuleCache() const {
const auto idx = ePropertyUseModuleCache;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_platform_properties[idx].default_uint_value != 0);
}
bool PlatformProperties::SetUseModuleCache(bool use_module_cache) {
@@ -384,10 +384,9 @@ Platform::Platform(bool is_host)
m_rsync_opts(), m_rsync_prefix(), m_supports_ssh(false), m_ssh_opts(),
m_ignores_remote_hostname(false), m_trap_handlers(),
m_calculated_trap_handlers(false),
- m_module_cache(llvm::make_unique<ModuleCache>()) {
+ m_module_cache(std::make_unique<ModuleCache>()) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p Platform::Platform()", static_cast<void *>(this));
+ LLDB_LOGF(log, "%p Platform::Platform()", static_cast<void *>(this));
}
/// Destructor.
@@ -396,8 +395,7 @@ Platform::Platform(bool is_host)
/// inherited from by the plug-in instance.
Platform::~Platform() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p Platform::~Platform()", static_cast<void *>(this));
+ LLDB_LOGF(log, "%p Platform::~Platform()", static_cast<void *>(this));
}
void Platform::GetStatus(Stream &strm) {
@@ -637,9 +635,8 @@ Status Platform::Install(const FileSpec &src, const FileSpec &dst) {
Status error;
Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
- if (log)
- log->Printf("Platform::Install (src='%s', dst='%s')", src.GetPath().c_str(),
- dst.GetPath().c_str());
+ LLDB_LOGF(log, "Platform::Install (src='%s', dst='%s')",
+ src.GetPath().c_str(), dst.GetPath().c_str());
FileSpec fixed_dst(dst);
if (!fixed_dst.GetFilename())
@@ -690,10 +687,9 @@ Status Platform::Install(const FileSpec &src, const FileSpec &dst) {
}
}
- if (log)
- log->Printf("Platform::Install (src='%s', dst='%s') fixed_dst='%s'",
- src.GetPath().c_str(), dst.GetPath().c_str(),
- fixed_dst.GetPath().c_str());
+ LLDB_LOGF(log, "Platform::Install (src='%s', dst='%s') fixed_dst='%s'",
+ src.GetPath().c_str(), dst.GetPath().c_str(),
+ fixed_dst.GetPath().c_str());
if (GetSupportsRSync()) {
error = PutFile(src, dst);
@@ -821,9 +817,8 @@ ConstString Platform::GetFullNameForDylib(ConstString basename) {
bool Platform::SetRemoteWorkingDirectory(const FileSpec &working_dir) {
Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
- if (log)
- log->Printf("Platform::SetRemoteWorkingDirectory('%s')",
- working_dir.GetCString());
+ LLDB_LOGF(log, "Platform::SetRemoteWorkingDirectory('%s')",
+ working_dir.GetCString());
m_working_dir = working_dir;
return true;
}
@@ -1010,8 +1005,7 @@ uint32_t Platform::FindProcesses(const ProcessInstanceInfoMatch &match_info,
Status Platform::LaunchProcess(ProcessLaunchInfo &launch_info) {
Status error;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
- if (log)
- log->Printf("Platform::%s()", __FUNCTION__);
+ LLDB_LOGF(log, "Platform::%s()", __FUNCTION__);
// Take care of the host case so that each subclass can just call this
// function to get the host functionality.
@@ -1027,10 +1021,10 @@ Status Platform::LaunchProcess(ProcessLaunchInfo &launch_info) {
if (log) {
const FileSpec &shell = launch_info.GetShell();
std::string shell_str = (shell) ? shell.GetPath() : "<null>";
- log->Printf(
- "Platform::%s GetResumeCountForLaunchInfo() returned %" PRIu32
- ", shell is '%s'",
- __FUNCTION__, num_resumes, shell_str.c_str());
+ LLDB_LOGF(log,
+ "Platform::%s GetResumeCountForLaunchInfo() returned %" PRIu32
+ ", shell is '%s'",
+ __FUNCTION__, num_resumes, shell_str.c_str());
}
if (!launch_info.ConvertArgumentsForLaunchingInShell(
@@ -1048,9 +1042,8 @@ Status Platform::LaunchProcess(ProcessLaunchInfo &launch_info) {
}
}
- if (log)
- log->Printf("Platform::%s final launch_info resume count: %" PRIu32,
- __FUNCTION__, launch_info.GetResumeCount());
+ LLDB_LOGF(log, "Platform::%s final launch_info resume count: %" PRIu32,
+ __FUNCTION__, launch_info.GetResumeCount());
error = Host::LaunchProcess(launch_info);
} else
@@ -1067,8 +1060,7 @@ Status Platform::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
Status Platform::KillProcess(const lldb::pid_t pid) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
- if (log)
- log->Printf("Platform::%s, pid %" PRIu64, __FUNCTION__, pid);
+ LLDB_LOGF(log, "Platform::%s, pid %" PRIu64, __FUNCTION__, pid);
// Try to find a process plugin to handle this Kill request. If we can't,
// fall back to the default OS implementation.
@@ -1098,9 +1090,8 @@ Platform::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
// new target, else use existing one
Status &error) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
- if (log)
- log->Printf("Platform::%s entered (target %p)", __FUNCTION__,
- static_cast<void *>(target));
+ LLDB_LOGF(log, "Platform::%s entered (target %p)", __FUNCTION__,
+ static_cast<void *>(target));
ProcessSP process_sp;
// Make sure we stop at the entry point
@@ -1124,10 +1115,10 @@ Platform::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
// Give this ProcessLaunchInfo filter a chance to adjust the launch info.
error = (*filter_callback)(launch_info, target);
if (!error.Success()) {
- if (log)
- log->Printf("Platform::%s() StructuredDataPlugin launch "
- "filter failed.",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "Platform::%s() StructuredDataPlugin launch "
+ "filter failed.",
+ __FUNCTION__);
return process_sp;
}
}
@@ -1135,17 +1126,15 @@ Platform::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
error = LaunchProcess(launch_info);
if (error.Success()) {
- if (log)
- log->Printf("Platform::%s LaunchProcess() call succeeded (pid=%" PRIu64
- ")",
- __FUNCTION__, launch_info.GetProcessID());
+ LLDB_LOGF(log,
+ "Platform::%s LaunchProcess() call succeeded (pid=%" PRIu64 ")",
+ __FUNCTION__, launch_info.GetProcessID());
if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) {
ProcessAttachInfo attach_info(launch_info);
process_sp = Attach(attach_info, debugger, target, error);
if (process_sp) {
- if (log)
- log->Printf("Platform::%s Attach() succeeded, Process plugin: %s",
- __FUNCTION__, process_sp->GetPluginName().AsCString());
+ LLDB_LOGF(log, "Platform::%s Attach() succeeded, Process plugin: %s",
+ __FUNCTION__, process_sp->GetPluginName().AsCString());
launch_info.SetHijackListener(attach_info.GetHijackListener());
// Since we attached to the process, it will think it needs to detach
@@ -1163,20 +1152,18 @@ Platform::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
process_sp->SetSTDIOFileDescriptor(pty_fd);
}
} else {
- if (log)
- log->Printf("Platform::%s Attach() failed: %s", __FUNCTION__,
- error.AsCString());
+ LLDB_LOGF(log, "Platform::%s Attach() failed: %s", __FUNCTION__,
+ error.AsCString());
}
} else {
- if (log)
- log->Printf("Platform::%s LaunchProcess() returned launch_info with "
- "invalid process id",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "Platform::%s LaunchProcess() returned launch_info with "
+ "invalid process id",
+ __FUNCTION__);
}
} else {
- if (log)
- log->Printf("Platform::%s LaunchProcess() failed: %s", __FUNCTION__,
- error.AsCString());
+ LLDB_LOGF(log, "Platform::%s LaunchProcess() failed: %s", __FUNCTION__,
+ error.AsCString());
}
return process_sp;
@@ -1231,30 +1218,28 @@ bool Platform::IsCompatibleArchitecture(const ArchSpec &arch,
Status Platform::PutFile(const FileSpec &source, const FileSpec &destination,
uint32_t uid, uint32_t gid) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
- if (log)
- log->Printf("[PutFile] Using block by block transfer....\n");
+ LLDB_LOGF(log, "[PutFile] Using block by block transfer....\n");
- uint32_t source_open_options =
+ auto source_open_options =
File::eOpenOptionRead | File::eOpenOptionCloseOnExec;
namespace fs = llvm::sys::fs;
if (fs::is_symlink_file(source.GetPath()))
source_open_options |= File::eOpenOptionDontFollowSymlinks;
- File source_file;
- Status error = FileSystem::Instance().Open(
- source_file, source, source_open_options, lldb::eFilePermissionsUserRW);
- uint32_t permissions = source_file.GetPermissions(error);
+ auto source_file = FileSystem::Instance().Open(source, source_open_options,
+ lldb::eFilePermissionsUserRW);
+ if (!source_file)
+ return Status(source_file.takeError());
+ Status error;
+ uint32_t permissions = source_file.get()->GetPermissions(error);
if (permissions == 0)
permissions = lldb::eFilePermissionsFileDefault;
- if (!source_file.IsValid())
- return Status("PutFile: unable to open source file");
lldb::user_id_t dest_file = OpenFile(
destination, File::eOpenOptionCanCreate | File::eOpenOptionWrite |
File::eOpenOptionTruncate | File::eOpenOptionCloseOnExec,
permissions, error);
- if (log)
- log->Printf("dest_file = %" PRIu64 "\n", dest_file);
+ LLDB_LOGF(log, "dest_file = %" PRIu64 "\n", dest_file);
if (error.Fail())
return error;
@@ -1264,7 +1249,7 @@ Status Platform::PutFile(const FileSpec &source, const FileSpec &destination,
uint64_t offset = 0;
for (;;) {
size_t bytes_read = buffer_sp->GetByteSize();
- error = source_file.Read(buffer_sp->GetBytes(), bytes_read);
+ error = source_file.get()->Read(buffer_sp->GetBytes(), bytes_read);
if (error.Fail() || bytes_read == 0)
break;
@@ -1277,7 +1262,7 @@ Status Platform::PutFile(const FileSpec &source, const FileSpec &destination,
if (bytes_written != bytes_read) {
// We didn't write the correct number of bytes, so adjust the file
// position in the source file we are reading from...
- source_file.SeekFromStart(offset);
+ source_file.get()->SeekFromStart(offset);
}
}
CloseFile(dest_file, error);
@@ -1630,10 +1615,9 @@ bool Platform::GetCachedSharedModule(const ModuleSpec &module_spec,
if (error.Success())
return true;
- if (log)
- log->Printf("Platform::%s - module %s not found in local cache: %s",
- __FUNCTION__, module_spec.GetUUID().GetAsString().c_str(),
- error.AsCString());
+ LLDB_LOGF(log, "Platform::%s - module %s not found in local cache: %s",
+ __FUNCTION__, module_spec.GetUUID().GetAsString().c_str(),
+ error.AsCString());
return false;
}
@@ -1644,7 +1628,7 @@ Status Platform::DownloadModuleSlice(const FileSpec &src_file_spec,
Status error;
std::error_code EC;
- llvm::raw_fd_ostream dst(dst_file_spec.GetPath(), EC, llvm::sys::fs::F_None);
+ llvm::raw_fd_ostream dst(dst_file_spec.GetPath(), EC, llvm::sys::fs::OF_None);
if (EC) {
error.SetErrorStringWithFormat("unable to open destination file: %s",
dst_file_spec.GetPath().c_str());
@@ -1736,7 +1720,7 @@ uint32_t Platform::LoadImage(lldb_private::Process *process,
return LLDB_INVALID_IMAGE_TOKEN;
}
return DoLoadImage(process, target_file, nullptr, error);
- }
+ }
if (remote_file) {
// Only remote file was specified so we don't have to do any copying
@@ -1769,7 +1753,7 @@ uint32_t Platform::LoadImageUsingPaths(lldb_private::Process *process,
remote_filename.GetPathStyle());
else
file_to_use = remote_filename;
-
+
return DoLoadImage(process, file_to_use, &paths, error, loaded_path);
}
@@ -1812,8 +1796,7 @@ lldb::ProcessSP Platform::ConnectProcess(llvm::StringRef connect_url,
if (!process_sp)
return nullptr;
- error =
- process_sp->ConnectRemote(debugger.GetOutputFile().get(), connect_url);
+ error = process_sp->ConnectRemote(&debugger.GetOutputStream(), connect_url);
if (error.Fail())
return nullptr;
@@ -1833,12 +1816,19 @@ size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target,
size_t trap_opcode_size = 0;
switch (arch.GetMachine()) {
+ case llvm::Triple::aarch64_32:
case llvm::Triple::aarch64: {
static const uint8_t g_aarch64_opcode[] = {0x00, 0x00, 0x20, 0xd4};
trap_opcode = g_aarch64_opcode;
trap_opcode_size = sizeof(g_aarch64_opcode);
} break;
+ case llvm::Triple::arc: {
+ static const uint8_t g_hex_opcode[] = { 0xff, 0x7f };
+ trap_opcode = g_hex_opcode;
+ trap_opcode_size = sizeof(g_hex_opcode);
+ } break;
+
// TODO: support big-endian arm and thumb trap codes.
case llvm::Triple::arm: {
// The ARM reference recommends the use of 0xe7fddefe and 0xdefe but the
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index 6c634dba00c7..ed0b951fbce1 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -13,7 +13,6 @@
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/Threading.h"
-#include "Plugins/Process/Utility/InferiorCallPOSIX.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
@@ -59,6 +58,7 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanBase.h"
+#include "lldb/Target/ThreadPlanCallFunction.h"
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/Event.h"
#include "lldb/Utility/Log.h"
@@ -112,55 +112,12 @@ public:
}
};
-static constexpr PropertyDefinition g_properties[] = {
- {"disable-memory-cache", OptionValue::eTypeBoolean, false,
- DISABLE_MEM_CACHE_DEFAULT, nullptr, {},
- "Disable reading and caching of memory in fixed-size units."},
- {"extra-startup-command", OptionValue::eTypeArray, false,
- OptionValue::eTypeString, nullptr, {},
- "A list containing extra commands understood by the particular process "
- "plugin used. "
- "For instance, to turn on debugserver logging set this to "
- "\"QSetLogging:bitmask=LOG_DEFAULT;\""},
- {"ignore-breakpoints-in-expressions", OptionValue::eTypeBoolean, true, true,
- nullptr, {},
- "If true, breakpoints will be ignored during expression evaluation."},
- {"unwind-on-error-in-expressions", OptionValue::eTypeBoolean, true, true,
- nullptr, {}, "If true, errors in expression evaluation will unwind "
- "the stack back to the state before the call."},
- {"python-os-plugin-path", OptionValue::eTypeFileSpec, false, true, nullptr,
- {}, "A path to a python OS plug-in module file that contains a "
- "OperatingSystemPlugIn class."},
- {"stop-on-sharedlibrary-events", OptionValue::eTypeBoolean, true, false,
- nullptr, {},
- "If true, stop when a shared library is loaded or unloaded."},
- {"detach-keeps-stopped", OptionValue::eTypeBoolean, true, false, nullptr,
- {}, "If true, detach will attempt to keep the process stopped."},
- {"memory-cache-line-size", OptionValue::eTypeUInt64, false, 512, nullptr,
- {}, "The memory cache line size"},
- {"optimization-warnings", OptionValue::eTypeBoolean, false, true, nullptr,
- {}, "If true, warn when stopped in code that is optimized where "
- "stepping and variable availability may not behave as expected."},
- {"stop-on-exec", OptionValue::eTypeBoolean, true, true,
- nullptr, {},
- "If true, stop when a shared library is loaded or unloaded."},
- {"utility-expression-timeout", OptionValue::eTypeUInt64, false, 15,
- nullptr, {},
- "The time in seconds to wait for LLDB-internal utility expressions."}
-};
+#define LLDB_PROPERTIES_process
+#include "TargetProperties.inc"
enum {
- ePropertyDisableMemCache,
- ePropertyExtraStartCommand,
- ePropertyIgnoreBreakpointsInExpressions,
- ePropertyUnwindOnErrorInExpressions,
- ePropertyPythonOSPluginPath,
- ePropertyStopOnSharedLibraryEvents,
- ePropertyDetachKeepsStopped,
- ePropertyMemCacheLineSize,
- ePropertyWarningOptimization,
- ePropertyStopOnExec,
- ePropertyUtilityExpressionTimeout,
+#define LLDB_PROPERTIES_process
+#include "TargetPropertiesEnum.inc"
};
ProcessProperties::ProcessProperties(lldb_private::Process *process)
@@ -171,7 +128,7 @@ ProcessProperties::ProcessProperties(lldb_private::Process *process)
// Global process properties, set them up one time
m_collection_sp =
std::make_shared<ProcessOptionValueProperties>(ConstString("process"));
- m_collection_sp->Initialize(g_properties);
+ m_collection_sp->Initialize(g_process_properties);
m_collection_sp->AppendProperty(
ConstString("thread"), ConstString("Settings specific to threads."),
true, Thread::GetGlobalProperties()->GetValueProperties());
@@ -196,13 +153,13 @@ void ProcessProperties::OptionValueChangedCallback(void *baton,
bool ProcessProperties::GetDisableMemoryCache() const {
const uint32_t idx = ePropertyDisableMemCache;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
uint64_t ProcessProperties::GetMemoryCacheLineSize() const {
const uint32_t idx = ePropertyMemCacheLineSize;
return m_collection_sp->GetPropertyAtIndexAsUInt64(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_process_properties[idx].default_uint_value);
}
Args ProcessProperties::GetExtraStartupCommands() const {
@@ -230,7 +187,7 @@ void ProcessProperties::SetPythonOSPluginPath(const FileSpec &file) {
bool ProcessProperties::GetIgnoreBreakpointsInExpressions() const {
const uint32_t idx = ePropertyIgnoreBreakpointsInExpressions;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
void ProcessProperties::SetIgnoreBreakpointsInExpressions(bool ignore) {
@@ -241,7 +198,7 @@ void ProcessProperties::SetIgnoreBreakpointsInExpressions(bool ignore) {
bool ProcessProperties::GetUnwindOnErrorInExpressions() const {
const uint32_t idx = ePropertyUnwindOnErrorInExpressions;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
void ProcessProperties::SetUnwindOnErrorInExpressions(bool ignore) {
@@ -252,7 +209,7 @@ void ProcessProperties::SetUnwindOnErrorInExpressions(bool ignore) {
bool ProcessProperties::GetStopOnSharedLibraryEvents() const {
const uint32_t idx = ePropertyStopOnSharedLibraryEvents;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
void ProcessProperties::SetStopOnSharedLibraryEvents(bool stop) {
@@ -263,7 +220,7 @@ void ProcessProperties::SetStopOnSharedLibraryEvents(bool stop) {
bool ProcessProperties::GetDetachKeepsStopped() const {
const uint32_t idx = ePropertyDetachKeepsStopped;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
void ProcessProperties::SetDetachKeepsStopped(bool stop) {
@@ -274,19 +231,19 @@ void ProcessProperties::SetDetachKeepsStopped(bool stop) {
bool ProcessProperties::GetWarningsOptimization() const {
const uint32_t idx = ePropertyWarningOptimization;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
bool ProcessProperties::GetStopOnExec() const {
const uint32_t idx = ePropertyStopOnExec;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
std::chrono::seconds ProcessProperties::GetUtilityExpressionTimeout() const {
const uint32_t idx = ePropertyUtilityExpressionTimeout;
uint64_t value = m_collection_sp->GetPropertyAtIndexAsUInt64(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_process_properties[idx].default_uint_value);
return std::chrono::seconds(value);
}
@@ -544,8 +501,7 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp,
CheckInWithManager();
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p Process::Process()", static_cast<void *>(this));
+ LLDB_LOGF(log, "%p Process::Process()", static_cast<void *>(this));
if (!m_unix_signals_sp)
m_unix_signals_sp = std::make_shared<UnixSignals>();
@@ -593,8 +549,7 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp,
Process::~Process() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p Process::~Process()", static_cast<void *>(this));
+ LLDB_LOGF(log, "%p Process::~Process()", static_cast<void *>(this));
StopPrivateStateThread();
// ThreadList::Clear() will try to acquire this process's mutex, so
@@ -781,10 +736,10 @@ StateType Process::WaitForProcessToStop(const Timeout<std::micro> &timeout,
if (!wait_always && StateIsStoppedState(state, true) &&
StateIsStoppedState(GetPrivateState(), true)) {
- if (log)
- log->Printf("Process::%s returning without waiting for events; process "
- "private and public states are already 'stopped'.",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "Process::%s returning without waiting for events; process "
+ "private and public states are already 'stopped'.",
+ __FUNCTION__);
// We need to toggle the run lock as this won't get done in
// SetPublicState() if the process is hijacked.
if (hijack_listener_sp && use_run_lock)
@@ -1073,19 +1028,17 @@ StateType Process::GetStateChangedEvents(EventSP &event_sp,
Event *Process::PeekAtStateChangedEvents() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::%s...", __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s...", __FUNCTION__);
Event *event_ptr;
event_ptr = m_listener_sp->PeekAtNextEventForBroadcasterWithType(
this, eBroadcastBitStateChanged);
if (log) {
if (event_ptr) {
- log->Printf(
- "Process::%s (event_ptr) => %s", __FUNCTION__,
- StateAsCString(ProcessEventData::GetStateFromEvent(event_ptr)));
+ LLDB_LOGF(log, "Process::%s (event_ptr) => %s", __FUNCTION__,
+ StateAsCString(ProcessEventData::GetStateFromEvent(event_ptr)));
} else {
- log->Printf("Process::%s no events found", __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s no events found", __FUNCTION__);
}
}
return event_ptr;
@@ -1149,17 +1102,14 @@ bool Process::SetExitStatus(int status, const char *cstr) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STATE |
LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "Process::SetExitStatus (status=%i (0x%8.8x), description=%s%s%s)",
- status, status, cstr ? "\"" : "", cstr ? cstr : "NULL",
- cstr ? "\"" : "");
+ LLDB_LOGF(
+ log, "Process::SetExitStatus (status=%i (0x%8.8x), description=%s%s%s)",
+ status, status, cstr ? "\"" : "", cstr ? cstr : "NULL", cstr ? "\"" : "");
// We were already in the exited state
if (m_private_state.GetValue() == eStateExited) {
- if (log)
- log->Printf("Process::SetExitStatus () ignoring exit status because "
- "state was already set to eStateExited");
+ LLDB_LOGF(log, "Process::SetExitStatus () ignoring exit status because "
+ "state was already set to eStateExited");
return false;
}
@@ -1207,10 +1157,10 @@ bool Process::SetProcessExitStatus(
int exit_status // Exit value of process if signal is zero
) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::SetProcessExitStatus (pid=%" PRIu64
- ", exited=%i, signal=%i, exit_status=%i)\n",
- pid, exited, signo, exit_status);
+ LLDB_LOGF(log,
+ "Process::SetProcessExitStatus (pid=%" PRIu64
+ ", exited=%i, signal=%i, exit_status=%i)\n",
+ pid, exited, signo, exit_status);
if (exited) {
TargetSP target_sp(Debugger::FindTargetWithProcessID(pid));
@@ -1353,9 +1303,8 @@ StateType Process::GetState() {
void Process::SetPublicState(StateType new_state, bool restarted) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STATE |
LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::SetPublicState (state = %s, restarted = %i)",
- StateAsCString(new_state), restarted);
+ LLDB_LOGF(log, "Process::SetPublicState (state = %s, restarted = %i)",
+ StateAsCString(new_state), restarted);
const StateType old_state = m_public_state.GetValue();
m_public_state.SetValue(new_state);
@@ -1364,19 +1313,17 @@ void Process::SetPublicState(StateType new_state, bool restarted) {
// program to run.
if (!StateChangedIsExternallyHijacked()) {
if (new_state == eStateDetached) {
- if (log)
- log->Printf(
- "Process::SetPublicState (%s) -- unlocking run lock for detach",
- StateAsCString(new_state));
+ LLDB_LOGF(log,
+ "Process::SetPublicState (%s) -- unlocking run lock for detach",
+ StateAsCString(new_state));
m_public_run_lock.SetStopped();
} else {
const bool old_state_is_stopped = StateIsStoppedState(old_state, false);
const bool new_state_is_stopped = StateIsStoppedState(new_state, false);
if ((old_state_is_stopped != new_state_is_stopped)) {
if (new_state_is_stopped && !restarted) {
- if (log)
- log->Printf("Process::SetPublicState (%s) -- unlocking run lock",
- StateAsCString(new_state));
+ LLDB_LOGF(log, "Process::SetPublicState (%s) -- unlocking run lock",
+ StateAsCString(new_state));
m_public_run_lock.SetStopped();
}
}
@@ -1387,12 +1334,10 @@ void Process::SetPublicState(StateType new_state, bool restarted) {
Status Process::Resume() {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STATE |
LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::Resume -- locking run lock");
+ LLDB_LOGF(log, "Process::Resume -- locking run lock");
if (!m_public_run_lock.TrySetRunning()) {
Status error("Resume request failed - process still running.");
- if (log)
- log->Printf("Process::Resume: -- TrySetRunning failed, not resuming.");
+ LLDB_LOGF(log, "Process::Resume: -- TrySetRunning failed, not resuming.");
return error;
}
Status error = PrivateResume();
@@ -1408,12 +1353,10 @@ static const char *g_resume_sync_name = "lldb.Process.ResumeSynchronous.hijack";
Status Process::ResumeSynchronous(Stream *stream) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STATE |
LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::ResumeSynchronous -- locking run lock");
+ LLDB_LOGF(log, "Process::ResumeSynchronous -- locking run lock");
if (!m_public_run_lock.TrySetRunning()) {
Status error("Resume request failed - process still running.");
- if (log)
- log->Printf("Process::Resume: -- TrySetRunning failed, not resuming.");
+ LLDB_LOGF(log, "Process::Resume: -- TrySetRunning failed, not resuming.");
return error;
}
@@ -1472,8 +1415,7 @@ void Process::SetPrivateState(StateType new_state) {
LIBLLDB_LOG_PROCESS));
bool state_changed = false;
- if (log)
- log->Printf("Process::SetPrivateState (%s)", StateAsCString(new_state));
+ LLDB_LOGF(log, "Process::SetPrivateState (%s)", StateAsCString(new_state));
std::lock_guard<std::recursive_mutex> thread_guard(m_thread_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_private_state.GetMutex());
@@ -1512,9 +1454,8 @@ void Process::SetPrivateState(StateType new_state) {
if (!m_mod_id.IsLastResumeForUserExpression())
m_mod_id.SetStopEventForLastNaturalStopID(event_sp);
m_memory_cache.Clear();
- if (log)
- log->Printf("Process::SetPrivateState (%s) stop_id = %u",
- StateAsCString(new_state), m_mod_id.GetStopID());
+ LLDB_LOGF(log, "Process::SetPrivateState (%s) stop_id = %u",
+ StateAsCString(new_state), m_mod_id.GetStopID());
}
// Use our target to get a shared pointer to ourselves...
@@ -1523,10 +1464,9 @@ void Process::SetPrivateState(StateType new_state) {
else
m_private_state_broadcaster.BroadcastEvent(event_sp);
} else {
- if (log)
- log->Printf(
- "Process::SetPrivateState (%s) state didn't change. Ignoring...",
- StateAsCString(new_state));
+ LLDB_LOGF(log,
+ "Process::SetPrivateState (%s) state didn't change. Ignoring...",
+ StateAsCString(new_state));
}
}
@@ -1709,7 +1649,7 @@ Process::CreateBreakpointSite(const BreakpointLocationSP &owner,
Address symbol_address = symbol->GetAddress();
load_addr = ResolveIndirectFunction(&symbol_address, error);
if (!error.Success() && show_error) {
- GetTarget().GetDebugger().GetErrorFile()->Printf(
+ GetTarget().GetDebugger().GetErrorStream().Printf(
"warning: failed to resolve indirect function at 0x%" PRIx64
" for breakpoint %i.%i: %s\n",
symbol->GetLoadAddress(&GetTarget()),
@@ -1748,7 +1688,7 @@ Process::CreateBreakpointSite(const BreakpointLocationSP &owner,
} else {
if (show_error || use_hardware) {
// Report error for setting breakpoint...
- GetTarget().GetDebugger().GetErrorFile()->Printf(
+ GetTarget().GetDebugger().GetErrorStream().Printf(
"warning: failed to set breakpoint site at 0x%" PRIx64
" for breakpoint %i.%i: %s\n",
load_addr, owner->GetBreakpoint().GetID(), owner->GetID(),
@@ -1816,16 +1756,15 @@ Status Process::EnableSoftwareBreakpoint(BreakpointSite *bp_site) {
assert(bp_site != nullptr);
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
const addr_t bp_addr = bp_site->GetLoadAddress();
- if (log)
- log->Printf(
- "Process::EnableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64,
- bp_site->GetID(), (uint64_t)bp_addr);
+ LLDB_LOGF(
+ log, "Process::EnableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64,
+ bp_site->GetID(), (uint64_t)bp_addr);
if (bp_site->IsEnabled()) {
- if (log)
- log->Printf(
- "Process::EnableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
- " -- already enabled",
- bp_site->GetID(), (uint64_t)bp_addr);
+ LLDB_LOGF(
+ log,
+ "Process::EnableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
+ " -- already enabled",
+ bp_site->GetID(), (uint64_t)bp_addr);
return error;
}
@@ -1864,10 +1803,10 @@ Status Process::EnableSoftwareBreakpoint(BreakpointSite *bp_site) {
bp_opcode_size) == 0) {
bp_site->SetEnabled(true);
bp_site->SetType(BreakpointSite::eSoftware);
- if (log)
- log->Printf("Process::EnableSoftwareBreakpoint (site_id = %d) "
- "addr = 0x%" PRIx64 " -- SUCCESS",
- bp_site->GetID(), (uint64_t)bp_addr);
+ LLDB_LOGF(log,
+ "Process::EnableSoftwareBreakpoint (site_id = %d) "
+ "addr = 0x%" PRIx64 " -- SUCCESS",
+ bp_site->GetID(), (uint64_t)bp_addr);
} else
error.SetErrorString(
"failed to verify the breakpoint trap in memory.");
@@ -1880,7 +1819,8 @@ Status Process::EnableSoftwareBreakpoint(BreakpointSite *bp_site) {
error.SetErrorString("Unable to read memory at breakpoint address.");
}
if (log && error.Fail())
- log->Printf(
+ LLDB_LOGF(
+ log,
"Process::EnableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
" -- FAILED: %s",
bp_site->GetID(), (uint64_t)bp_addr, error.AsCString());
@@ -1893,10 +1833,10 @@ Status Process::DisableSoftwareBreakpoint(BreakpointSite *bp_site) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
addr_t bp_addr = bp_site->GetLoadAddress();
lldb::user_id_t breakID = bp_site->GetID();
- if (log)
- log->Printf("Process::DisableSoftwareBreakpoint (breakID = %" PRIu64
- ") addr = 0x%" PRIx64,
- breakID, (uint64_t)bp_addr);
+ LLDB_LOGF(log,
+ "Process::DisableSoftwareBreakpoint (breakID = %" PRIu64
+ ") addr = 0x%" PRIx64,
+ breakID, (uint64_t)bp_addr);
if (bp_site->IsHardware()) {
error.SetErrorString("Breakpoint site is a hardware breakpoint.");
@@ -1943,10 +1883,10 @@ Status Process::DisableSoftwareBreakpoint(BreakpointSite *bp_site) {
break_op_size) == 0) {
// SUCCESS
bp_site->SetEnabled(false);
- if (log)
- log->Printf("Process::DisableSoftwareBreakpoint (site_id = %d) "
- "addr = 0x%" PRIx64 " -- SUCCESS",
- bp_site->GetID(), (uint64_t)bp_addr);
+ LLDB_LOGF(log,
+ "Process::DisableSoftwareBreakpoint (site_id = %d) "
+ "addr = 0x%" PRIx64 " -- SUCCESS",
+ bp_site->GetID(), (uint64_t)bp_addr);
return error;
} else {
if (break_op_found)
@@ -1961,19 +1901,19 @@ Status Process::DisableSoftwareBreakpoint(BreakpointSite *bp_site) {
"Unable to read memory that should contain the breakpoint trap.");
}
} else {
- if (log)
- log->Printf(
- "Process::DisableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
- " -- already disabled",
- bp_site->GetID(), (uint64_t)bp_addr);
+ LLDB_LOGF(
+ log,
+ "Process::DisableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
+ " -- already disabled",
+ bp_site->GetID(), (uint64_t)bp_addr);
return error;
}
- if (log)
- log->Printf(
- "Process::DisableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
- " -- FAILED: %s",
- bp_site->GetID(), (uint64_t)bp_addr, error.AsCString());
+ LLDB_LOGF(
+ log,
+ "Process::DisableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
+ " -- FAILED: %s",
+ bp_site->GetID(), (uint64_t)bp_addr, error.AsCString());
return error;
}
@@ -2371,13 +2311,13 @@ addr_t Process::AllocateMemory(size_t size, uint32_t permissions,
#else
addr_t allocated_addr = DoAllocateMemory(size, permissions, error);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::AllocateMemory(size=%" PRIu64
- ", permissions=%s) => 0x%16.16" PRIx64
- " (m_stop_id = %u m_memory_id = %u)",
- (uint64_t)size, GetPermissionsAsCString(permissions),
- (uint64_t)allocated_addr, m_mod_id.GetStopID(),
- m_mod_id.GetMemoryID());
+ LLDB_LOGF(log,
+ "Process::AllocateMemory(size=%" PRIu64
+ ", permissions=%s) => 0x%16.16" PRIx64
+ " (m_stop_id = %u m_memory_id = %u)",
+ (uint64_t)size, GetPermissionsAsCString(permissions),
+ (uint64_t)allocated_addr, m_mod_id.GetStopID(),
+ m_mod_id.GetMemoryID());
return allocated_addr;
#endif
}
@@ -2403,16 +2343,16 @@ bool Process::CanJIT() {
if (err.Success()) {
m_can_jit = eCanJITYes;
- if (log)
- log->Printf("Process::%s pid %" PRIu64
- " allocation test passed, CanJIT () is true",
- __FUNCTION__, GetID());
+ LLDB_LOGF(log,
+ "Process::%s pid %" PRIu64
+ " allocation test passed, CanJIT () is true",
+ __FUNCTION__, GetID());
} else {
m_can_jit = eCanJITNo;
- if (log)
- log->Printf("Process::%s pid %" PRIu64
- " allocation test failed, CanJIT () is false: %s",
- __FUNCTION__, GetID(), err.AsCString());
+ LLDB_LOGF(log,
+ "Process::%s pid %" PRIu64
+ " allocation test failed, CanJIT () is false: %s",
+ __FUNCTION__, GetID(), err.AsCString());
}
DeallocateMemory(allocated_memory);
@@ -2441,11 +2381,11 @@ Status Process::DeallocateMemory(addr_t ptr) {
error = DoDeallocateMemory(ptr);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::DeallocateMemory(addr=0x%16.16" PRIx64
- ") => err = %s (m_stop_id = %u, m_memory_id = %u)",
- ptr, error.AsCString("SUCCESS"), m_mod_id.GetStopID(),
- m_mod_id.GetMemoryID());
+ LLDB_LOGF(log,
+ "Process::DeallocateMemory(addr=0x%16.16" PRIx64
+ ") => err = %s (m_stop_id = %u, m_memory_id = %u)",
+ ptr, error.AsCString("SUCCESS"), m_mod_id.GetStopID(),
+ m_mod_id.GetMemoryID());
#endif
return error;
}
@@ -2455,8 +2395,9 @@ ModuleSP Process::ReadModuleFromMemory(const FileSpec &file_spec,
size_t size_to_read) {
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log) {
- log->Printf("Process::ReadModuleFromMemory reading %s binary from memory",
- file_spec.GetPath().c_str());
+ LLDB_LOGF(log,
+ "Process::ReadModuleFromMemory reading %s binary from memory",
+ file_spec.GetPath().c_str());
}
ModuleSP module_sp(new Module(file_spec, ArchSpec()));
if (module_sp) {
@@ -2691,9 +2632,8 @@ Status Process::LoadCore() {
if (!StateIsStoppedState(state, false)) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::Halt() failed to stop, state is: %s",
- StateAsCString(state));
+ LLDB_LOGF(log, "Process::Halt() failed to stop, state is: %s",
+ StateAsCString(state));
error.SetErrorString(
"Did not get stopped event after loading the core file.");
}
@@ -2728,10 +2668,10 @@ Process::AttachCompletionHandler::AttachCompletionHandler(Process *process,
uint32_t exec_count)
: NextEventAction(process), m_exec_count(exec_count) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "Process::AttachCompletionHandler::%s process=%p, exec_count=%" PRIu32,
- __FUNCTION__, static_cast<void *>(process), exec_count);
+ LLDB_LOGF(
+ log,
+ "Process::AttachCompletionHandler::%s process=%p, exec_count=%" PRIu32,
+ __FUNCTION__, static_cast<void *>(process), exec_count);
}
Process::NextEventAction::EventActionResult
@@ -2739,10 +2679,9 @@ Process::AttachCompletionHandler::PerformAction(lldb::EventSP &event_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
StateType state = ProcessEventData::GetStateFromEvent(event_sp.get());
- if (log)
- log->Printf(
- "Process::AttachCompletionHandler::%s called with state %s (%d)",
- __FUNCTION__, StateAsCString(state), static_cast<int>(state));
+ LLDB_LOGF(log,
+ "Process::AttachCompletionHandler::%s called with state %s (%d)",
+ __FUNCTION__, StateAsCString(state), static_cast<int>(state));
switch (state) {
case eStateAttaching:
@@ -2764,18 +2703,18 @@ Process::AttachCompletionHandler::PerformAction(lldb::EventSP &event_sp) {
if (m_exec_count > 0) {
--m_exec_count;
- if (log)
- log->Printf("Process::AttachCompletionHandler::%s state %s: reduced "
- "remaining exec count to %" PRIu32 ", requesting resume",
- __FUNCTION__, StateAsCString(state), m_exec_count);
+ LLDB_LOGF(log,
+ "Process::AttachCompletionHandler::%s state %s: reduced "
+ "remaining exec count to %" PRIu32 ", requesting resume",
+ __FUNCTION__, StateAsCString(state), m_exec_count);
RequestResume();
return eEventActionRetry;
} else {
- if (log)
- log->Printf("Process::AttachCompletionHandler::%s state %s: no more "
- "execs expected to start, continuing with attach",
- __FUNCTION__, StateAsCString(state));
+ LLDB_LOGF(log,
+ "Process::AttachCompletionHandler::%s state %s: no more "
+ "execs expected to start, continuing with attach",
+ __FUNCTION__, StateAsCString(state));
m_process->CompleteAttach();
return eEventActionSuccess;
@@ -2932,8 +2871,7 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
void Process::CompleteAttach() {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS |
LIBLLDB_LOG_TARGET));
- if (log)
- log->Printf("Process::%s()", __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s()", __FUNCTION__);
// Let the process subclass figure out at much as it can about the process
// before we go looking for a dynamic loader plug-in.
@@ -2944,9 +2882,10 @@ void Process::CompleteAttach() {
GetTarget().SetArchitecture(process_arch);
if (log) {
const char *triple_str = process_arch.GetTriple().getTriple().c_str();
- log->Printf("Process::%s replacing process architecture with DidAttach() "
- "architecture: %s",
- __FUNCTION__, triple_str ? triple_str : "<null>");
+ LLDB_LOGF(log,
+ "Process::%s replacing process architecture with DidAttach() "
+ "architecture: %s",
+ __FUNCTION__, triple_str ? triple_str : "<null>");
}
}
@@ -2965,11 +2904,11 @@ void Process::CompleteAttach() {
if (platform_sp) {
GetTarget().SetPlatform(platform_sp);
GetTarget().SetArchitecture(platform_arch);
- if (log)
- log->Printf("Process::%s switching platform to %s and architecture "
- "to %s based on info from attach",
- __FUNCTION__, platform_sp->GetName().AsCString(""),
- platform_arch.GetTriple().getTriple().c_str());
+ LLDB_LOGF(log,
+ "Process::%s switching platform to %s and architecture "
+ "to %s based on info from attach",
+ __FUNCTION__, platform_sp->GetName().AsCString(""),
+ platform_arch.GetTriple().getTriple().c_str());
}
} else if (!process_arch.IsValid()) {
ProcessInstanceInfo process_info;
@@ -2978,11 +2917,11 @@ void Process::CompleteAttach() {
if (process_arch.IsValid() &&
!GetTarget().GetArchitecture().IsExactMatch(process_arch)) {
GetTarget().SetArchitecture(process_arch);
- if (log)
- log->Printf("Process::%s switching architecture to %s based on info "
- "the platform retrieved for pid %" PRIu64,
- __FUNCTION__,
- process_arch.GetTriple().getTriple().c_str(), GetID());
+ LLDB_LOGF(log,
+ "Process::%s switching architecture to %s based on info "
+ "the platform retrieved for pid %" PRIu64,
+ __FUNCTION__, process_arch.GetTriple().getTriple().c_str(),
+ GetID());
}
}
}
@@ -2994,12 +2933,13 @@ void Process::CompleteAttach() {
dyld->DidAttach();
if (log) {
ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
- log->Printf("Process::%s after DynamicLoader::DidAttach(), target "
- "executable is %s (using %s plugin)",
- __FUNCTION__,
- exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
- : "<none>",
- dyld->GetPluginName().AsCString("<unnamed>"));
+ LLDB_LOGF(log,
+ "Process::%s after DynamicLoader::DidAttach(), target "
+ "executable is %s (using %s plugin)",
+ __FUNCTION__,
+ exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
+ : "<none>",
+ dyld->GetPluginName().AsCString("<unnamed>"));
}
}
@@ -3010,12 +2950,13 @@ void Process::CompleteAttach() {
system_runtime->DidAttach();
if (log) {
ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
- log->Printf("Process::%s after SystemRuntime::DidAttach(), target "
- "executable is %s (using %s plugin)",
- __FUNCTION__,
- exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
- : "<none>",
- system_runtime->GetPluginName().AsCString("<unnamed>"));
+ LLDB_LOGF(log,
+ "Process::%s after SystemRuntime::DidAttach(), target "
+ "executable is %s (using %s plugin)",
+ __FUNCTION__,
+ exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
+ : "<none>",
+ system_runtime->GetPluginName().AsCString("<unnamed>"));
}
}
@@ -3048,7 +2989,8 @@ void Process::CompleteAttach() {
eLoadDependentsNo);
if (log) {
ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
- log->Printf(
+ LLDB_LOGF(
+ log,
"Process::%s after looping through modules, target executable is %s",
__FUNCTION__,
exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
@@ -3092,11 +3034,11 @@ Status Process::ConnectRemote(Stream *strm, llvm::StringRef remote_url) {
Status Process::PrivateResume() {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS |
LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("Process::PrivateResume() m_stop_id = %u, public state: %s "
- "private state: %s",
- m_mod_id.GetStopID(), StateAsCString(m_public_state.GetValue()),
- StateAsCString(m_private_state.GetValue()));
+ LLDB_LOGF(log,
+ "Process::PrivateResume() m_stop_id = %u, public state: %s "
+ "private state: %s",
+ m_mod_id.GetStopID(), StateAsCString(m_public_state.GetValue()),
+ StateAsCString(m_private_state.GetValue()));
// If signals handing status changed we might want to update our signal
// filters before resuming.
@@ -3123,12 +3065,9 @@ Status Process::PrivateResume() {
if (error.Success()) {
DidResume();
m_thread_list.DidResume();
- if (log)
- log->Printf("Process thinks the process has resumed.");
+ LLDB_LOGF(log, "Process thinks the process has resumed.");
} else {
- if (log)
- log->Printf(
- "Process::PrivateResume() DoResume failed.");
+ LLDB_LOGF(log, "Process::PrivateResume() DoResume failed.");
return error;
}
}
@@ -3137,16 +3076,15 @@ Status Process::PrivateResume() {
// from one frame of a set of inlined frames that share the same PC to
// another.) So generate a continue & a stopped event, and let the world
// handle them.
- if (log)
- log->Printf(
- "Process::PrivateResume() asked to simulate a start & stop.");
+ LLDB_LOGF(log,
+ "Process::PrivateResume() asked to simulate a start & stop.");
SetPrivateState(eStateRunning);
SetPrivateState(eStateStopped);
}
- } else if (log)
- log->Printf("Process::PrivateResume() got an error \"%s\".",
- error.AsCString("<unknown error>"));
+ } else
+ LLDB_LOGF(log, "Process::PrivateResume() got an error \"%s\".",
+ error.AsCString("<unknown error>"));
return error;
}
@@ -3199,8 +3137,7 @@ Status Process::StopForDestroyOrDetach(lldb::EventSP &exit_event_sp) {
if (m_public_state.GetValue() == eStateRunning ||
m_private_state.GetValue() == eStateRunning) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::%s() About to stop.", __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s() About to stop.", __FUNCTION__);
ListenerSP listener_sp(
Listener::MakeListener("lldb.Process.StopForDestroyOrDetach.hijack"));
@@ -3220,17 +3157,15 @@ Status Process::StopForDestroyOrDetach(lldb::EventSP &exit_event_sp) {
// anymore...
if (state == eStateExited || m_private_state.GetValue() == eStateExited) {
- if (log)
- log->Printf("Process::%s() Process exited while waiting to stop.",
- __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s() Process exited while waiting to stop.",
+ __FUNCTION__);
return error;
} else
exit_event_sp.reset(); // It is ok to consume any non-exit stop events
if (state != eStateStopped) {
- if (log)
- log->Printf("Process::%s() failed to stop, state is: %s", __FUNCTION__,
- StateAsCString(state));
+ LLDB_LOGF(log, "Process::%s() failed to stop, state is: %s", __FUNCTION__,
+ StateAsCString(state));
// If we really couldn't stop the process then we should just error out
// here, but if the lower levels just bobbled sending the event and we
// really are stopped, then continue on.
@@ -3475,10 +3410,10 @@ bool Process::ShouldBroadcastEvent(Event *event_ptr) {
m_stdio_communication.SynchronizeWithReadThread();
RefreshStateAfterStop();
if (ProcessEventData::GetInterruptedFromEvent(event_ptr)) {
- if (log)
- log->Printf("Process::ShouldBroadcastEvent (%p) stopped due to an "
- "interrupt, state: %s",
- static_cast<void *>(event_ptr), StateAsCString(state));
+ LLDB_LOGF(log,
+ "Process::ShouldBroadcastEvent (%p) stopped due to an "
+ "interrupt, state: %s",
+ static_cast<void *>(event_ptr), StateAsCString(state));
// Even though we know we are going to stop, we should let the threads
// have a look at the stop, so they can properly set their state.
m_thread_list.ShouldStop(event_ptr);
@@ -3496,11 +3431,11 @@ bool Process::ShouldBroadcastEvent(Event *event_ptr) {
if (was_restarted || should_resume || m_resume_requested) {
Vote stop_vote = m_thread_list.ShouldReportStop(event_ptr);
- if (log)
- log->Printf("Process::ShouldBroadcastEvent: should_resume: %i state: "
- "%s was_restarted: %i stop_vote: %d.",
- should_resume, StateAsCString(state), was_restarted,
- stop_vote);
+ LLDB_LOGF(log,
+ "Process::ShouldBroadcastEvent: should_resume: %i state: "
+ "%s was_restarted: %i stop_vote: %d.",
+ should_resume, StateAsCString(state), was_restarted,
+ stop_vote);
switch (stop_vote) {
case eVoteYes:
@@ -3513,10 +3448,10 @@ bool Process::ShouldBroadcastEvent(Event *event_ptr) {
}
if (!was_restarted) {
- if (log)
- log->Printf("Process::ShouldBroadcastEvent (%p) Restarting process "
- "from state: %s",
- static_cast<void *>(event_ptr), StateAsCString(state));
+ LLDB_LOGF(log,
+ "Process::ShouldBroadcastEvent (%p) Restarting process "
+ "from state: %s",
+ static_cast<void *>(event_ptr), StateAsCString(state));
ProcessEventData::SetRestartedInEvent(event_ptr, true);
PrivateResume();
}
@@ -3543,12 +3478,12 @@ bool Process::ShouldBroadcastEvent(Event *event_ptr) {
if (return_value)
m_last_broadcast_state = state;
- if (log)
- log->Printf("Process::ShouldBroadcastEvent (%p) => new state: %s, last "
- "broadcast state: %s - %s",
- static_cast<void *>(event_ptr), StateAsCString(state),
- StateAsCString(m_last_broadcast_state),
- return_value ? "YES" : "NO");
+ LLDB_LOGF(log,
+ "Process::ShouldBroadcastEvent (%p) => new state: %s, last "
+ "broadcast state: %s - %s",
+ static_cast<void *>(event_ptr), StateAsCString(state),
+ StateAsCString(m_last_broadcast_state),
+ return_value ? "YES" : "NO");
return return_value;
}
@@ -3556,10 +3491,9 @@ bool Process::StartPrivateStateThread(bool is_secondary_thread) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS));
bool already_running = PrivateStateThreadIsValid();
- if (log)
- log->Printf("Process::%s()%s ", __FUNCTION__,
- already_running ? " already running"
- : " starting private state thread");
+ LLDB_LOGF(log, "Process::%s()%s ", __FUNCTION__,
+ already_running ? " already running"
+ : " starting private state thread");
if (!is_secondary_thread && already_running)
return true;
@@ -3617,9 +3551,9 @@ void Process::StopPrivateStateThread() {
ControlPrivateStateThread(eBroadcastInternalStateControlStop);
else {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "Went to stop the private state thread, but it was already invalid.");
+ LLDB_LOGF(
+ log,
+ "Went to stop the private state thread, but it was already invalid.");
}
}
@@ -3630,8 +3564,7 @@ void Process::ControlPrivateStateThread(uint32_t signal) {
signal == eBroadcastInternalStateControlPause ||
signal == eBroadcastInternalStateControlResume);
- if (log)
- log->Printf("Process::%s (signal = %d)", __FUNCTION__, signal);
+ LLDB_LOGF(log, "Process::%s (signal = %d)", __FUNCTION__, signal);
// Signal the private state thread
if (m_private_state_thread.IsJoinable()) {
@@ -3640,8 +3573,7 @@ void Process::ControlPrivateStateThread(uint32_t signal) {
// possible that the thread state is invalid but that the thread is waiting
// on a control event instead of simply being on its way out (this should
// not happen, but it apparently can).
- if (log)
- log->Printf("Sending control event of type: %d.", signal);
+ LLDB_LOGF(log, "Sending control event of type: %d.", signal);
std::shared_ptr<EventDataReceipt> event_receipt_sp(new EventDataReceipt());
m_private_state_control_broadcaster.BroadcastEvent(signal,
event_receipt_sp);
@@ -3669,9 +3601,9 @@ void Process::ControlPrivateStateThread(uint32_t signal) {
m_private_state_thread.Reset();
}
} else {
- if (log)
- log->Printf(
- "Private state thread already dead, no need to signal it to stop.");
+ LLDB_LOGF(
+ log,
+ "Private state thread already dead, no need to signal it to stop.");
}
}
@@ -3694,8 +3626,7 @@ void Process::HandlePrivateEvent(EventSP &event_sp) {
if (m_next_event_action_up) {
NextEventAction::EventActionResult action_result =
m_next_event_action_up->PerformAction(event_sp);
- if (log)
- log->Printf("Ran next event action, result was %d.", action_result);
+ LLDB_LOGF(log, "Ran next event action, result was %d.", action_result);
switch (action_result) {
case NextEventAction::eEventActionSuccess:
@@ -3726,11 +3657,12 @@ void Process::HandlePrivateEvent(EventSP &event_sp) {
if (should_broadcast) {
const bool is_hijacked = IsHijackedForEvent(eBroadcastBitStateChanged);
if (log) {
- log->Printf("Process::%s (pid = %" PRIu64
- ") broadcasting new state %s (old state %s) to %s",
- __FUNCTION__, GetID(), StateAsCString(new_state),
- StateAsCString(GetState()),
- is_hijacked ? "hijacked" : "public");
+ LLDB_LOGF(log,
+ "Process::%s (pid = %" PRIu64
+ ") broadcasting new state %s (old state %s) to %s",
+ __FUNCTION__, GetID(), StateAsCString(new_state),
+ StateAsCString(GetState()),
+ is_hijacked ? "hijacked" : "public");
}
Process::ProcessEventData::SetUpdateStateOnRemoval(event_sp.get());
if (StateIsRunningState(new_state)) {
@@ -3742,9 +3674,8 @@ void Process::HandlePrivateEvent(EventSP &event_sp) {
PushProcessIOHandler();
m_iohandler_sync.SetValue(m_iohandler_sync.GetValue() + 1,
eBroadcastAlways);
- if (log)
- log->Printf("Process::%s updated m_iohandler_sync to %d",
- __FUNCTION__, m_iohandler_sync.GetValue());
+ LLDB_LOGF(log, "Process::%s updated m_iohandler_sync to %d",
+ __FUNCTION__, m_iohandler_sync.GetValue());
}
} else if (StateIsStoppedState(new_state, false)) {
if (!Process::ProcessEventData::GetRestartedFromEvent(event_sp.get())) {
@@ -3785,7 +3716,8 @@ void Process::HandlePrivateEvent(EventSP &event_sp) {
BroadcastEvent(event_sp);
} else {
if (log) {
- log->Printf(
+ LLDB_LOGF(
+ log,
"Process::%s (pid = %" PRIu64
") suppressing state %s (old state %s): should_broadcast == false",
__FUNCTION__, GetID(), StateAsCString(new_state),
@@ -3820,9 +3752,8 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
bool control_only = true;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64 ") thread starting...",
- __FUNCTION__, static_cast<void *>(this), GetID());
+ LLDB_LOGF(log, "Process::%s (arg = %p, pid = %" PRIu64 ") thread starting...",
+ __FUNCTION__, static_cast<void *>(this), GetID());
bool exit_now = false;
bool interrupt_requested = false;
@@ -3830,11 +3761,11 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
EventSP event_sp;
GetEventsPrivate(event_sp, llvm::None, control_only);
if (event_sp->BroadcasterIs(&m_private_state_control_broadcaster)) {
- if (log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64
- ") got a control event: %d",
- __FUNCTION__, static_cast<void *>(this), GetID(),
- event_sp->GetType());
+ LLDB_LOGF(log,
+ "Process::%s (arg = %p, pid = %" PRIu64
+ ") got a control event: %d",
+ __FUNCTION__, static_cast<void *>(this), GetID(),
+ event_sp->GetType());
switch (event_sp->GetType()) {
case eBroadcastInternalStateControlStop:
@@ -3853,23 +3784,24 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
continue;
} else if (event_sp->GetType() == eBroadcastBitInterrupt) {
if (m_public_state.GetValue() == eStateAttaching) {
- if (log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64
- ") woke up with an interrupt while attaching - "
- "forwarding interrupt.",
- __FUNCTION__, static_cast<void *>(this), GetID());
+ LLDB_LOGF(log,
+ "Process::%s (arg = %p, pid = %" PRIu64
+ ") woke up with an interrupt while attaching - "
+ "forwarding interrupt.",
+ __FUNCTION__, static_cast<void *>(this), GetID());
BroadcastEvent(eBroadcastBitInterrupt, nullptr);
} else if (StateIsRunningState(m_last_broadcast_state)) {
- if (log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64
- ") woke up with an interrupt - Halting.",
- __FUNCTION__, static_cast<void *>(this), GetID());
+ LLDB_LOGF(log,
+ "Process::%s (arg = %p, pid = %" PRIu64
+ ") woke up with an interrupt - Halting.",
+ __FUNCTION__, static_cast<void *>(this), GetID());
Status error = HaltPrivate();
if (error.Fail() && log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64
- ") failed to halt the process: %s",
- __FUNCTION__, static_cast<void *>(this), GetID(),
- error.AsCString());
+ LLDB_LOGF(log,
+ "Process::%s (arg = %p, pid = %" PRIu64
+ ") failed to halt the process: %s",
+ __FUNCTION__, static_cast<void *>(this), GetID(),
+ error.AsCString());
// Halt should generate a stopped event. Make a note of the fact that
// we were doing the interrupt, so we can set the interrupted flag
// after we receive the event. We deliberately set this to true even if
@@ -3883,10 +3815,9 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
// request. We use m_last_broadcast_state, because the Stopped event
// may not have been popped of the event queue yet, which is when the
// public state gets updated.
- if (log)
- log->Printf(
- "Process::%s ignoring interrupt as we have already stopped.",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "Process::%s ignoring interrupt as we have already stopped.",
+ __FUNCTION__);
}
continue;
}
@@ -3908,9 +3839,10 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
ProcessEventData::SetInterruptedInEvent(event_sp.get(), true);
interrupt_requested = false;
} else if (log) {
- log->Printf("Process::%s interrupt_requested, but a non-stopped "
- "state '%s' received.",
- __FUNCTION__, StateAsCString(internal_state));
+ LLDB_LOGF(log,
+ "Process::%s interrupt_requested, but a non-stopped "
+ "state '%s' received.",
+ __FUNCTION__, StateAsCString(internal_state));
}
}
@@ -3919,20 +3851,19 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
if (internal_state == eStateInvalid || internal_state == eStateExited ||
internal_state == eStateDetached) {
- if (log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64
- ") about to exit with internal state %s...",
- __FUNCTION__, static_cast<void *>(this), GetID(),
- StateAsCString(internal_state));
+ LLDB_LOGF(log,
+ "Process::%s (arg = %p, pid = %" PRIu64
+ ") about to exit with internal state %s...",
+ __FUNCTION__, static_cast<void *>(this), GetID(),
+ StateAsCString(internal_state));
break;
}
}
// Verify log is still enabled before attempting to write to it...
- if (log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64 ") thread exiting...",
- __FUNCTION__, static_cast<void *>(this), GetID());
+ LLDB_LOGF(log, "Process::%s (arg = %p, pid = %" PRIu64 ") thread exiting...",
+ __FUNCTION__, static_cast<void *>(this), GetID());
// If we are a secondary thread, then the primary thread we are working for
// will have already acquired the public_run_lock, and isn't done with what
@@ -4042,10 +3973,10 @@ void Process::ProcessEventData::DoOnRemoval(Event *event_ptr) {
if (curr_thread_list.GetSize() != num_threads) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP |
LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "Number of threads changed from %u to %u while processing event.",
- num_threads, curr_thread_list.GetSize());
+ LLDB_LOGF(
+ log,
+ "Number of threads changed from %u to %u while processing event.",
+ num_threads, curr_thread_list.GetSize());
break;
}
@@ -4054,10 +3985,10 @@ void Process::ProcessEventData::DoOnRemoval(Event *event_ptr) {
if (thread_sp->GetIndexID() != thread_index_array[idx]) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP |
LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("The thread at position %u changed from %u to %u while "
- "processing event.",
- idx, thread_index_array[idx], thread_sp->GetIndexID());
+ LLDB_LOGF(log,
+ "The thread at position %u changed from %u to %u while "
+ "processing event.",
+ idx, thread_index_array[idx], thread_sp->GetIndexID());
break;
}
@@ -4303,9 +4234,8 @@ size_t Process::GetAsyncProfileData(char *buf, size_t buf_size, Status &error) {
size_t bytes_available = one_profile_data.size();
if (bytes_available > 0) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::GetProfileData (buf = %p, size = %" PRIu64 ")",
- static_cast<void *>(buf), static_cast<uint64_t>(buf_size));
+ LLDB_LOGF(log, "Process::GetProfileData (buf = %p, size = %" PRIu64 ")",
+ static_cast<void *>(buf), static_cast<uint64_t>(buf_size));
if (bytes_available > buf_size) {
memcpy(buf, one_profile_data.c_str(), buf_size);
one_profile_data.erase(0, buf_size);
@@ -4325,9 +4255,8 @@ size_t Process::GetSTDOUT(char *buf, size_t buf_size, Status &error) {
size_t bytes_available = m_stdout_data.size();
if (bytes_available > 0) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::GetSTDOUT (buf = %p, size = %" PRIu64 ")",
- static_cast<void *>(buf), static_cast<uint64_t>(buf_size));
+ LLDB_LOGF(log, "Process::GetSTDOUT (buf = %p, size = %" PRIu64 ")",
+ static_cast<void *>(buf), static_cast<uint64_t>(buf_size));
if (bytes_available > buf_size) {
memcpy(buf, m_stdout_data.c_str(), buf_size);
m_stdout_data.erase(0, buf_size);
@@ -4345,9 +4274,8 @@ size_t Process::GetSTDERR(char *buf, size_t buf_size, Status &error) {
size_t bytes_available = m_stderr_data.size();
if (bytes_available > 0) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::GetSTDERR (buf = %p, size = %" PRIu64 ")",
- static_cast<void *>(buf), static_cast<uint64_t>(buf_size));
+ LLDB_LOGF(log, "Process::GetSTDERR (buf = %p, size = %" PRIu64 ")",
+ static_cast<void *>(buf), static_cast<uint64_t>(buf_size));
if (bytes_available > buf_size) {
memcpy(buf, m_stderr_data.c_str(), buf_size);
m_stderr_data.erase(0, buf_size);
@@ -4371,9 +4299,10 @@ public:
IOHandlerProcessSTDIO(Process *process, int write_fd)
: IOHandler(process->GetTarget().GetDebugger(),
IOHandler::Type::ProcessIO),
- m_process(process), m_write_file(write_fd, false) {
+ m_process(process),
+ m_read_file(GetInputFD(), File::eOpenOptionRead, false),
+ m_write_file(write_fd, File::eOpenOptionWrite, false) {
m_pipe.CreateNew(false);
- m_read_file.SetDescriptor(GetInputFD(), false);
}
~IOHandlerProcessSTDIO() override = default;
@@ -4493,9 +4422,9 @@ public:
protected:
Process *m_process;
- File m_read_file; // Read from this file (usually actual STDIN for LLDB
- File m_write_file; // Write to this file (usually the master pty for getting
- // io to debuggee)
+ NativeFile m_read_file; // Read from this file (usually actual STDIN for LLDB
+ NativeFile m_write_file; // Write to this file (usually the master pty for
+ // getting io to debuggee)
Pipe m_pipe;
std::atomic<bool> m_is_running{false};
};
@@ -4532,8 +4461,7 @@ bool Process::PushProcessIOHandler() {
IOHandlerSP io_handler_sp(m_process_input_reader);
if (io_handler_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::%s pushing IO handler", __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s pushing IO handler", __FUNCTION__);
io_handler_sp->SetIsDone(false);
// If we evaluate an utility function, then we don't cancel the current
@@ -4797,9 +4725,8 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
// public events. The simplest thing to do is to spin up a temporary thread
// to handle private state thread events while we are fielding public
// events here.
- if (log)
- log->Printf("Running thread plan on private state thread, spinning up "
- "another state thread to handle the events.");
+ LLDB_LOGF(log, "Running thread plan on private state thread, spinning up "
+ "another state thread to handle the events.");
backup_private_state_thread = m_private_state_thread;
@@ -4854,9 +4781,10 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
if (log) {
StreamString s;
thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
- log->Printf("Process::RunThreadPlan(): Resuming thread %u - 0x%4.4" PRIx64
- " to run thread plan \"%s\".",
- thread->GetIndexID(), thread->GetID(), s.GetData());
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): Resuming thread %u - 0x%4.4" PRIx64
+ " to run thread plan \"%s\".",
+ thread->GetIndexID(), thread->GetID(), s.GetData());
}
bool got_event;
@@ -4877,10 +4805,9 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
if (!options.GetStopOthers() || !options.GetTryAllThreads())
before_first_timeout = false;
- if (log)
- log->Printf("Stop others: %u, try all: %u, before_first: %u.\n",
- options.GetStopOthers(), options.GetTryAllThreads(),
- before_first_timeout);
+ LLDB_LOGF(log, "Stop others: %u, try all: %u, before_first: %u.\n",
+ options.GetStopOthers(), options.GetTryAllThreads(),
+ before_first_timeout);
// This isn't going to work if there are unfetched events on the queue. Are
// there cases where we might want to run the remaining events here, and
@@ -4919,10 +4846,10 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
// loop. The only exception is if we get two running events with no
// intervening stop, which can happen, we will just wait for then next
// stop event.
- if (log)
- log->Printf("Top of while loop: do_resume: %i handle_running_event: %i "
- "before_first_timeout: %i.",
- do_resume, handle_running_event, before_first_timeout);
+ LLDB_LOGF(log,
+ "Top of while loop: do_resume: %i handle_running_event: %i "
+ "before_first_timeout: %i.",
+ do_resume, handle_running_event, before_first_timeout);
if (do_resume || handle_running_event) {
// Do the initial resume and wait for the running event before going
@@ -4944,10 +4871,10 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
got_event =
listener_sp->GetEvent(event_sp, GetUtilityExpressionTimeout());
if (!got_event) {
- if (log)
- log->Printf("Process::RunThreadPlan(): didn't get any event after "
- "resume %" PRIu32 ", exiting.",
- num_resumes);
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): didn't get any event after "
+ "resume %" PRIu32 ", exiting.",
+ num_resumes);
diagnostic_manager.Printf(eDiagnosticSeverityError,
"didn't get any event after resume %" PRIu32
@@ -4966,13 +4893,13 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
if (stop_state == eStateStopped) {
restarted = Process::ProcessEventData::GetRestartedFromEvent(
event_sp.get());
- if (log)
- log->Printf(
- "Process::RunThreadPlan(): didn't get running event after "
- "resume %d, got %s instead (restarted: %i, do_resume: %i, "
- "handle_running_event: %i).",
- num_resumes, StateAsCString(stop_state), restarted, do_resume,
- handle_running_event);
+ LLDB_LOGF(
+ log,
+ "Process::RunThreadPlan(): didn't get running event after "
+ "resume %d, got %s instead (restarted: %i, do_resume: %i, "
+ "handle_running_event: %i).",
+ num_resumes, StateAsCString(stop_state), restarted, do_resume,
+ handle_running_event);
}
if (restarted) {
@@ -5015,19 +4942,20 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
if (log) {
if (timeout) {
auto now = system_clock::now();
- log->Printf("Process::RunThreadPlan(): about to wait - now is %s - "
- "endpoint is %s",
- llvm::to_string(now).c_str(),
- llvm::to_string(now + *timeout).c_str());
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): about to wait - now is %s - "
+ "endpoint is %s",
+ llvm::to_string(now).c_str(),
+ llvm::to_string(now + *timeout).c_str());
} else {
- log->Printf("Process::RunThreadPlan(): about to wait forever.");
+ LLDB_LOGF(log, "Process::RunThreadPlan(): about to wait forever.");
}
}
#ifdef LLDB_RUN_THREAD_HALT_WITH_EVENT
// See comment above...
if (miss_first_event) {
- usleep(1000);
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
miss_first_event = false;
got_event = false;
} else
@@ -5044,17 +4972,15 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
return_value = eExpressionInterrupted;
diagnostic_manager.PutString(eDiagnosticSeverityRemark,
"execution halted by user interrupt.");
- if (log)
- log->Printf("Process::RunThreadPlan(): Got interrupted by "
- "eBroadcastBitInterrupted, exiting.");
+ LLDB_LOGF(log, "Process::RunThreadPlan(): Got interrupted by "
+ "eBroadcastBitInterrupted, exiting.");
break;
} else {
stop_state =
Process::ProcessEventData::GetStateFromEvent(event_sp.get());
- if (log)
- log->Printf(
- "Process::RunThreadPlan(): in while loop, got event: %s.",
- StateAsCString(stop_state));
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): in while loop, got event: %s.",
+ StateAsCString(stop_state));
switch (stop_state) {
case lldb::eStateStopped: {
@@ -5064,18 +4990,18 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
if (!thread_sp) {
// Ooh, our thread has vanished. Unlikely that this was
// successful execution...
- if (log)
- log->Printf("Process::RunThreadPlan(): execution completed "
- "but our thread (index-id=%u) has vanished.",
- thread_idx_id);
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): execution completed "
+ "but our thread (index-id=%u) has vanished.",
+ thread_idx_id);
return_value = eExpressionInterrupted;
} else if (Process::ProcessEventData::GetRestartedFromEvent(
event_sp.get())) {
// If we were restarted, we just need to go back up to fetch
// another event.
if (log) {
- log->Printf("Process::RunThreadPlan(): Got a stop and "
- "restart, so we'll continue waiting.");
+ LLDB_LOGF(log, "Process::RunThreadPlan(): Got a stop and "
+ "restart, so we'll continue waiting.");
}
keep_going = true;
do_resume = false;
@@ -5098,10 +5024,10 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
break;
default:
- if (log)
- log->Printf("Process::RunThreadPlan(): execution stopped with "
- "unexpected state: %s.",
- StateAsCString(stop_state));
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): execution stopped with "
+ "unexpected state: %s.",
+ StateAsCString(stop_state));
if (stop_state == eStateExited)
event_to_broadcast_sp = event_sp;
@@ -5162,8 +5088,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
while (try_halt_again < num_retries) {
Status halt_error;
if (do_halt) {
- if (log)
- log->Printf("Process::RunThreadPlan(): Running Halt.");
+ LLDB_LOGF(log, "Process::RunThreadPlan(): Running Halt.");
const bool clear_thread_plans = false;
const bool use_run_lock = false;
Halt(clear_thread_plans, use_run_lock);
@@ -5179,8 +5104,9 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
stop_state =
Process::ProcessEventData::GetStateFromEvent(event_sp.get());
if (log) {
- log->Printf("Process::RunThreadPlan(): Stopped with event: %s",
- StateAsCString(stop_state));
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): Stopped with event: %s",
+ StateAsCString(stop_state));
if (stop_state == lldb::eStateStopped &&
Process::ProcessEventData::GetInterruptedFromEvent(
event_sp.get()))
@@ -5379,24 +5305,25 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
} while (false);
if (event_explanation)
- log->Printf("Process::RunThreadPlan(): execution interrupted: %s %s",
- s.GetData(), event_explanation);
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): execution interrupted: %s %s",
+ s.GetData(), event_explanation);
else
- log->Printf("Process::RunThreadPlan(): execution interrupted: %s",
- s.GetData());
+ LLDB_LOGF(log, "Process::RunThreadPlan(): execution interrupted: %s",
+ s.GetData());
}
if (should_unwind) {
- if (log)
- log->Printf("Process::RunThreadPlan: ExecutionInterrupted - "
- "discarding thread plans up to %p.",
- static_cast<void *>(thread_plan_sp.get()));
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan: ExecutionInterrupted - "
+ "discarding thread plans up to %p.",
+ static_cast<void *>(thread_plan_sp.get()));
thread->DiscardThreadPlansUpToPlan(thread_plan_sp);
} else {
- if (log)
- log->Printf("Process::RunThreadPlan: ExecutionInterrupted - for "
- "plan: %p not discarding.",
- static_cast<void *>(thread_plan_sp.get()));
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan: ExecutionInterrupted - for "
+ "plan: %p not discarding.",
+ static_cast<void *>(thread_plan_sp.get()));
}
} else if (return_value == eExpressionSetupError) {
if (log)
@@ -5559,9 +5486,8 @@ size_t Process::GetThreadStatus(Stream &strm,
++num_thread_infos_dumped;
} else {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::GetThreadStatus - thread 0x" PRIu64
- " vanished while running Thread::GetStatus.");
+ LLDB_LOGF(log, "Process::GetThreadStatus - thread 0x" PRIu64
+ " vanished while running Thread::GetStatus.");
}
}
return num_thread_infos_dumped;
@@ -5612,6 +5538,12 @@ ProcessRunLock &Process::GetRunLock() {
return m_public_run_lock;
}
+bool Process::CurrentThreadIsPrivateStateThread()
+{
+ return m_private_state_thread.EqualsThread(Host::GetCurrentThread());
+}
+
+
void Process::Flush() {
m_thread_list.Flush();
m_extended_thread_list.Flush();
@@ -5622,8 +5554,7 @@ void Process::Flush() {
void Process::DidExec() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::%s()", __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s()", __FUNCTION__);
Target &target = GetTarget();
target.CleanupProcess();
@@ -5669,7 +5600,7 @@ addr_t Process::ResolveIndirectFunction(const Address *address, Status &error) {
if (iter != m_resolved_indirect_addresses.end()) {
function_addr = (*iter).second;
} else {
- if (!InferiorCall(this, address, function_addr)) {
+ if (!CallVoidArgVoidPtrReturn(address, function_addr)) {
Symbol *symbol = address->CalculateSymbolContextSymbol();
error.SetErrorStringWithFormat(
"Unable to call resolver for indirect function %s",
@@ -5929,19 +5860,18 @@ void Process::MapSupportedStructuredDataPlugins(
// Bail out early if there are no type names to map.
if (supported_type_names.GetSize() == 0) {
- if (log)
- log->Printf("Process::%s(): no structured data types supported",
- __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s(): no structured data types supported",
+ __FUNCTION__);
return;
}
// Convert StructuredData type names to ConstString instances.
std::set<ConstString> const_type_names;
- if (log)
- log->Printf("Process::%s(): the process supports the following async "
- "structured data types:",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "Process::%s(): the process supports the following async "
+ "structured data types:",
+ __FUNCTION__);
supported_type_names.ForEach(
[&const_type_names, &log](StructuredData::Object *object) {
@@ -5988,11 +5918,11 @@ void Process::MapSupportedStructuredDataPlugins(
m_structured_data_plugin_map.insert(
std::make_pair(type_name, plugin_sp));
names_to_remove.push_back(type_name);
- if (log)
- log->Printf("Process::%s(): using plugin %s for type name "
- "%s",
- __FUNCTION__, plugin_sp->GetPluginName().GetCString(),
- type_name.GetCString());
+ LLDB_LOGF(log,
+ "Process::%s(): using plugin %s for type name "
+ "%s",
+ __FUNCTION__, plugin_sp->GetPluginName().GetCString(),
+ type_name.GetCString());
}
}
@@ -6042,7 +5972,62 @@ UtilityFunction *Process::GetLoadImageUtilityFunction(
llvm::function_ref<std::unique_ptr<UtilityFunction>()> factory) {
if (platform != GetTarget().GetPlatform().get())
return nullptr;
- std::call_once(m_dlopen_utility_func_flag_once,
- [&] { m_dlopen_utility_func_up = factory(); });
+ llvm::call_once(m_dlopen_utility_func_flag_once,
+ [&] { m_dlopen_utility_func_up = factory(); });
return m_dlopen_utility_func_up.get();
}
+
+bool Process::CallVoidArgVoidPtrReturn(const Address *address,
+ addr_t &returned_func,
+ bool trap_exceptions) {
+ Thread *thread = GetThreadList().GetExpressionExecutionThread().get();
+ if (thread == nullptr || address == nullptr)
+ return false;
+
+ EvaluateExpressionOptions options;
+ options.SetStopOthers(true);
+ options.SetUnwindOnError(true);
+ options.SetIgnoreBreakpoints(true);
+ options.SetTryAllThreads(true);
+ options.SetDebug(false);
+ options.SetTimeout(GetUtilityExpressionTimeout());
+ options.SetTrapExceptions(trap_exceptions);
+
+ auto type_system_or_err =
+ GetTarget().GetScratchTypeSystemForLanguage(eLanguageTypeC);
+ if (!type_system_or_err) {
+ llvm::consumeError(type_system_or_err.takeError());
+ return false;
+ }
+ CompilerType void_ptr_type =
+ type_system_or_err->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType();
+ lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallFunction(
+ *thread, *address, void_ptr_type, llvm::ArrayRef<addr_t>(), options));
+ if (call_plan_sp) {
+ DiagnosticManager diagnostics;
+
+ StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
+ if (frame) {
+ ExecutionContext exe_ctx;
+ frame->CalculateExecutionContext(exe_ctx);
+ ExpressionResults result =
+ RunThreadPlan(exe_ctx, call_plan_sp, options, diagnostics);
+ if (result == eExpressionCompleted) {
+ returned_func =
+ call_plan_sp->GetReturnValueObject()->GetValueAsUnsigned(
+ LLDB_INVALID_ADDRESS);
+
+ if (GetAddressByteSize() == 4) {
+ if (returned_func == UINT32_MAX)
+ return false;
+ } else if (GetAddressByteSize() == 8) {
+ if (returned_func == UINT64_MAX)
+ return false;
+ }
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
diff --git a/source/Target/RegisterContext.cpp b/source/Target/RegisterContext.cpp
index c960260f30c8..f29cf435d028 100644
--- a/source/Target/RegisterContext.cpp
+++ b/source/Target/RegisterContext.cpp
@@ -82,14 +82,12 @@ RegisterContext::UpdateDynamicRegisterSize(const lldb_private::ArchSpec &arch,
DataExtractor dwarf_data(dwarf_opcode_ptr, dwarf_opcode_len,
arch.GetByteOrder(), addr_size);
ModuleSP opcode_ctx;
- DWARFExpression dwarf_expr(opcode_ctx, dwarf_data, nullptr, 0,
- dwarf_opcode_len);
+ DWARFExpression dwarf_expr(opcode_ctx, dwarf_data, nullptr);
Value result;
Status error;
- const lldb::offset_t offset = 0;
if (dwarf_expr.Evaluate(&exe_ctx, this, opcode_ctx, dwarf_data, nullptr,
- offset, dwarf_opcode_len, eRegisterKindDWARF, nullptr,
- nullptr, result, &error)) {
+ eRegisterKindDWARF, nullptr, nullptr, result,
+ &error)) {
expr_result = result.GetScalar().SInt(-1);
switch (expr_result) {
case 0:
diff --git a/source/Target/RemoteAwarePlatform.cpp b/source/Target/RemoteAwarePlatform.cpp
index 1704e1533e9c..faa217ac83ef 100644
--- a/source/Target/RemoteAwarePlatform.cpp
+++ b/source/Target/RemoteAwarePlatform.cpp
@@ -61,8 +61,8 @@ Status RemoteAwarePlatform::SetFilePermissions(const FileSpec &file_spec,
}
lldb::user_id_t RemoteAwarePlatform::OpenFile(const FileSpec &file_spec,
- uint32_t flags, uint32_t mode,
- Status &error) {
+ File::OpenOptions flags,
+ uint32_t mode, Status &error) {
if (IsHost())
return FileCache::GetInstance().OpenFile(file_spec, flags, mode, error);
if (m_remote_platform_sp)
diff --git a/source/Target/SectionLoadList.cpp b/source/Target/SectionLoadList.cpp
index 598f49ca13de..f2546a893194 100644
--- a/source/Target/SectionLoadList.cpp
+++ b/source/Target/SectionLoadList.cpp
@@ -121,7 +121,8 @@ bool SectionLoadList::SetSectionLoadAddress(const lldb::SectionSP &section,
} else {
if (log) {
- log->Printf(
+ LLDB_LOGF(
+ log,
"SectionLoadList::%s (section = %p (%s), load_addr = 0x%16.16" PRIx64
") error: module has been deleted",
__FUNCTION__, static_cast<void *>(section.get()),
@@ -145,9 +146,9 @@ size_t SectionLoadList::SetSectionUnloaded(const lldb::SectionSP &section_sp) {
section_sp->GetModule()->GetFileSpec());
module_name = module_file_spec.GetPath();
}
- log->Printf("SectionLoadList::%s (section = %p (%s.%s))", __FUNCTION__,
- static_cast<void *>(section_sp.get()), module_name.c_str(),
- section_sp->GetName().AsCString());
+ LLDB_LOGF(log, "SectionLoadList::%s (section = %p (%s.%s))", __FUNCTION__,
+ static_cast<void *>(section_sp.get()), module_name.c_str(),
+ section_sp->GetName().AsCString());
}
std::lock_guard<std::recursive_mutex> guard(m_mutex);
@@ -179,7 +180,8 @@ bool SectionLoadList::SetSectionUnloaded(const lldb::SectionSP &section_sp,
const FileSpec &module_file_spec(section_sp->GetModule()->GetFileSpec());
module_name = module_file_spec.GetPath();
}
- log->Printf(
+ LLDB_LOGF(
+ log,
"SectionLoadList::%s (section = %p (%s.%s), load_addr = 0x%16.16" PRIx64
")",
__FUNCTION__, static_cast<void *>(section_sp.get()),
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index f8b22d96e16f..5e5a596e471d 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -29,6 +29,7 @@
#include "lldb/Target/StackFrameRecognizer.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Log.h"
#include "lldb/Utility/RegisterValue.h"
#include "lldb/lldb-enumerations.h"
@@ -50,14 +51,16 @@ using namespace lldb_private;
StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx,
user_id_t unwind_frame_index, addr_t cfa,
bool cfa_is_valid, addr_t pc, StackFrame::Kind kind,
+ bool behaves_like_zeroth_frame,
const SymbolContext *sc_ptr)
: m_thread_wp(thread_sp), m_frame_index(frame_idx),
m_concrete_frame_index(unwind_frame_index), m_reg_context_sp(),
m_id(pc, cfa, nullptr), m_frame_code_addr(pc), m_sc(), m_flags(),
m_frame_base(), m_frame_base_error(), m_cfa_is_valid(cfa_is_valid),
- m_stack_frame_kind(kind), m_variable_list_sp(),
- m_variable_list_value_objects(), m_recognized_frame_sp(), m_disassembly(),
- m_mutex() {
+ m_stack_frame_kind(kind),
+ m_behaves_like_zeroth_frame(behaves_like_zeroth_frame),
+ m_variable_list_sp(), m_variable_list_value_objects(),
+ m_recognized_frame_sp(), m_disassembly(), m_mutex() {
// If we don't have a CFA value, use the frame index for our StackID so that
// recursive functions properly aren't confused with one another on a history
// stack.
@@ -74,15 +77,17 @@ StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx,
StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx,
user_id_t unwind_frame_index,
const RegisterContextSP &reg_context_sp, addr_t cfa,
- addr_t pc, const SymbolContext *sc_ptr)
+ addr_t pc, bool behaves_like_zeroth_frame,
+ const SymbolContext *sc_ptr)
: m_thread_wp(thread_sp), m_frame_index(frame_idx),
m_concrete_frame_index(unwind_frame_index),
m_reg_context_sp(reg_context_sp), m_id(pc, cfa, nullptr),
m_frame_code_addr(pc), m_sc(), m_flags(), m_frame_base(),
m_frame_base_error(), m_cfa_is_valid(true),
- m_stack_frame_kind(StackFrame::Kind::Regular), m_variable_list_sp(),
- m_variable_list_value_objects(), m_recognized_frame_sp(), m_disassembly(),
- m_mutex() {
+ m_stack_frame_kind(StackFrame::Kind::Regular),
+ m_behaves_like_zeroth_frame(behaves_like_zeroth_frame),
+ m_variable_list_sp(), m_variable_list_value_objects(),
+ m_recognized_frame_sp(), m_disassembly(), m_mutex() {
if (sc_ptr != nullptr) {
m_sc = *sc_ptr;
m_flags.Set(m_sc.GetResolvedMask());
@@ -98,7 +103,8 @@ StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx,
StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx,
user_id_t unwind_frame_index,
const RegisterContextSP &reg_context_sp, addr_t cfa,
- const Address &pc_addr, const SymbolContext *sc_ptr)
+ const Address &pc_addr, bool behaves_like_zeroth_frame,
+ const SymbolContext *sc_ptr)
: m_thread_wp(thread_sp), m_frame_index(frame_idx),
m_concrete_frame_index(unwind_frame_index),
m_reg_context_sp(reg_context_sp),
@@ -106,9 +112,10 @@ StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx,
nullptr),
m_frame_code_addr(pc_addr), m_sc(), m_flags(), m_frame_base(),
m_frame_base_error(), m_cfa_is_valid(true),
- m_stack_frame_kind(StackFrame::Kind::Regular), m_variable_list_sp(),
- m_variable_list_value_objects(), m_recognized_frame_sp(), m_disassembly(),
- m_mutex() {
+ m_stack_frame_kind(StackFrame::Kind::Regular),
+ m_behaves_like_zeroth_frame(behaves_like_zeroth_frame),
+ m_variable_list_sp(), m_variable_list_value_objects(),
+ m_recognized_frame_sp(), m_disassembly(), m_mutex() {
if (sc_ptr != nullptr) {
m_sc = *sc_ptr;
m_flags.Set(m_sc.GetResolvedMask());
@@ -288,7 +295,7 @@ StackFrame::GetSymbolContext(SymbolContextItem resolve_scope) {
// following the function call instruction...
Address lookup_addr(GetFrameCodeAddress());
- if (m_frame_index > 0 && lookup_addr.IsValid()) {
+ if (!m_behaves_like_zeroth_frame && lookup_addr.IsValid()) {
addr_t offset = lookup_addr.GetOffset();
if (offset > 0) {
lookup_addr.SetOffset(offset - 1);
@@ -1357,13 +1364,16 @@ lldb::ValueObjectSP StackFrame::GuessValueForAddress(lldb::addr_t addr) {
if (target_sp->ResolveLoadAddress(base_and_offset.first->m_immediate +
base_and_offset.second,
addr)) {
- TypeSystem *c_type_system =
- target_sp->GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC);
- if (!c_type_system) {
+ auto c_type_system_or_err =
+ target_sp->GetScratchTypeSystemForLanguage(eLanguageTypeC);
+ if (auto err = c_type_system_or_err.takeError()) {
+ LLDB_LOG_ERROR(
+ lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD),
+ std::move(err), "Unable to guess value for given address");
return ValueObjectSP();
} else {
CompilerType void_ptr_type =
- c_type_system
+ c_type_system_or_err
->GetBasicTypeFromAST(lldb::BasicType::eBasicTypeChar)
.GetPointerType();
return ValueObjectMemory::Create(this, "", addr, void_ptr_type);
diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp
index 5492dda46402..6d0c46259c20 100644
--- a/source/Target/StackFrameList.cpp
+++ b/source/Target/StackFrameList.cpp
@@ -67,7 +67,8 @@ uint32_t StackFrameList::GetCurrentInlinedDepth() {
m_current_inlined_depth = UINT32_MAX;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (log && log->GetVerbose())
- log->Printf(
+ LLDB_LOGF(
+ log,
"GetCurrentInlinedDepth: invalidating current inlined depth.\n");
}
return m_current_inlined_depth;
@@ -90,7 +91,8 @@ void StackFrameList::ResetCurrentInlinedDepth() {
m_current_inlined_pc = LLDB_INVALID_ADDRESS;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (log && log->GetVerbose())
- log->Printf(
+ LLDB_LOGF(
+ log,
"ResetCurrentInlinedDepth: Invalidating current inlined depth.\n");
return;
}
@@ -184,9 +186,10 @@ void StackFrameList::ResetCurrentInlinedDepth() {
m_current_inlined_depth = num_inlined_functions + 1;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (log && log->GetVerbose())
- log->Printf("ResetCurrentInlinedDepth: setting inlined "
- "depth: %d 0x%" PRIx64 ".\n",
- m_current_inlined_depth, curr_pc);
+ LLDB_LOGF(log,
+ "ResetCurrentInlinedDepth: setting inlined "
+ "depth: %d 0x%" PRIx64 ".\n",
+ m_current_inlined_depth, curr_pc);
break;
}
@@ -247,26 +250,19 @@ static void FindInterveningFrames(Function &begin, Function &end,
begin.GetDisplayName(), end.GetDisplayName(), return_pc);
// Find a non-tail calling edge with the correct return PC.
- auto first_level_edges = begin.GetCallEdges();
if (log)
- for (const CallEdge &edge : first_level_edges)
+ for (const CallEdge &edge : begin.GetCallEdges())
LLDB_LOG(log, "FindInterveningFrames: found call with retn-PC = {0:x}",
edge.GetReturnPCAddress(begin, target));
- auto first_edge_it = std::lower_bound(
- first_level_edges.begin(), first_level_edges.end(), return_pc,
- [&](const CallEdge &edge, addr_t target_pc) {
- return edge.GetReturnPCAddress(begin, target) < target_pc;
- });
- if (first_edge_it == first_level_edges.end() ||
- first_edge_it->GetReturnPCAddress(begin, target) != return_pc) {
+ CallEdge *first_edge = begin.GetCallEdgeForReturnAddress(return_pc, target);
+ if (!first_edge) {
LLDB_LOG(log, "No call edge outgoing from {0} with retn-PC == {1:x}",
begin.GetDisplayName(), return_pc);
return;
}
- CallEdge &first_edge = const_cast<CallEdge &>(*first_edge_it);
// The first callee may not be resolved, or there may be nothing to fill in.
- Function *first_callee = first_edge.GetCallee(images);
+ Function *first_callee = first_edge->GetCallee(images);
if (!first_callee) {
LLDB_LOG(log, "Could not resolve callee");
return;
@@ -290,15 +286,15 @@ static void FindInterveningFrames(Function &begin, Function &end,
DFS(Function *end, ModuleList &images) : end(end), images(images) {}
- void search(Function *first_callee, std::vector<Function *> &path) {
+ void search(Function &first_callee, std::vector<Function *> &path) {
dfs(first_callee);
if (!ambiguous)
path = std::move(solution_path);
}
- void dfs(Function *callee) {
+ void dfs(Function &callee) {
// Found a path to the target function.
- if (callee == end) {
+ if (&callee == end) {
if (solution_path.empty())
solution_path = active_path;
else
@@ -310,19 +306,19 @@ static void FindInterveningFrames(Function &begin, Function &end,
// there's more than one way to reach a target. This errs on the side of
// caution: it conservatively stops searching when some solutions are
// still possible to save time in the average case.
- if (!visited_nodes.insert(callee).second) {
+ if (!visited_nodes.insert(&callee).second) {
ambiguous = true;
return;
}
// Search the calls made from this callee.
- active_path.push_back(callee);
- for (CallEdge &edge : callee->GetTailCallingEdges()) {
+ active_path.push_back(&callee);
+ for (CallEdge &edge : callee.GetTailCallingEdges()) {
Function *next_callee = edge.GetCallee(images);
if (!next_callee)
continue;
- dfs(next_callee);
+ dfs(*next_callee);
if (ambiguous)
return;
}
@@ -330,7 +326,7 @@ static void FindInterveningFrames(Function &begin, Function &end,
}
};
- DFS(&end, images).search(first_callee, path);
+ DFS(&end, images).search(*first_callee, path);
}
/// Given that \p next_frame will be appended to the frame list, synthesize
@@ -394,11 +390,13 @@ void StackFrameList::SynthesizeTailCallFrames(StackFrame &next_frame) {
bool cfa_is_valid = false;
addr_t pc =
callee->GetAddressRange().GetBaseAddress().GetLoadAddress(&target);
+ constexpr bool behaves_like_zeroth_frame = false;
SymbolContext sc;
callee->CalculateSymbolContext(&sc);
auto synth_frame = std::make_shared<StackFrame>(
m_thread.shared_from_this(), frame_idx, concrete_frame_idx, cfa,
- cfa_is_valid, pc, StackFrame::Kind::Artificial, &sc);
+ cfa_is_valid, pc, StackFrame::Kind::Artificial,
+ behaves_like_zeroth_frame, &sc);
m_frames.push_back(synth_frame);
LLDB_LOG(log, "Pushed frame {0}", callee->GetDisplayName());
}
@@ -448,6 +446,7 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
uint32_t idx = m_concrete_frames_fetched++;
lldb::addr_t pc = LLDB_INVALID_ADDRESS;
lldb::addr_t cfa = LLDB_INVALID_ADDRESS;
+ bool behaves_like_zeroth_frame = (idx == 0);
if (idx == 0) {
// We might have already created frame zero, only create it if we need
// to.
@@ -455,8 +454,9 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
RegisterContextSP reg_ctx_sp(m_thread.GetRegisterContext());
if (reg_ctx_sp) {
- const bool success =
- unwinder && unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
+ const bool success = unwinder &&
+ unwinder->GetFrameInfoAtIndex(
+ idx, cfa, pc, behaves_like_zeroth_frame);
// There shouldn't be any way not to get the frame info for frame
// 0. But if the unwinder can't make one, lets make one by hand
// with the SP as the CFA and see if that gets any further.
@@ -467,7 +467,7 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
unwind_frame_sp = std::make_shared<StackFrame>(
m_thread.shared_from_this(), m_frames.size(), idx, reg_ctx_sp,
- cfa, pc, nullptr);
+ cfa, pc, behaves_like_zeroth_frame, nullptr);
m_frames.push_back(unwind_frame_sp);
}
} else {
@@ -475,8 +475,9 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
cfa = unwind_frame_sp->m_id.GetCallFrameAddress();
}
} else {
- const bool success =
- unwinder && unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
+ const bool success = unwinder &&
+ unwinder->GetFrameInfoAtIndex(
+ idx, cfa, pc, behaves_like_zeroth_frame);
if (!success) {
// We've gotten to the end of the stack.
SetAllFramesFetched();
@@ -485,7 +486,7 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
const bool cfa_is_valid = true;
unwind_frame_sp = std::make_shared<StackFrame>(
m_thread.shared_from_this(), m_frames.size(), idx, cfa, cfa_is_valid,
- pc, StackFrame::Kind::Regular, nullptr);
+ pc, StackFrame::Kind::Regular, behaves_like_zeroth_frame, nullptr);
// Create synthetic tail call frames between the previous frame and the
// newly-found frame. The new frame's index may change after this call,
@@ -527,10 +528,11 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
while (unwind_sc.GetParentOfInlinedScope(
curr_frame_address, next_frame_sc, next_frame_address)) {
next_frame_sc.line_entry.ApplyFileMappings(target_sp);
- StackFrameSP frame_sp(
- new StackFrame(m_thread.shared_from_this(), m_frames.size(), idx,
- unwind_frame_sp->GetRegisterContextSP(), cfa,
- next_frame_address, &next_frame_sc));
+ behaves_like_zeroth_frame = false;
+ StackFrameSP frame_sp(new StackFrame(
+ m_thread.shared_from_this(), m_frames.size(), idx,
+ unwind_frame_sp->GetRegisterContextSP(), cfa, next_frame_address,
+ behaves_like_zeroth_frame, &next_frame_sc));
m_frames.push_back(frame_sp);
unwind_sc = next_frame_sc;
@@ -661,11 +663,13 @@ StackFrameSP StackFrameList::GetFrameAtIndex(uint32_t idx) {
Unwind *unwinder = m_thread.GetUnwinder();
if (unwinder) {
addr_t pc, cfa;
- if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc)) {
+ bool behaves_like_zeroth_frame = (idx == 0);
+ if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc,
+ behaves_like_zeroth_frame)) {
const bool cfa_is_valid = true;
frame_sp = std::make_shared<StackFrame>(
m_thread.shared_from_this(), idx, idx, cfa, cfa_is_valid, pc,
- StackFrame::Kind::Regular, nullptr);
+ StackFrame::Kind::Regular, behaves_like_zeroth_frame, nullptr);
Function *function =
frame_sp->GetSymbolContext(eSymbolContextFunction).function;
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp
index 6db0c2b037e9..28179b7e1ce0 100644
--- a/source/Target/StopInfo.cpp
+++ b/source/Target/StopInfo.cpp
@@ -147,10 +147,10 @@ public:
} else {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "Process::%s could not find breakpoint site id: %" PRId64 "...",
- __FUNCTION__, m_value);
+ LLDB_LOGF(log,
+ "Process::%s could not find breakpoint site id: %" PRId64
+ "...",
+ __FUNCTION__, m_value);
m_should_stop = true;
}
@@ -270,7 +270,7 @@ protected:
if (!thread_sp->IsValid()) {
// This shouldn't ever happen, but just in case, don't do more harm.
if (log) {
- log->Printf("PerformAction got called with an invalid thread.");
+ LLDB_LOGF(log, "PerformAction got called with an invalid thread.");
}
m_should_stop = true;
m_should_stop_is_valid = true;
@@ -339,10 +339,9 @@ protected:
return;
}
- if (log)
- log->Printf("StopInfoBreakpoint::PerformAction - Hit a "
- "breakpoint while running an expression,"
- " not running commands to avoid recursion.");
+ LLDB_LOGF(log, "StopInfoBreakpoint::PerformAction - Hit a "
+ "breakpoint while running an expression,"
+ " not running commands to avoid recursion.");
bool ignoring_breakpoints =
process->GetIgnoreBreakpointsInExpressions();
if (ignoring_breakpoints) {
@@ -359,10 +358,10 @@ protected:
} else {
m_should_stop = true;
}
- if (log)
- log->Printf("StopInfoBreakpoint::PerformAction - in expression, "
- "continuing: %s.",
- m_should_stop ? "true" : "false");
+ LLDB_LOGF(log,
+ "StopInfoBreakpoint::PerformAction - in expression, "
+ "continuing: %s.",
+ m_should_stop ? "true" : "false");
process->GetTarget().GetDebugger().GetAsyncOutputStream()->Printf(
"Warning: hit breakpoint while running function, skipping "
"commands and conditions to prevent recursion.\n");
@@ -402,10 +401,11 @@ protected:
// aren't:
if (!bp_loc_sp->ValidForThisThread(thread_sp.get())) {
if (log) {
- log->Printf("Breakpoint %s hit on thread 0x%llx but it was not "
- "for this thread, continuing.",
- loc_desc.GetData(), static_cast<unsigned long long>(
- thread_sp->GetID()));
+ LLDB_LOGF(log,
+ "Breakpoint %s hit on thread 0x%llx but it was not "
+ "for this thread, continuing.",
+ loc_desc.GetData(),
+ static_cast<unsigned long long>(thread_sp->GetID()));
}
continue;
}
@@ -445,21 +445,18 @@ protected:
error_sp->EOL();
const char *err_str =
condition_error.AsCString("<Unknown Error>");
- if (log)
- log->Printf("Error evaluating condition: \"%s\"\n", err_str);
+ LLDB_LOGF(log, "Error evaluating condition: \"%s\"\n", err_str);
error_sp->PutCString(err_str);
error_sp->EOL();
error_sp->Flush();
} else {
- if (log) {
- log->Printf("Condition evaluated for breakpoint %s on thread "
- "0x%llx conditon_says_stop: %i.",
- loc_desc.GetData(),
- static_cast<unsigned long long>(
- thread_sp->GetID()),
- condition_says_stop);
- }
+ LLDB_LOGF(log,
+ "Condition evaluated for breakpoint %s on thread "
+ "0x%llx conditon_says_stop: %i.",
+ loc_desc.GetData(),
+ static_cast<unsigned long long>(thread_sp->GetID()),
+ condition_says_stop);
if (!condition_says_stop) {
// We don't want to increment the hit count of breakpoints if
// the condition fails. We've already bumped it by the time
@@ -479,9 +476,9 @@ protected:
bool auto_continue_says_stop = true;
if (bp_loc_sp->IsAutoContinue())
{
- if (log)
- log->Printf("Continuing breakpoint %s as AutoContinue was set.",
- loc_desc.GetData());
+ LLDB_LOGF(log,
+ "Continuing breakpoint %s as AutoContinue was set.",
+ loc_desc.GetData());
// We want this stop reported, so you will know we auto-continued
// but only for external breakpoints:
if (!internal_breakpoint)
@@ -533,10 +530,10 @@ protected:
Log *log_process(
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log_process)
- log_process->Printf(
- "Process::%s could not find breakpoint site id: %" PRId64 "...",
- __FUNCTION__, m_value);
+ LLDB_LOGF(log_process,
+ "Process::%s could not find breakpoint site id: %" PRId64
+ "...",
+ __FUNCTION__, m_value);
}
if ((!m_should_stop || internal_breakpoint) &&
@@ -546,15 +543,15 @@ protected:
// additionally to the breakpoint
m_should_stop = true;
- // Here we clean the preset stop info so the next GetStopInfo call will
- // find the appropriate stop info, which should be the stop info
- // related to the completed plan
- thread_sp->ResetStopInfo();
+ // We know we're stopping for a completed plan and we don't want to
+ // show the breakpoint stop, so compute the public stop info immediately
+ // here.
+ thread_sp->CalculatePublicStopInfo();
}
- if (log)
- log->Printf("Process::%s returning from action with m_should_stop: %d.",
- __FUNCTION__, m_should_stop);
+ LLDB_LOGF(log,
+ "Process::%s returning from action with m_should_stop: %d.",
+ __FUNCTION__, m_should_stop);
}
}
@@ -664,11 +661,10 @@ protected:
} else {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "Process::%s could not find watchpoint location id: %" PRId64
- "...",
- __FUNCTION__, GetValue());
+ LLDB_LOGF(log,
+ "Process::%s could not find watchpoint location id: %" PRId64
+ "...",
+ __FUNCTION__, GetValue());
m_should_stop = true;
}
@@ -817,15 +813,14 @@ protected:
m_should_stop = false;
} else
m_should_stop = true;
- if (log)
- log->Printf(
- "Condition successfully evaluated, result is %s.\n",
- m_should_stop ? "true" : "false");
+ LLDB_LOGF(log,
+ "Condition successfully evaluated, result is %s.\n",
+ m_should_stop ? "true" : "false");
} else {
m_should_stop = true;
- if (log)
- log->Printf(
- "Failed to get an integer result from the expression.");
+ LLDB_LOGF(
+ log,
+ "Failed to get an integer result from the expression.");
}
}
} else {
@@ -836,8 +831,7 @@ protected:
error_sp->Printf(": \"%s\"", wp_sp->GetConditionText());
error_sp->EOL();
const char *err_str = error.AsCString("<Unknown Error>");
- if (log)
- log->Printf("Error evaluating condition: \"%s\"\n", err_str);
+ LLDB_LOGF(log, "Error evaluating condition: \"%s\"\n", err_str);
error_sp->PutCString(err_str);
error_sp->EOL();
@@ -889,14 +883,13 @@ protected:
Log *log_process(
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log_process)
- log_process->Printf(
- "Process::%s could not find watchpoint id: %" PRId64 "...",
- __FUNCTION__, m_value);
+ LLDB_LOGF(log_process,
+ "Process::%s could not find watchpoint id: %" PRId64 "...",
+ __FUNCTION__, m_value);
}
- if (log)
- log->Printf("Process::%s returning from action with m_should_stop: %d.",
- __FUNCTION__, m_should_stop);
+ LLDB_LOGF(log,
+ "Process::%s returning from action with m_should_stop: %d.",
+ __FUNCTION__, m_should_stop);
m_should_stop_is_valid = true;
}
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;
+}
diff --git a/source/Target/TargetProperties.td b/source/Target/TargetProperties.td
new file mode 100644
index 000000000000..9079c3cf4276
--- /dev/null
+++ b/source/Target/TargetProperties.td
@@ -0,0 +1,237 @@
+include "../../include/lldb/Core/PropertiesBase.td"
+
+let Definition = "experimental" in {
+ def InjectLocalVars : Property<"inject-local-vars", "Boolean">,
+ Global, DefaultTrue,
+ Desc<"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.">;
+ def UseModernTypeLookup : Property<"use-modern-type-lookup", "Boolean">,
+ Global, DefaultFalse,
+ Desc<"If true, use Clang's modern type lookup infrastructure.">;
+}
+
+let Definition = "target" in {
+ def DefaultArch: Property<"default-arch", "Arch">,
+ Global,
+ DefaultStringValue<"">,
+ Desc<"Default architecture to choose, when there's a choice.">;
+ def MoveToNearestCode: Property<"move-to-nearest-code", "Boolean">,
+ DefaultTrue,
+ Desc<"Move breakpoints to nearest code.">;
+ def Language: Property<"language", "Language">,
+ DefaultEnumValue<"eLanguageTypeUnknown">,
+ Desc<"The language to use when interpreting expressions entered in commands.">;
+ def ExprPrefix: Property<"expr-prefix", "FileSpec">,
+ DefaultStringValue<"">,
+ Desc<"Path to a file containing expressions to be prepended to all expressions.">;
+ def PreferDynamic: Property<"prefer-dynamic-value", "Enum">,
+ DefaultEnumValue<"eDynamicDontRunTarget">,
+ EnumValues<"OptionEnumValues(g_dynamic_value_types)">,
+ Desc<"Should printed values be shown as their dynamic value.">;
+ def EnableSynthetic: Property<"enable-synthetic-value", "Boolean">,
+ DefaultTrue,
+ Desc<"Should synthetic values be used by default whenever available.">;
+ def SkipPrologue: Property<"skip-prologue", "Boolean">,
+ DefaultTrue,
+ Desc<"Skip function prologues when setting breakpoints by name.">;
+ def SourceMap: Property<"source-map", "PathMap">,
+ DefaultStringValue<"">,
+ Desc<"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.">;
+ def ExecutableSearchPaths: Property<"exec-search-paths", "FileSpecList">,
+ DefaultStringValue<"">,
+ Desc<"Executable search paths to use when locating executable files whose paths don't match the local file system.">;
+ def DebugFileSearchPaths: Property<"debug-file-search-paths", "FileSpecList">,
+ DefaultStringValue<"">,
+ Desc<"List of directories to be searched when locating debug symbol files. See also symbols.enable-external-lookup.">;
+ def ClangModuleSearchPaths: Property<"clang-module-search-paths", "FileSpecList">,
+ DefaultStringValue<"">,
+ Desc<"List of directories to be searched when locating modules for Clang.">;
+ def AutoImportClangModules: Property<"auto-import-clang-modules", "Boolean">,
+ DefaultTrue,
+ Desc<"Automatically load Clang modules referred to by the program.">;
+ def ImportStdModule: Property<"import-std-module", "Boolean">,
+ DefaultFalse,
+ Desc<"Import the C++ std module to improve debugging STL containers.">;
+ def AutoApplyFixIts: Property<"auto-apply-fixits", "Boolean">,
+ DefaultTrue,
+ Desc<"Automatically apply fix-it hints to expressions.">;
+ def NotifyAboutFixIts: Property<"notify-about-fixits", "Boolean">,
+ DefaultTrue,
+ Desc<"Print the fixed expression text.">;
+ def SaveObjects: Property<"save-jit-objects", "Boolean">,
+ DefaultFalse,
+ Desc<"Save intermediate object files generated by the LLVM JIT">;
+ def MaxZeroPaddingInFloatFormat: Property<"max-zero-padding-in-float-format", "UInt64">,
+ DefaultUnsignedValue<6>,
+ Desc<"The maximum number of zeroes to insert when displaying a very small float before falling back to scientific notation.">;
+ def MaxChildrenCount: Property<"max-children-count", "SInt64">,
+ DefaultUnsignedValue<256>,
+ Desc<"Maximum number of children to expand in any level of depth.">;
+ def MaxSummaryLength: Property<"max-string-summary-length", "SInt64">,
+ DefaultUnsignedValue<1024>,
+ Desc<"Maximum number of characters to show when using %s in summary strings.">;
+ def MaxMemReadSize: Property<"max-memory-read-size", "SInt64">,
+ DefaultUnsignedValue<1024>,
+ Desc<"Maximum number of bytes that 'memory read' will fetch before --force must be specified.">;
+ def BreakpointUseAvoidList: Property<"breakpoints-use-platform-avoid-list", "Boolean">,
+ DefaultTrue,
+ Desc<"Consult the platform module avoid list when setting non-module specific breakpoints.">;
+ def Arg0: Property<"arg0", "String">,
+ DefaultStringValue<"">,
+ Desc<"The first argument passed to the program in the argument array which can be different from the executable itself.">;
+ def RunArgs: Property<"run-args", "Args">,
+ DefaultStringValue<"">,
+ Desc<"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.">;
+ def EnvVars: Property<"env-vars", "Dictionary">,
+ DefaultUnsignedValue<16>,
+ Desc<"A list of all the environment variables to be passed to the executable's environment, and their values.">;
+ def InheritEnv: Property<"inherit-env", "Boolean">,
+ DefaultTrue,
+ Desc<"Inherit the environment from the process that is running LLDB.">;
+ def InputPath: Property<"input-path", "FileSpec">,
+ DefaultStringValue<"">,
+ Desc<"The file/path to be used by the executable program for reading its standard input.">;
+ def OutputPath: Property<"output-path", "FileSpec">,
+ DefaultStringValue<"">,
+ Desc<"The file/path to be used by the executable program for writing its standard output.">;
+ def ErrorPath: Property<"error-path", "FileSpec">,
+ DefaultStringValue<"">,
+ Desc<"The file/path to be used by the executable program for writing its standard error.">;
+ def DetachOnError: Property<"detach-on-error", "Boolean">,
+ DefaultTrue,
+ Desc<"debugserver will detach (rather than killing) a process if it loses connection with lldb.">;
+ def PreloadSymbols: Property<"preload-symbols", "Boolean">,
+ DefaultTrue,
+ Desc<"Enable loading of symbol tables before they are needed.">;
+ def DisableASLR: Property<"disable-aslr", "Boolean">,
+ DefaultTrue,
+ Desc<"Disable Address Space Layout Randomization (ASLR)">;
+ def DisableSTDIO: Property<"disable-stdio", "Boolean">,
+ DefaultFalse,
+ Desc<"Disable stdin/stdout for process (e.g. for a GUI application)">;
+ def InlineStrategy: Property<"inline-breakpoint-strategy", "Enum">,
+ DefaultEnumValue<"eInlineBreakpointsAlways">,
+ EnumValues<"OptionEnumValues(g_inline_breakpoint_enums)">,
+ Desc<"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.">;
+ def DisassemblyFlavor: Property<"x86-disassembly-flavor", "Enum">,
+ DefaultEnumValue<"eX86DisFlavorDefault">,
+ EnumValues<"OptionEnumValues(g_x86_dis_flavor_value_types)">,
+ Desc<"The default disassembly flavor to use for x86 or x86-64 targets.">;
+ def UseHexImmediates: Property<"use-hex-immediates", "Boolean">,
+ DefaultTrue,
+ Desc<"Show immediates in disassembly as hexadecimal.">;
+ def HexImmediateStyle: Property<"hex-immediate-style", "Enum">,
+ DefaultEnumValue<"Disassembler::eHexStyleC">,
+ EnumValues<"OptionEnumValues(g_hex_immediate_style_values)">,
+ Desc<"Which style to use for printing hexadecimal disassembly values.">;
+ def UseFastStepping: Property<"use-fast-stepping", "Boolean">,
+ DefaultTrue,
+ Desc<"Use a fast stepping algorithm based on running from branch to branch rather than instruction single-stepping.">;
+ def LoadScriptFromSymbolFile: Property<"load-script-from-symbol-file", "Enum">,
+ DefaultEnumValue<"eLoadScriptFromSymFileWarn">,
+ EnumValues<"OptionEnumValues(g_load_script_from_sym_file_values)">,
+ Desc<"Allow LLDB to load scripting resources embedded in symbol files when available.">;
+ def LoadCWDlldbinitFile: Property<"load-cwd-lldbinit", "Enum">,
+ DefaultEnumValue<"eLoadCWDlldbinitWarn">,
+ EnumValues<"OptionEnumValues(g_load_cwd_lldbinit_values)">,
+ Desc<"Allow LLDB to .lldbinit files from the current directory automatically.">;
+ def MemoryModuleLoadLevel: Property<"memory-module-load-level", "Enum">,
+ DefaultEnumValue<"eMemoryModuleLoadLevelComplete">,
+ EnumValues<"OptionEnumValues(g_memory_module_load_level_values)">,
+ Desc<"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). ">;
+ def DisplayExpressionsInCrashlogs: Property<"display-expression-in-crashlogs", "Boolean">,
+ DefaultFalse,
+ Desc<"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.">;
+ def TrapHandlerNames: Property<"trap-handler-names", "Array">,
+ Global,
+ DefaultUnsignedValue<16>,
+ Desc<"A list of trap handler function names, e.g. a common Unix user process one is _sigtramp.">;
+ def DisplayRuntimeSupportValues: Property<"display-runtime-support-values", "Boolean">,
+ DefaultFalse,
+ Desc<"If true, LLDB will show variables that are meant to support the operation of a language's runtime support.">;
+ def DisplayRecognizedArguments: Property<"display-recognized-arguments", "Boolean">,
+ DefaultFalse,
+ Desc<"Show recognized arguments in variable listings by default.">;
+ def NonStopModeEnabled: Property<"non-stop-mode", "Boolean">,
+ DefaultFalse,
+ Desc<"Disable lock-step debugging, instead control threads independently.">;
+ def RequireHardwareBreakpoints: Property<"require-hardware-breakpoint", "Boolean">,
+ DefaultFalse,
+ Desc<"Require all breakpoints to be hardware breakpoints.">;
+}
+
+let Definition = "process" in {
+ def DisableMemCache: Property<"disable-memory-cache", "Boolean">,
+ DefaultFalse,
+ Desc<"Disable reading and caching of memory in fixed-size units.">;
+ def ExtraStartCommand: Property<"extra-startup-command", "Array">,
+ DefaultUnsignedValue<16>,
+ Desc<"A list containing extra commands understood by the particular process plugin used. For instance, to turn on debugserver logging set this to 'QSetLogging:bitmask=LOG_DEFAULT;'">;
+ def IgnoreBreakpointsInExpressions: Property<"ignore-breakpoints-in-expressions", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"If true, breakpoints will be ignored during expression evaluation.">;
+ def UnwindOnErrorInExpressions: Property<"unwind-on-error-in-expressions", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"If true, errors in expression evaluation will unwind the stack back to the state before the call.">;
+ def PythonOSPluginPath: Property<"python-os-plugin-path", "FileSpec">,
+ DefaultUnsignedValue<1>,
+ Desc<"A path to a python OS plug-in module file that contains a OperatingSystemPlugIn class.">;
+ def StopOnSharedLibraryEvents: Property<"stop-on-sharedlibrary-events", "Boolean">,
+ Global,
+ DefaultFalse,
+ Desc<"If true, stop when a shared library is loaded or unloaded.">;
+ def DetachKeepsStopped: Property<"detach-keeps-stopped", "Boolean">,
+ Global,
+ DefaultFalse,
+ Desc<"If true, detach will attempt to keep the process stopped.">;
+ def MemCacheLineSize: Property<"memory-cache-line-size", "UInt64">,
+ DefaultUnsignedValue<512>,
+ Desc<"The memory cache line size">;
+ def WarningOptimization: Property<"optimization-warnings", "Boolean">,
+ DefaultTrue,
+ Desc<"If true, warn when stopped in code that is optimized where stepping and variable availability may not behave as expected.">;
+ def StopOnExec: Property<"stop-on-exec", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"If true, stop when a shared library is loaded or unloaded.">;
+ def UtilityExpressionTimeout: Property<"utility-expression-timeout", "UInt64">,
+ DefaultUnsignedValue<15>,
+ Desc<"The time in seconds to wait for LLDB-internal utility expressions.">;
+}
+
+let Definition = "platform" in {
+ def UseModuleCache: Property<"use-module-cache", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"Use module cache.">;
+ def ModuleCacheDirectory: Property<"module-cache-directory", "FileSpec">,
+ Global,
+ DefaultStringValue<"">,
+ Desc<"Root directory for cached modules.">;
+}
+
+let Definition = "thread" in {
+ def StepInAvoidsNoDebug: Property<"step-in-avoid-nodebug", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"If true, step-in will not stop in functions with no debug information.">;
+ def StepOutAvoidsNoDebug: Property<"step-out-avoid-nodebug", "Boolean">,
+ Global,
+ DefaultFalse,
+ Desc<"If true, when step-in/step-out/step-over leave the current frame, they will continue to step out till they come to a function with debug information. Passing a frame argument to step-out will override this option.">;
+ def StepAvoidRegex: Property<"step-avoid-regexp", "Regex">,
+ Global,
+ DefaultStringValue<"^std::">,
+ Desc<"A regular expression defining functions step-in won't stop in.">;
+ def StepAvoidLibraries: Property<"step-avoid-libraries", "FileSpecList">,
+ Global,
+ DefaultStringValue<"">,
+ Desc<"A list of libraries that source stepping won't stop in.">;
+ def EnableThreadTrace: Property<"trace-thread", "Boolean">,
+ DefaultFalse,
+ Desc<"If true, this thread will single-step and log execution.">;
+ def MaxBacktraceDepth: Property<"max-backtrace-depth", "UInt64">,
+ DefaultUnsignedValue<300000>,
+ Desc<"Maximum number of frames to backtrace.">;
+}
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index 7a6b49e55252..e12b90501103 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -13,6 +13,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/OptionValueFileSpecList.h"
@@ -63,31 +64,12 @@ const ThreadPropertiesSP &Thread::GetGlobalProperties() {
return *g_settings_sp_ptr;
}
-static constexpr PropertyDefinition g_properties[] = {
- {"step-in-avoid-nodebug", OptionValue::eTypeBoolean, true, true, nullptr,
- {},
- "If true, step-in will not stop in functions with no debug information."},
- {"step-out-avoid-nodebug", OptionValue::eTypeBoolean, true, false, nullptr,
- {}, "If true, when step-in/step-out/step-over leave the current frame, "
- "they will continue to step out till they come to a function with "
- "debug information. Passing a frame argument to step-out will "
- "override this option."},
- {"step-avoid-regexp", OptionValue::eTypeRegex, true, 0, "^std::", {},
- "A regular expression defining functions step-in won't stop in."},
- {"step-avoid-libraries", OptionValue::eTypeFileSpecList, true, 0, nullptr,
- {}, "A list of libraries that source stepping won't stop in."},
- {"trace-thread", OptionValue::eTypeBoolean, false, false, nullptr, {},
- "If true, this thread will single-step and log execution."},
- {"max-backtrace-depth", OptionValue::eTypeUInt64, false, 300000, nullptr,
- {}, "Maximum number of frames to backtrace."}};
+#define LLDB_PROPERTIES_thread
+#include "TargetProperties.inc"
enum {
- ePropertyStepInAvoidsNoDebug,
- ePropertyStepOutAvoidsNoDebug,
- ePropertyStepAvoidRegex,
- ePropertyStepAvoidLibraries,
- ePropertyEnableThreadTrace,
- ePropertyMaxBacktraceDepth
+#define LLDB_PROPERTIES_thread
+#include "TargetPropertiesEnum.inc"
};
class ThreadOptionValueProperties : public OptionValueProperties {
@@ -125,7 +107,7 @@ ThreadProperties::ThreadProperties(bool is_global) : Properties() {
if (is_global) {
m_collection_sp =
std::make_shared<ThreadOptionValueProperties>(ConstString("thread"));
- m_collection_sp->Initialize(g_properties);
+ m_collection_sp->Initialize(g_thread_properties);
} else
m_collection_sp = std::make_shared<ThreadOptionValueProperties>(
Thread::GetGlobalProperties().get());
@@ -150,25 +132,25 @@ FileSpecList ThreadProperties::GetLibrariesToAvoid() const {
bool ThreadProperties::GetTraceEnabledState() const {
const uint32_t idx = ePropertyEnableThreadTrace;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_thread_properties[idx].default_uint_value != 0);
}
bool ThreadProperties::GetStepInAvoidsNoDebug() const {
const uint32_t idx = ePropertyStepInAvoidsNoDebug;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_thread_properties[idx].default_uint_value != 0);
}
bool ThreadProperties::GetStepOutAvoidsNoDebug() const {
const uint32_t idx = ePropertyStepOutAvoidsNoDebug;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_thread_properties[idx].default_uint_value != 0);
}
uint64_t ThreadProperties::GetMaxBacktraceDepth() const {
const uint32_t idx = ePropertyMaxBacktraceDepth;
return m_collection_sp->GetPropertyAtIndexAsUInt64(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_thread_properties[idx].default_uint_value != 0);
}
// Thread Event Data
@@ -256,9 +238,8 @@ Thread::Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id)
m_override_should_notify(eLazyBoolCalculate),
m_extended_info_fetched(false), m_extended_info() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p Thread::Thread(tid = 0x%4.4" PRIx64 ")",
- static_cast<void *>(this), GetID());
+ LLDB_LOGF(log, "%p Thread::Thread(tid = 0x%4.4" PRIx64 ")",
+ static_cast<void *>(this), GetID());
CheckInWithManager();
@@ -267,9 +248,8 @@ Thread::Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id)
Thread::~Thread() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p Thread::~Thread(tid = 0x%4.4" PRIx64 ")",
- static_cast<void *>(this), GetID());
+ LLDB_LOGF(log, "%p Thread::~Thread(tid = 0x%4.4" PRIx64 ")",
+ static_cast<void *>(this), GetID());
/// If you hit this assert, it means your derived class forgot to call
/// DoDestroy in its destructor.
assert(m_destroy_called);
@@ -411,6 +391,11 @@ lldb::StopInfoSP Thread::GetStopInfo() {
}
}
+void Thread::CalculatePublicStopInfo() {
+ ResetStopInfo();
+ SetStopInfo(GetStopInfo());
+}
+
lldb::StopInfoSP Thread::GetPrivateStopInfo() {
if (m_destroy_called)
return m_stop_info_sp;
@@ -490,11 +475,10 @@ void Thread::SetStopInfo(const lldb::StopInfoSP &stop_info_sp) {
else
m_stop_info_stop_id = UINT32_MAX;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
- if (log)
- log->Printf("%p: tid = 0x%" PRIx64 ": stop info = %s (stop_id = %u)",
- static_cast<void *>(this), GetID(),
- stop_info_sp ? stop_info_sp->GetDescription() : "<NULL>",
- m_stop_info_stop_id);
+ LLDB_LOGF(log, "%p: tid = 0x%" PRIx64 ": stop info = %s (stop_id = %u)",
+ static_cast<void *>(this), GetID(),
+ stop_info_sp ? stop_info_sp->GetDescription() : "<NULL>",
+ m_stop_info_stop_id);
}
void Thread::SetShouldReportStop(Vote vote) {
@@ -721,18 +705,18 @@ bool Thread::ShouldStop(Event *event_ptr) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (GetResumeState() == eStateSuspended) {
- if (log)
- log->Printf("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
- ", should_stop = 0 (ignore since thread was suspended)",
- __FUNCTION__, GetID(), GetProtocolID());
+ LLDB_LOGF(log,
+ "Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
+ ", should_stop = 0 (ignore since thread was suspended)",
+ __FUNCTION__, GetID(), GetProtocolID());
return false;
}
if (GetTemporaryResumeState() == eStateSuspended) {
- if (log)
- log->Printf("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
- ", should_stop = 0 (ignore since thread was suspended)",
- __FUNCTION__, GetID(), GetProtocolID());
+ LLDB_LOGF(log,
+ "Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
+ ", should_stop = 0 (ignore since thread was suspended)",
+ __FUNCTION__, GetID(), GetProtocolID());
return false;
}
@@ -740,28 +724,28 @@ bool Thread::ShouldStop(Event *event_ptr) {
// thread caused the process to stop. NOTE: this must take place before the
// plan is moved from the current plan stack to the completed plan stack.
if (!ThreadStoppedForAReason()) {
- if (log)
- log->Printf("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
- ", pc = 0x%16.16" PRIx64
- ", should_stop = 0 (ignore since no stop reason)",
- __FUNCTION__, GetID(), GetProtocolID(),
- GetRegisterContext() ? GetRegisterContext()->GetPC()
- : LLDB_INVALID_ADDRESS);
+ LLDB_LOGF(log,
+ "Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
+ ", pc = 0x%16.16" PRIx64
+ ", should_stop = 0 (ignore since no stop reason)",
+ __FUNCTION__, GetID(), GetProtocolID(),
+ GetRegisterContext() ? GetRegisterContext()->GetPC()
+ : LLDB_INVALID_ADDRESS);
return false;
}
if (log) {
- log->Printf("Thread::%s(%p) for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
- ", pc = 0x%16.16" PRIx64,
- __FUNCTION__, static_cast<void *>(this), GetID(),
- GetProtocolID(),
- GetRegisterContext() ? GetRegisterContext()->GetPC()
- : LLDB_INVALID_ADDRESS);
- log->Printf("^^^^^^^^ Thread::ShouldStop Begin ^^^^^^^^");
+ LLDB_LOGF(log,
+ "Thread::%s(%p) for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
+ ", pc = 0x%16.16" PRIx64,
+ __FUNCTION__, static_cast<void *>(this), GetID(), GetProtocolID(),
+ GetRegisterContext() ? GetRegisterContext()->GetPC()
+ : LLDB_INVALID_ADDRESS);
+ LLDB_LOGF(log, "^^^^^^^^ Thread::ShouldStop Begin ^^^^^^^^");
StreamString s;
s.IndentMore();
DumpThreadPlans(&s);
- log->Printf("Plan stack initial state:\n%s", s.GetData());
+ LLDB_LOGF(log, "Plan stack initial state:\n%s", s.GetData());
}
// The top most plan always gets to do the trace log...
@@ -774,9 +758,8 @@ bool Thread::ShouldStop(Event *event_ptr) {
StopInfoSP private_stop_info(GetPrivateStopInfo());
if (private_stop_info &&
!private_stop_info->ShouldStopSynchronous(event_ptr)) {
- if (log)
- log->Printf("StopInfo::ShouldStop async callback says we should not "
- "stop, returning ShouldStop of false.");
+ LLDB_LOGF(log, "StopInfo::ShouldStop async callback says we should not "
+ "stop, returning ShouldStop of false.");
return false;
}
@@ -840,15 +823,13 @@ bool Thread::ShouldStop(Event *event_ptr) {
if (!done_processing_current_plan) {
bool over_ride_stop = current_plan->ShouldAutoContinue(event_ptr);
- if (log)
- log->Printf("Plan %s explains stop, auto-continue %i.",
- current_plan->GetName(), over_ride_stop);
+ LLDB_LOGF(log, "Plan %s explains stop, auto-continue %i.",
+ current_plan->GetName(), over_ride_stop);
// We're starting from the base plan, so just let it decide;
if (PlanIsBasePlan(current_plan)) {
should_stop = current_plan->ShouldStop(event_ptr);
- if (log)
- log->Printf("Base plan says should stop: %i.", should_stop);
+ LLDB_LOGF(log, "Base plan says should stop: %i.", should_stop);
} else {
// Otherwise, don't let the base plan override what the other plans say
// to do, since presumably if there were other plans they would know what
@@ -858,9 +839,8 @@ bool Thread::ShouldStop(Event *event_ptr) {
break;
should_stop = current_plan->ShouldStop(event_ptr);
- if (log)
- log->Printf("Plan %s should stop: %d.", current_plan->GetName(),
- should_stop);
+ LLDB_LOGF(log, "Plan %s should stop: %d.", current_plan->GetName(),
+ should_stop);
if (current_plan->MischiefManaged()) {
if (should_stop)
current_plan->WillStop();
@@ -907,10 +887,10 @@ bool Thread::ShouldStop(Event *event_ptr) {
plan_ptr = GetPreviousPlan(examined_plan);
if (stale) {
- if (log)
- log->Printf(
- "Plan %s being discarded in cleanup, it says it is already done.",
- examined_plan->GetName());
+ LLDB_LOGF(
+ log,
+ "Plan %s being discarded in cleanup, it says it is already done.",
+ examined_plan->GetName());
while (GetCurrentPlan() != examined_plan) {
DiscardPlan();
}
@@ -929,9 +909,9 @@ bool Thread::ShouldStop(Event *event_ptr) {
StreamString s;
s.IndentMore();
DumpThreadPlans(&s);
- log->Printf("Plan stack final state:\n%s", s.GetData());
- log->Printf("vvvvvvvv Thread::ShouldStop End (returning %i) vvvvvvvv",
- should_stop);
+ LLDB_LOGF(log, "Plan stack final state:\n%s", s.GetData());
+ LLDB_LOGF(log, "vvvvvvvv Thread::ShouldStop End (returning %i) vvvvvvvv",
+ should_stop);
}
return should_stop;
}
@@ -943,37 +923,36 @@ Vote Thread::ShouldReportStop(Event *event_ptr) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (thread_state == eStateSuspended || thread_state == eStateInvalid) {
- if (log)
- log->Printf("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
- ": returning vote %i (state was suspended or invalid)",
- GetID(), eVoteNoOpinion);
+ LLDB_LOGF(log,
+ "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
+ ": returning vote %i (state was suspended or invalid)",
+ GetID(), eVoteNoOpinion);
return eVoteNoOpinion;
}
if (temp_thread_state == eStateSuspended ||
temp_thread_state == eStateInvalid) {
- if (log)
- log->Printf(
- "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
- ": returning vote %i (temporary state was suspended or invalid)",
- GetID(), eVoteNoOpinion);
+ LLDB_LOGF(log,
+ "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
+ ": returning vote %i (temporary state was suspended or invalid)",
+ GetID(), eVoteNoOpinion);
return eVoteNoOpinion;
}
if (!ThreadStoppedForAReason()) {
- if (log)
- log->Printf("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
- ": returning vote %i (thread didn't stop for a reason.)",
- GetID(), eVoteNoOpinion);
+ LLDB_LOGF(log,
+ "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
+ ": returning vote %i (thread didn't stop for a reason.)",
+ GetID(), eVoteNoOpinion);
return eVoteNoOpinion;
}
if (m_completed_plan_stack.size() > 0) {
// Don't use GetCompletedPlan here, since that suppresses private plans.
- if (log)
- log->Printf("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
- ": returning vote for complete stack's back plan",
- GetID());
+ LLDB_LOGF(log,
+ "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
+ ": returning vote for complete stack's back plan",
+ GetID());
return m_completed_plan_stack.back()->ShouldReportStop(event_ptr);
} else {
Vote thread_vote = eVoteNoOpinion;
@@ -988,10 +967,10 @@ Vote Thread::ShouldReportStop(Event *event_ptr) {
else
plan_ptr = GetPreviousPlan(plan_ptr);
}
- if (log)
- log->Printf("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
- ": returning vote %i for current plan",
- GetID(), thread_vote);
+ LLDB_LOGF(log,
+ "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
+ ": returning vote %i for current plan",
+ GetID(), thread_vote);
return thread_vote;
}
@@ -1007,21 +986,21 @@ Vote Thread::ShouldReportRun(Event *event_ptr) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (m_completed_plan_stack.size() > 0) {
// Don't use GetCompletedPlan here, since that suppresses private plans.
- if (log)
- log->Printf("Current Plan for thread %d(%p) (0x%4.4" PRIx64
- ", %s): %s being asked whether we should report run.",
- GetIndexID(), static_cast<void *>(this), GetID(),
- StateAsCString(GetTemporaryResumeState()),
- m_completed_plan_stack.back()->GetName());
+ LLDB_LOGF(log,
+ "Current Plan for thread %d(%p) (0x%4.4" PRIx64
+ ", %s): %s being asked whether we should report run.",
+ GetIndexID(), static_cast<void *>(this), GetID(),
+ StateAsCString(GetTemporaryResumeState()),
+ m_completed_plan_stack.back()->GetName());
return m_completed_plan_stack.back()->ShouldReportRun(event_ptr);
} else {
- if (log)
- log->Printf("Current Plan for thread %d(%p) (0x%4.4" PRIx64
- ", %s): %s being asked whether we should report run.",
- GetIndexID(), static_cast<void *>(this), GetID(),
- StateAsCString(GetTemporaryResumeState()),
- GetCurrentPlan()->GetName());
+ LLDB_LOGF(log,
+ "Current Plan for thread %d(%p) (0x%4.4" PRIx64
+ ", %s): %s being asked whether we should report run.",
+ GetIndexID(), static_cast<void *>(this), GetID(),
+ StateAsCString(GetTemporaryResumeState()),
+ GetCurrentPlan()->GetName());
return GetCurrentPlan()->ShouldReportRun(event_ptr);
}
@@ -1048,9 +1027,9 @@ void Thread::PushPlan(ThreadPlanSP &thread_plan_sp) {
if (log) {
StreamString s;
thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelFull);
- log->Printf("Thread::PushPlan(0x%p): \"%s\", tid = 0x%4.4" PRIx64 ".",
- static_cast<void *>(this), s.GetData(),
- thread_plan_sp->GetThread().GetID());
+ LLDB_LOGF(log, "Thread::PushPlan(0x%p): \"%s\", tid = 0x%4.4" PRIx64 ".",
+ static_cast<void *>(this), s.GetData(),
+ thread_plan_sp->GetThread().GetID());
}
}
}
@@ -1063,8 +1042,8 @@ void Thread::PopPlan() {
else {
ThreadPlanSP &plan = m_plan_stack.back();
if (log) {
- log->Printf("Popping plan: \"%s\", tid = 0x%4.4" PRIx64 ".",
- plan->GetName(), plan->GetThread().GetID());
+ LLDB_LOGF(log, "Popping plan: \"%s\", tid = 0x%4.4" PRIx64 ".",
+ plan->GetName(), plan->GetThread().GetID());
}
m_completed_plan_stack.push_back(plan);
plan->WillPop();
@@ -1076,9 +1055,8 @@ void Thread::DiscardPlan() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (m_plan_stack.size() > 1) {
ThreadPlanSP &plan = m_plan_stack.back();
- if (log)
- log->Printf("Discarding plan: \"%s\", tid = 0x%4.4" PRIx64 ".",
- plan->GetName(), plan->GetThread().GetID());
+ LLDB_LOGF(log, "Discarding plan: \"%s\", tid = 0x%4.4" PRIx64 ".",
+ plan->GetName(), plan->GetThread().GetID());
m_discarded_plan_stack.push_back(plan);
plan->WillPop();
@@ -1252,10 +1230,10 @@ void Thread::DiscardThreadPlansUpToPlan(lldb::ThreadPlanSP &up_to_plan_sp) {
void Thread::DiscardThreadPlansUpToPlan(ThreadPlan *up_to_plan_ptr) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("Discarding thread plans for thread tid = 0x%4.4" PRIx64
- ", up to %p",
- GetID(), static_cast<void *>(up_to_plan_ptr));
+ LLDB_LOGF(log,
+ "Discarding thread plans for thread tid = 0x%4.4" PRIx64
+ ", up to %p",
+ GetID(), static_cast<void *>(up_to_plan_ptr));
int stack_size = m_plan_stack.size();
@@ -1285,9 +1263,10 @@ void Thread::DiscardThreadPlansUpToPlan(ThreadPlan *up_to_plan_ptr) {
void Thread::DiscardThreadPlans(bool force) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (log) {
- log->Printf("Discarding thread plans for thread (tid = 0x%4.4" PRIx64
- ", force %d)",
- GetID(), force);
+ LLDB_LOGF(log,
+ "Discarding thread plans for thread (tid = 0x%4.4" PRIx64
+ ", force %d)",
+ GetID(), force);
}
if (force) {
@@ -1504,9 +1483,18 @@ ThreadPlanSP Thread::QueueThreadPlanForStepUntil(
}
lldb::ThreadPlanSP Thread::QueueThreadPlanForStepScripted(
- bool abort_other_plans, const char *class_name, bool stop_other_threads,
+ bool abort_other_plans, const char *class_name,
+ StructuredData::ObjectSP extra_args_sp, bool stop_other_threads,
Status &status) {
- ThreadPlanSP thread_plan_sp(new ThreadPlanPython(*this, class_name));
+
+ StructuredDataImpl *extra_args_impl = nullptr;
+ if (extra_args_sp) {
+ extra_args_impl = new StructuredDataImpl();
+ extra_args_impl->SetObjectSP(extra_args_sp);
+ }
+
+ ThreadPlanSP thread_plan_sp(new ThreadPlanPython(*this, class_name,
+ extra_args_impl));
status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
return thread_plan_sp;
@@ -2062,6 +2050,7 @@ Unwind *Thread::GetUnwinder() {
case llvm::Triple::x86:
case llvm::Triple::arm:
case llvm::Triple::aarch64:
+ case llvm::Triple::aarch64_32:
case llvm::Triple::thumb:
case llvm::Triple::mips:
case llvm::Triple::mipsel:
@@ -2072,6 +2061,7 @@ Unwind *Thread::GetUnwinder() {
case llvm::Triple::ppc64le:
case llvm::Triple::systemz:
case llvm::Triple::hexagon:
+ case llvm::Triple::arc:
m_unwinder_up.reset(new UnwindLLDB(*this));
break;
diff --git a/source/Target/ThreadList.cpp b/source/Target/ThreadList.cpp
index afdfda3b0ae1..183b39c2cfa9 100644
--- a/source/Target/ThreadList.cpp
+++ b/source/Target/ThreadList.cpp
@@ -267,10 +267,11 @@ bool ThreadList::ShouldStop(Event *event_ptr) {
if (log) {
log->PutCString("");
- log->Printf("ThreadList::%s: %" PRIu64 " threads, %" PRIu64
- " unsuspended threads",
- __FUNCTION__, (uint64_t)m_threads.size(),
- (uint64_t)threads_copy.size());
+ LLDB_LOGF(log,
+ "ThreadList::%s: %" PRIu64 " threads, %" PRIu64
+ " unsuspended threads",
+ __FUNCTION__, (uint64_t)m_threads.size(),
+ (uint64_t)threads_copy.size());
}
bool did_anybody_stop_for_a_reason = false;
@@ -279,10 +280,9 @@ bool ThreadList::ShouldStop(Event *event_ptr) {
// what. Otherwise, presume we won't stop.
bool should_stop = false;
if (Process::ProcessEventData::GetInterruptedFromEvent(event_ptr)) {
- if (log)
- log->Printf(
- "ThreadList::%s handling interrupt event, should stop set to true",
- __FUNCTION__);
+ LLDB_LOGF(
+ log, "ThreadList::%s handling interrupt event, should stop set to true",
+ __FUNCTION__);
should_stop = true;
}
@@ -334,15 +334,14 @@ bool ThreadList::ShouldStop(Event *event_ptr) {
if (!should_stop && !did_anybody_stop_for_a_reason) {
should_stop = true;
- if (log)
- log->Printf("ThreadList::%s we stopped but no threads had a stop reason, "
- "overriding should_stop and stopping.",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "ThreadList::%s we stopped but no threads had a stop reason, "
+ "overriding should_stop and stopping.",
+ __FUNCTION__);
}
- if (log)
- log->Printf("ThreadList::%s overall should_stop = %i", __FUNCTION__,
- should_stop);
+ LLDB_LOGF(log, "ThreadList::%s overall should_stop = %i", __FUNCTION__,
+ should_stop);
if (should_stop) {
for (pos = threads_copy.begin(); pos != end; ++pos) {
@@ -363,9 +362,8 @@ Vote ThreadList::ShouldReportStop(Event *event_ptr) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("ThreadList::%s %" PRIu64 " threads", __FUNCTION__,
- (uint64_t)m_threads.size());
+ LLDB_LOGF(log, "ThreadList::%s %" PRIu64 " threads", __FUNCTION__,
+ (uint64_t)m_threads.size());
// Run through the threads and ask whether we should report this event. For
// stopping, a YES vote wins over everything. A NO vote wins over NO
@@ -430,10 +428,10 @@ Vote ThreadList::ShouldReportRun(Event *event_ptr) {
result = eVoteYes;
break;
case eVoteNo:
- if (log)
- log->Printf("ThreadList::ShouldReportRun() thread %d (0x%4.4" PRIx64
- ") says don't report.",
- (*pos)->GetIndexID(), (*pos)->GetID());
+ LLDB_LOGF(log,
+ "ThreadList::ShouldReportRun() thread %d (0x%4.4" PRIx64
+ ") says don't report.",
+ (*pos)->GetIndexID(), (*pos)->GetID());
result = eVoteNo;
break;
}
@@ -464,8 +462,9 @@ void ThreadList::RefreshStateAfterStop() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (log && log->GetVerbose())
- log->Printf("Turning off notification of new threads while single stepping "
- "a thread.");
+ LLDB_LOGF(log,
+ "Turning off notification of new threads while single stepping "
+ "a thread.");
collection::iterator pos, end = m_threads.end();
for (pos = m_threads.begin(); pos != end; ++pos)
@@ -517,14 +516,14 @@ bool ThreadList::WillResume() {
if (wants_solo_run) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (log && log->GetVerbose())
- log->Printf("Turning on notification of new threads while single "
- "stepping a thread.");
+ LLDB_LOGF(log, "Turning on notification of new threads while single "
+ "stepping a thread.");
m_process->StartNoticingNewThreads();
} else {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (log && log->GetVerbose())
- log->Printf("Turning off notification of new threads while single "
- "stepping a thread.");
+ LLDB_LOGF(log, "Turning off notification of new threads while single "
+ "stepping a thread.");
m_process->StopNoticingNewThreads();
}
diff --git a/source/Target/ThreadPlan.cpp b/source/Target/ThreadPlan.cpp
index 1d8cc18db4d6..ba56f8d15d8a 100644
--- a/source/Target/ThreadPlan.cpp
+++ b/source/Target/ThreadPlan.cpp
@@ -108,7 +108,8 @@ bool ThreadPlan::WillResume(StateType resume_state, bool current_plan) {
addr_t pc = reg_ctx->GetPC();
addr_t sp = reg_ctx->GetSP();
addr_t fp = reg_ctx->GetFP();
- log->Printf(
+ LLDB_LOGF(
+ log,
"%s Thread #%u (0x%p): tid = 0x%4.4" PRIx64 ", pc = 0x%8.8" PRIx64
", sp = 0x%8.8" PRIx64 ", fp = 0x%8.8" PRIx64 ", "
"plan = '%s', state = %s, stop others = %d",
diff --git a/source/Target/ThreadPlanBase.cpp b/source/Target/ThreadPlanBase.cpp
index 9cd4bcb455be..821643d4bce5 100644
--- a/source/Target/ThreadPlanBase.cpp
+++ b/source/Target/ThreadPlanBase.cpp
@@ -92,11 +92,11 @@ bool ThreadPlanBase::ShouldStop(Event *event_ptr) {
// If we are going to stop for a breakpoint, then unship the other
// plans at this point. Don't force the discard, however, so Master
// plans can stay in place if they want to.
- if (log)
- log->Printf(
- "Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
- " (breakpoint hit.)",
- m_thread.GetID());
+ LLDB_LOGF(
+ log,
+ "Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
+ " (breakpoint hit.)",
+ m_thread.GetID());
m_thread.DiscardThreadPlans(false);
return true;
}
@@ -122,11 +122,11 @@ bool ThreadPlanBase::ShouldStop(Event *event_ptr) {
// If we crashed, discard thread plans and stop. Don't force the
// discard, however, since on rerun the target may clean up this
// exception and continue normally from there.
- if (log)
- log->Printf(
- "Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
- " (exception: %s)",
- m_thread.GetID(), stop_info_sp->GetDescription());
+ LLDB_LOGF(
+ log,
+ "Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
+ " (exception: %s)",
+ m_thread.GetID(), stop_info_sp->GetDescription());
m_thread.DiscardThreadPlans(false);
return true;
@@ -134,22 +134,22 @@ bool ThreadPlanBase::ShouldStop(Event *event_ptr) {
// If we crashed, discard thread plans and stop. Don't force the
// discard, however, since on rerun the target may clean up this
// exception and continue normally from there.
- if (log)
- log->Printf(
- "Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
- " (exec.)",
- m_thread.GetID());
+ LLDB_LOGF(
+ log,
+ "Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
+ " (exec.)",
+ m_thread.GetID());
m_thread.DiscardThreadPlans(false);
return true;
case eStopReasonThreadExiting:
case eStopReasonSignal:
if (stop_info_sp->ShouldStop(event_ptr)) {
- if (log)
- log->Printf(
- "Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
- " (signal: %s)",
- m_thread.GetID(), stop_info_sp->GetDescription());
+ LLDB_LOGF(
+ log,
+ "Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
+ " (signal: %s)",
+ m_thread.GetID(), stop_info_sp->GetDescription());
m_thread.DiscardThreadPlans(false);
return true;
} else {
diff --git a/source/Target/ThreadPlanCallFunction.cpp b/source/Target/ThreadPlanCallFunction.cpp
index 68d771c37946..23d114e30990 100644
--- a/source/Target/ThreadPlanCallFunction.cpp
+++ b/source/Target/ThreadPlanCallFunction.cpp
@@ -59,46 +59,21 @@ bool ThreadPlanCallFunction::ConstructorSetup(
m_constructor_errors.Printf(
"Trying to put the stack in unreadable memory at: 0x%" PRIx64 ".",
m_function_sp);
- if (log)
- log->Printf("ThreadPlanCallFunction(%p): %s.", static_cast<void *>(this),
- m_constructor_errors.GetData());
+ LLDB_LOGF(log, "ThreadPlanCallFunction(%p): %s.", static_cast<void *>(this),
+ m_constructor_errors.GetData());
return false;
}
- Module *exe_module = GetTarget().GetExecutableModulePointer();
-
- if (exe_module == nullptr) {
+ llvm::Expected<Address> start_address = GetTarget().GetEntryPointAddress();
+ if (!start_address) {
m_constructor_errors.Printf(
- "Can't execute code without an executable module.");
- if (log)
- log->Printf("ThreadPlanCallFunction(%p): %s.", static_cast<void *>(this),
- m_constructor_errors.GetData());
+ "%s", llvm::toString(start_address.takeError()).c_str());
+ LLDB_LOGF(log, "ThreadPlanCallFunction(%p): %s.", static_cast<void *>(this),
+ m_constructor_errors.GetData());
return false;
- } else {
- ObjectFile *objectFile = exe_module->GetObjectFile();
- if (!objectFile) {
- m_constructor_errors.Printf(
- "Could not find object file for module \"%s\".",
- exe_module->GetFileSpec().GetFilename().AsCString());
-
- if (log)
- log->Printf("ThreadPlanCallFunction(%p): %s.",
- static_cast<void *>(this), m_constructor_errors.GetData());
- return false;
- }
-
- m_start_addr = objectFile->GetEntryPointAddress();
- if (!m_start_addr.IsValid()) {
- m_constructor_errors.Printf(
- "Could not find entry point address for executable module \"%s\".",
- exe_module->GetFileSpec().GetFilename().AsCString());
- if (log)
- log->Printf("ThreadPlanCallFunction(%p): %s.",
- static_cast<void *>(this), m_constructor_errors.GetData());
- return false;
- }
}
+ m_start_addr = *start_address;
start_load_addr = m_start_addr.GetLoadAddress(&GetTarget());
// Checkpoint the thread state so we can restore it later.
@@ -109,9 +84,8 @@ bool ThreadPlanCallFunction::ConstructorSetup(
if (!thread.CheckpointThreadState(m_stored_thread_state)) {
m_constructor_errors.Printf("Setting up ThreadPlanCallFunction, failed to "
"checkpoint thread state.");
- if (log)
- log->Printf("ThreadPlanCallFunction(%p): %s.", static_cast<void *>(this),
- m_constructor_errors.GetData());
+ LLDB_LOGF(log, "ThreadPlanCallFunction(%p): %s.", static_cast<void *>(this),
+ m_constructor_errors.GetData());
return false;
}
function_load_addr = m_function_addr.GetLoadAddress(&GetTarget());
@@ -196,10 +170,10 @@ void ThreadPlanCallFunction::DoTakedown(bool success) {
if (!m_valid) {
// Don't call DoTakedown if we were never valid to begin with.
- if (log)
- log->Printf("ThreadPlanCallFunction(%p): Log called on "
- "ThreadPlanCallFunction that was never valid.",
- static_cast<void *>(this));
+ LLDB_LOGF(log,
+ "ThreadPlanCallFunction(%p): Log called on "
+ "ThreadPlanCallFunction that was never valid.",
+ static_cast<void *>(this));
return;
}
@@ -207,20 +181,20 @@ void ThreadPlanCallFunction::DoTakedown(bool success) {
if (success) {
SetReturnValue();
}
- if (log)
- log->Printf("ThreadPlanCallFunction(%p): DoTakedown called for thread "
- "0x%4.4" PRIx64 ", m_valid: %d complete: %d.\n",
- static_cast<void *>(this), m_thread.GetID(), m_valid,
- IsPlanComplete());
+ LLDB_LOGF(log,
+ "ThreadPlanCallFunction(%p): DoTakedown called for thread "
+ "0x%4.4" PRIx64 ", m_valid: %d complete: %d.\n",
+ static_cast<void *>(this), m_thread.GetID(), m_valid,
+ IsPlanComplete());
m_takedown_done = true;
m_stop_address =
m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
m_real_stop_info_sp = GetPrivateStopInfo();
if (!m_thread.RestoreRegisterStateFromCheckpoint(m_stored_thread_state)) {
- if (log)
- log->Printf("ThreadPlanCallFunction(%p): DoTakedown failed to restore "
- "register state",
- static_cast<void *>(this));
+ LLDB_LOGF(log,
+ "ThreadPlanCallFunction(%p): DoTakedown failed to restore "
+ "register state",
+ static_cast<void *>(this));
}
SetPlanComplete(success);
ClearBreakpoints();
@@ -228,11 +202,11 @@ void ThreadPlanCallFunction::DoTakedown(bool success) {
ReportRegisterState("Restoring thread state after function call. "
"Restored register state:");
} else {
- if (log)
- log->Printf("ThreadPlanCallFunction(%p): DoTakedown called as no-op for "
- "thread 0x%4.4" PRIx64 ", m_valid: %d complete: %d.\n",
- static_cast<void *>(this), m_thread.GetID(), m_valid,
- IsPlanComplete());
+ LLDB_LOGF(log,
+ "ThreadPlanCallFunction(%p): DoTakedown called as no-op for "
+ "thread 0x%4.4" PRIx64 ", m_valid: %d complete: %d.\n",
+ static_cast<void *>(this), m_thread.GetID(), m_valid,
+ IsPlanComplete());
}
}
@@ -288,10 +262,9 @@ bool ThreadPlanCallFunction::DoPlanExplainsStop(Event *event_ptr) {
stop_reason = eStopReasonNone;
else
stop_reason = m_real_stop_info_sp->GetStopReason();
- if (log)
- log->Printf(
- "ThreadPlanCallFunction::PlanExplainsStop: Got stop reason - %s.",
- Thread::StopReasonAsCString(stop_reason));
+ LLDB_LOGF(log,
+ "ThreadPlanCallFunction::PlanExplainsStop: Got stop reason - %s.",
+ Thread::StopReasonAsCString(stop_reason));
if (stop_reason == eStopReasonBreakpoint && BreakpointsExplainStop())
return true;
@@ -300,9 +273,8 @@ bool ThreadPlanCallFunction::DoPlanExplainsStop(Event *event_ptr) {
// then we should not consider ourselves complete. Return true to
// acknowledge the stop.
if (Process::ProcessEventData::GetInterruptedFromEvent(event_ptr)) {
- if (log)
- log->Printf("ThreadPlanCallFunction::PlanExplainsStop: The event is an "
- "Interrupt, returning true.");
+ LLDB_LOGF(log, "ThreadPlanCallFunction::PlanExplainsStop: The event is an "
+ "Interrupt, returning true.");
return true;
}
// We control breakpoints separately from other "stop reasons." So first,
@@ -321,10 +293,10 @@ bool ThreadPlanCallFunction::DoPlanExplainsStop(Event *event_ptr) {
bool is_internal = true;
for (uint32_t i = 0; i < num_owners; i++) {
Breakpoint &bp = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
- if (log)
- log->Printf("ThreadPlanCallFunction::PlanExplainsStop: hit "
- "breakpoint %d while calling function",
- bp.GetID());
+ LLDB_LOGF(log,
+ "ThreadPlanCallFunction::PlanExplainsStop: hit "
+ "breakpoint %d while calling function",
+ bp.GetID());
if (!bp.IsInternal()) {
is_internal = false;
@@ -332,25 +304,23 @@ bool ThreadPlanCallFunction::DoPlanExplainsStop(Event *event_ptr) {
}
}
if (is_internal) {
- if (log)
- log->Printf("ThreadPlanCallFunction::PlanExplainsStop hit an "
- "internal breakpoint, not stopping.");
+ LLDB_LOGF(log, "ThreadPlanCallFunction::PlanExplainsStop hit an "
+ "internal breakpoint, not stopping.");
return false;
}
}
if (m_ignore_breakpoints) {
- if (log)
- log->Printf("ThreadPlanCallFunction::PlanExplainsStop: we are ignoring "
- "breakpoints, overriding breakpoint stop info ShouldStop, "
- "returning true");
+ LLDB_LOGF(log,
+ "ThreadPlanCallFunction::PlanExplainsStop: we are ignoring "
+ "breakpoints, overriding breakpoint stop info ShouldStop, "
+ "returning true");
m_real_stop_info_sp->OverrideShouldStop(false);
return true;
} else {
- if (log)
- log->Printf("ThreadPlanCallFunction::PlanExplainsStop: we are not "
- "ignoring breakpoints, overriding breakpoint stop info "
- "ShouldStop, returning true");
+ LLDB_LOGF(log, "ThreadPlanCallFunction::PlanExplainsStop: we are not "
+ "ignoring breakpoints, overriding breakpoint stop info "
+ "ShouldStop, returning true");
m_real_stop_info_sp->OverrideShouldStop(true);
return false;
}
@@ -418,9 +388,8 @@ bool ThreadPlanCallFunction::MischiefManaged() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (IsPlanComplete()) {
- if (log)
- log->Printf("ThreadPlanCallFunction(%p): Completed call function plan.",
- static_cast<void *>(this));
+ LLDB_LOGF(log, "ThreadPlanCallFunction(%p): Completed call function plan.",
+ static_cast<void *>(this));
ThreadPlan::MischiefManaged();
return true;
@@ -469,9 +438,8 @@ bool ThreadPlanCallFunction::BreakpointsExplainStop() {
m_objc_language_runtime->ExceptionBreakpointsExplainStop(
stop_info_sp))) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("ThreadPlanCallFunction::BreakpointsExplainStop - Hit an "
- "exception breakpoint, setting plan complete.");
+ LLDB_LOGF(log, "ThreadPlanCallFunction::BreakpointsExplainStop - Hit an "
+ "exception breakpoint, setting plan complete.");
SetPlanComplete(false);
diff --git a/source/Target/ThreadPlanCallUserExpression.cpp b/source/Target/ThreadPlanCallUserExpression.cpp
index 864808a4b5ea..436938c8f207 100644
--- a/source/Target/ThreadPlanCallUserExpression.cpp
+++ b/source/Target/ThreadPlanCallUserExpression.cpp
@@ -69,9 +69,8 @@ bool ThreadPlanCallUserExpression::MischiefManaged() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (IsPlanComplete()) {
- if (log)
- log->Printf("ThreadPlanCallFunction(%p): Completed call function plan.",
- static_cast<void *>(this));
+ LLDB_LOGF(log, "ThreadPlanCallFunction(%p): Completed call function plan.",
+ static_cast<void *>(this));
if (m_manage_materialization && PlanSucceeded() && m_user_expression_sp) {
lldb::addr_t function_stack_top;
diff --git a/source/Target/ThreadPlanPython.cpp b/source/Target/ThreadPlanPython.cpp
index 8b30c4ea7cb1..df432a0af3da 100644
--- a/source/Target/ThreadPlanPython.cpp
+++ b/source/Target/ThreadPlanPython.cpp
@@ -25,10 +25,11 @@ using namespace lldb_private;
// ThreadPlanPython
-ThreadPlanPython::ThreadPlanPython(Thread &thread, const char *class_name)
+ThreadPlanPython::ThreadPlanPython(Thread &thread, const char *class_name,
+ StructuredDataImpl *args_data)
: ThreadPlan(ThreadPlan::eKindPython, "Python based Thread Plan", thread,
eVoteNoOpinion, eVoteNoOpinion),
- m_class_name(class_name), m_did_push(false) {
+ m_class_name(class_name), m_args_data(args_data), m_did_push(false) {
SetIsMasterPlan(true);
SetOkayToDiscard(true);
SetPrivate(false);
@@ -45,7 +46,9 @@ bool ThreadPlanPython::ValidatePlan(Stream *error) {
if (!m_implementation_sp) {
if (error)
- error->Printf("Python thread plan does not have an implementation");
+ error->Printf("Error constructing Python ThreadPlan: %s",
+ m_error_str.empty() ? "<unknown error>"
+ : m_error_str.c_str());
return false;
}
@@ -63,16 +66,16 @@ void ThreadPlanPython::DidPush() {
.GetScriptInterpreter();
if (script_interp) {
m_implementation_sp = script_interp->CreateScriptedThreadPlan(
- m_class_name.c_str(), this->shared_from_this());
+ m_class_name.c_str(), m_args_data, m_error_str,
+ this->shared_from_this());
}
}
}
bool ThreadPlanPython::ShouldStop(Event *event_ptr) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
- if (log)
- log->Printf("%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
- m_class_name.c_str());
+ LLDB_LOGF(log, "%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
+ m_class_name.c_str());
bool should_stop = true;
if (m_implementation_sp) {
@@ -93,9 +96,8 @@ bool ThreadPlanPython::ShouldStop(Event *event_ptr) {
bool ThreadPlanPython::IsPlanStale() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
- if (log)
- log->Printf("%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
- m_class_name.c_str());
+ LLDB_LOGF(log, "%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
+ m_class_name.c_str());
bool is_stale = true;
if (m_implementation_sp) {
@@ -116,9 +118,8 @@ bool ThreadPlanPython::IsPlanStale() {
bool ThreadPlanPython::DoPlanExplainsStop(Event *event_ptr) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
- if (log)
- log->Printf("%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
- m_class_name.c_str());
+ LLDB_LOGF(log, "%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
+ m_class_name.c_str());
bool explains_stop = true;
if (m_implementation_sp) {
@@ -139,9 +140,8 @@ bool ThreadPlanPython::DoPlanExplainsStop(Event *event_ptr) {
bool ThreadPlanPython::MischiefManaged() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
- if (log)
- log->Printf("%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
- m_class_name.c_str());
+ LLDB_LOGF(log, "%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
+ m_class_name.c_str());
bool mischief_managed = true;
if (m_implementation_sp) {
// I don't really need mischief_managed, since it's simpler to just call
@@ -155,9 +155,8 @@ bool ThreadPlanPython::MischiefManaged() {
lldb::StateType ThreadPlanPython::GetPlanRunState() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
- if (log)
- log->Printf("%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
- m_class_name.c_str());
+ LLDB_LOGF(log, "%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
+ m_class_name.c_str());
lldb::StateType run_state = eStateRunning;
if (m_implementation_sp) {
ScriptInterpreter *script_interp = m_thread.GetProcess()
@@ -188,8 +187,7 @@ void ThreadPlanPython::GetDescription(Stream *s, lldb::DescriptionLevel level) {
bool ThreadPlanPython::WillStop() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
- if (log)
- log->Printf("%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
- m_class_name.c_str());
+ LLDB_LOGF(log, "%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
+ m_class_name.c_str());
return true;
}
diff --git a/source/Target/ThreadPlanRunToAddress.cpp b/source/Target/ThreadPlanRunToAddress.cpp
index a973bd112796..160743a9f3f8 100644
--- a/source/Target/ThreadPlanRunToAddress.cpp
+++ b/source/Target/ThreadPlanRunToAddress.cpp
@@ -182,8 +182,7 @@ bool ThreadPlanRunToAddress::MischiefManaged() {
m_break_ids[i] = LLDB_INVALID_BREAK_ID;
}
}
- if (log)
- log->Printf("Completed run to address plan.");
+ LLDB_LOGF(log, "Completed run to address plan.");
ThreadPlan::MischiefManaged();
return true;
} else
diff --git a/source/Target/ThreadPlanShouldStopHere.cpp b/source/Target/ThreadPlanShouldStopHere.cpp
index a0b7072a1071..9599d8197b07 100644
--- a/source/Target/ThreadPlanShouldStopHere.cpp
+++ b/source/Target/ThreadPlanShouldStopHere.cpp
@@ -46,8 +46,8 @@ bool ThreadPlanShouldStopHere::InvokeShouldStopHereCallback(
lldb::addr_t current_addr =
m_owner->GetThread().GetRegisterContext()->GetPC(0);
- log->Printf("ShouldStopHere callback returned %u from 0x%" PRIx64 ".",
- should_stop_here, current_addr);
+ LLDB_LOGF(log, "ShouldStopHere callback returned %u from 0x%" PRIx64 ".",
+ should_stop_here, current_addr);
}
}
@@ -69,8 +69,7 @@ bool ThreadPlanShouldStopHere::DefaultShouldStopHereCallback(
(operation == eFrameCompareSameParent &&
flags.Test(eStepInAvoidNoDebug))) {
if (!frame->HasDebugInformation()) {
- if (log)
- log->Printf("Stepping out of frame with no debug info");
+ LLDB_LOGF(log, "Stepping out of frame with no debug info");
should_stop_here = false;
}
@@ -118,16 +117,14 @@ ThreadPlanSP ThreadPlanShouldStopHere::DefaultStepFromHereCallback(
symbol_end.Slide(sc.symbol->GetByteSize() - 1);
if (range.ContainsFileAddress(sc.symbol->GetAddress()) &&
range.ContainsFileAddress(symbol_end)) {
- if (log)
- log->Printf("Stopped in a function with only line 0 lines, just "
- "stepping out.");
+ LLDB_LOGF(log, "Stopped in a function with only line 0 lines, just "
+ "stepping out.");
just_step_out = true;
}
}
if (!just_step_out) {
- if (log)
- log->Printf("ThreadPlanShouldStopHere::DefaultStepFromHereCallback "
- "Queueing StepInRange plan to step through line 0 code.");
+ LLDB_LOGF(log, "ThreadPlanShouldStopHere::DefaultStepFromHereCallback "
+ "Queueing StepInRange plan to step through line 0 code.");
return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepInRange(
false, range, sc, nullptr, eOnlyDuringStepping, status,
diff --git a/source/Target/ThreadPlanStepInRange.cpp b/source/Target/ThreadPlanStepInRange.cpp
index 2065fa55fa6a..71045cc7a990 100644
--- a/source/Target/ThreadPlanStepInRange.cpp
+++ b/source/Target/ThreadPlanStepInRange.cpp
@@ -148,7 +148,7 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
s.Address(
m_thread.GetRegisterContext()->GetPC(),
m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
- log->Printf("ThreadPlanStepInRange reached %s.", s.GetData());
+ LLDB_LOGF(log, "ThreadPlanStepInRange reached %s.", s.GetData());
}
if (IsPlanComplete())
@@ -197,13 +197,14 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
CheckShouldStopHereAndQueueStepOut(frame_order, m_status);
if (log) {
if (m_sub_plan_sp)
- log->Printf("ShouldStopHere found plan to step out of this frame.");
+ LLDB_LOGF(log,
+ "ShouldStopHere found plan to step out of this frame.");
else
- log->Printf("ShouldStopHere no plan to step out of this frame.");
+ LLDB_LOGF(log, "ShouldStopHere no plan to step out of this frame.");
}
} else if (log) {
- log->Printf(
- "Thought I stepped out, but in fact arrived at a trampoline.");
+ LLDB_LOGF(
+ log, "Thought I stepped out, but in fact arrived at a trampoline.");
}
} else if (frame_order == eFrameCompareEqual && InSymbol()) {
// If we are not in a place we should step through, we're done. One
@@ -237,9 +238,10 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
if (log) {
if (m_sub_plan_sp)
- log->Printf("Found a step through plan: %s", m_sub_plan_sp->GetName());
+ LLDB_LOGF(log, "Found a step through plan: %s",
+ m_sub_plan_sp->GetName());
else
- log->Printf("No step through plan found.");
+ LLDB_LOGF(log, "No step through plan found.");
}
// If not, give the "should_stop" callback a chance to push a plan to get
@@ -289,8 +291,7 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
if (bytes_to_skip != 0) {
func_start_address.Slide(bytes_to_skip);
log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP);
- if (log)
- log->Printf("Pushing past prologue ");
+ LLDB_LOGF(log, "Pushing past prologue ");
m_sub_plan_sp = m_thread.QueueThreadPlanForRunToAddress(
false, func_start_address, true, m_status);
@@ -312,10 +313,10 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
void ThreadPlanStepInRange::SetAvoidRegexp(const char *name) {
auto name_ref = llvm::StringRef::withNullAsEmpty(name);
- if (!m_avoid_regexp_up)
+ if (m_avoid_regexp_up)
+ *m_avoid_regexp_up = RegularExpression(name_ref);
+ else
m_avoid_regexp_up.reset(new RegularExpression(name_ref));
-
- m_avoid_regexp_up->Compile(name_ref);
}
void ThreadPlanStepInRange::SetDefaultFlagValue(uint32_t new_value) {
@@ -360,25 +361,17 @@ bool ThreadPlanStepInRange::FrameMatchesAvoidCriteria() {
sc.GetFunctionName(Mangled::ePreferDemangledWithoutArguments)
.GetCString();
if (frame_function_name) {
- size_t num_matches = 0;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (log)
- num_matches = 1;
-
- RegularExpression::Match regex_match(num_matches);
-
+ llvm::SmallVector<llvm::StringRef, 2> matches;
bool return_value =
- avoid_regexp_to_use->Execute(frame_function_name, &regex_match);
- if (return_value) {
- if (log) {
- std::string match;
- regex_match.GetMatchAtIndex(frame_function_name, 0, match);
- log->Printf("Stepping out of function \"%s\" because it matches "
- "the avoid regexp \"%s\" - match substring: \"%s\".",
- frame_function_name,
- avoid_regexp_to_use->GetText().str().c_str(),
- match.c_str());
- }
+ avoid_regexp_to_use->Execute(frame_function_name, &matches);
+ if (return_value && matches.size() > 1) {
+ std::string match = matches[1].str();
+ LLDB_LOGF(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP),
+ "Stepping out of function \"%s\" because it matches "
+ "the avoid regexp \"%s\" - match substring: \"%s\".",
+ frame_function_name,
+ avoid_regexp_to_use->GetText().str().c_str(),
+ match.c_str());
}
return return_value;
}
@@ -424,10 +417,11 @@ bool ThreadPlanStepInRange::DefaultShouldStopHereCallback(
should_stop_here = false;
}
if (log && !should_stop_here)
- log->Printf("Stepping out of frame %s which did not match step into "
- "target %s.",
- sc.GetFunctionName().AsCString(),
- step_in_range_plan->m_step_into_target.AsCString());
+ LLDB_LOGF(log,
+ "Stepping out of frame %s which did not match step into "
+ "target %s.",
+ sc.GetFunctionName().AsCString(),
+ step_in_range_plan->m_step_into_target.AsCString());
}
}
@@ -496,10 +490,10 @@ bool ThreadPlanStepInRange::DoWillResume(lldb::StateType resume_state,
bool step_without_resume = m_thread.DecrementCurrentInlinedDepth();
if (step_without_resume) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("ThreadPlanStepInRange::DoWillResume: returning false, "
- "inline_depth: %d",
- m_thread.GetCurrentInlinedDepth());
+ LLDB_LOGF(log,
+ "ThreadPlanStepInRange::DoWillResume: returning false, "
+ "inline_depth: %d",
+ m_thread.GetCurrentInlinedDepth());
SetStopInfo(StopInfo::CreateStopReasonToTrace(m_thread));
// FIXME: Maybe it would be better to create a InlineStep stop reason, but
diff --git a/source/Target/ThreadPlanStepInstruction.cpp b/source/Target/ThreadPlanStepInstruction.cpp
index a11b623c8acf..0c75cb811156 100644
--- a/source/Target/ThreadPlanStepInstruction.cpp
+++ b/source/Target/ThreadPlanStepInstruction.cpp
@@ -114,8 +114,9 @@ bool ThreadPlanStepInstruction::IsPlanStale() {
return !m_step_over;
} else {
if (log) {
- log->Printf("ThreadPlanStepInstruction::IsPlanStale - Current frame is "
- "older than start frame, plan is stale.");
+ LLDB_LOGF(log,
+ "ThreadPlanStepInstruction::IsPlanStale - Current frame is "
+ "older than start frame, plan is stale.");
}
return true;
}
@@ -127,9 +128,9 @@ bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) {
StackFrameSP cur_frame_sp = m_thread.GetStackFrameAtIndex(0);
if (!cur_frame_sp) {
- if (log)
- log->Printf(
- "ThreadPlanStepInstruction couldn't get the 0th frame, stopping.");
+ LLDB_LOGF(
+ log,
+ "ThreadPlanStepInstruction couldn't get the 0th frame, stopping.");
SetPlanComplete();
return true;
}
@@ -168,8 +169,9 @@ bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) {
cur_frame_sp->GetConcreteFrameIndex()) {
SetPlanComplete();
if (log) {
- log->Printf("Frame we stepped into is inlined into the frame "
- "we were stepping from, stopping.");
+ LLDB_LOGF(log,
+ "Frame we stepped into is inlined into the frame "
+ "we were stepping from, stopping.");
}
return true;
}
@@ -188,7 +190,7 @@ bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) {
s.Address(return_addr, m_thread.CalculateTarget()
->GetArchitecture()
.GetAddressByteSize());
- log->Printf("%s.", s.GetData());
+ LLDB_LOGF(log, "%s.", s.GetData());
}
// StepInstruction should probably have the tri-state RunMode, but
@@ -209,8 +211,7 @@ bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) {
return true;
}
} else {
- if (log)
- log->Printf("Could not find previous frame, stopping.");
+ LLDB_LOGF(log, "Could not find previous frame, stopping.");
SetPlanComplete();
return true;
}
@@ -243,8 +244,7 @@ bool ThreadPlanStepInstruction::WillStop() { return true; }
bool ThreadPlanStepInstruction::MischiefManaged() {
if (IsPlanComplete()) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("Completed single instruction step plan.");
+ LLDB_LOGF(log, "Completed single instruction step plan.");
ThreadPlan::MischiefManaged();
return true;
} else {
diff --git a/source/Target/ThreadPlanStepOut.cpp b/source/Target/ThreadPlanStepOut.cpp
index bf55c376513d..d7dae446b229 100644
--- a/source/Target/ThreadPlanStepOut.cpp
+++ b/source/Target/ThreadPlanStepOut.cpp
@@ -408,7 +408,7 @@ bool ThreadPlanStepOut::MischiefManaged() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (log)
- log->Printf("Completed step out plan.");
+ LLDB_LOGF(log, "Completed step out plan.");
if (m_return_bp_id != LLDB_INVALID_BREAK_ID) {
m_thread.CalculateTarget()->RemoveBreakpointByID(m_return_bp_id);
m_return_bp_id = LLDB_INVALID_BREAK_ID;
@@ -433,7 +433,7 @@ bool ThreadPlanStepOut::QueueInlinedStepPlan(bool queue_now) {
if (log) {
StreamString s;
immediate_return_from_sp->Dump(&s, true, false);
- log->Printf("Queuing inlined frame to step past: %s.", s.GetData());
+ LLDB_LOGF(log, "Queuing inlined frame to step past: %s.", s.GetData());
}
Block *from_block = immediate_return_from_sp->GetFrameBlock();
diff --git a/source/Target/ThreadPlanStepOverBreakpoint.cpp b/source/Target/ThreadPlanStepOverBreakpoint.cpp
index 4770b57ab7f2..725669b1e9a8 100644
--- a/source/Target/ThreadPlanStepOverBreakpoint.cpp
+++ b/source/Target/ThreadPlanStepOverBreakpoint.cpp
@@ -62,11 +62,9 @@ bool ThreadPlanStepOverBreakpoint::DoPlanExplainsStop(Event *event_ptr) {
StopReason reason = stop_info_sp->GetStopReason();
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+ LLDB_LOGF(log, "Step over breakpoint stopped for reason: %s.",
+ Thread::StopReasonAsCString(reason));
- if (log)
- log->Printf("Step over breakpoint stopped for reason: %s.",
- Thread::StopReasonAsCString(reason));
-
switch (reason) {
case eStopReasonTrace:
case eStopReasonNone:
@@ -91,9 +89,10 @@ bool ThreadPlanStepOverBreakpoint::DoPlanExplainsStop(Event *event_ptr) {
lldb::addr_t pc_addr = m_thread.GetRegisterContext()->GetPC();
if (pc_addr == m_breakpoint_addr) {
- if (log)
- log->Printf("Got breakpoint stop reason but pc: 0x%" PRIx64
- "hasn't changed.", pc_addr);
+ LLDB_LOGF(log,
+ "Got breakpoint stop reason but pc: 0x%" PRIx64
+ "hasn't changed.",
+ pc_addr);
return true;
}
@@ -149,8 +148,7 @@ bool ThreadPlanStepOverBreakpoint::MischiefManaged() {
return false;
} else {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("Completed step over breakpoint plan.");
+ LLDB_LOGF(log, "Completed step over breakpoint plan.");
// Otherwise, re-enable the breakpoint we were stepping over, and we're
// done.
ReenableBreakpointSite();
diff --git a/source/Target/ThreadPlanStepOverRange.cpp b/source/Target/ThreadPlanStepOverRange.cpp
index 3aaeac9f5b21..2de678597c8a 100644
--- a/source/Target/ThreadPlanStepOverRange.cpp
+++ b/source/Target/ThreadPlanStepOverRange.cpp
@@ -131,7 +131,7 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
s.Address(
m_thread.GetRegisterContext()->GetPC(),
m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
- log->Printf("ThreadPlanStepOverRange reached %s.", s.GetData());
+ LLDB_LOGF(log, "ThreadPlanStepOverRange reached %s.", s.GetData());
}
// If we're out of the range but in the same frame or in our caller's frame
@@ -155,8 +155,8 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
stop_others, m_status);
if (new_plan_sp && log)
- log->Printf(
- "Thought I stepped out, but in fact arrived at a trampoline.");
+ LLDB_LOGF(log,
+ "Thought I stepped out, but in fact arrived at a trampoline.");
} else if (frame_order == eFrameCompareYounger) {
// Make sure we really are in a new frame. Do that by unwinding and seeing
// if the start function really is our start function...
@@ -371,10 +371,10 @@ bool ThreadPlanStepOverRange::DoWillResume(lldb::StateType resume_state,
bool in_inlined_stack = m_thread.DecrementCurrentInlinedDepth();
if (in_inlined_stack) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("ThreadPlanStepInRange::DoWillResume: adjusting range to "
- "the frame at inlined depth %d.",
- m_thread.GetCurrentInlinedDepth());
+ LLDB_LOGF(log,
+ "ThreadPlanStepInRange::DoWillResume: adjusting range to "
+ "the frame at inlined depth %d.",
+ m_thread.GetCurrentInlinedDepth());
StackFrameSP stack_sp = m_thread.GetStackFrameAtIndex(0);
if (stack_sp) {
Block *frame_block = stack_sp->GetFrameBlock();
diff --git a/source/Target/ThreadPlanStepRange.cpp b/source/Target/ThreadPlanStepRange.cpp
index 49c72dbf0911..27513a34eadb 100644
--- a/source/Target/ThreadPlanStepRange.cpp
+++ b/source/Target/ThreadPlanStepRange.cpp
@@ -68,9 +68,8 @@ Vote ThreadPlanStepRange::ShouldReportStop(Event *event_ptr) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
const Vote vote = IsPlanComplete() ? eVoteYes : eVoteNo;
- if (log)
- log->Printf("ThreadPlanStepRange::ShouldReportStop() returning vote %i\n",
- vote);
+ LLDB_LOGF(log, "ThreadPlanStepRange::ShouldReportStop() returning vote %i\n",
+ vote);
return vote;
}
@@ -137,7 +136,8 @@ bool ThreadPlanStepRange::InRange() {
true, Address::DumpStyleLoadAddress,
Address::DumpStyleLoadAddress, true);
- log->Printf(
+ LLDB_LOGF(
+ log,
"Step range plan stepped to another range of same line: %s",
s.GetData());
}
@@ -155,9 +155,10 @@ bool ThreadPlanStepRange::InRange() {
true, Address::DumpStyleLoadAddress,
Address::DumpStyleLoadAddress, true);
- log->Printf("Step range plan stepped to a range at linenumber 0 "
- "stepping through that range: %s",
- s.GetData());
+ LLDB_LOGF(log,
+ "Step range plan stepped to a range at linenumber 0 "
+ "stepping through that range: %s",
+ s.GetData());
}
} else if (new_context.line_entry.range.GetBaseAddress().GetLoadAddress(
m_thread.CalculateTarget().get()) != pc_load_addr) {
@@ -177,9 +178,10 @@ bool ThreadPlanStepRange::InRange() {
true, Address::DumpStyleLoadAddress,
Address::DumpStyleLoadAddress, true);
- log->Printf("Step range plan stepped to the middle of new "
- "line(%d): %s, continuing to clear this line.",
- new_context.line_entry.line, s.GetData());
+ LLDB_LOGF(log,
+ "Step range plan stepped to the middle of new "
+ "line(%d): %s, continuing to clear this line.",
+ new_context.line_entry.line, s.GetData());
}
}
}
@@ -187,7 +189,7 @@ bool ThreadPlanStepRange::InRange() {
}
if (!ret_value && log)
- log->Printf("Step range plan out of range to 0x%" PRIx64, pc_load_addr);
+ LLDB_LOGF(log, "Step range plan out of range to 0x%" PRIx64, pc_load_addr);
return ret_value;
}
@@ -285,9 +287,8 @@ InstructionList *ThreadPlanStepRange::GetInstructionsForAddress(
void ThreadPlanStepRange::ClearNextBranchBreakpoint() {
if (m_next_branch_bp_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("Removing next branch breakpoint: %d.",
- m_next_branch_bp_sp->GetID());
+ LLDB_LOGF(log, "Removing next branch breakpoint: %d.",
+ m_next_branch_bp_sp->GetID());
GetTarget().RemoveBreakpointByID(m_next_branch_bp_sp->GetID());
m_next_branch_bp_sp.reset();
m_could_not_resolve_hw_bp = false;
@@ -357,11 +358,12 @@ bool ThreadPlanStepRange::SetNextBranchBreakpoint() {
bp_site_id = bp_site->GetID();
}
}
- log->Printf("ThreadPlanStepRange::SetNextBranchBreakpoint - Setting "
- "breakpoint %d (site %d) to run to address 0x%" PRIx64,
- m_next_branch_bp_sp->GetID(), bp_site_id,
- run_to_address.GetLoadAddress(
- &m_thread.GetProcess()->GetTarget()));
+ LLDB_LOGF(log,
+ "ThreadPlanStepRange::SetNextBranchBreakpoint - Setting "
+ "breakpoint %d (site %d) to run to address 0x%" PRIx64,
+ m_next_branch_bp_sp->GetID(), bp_site_id,
+ run_to_address.GetLoadAddress(
+ &m_thread.GetProcess()->GetTarget()));
}
m_next_branch_bp_sp->SetThreadID(m_thread.GetID());
@@ -402,11 +404,11 @@ bool ThreadPlanStepRange::NextRangeBreakpointExplainsStop(
break;
}
}
- if (log)
- log->Printf("ThreadPlanStepRange::NextRangeBreakpointExplainsStop - Hit "
- "next range breakpoint which has %" PRIu64
- " owners - explains stop: %u.",
- (uint64_t)num_owners, explains_stop);
+ LLDB_LOGF(log,
+ "ThreadPlanStepRange::NextRangeBreakpointExplainsStop - Hit "
+ "next range breakpoint which has %" PRIu64
+ " owners - explains stop: %u.",
+ (uint64_t)num_owners, explains_stop);
ClearNextBranchBreakpoint();
return explains_stop;
}
@@ -445,8 +447,7 @@ bool ThreadPlanStepRange::MischiefManaged() {
if (done) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("Completed step through range plan.");
+ LLDB_LOGF(log, "Completed step through range plan.");
ClearNextBranchBreakpoint();
ThreadPlan::MischiefManaged();
return true;
@@ -461,8 +462,8 @@ bool ThreadPlanStepRange::IsPlanStale() {
if (frame_order == eFrameCompareOlder) {
if (log) {
- log->Printf("ThreadPlanStepRange::IsPlanStale returning true, we've "
- "stepped out.");
+ LLDB_LOGF(log, "ThreadPlanStepRange::IsPlanStale returning true, we've "
+ "stepped out.");
}
return true;
} else if (frame_order == eFrameCompareEqual && InSymbol()) {
diff --git a/source/Target/ThreadPlanStepThrough.cpp b/source/Target/ThreadPlanStepThrough.cpp
index e46eba00184e..92b7fce1bc90 100644
--- a/source/Target/ThreadPlanStepThrough.cpp
+++ b/source/Target/ThreadPlanStepThrough.cpp
@@ -64,8 +64,8 @@ ThreadPlanStepThrough::ThreadPlanStepThrough(Thread &thread,
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (log) {
- log->Printf("Setting backstop breakpoint %d at address: 0x%" PRIx64,
- m_backstop_bkpt_id, m_backstop_addr);
+ LLDB_LOGF(log, "Setting backstop breakpoint %d at address: 0x%" PRIx64,
+ m_backstop_bkpt_id, m_backstop_addr);
}
}
}
@@ -103,11 +103,12 @@ void ThreadPlanStepThrough::LookForPlanToStepThroughFromCurrentPC() {
if (m_sub_plan_sp) {
StreamString s;
m_sub_plan_sp->GetDescription(&s, lldb::eDescriptionLevelFull);
- log->Printf("Found step through plan from 0x%" PRIx64 ": %s",
- current_address, s.GetData());
+ LLDB_LOGF(log, "Found step through plan from 0x%" PRIx64 ": %s",
+ current_address, s.GetData());
} else {
- log->Printf("Couldn't find step through plan from address 0x%" PRIx64 ".",
- current_address);
+ LLDB_LOGF(log,
+ "Couldn't find step through plan from address 0x%" PRIx64 ".",
+ current_address);
}
}
}
@@ -234,8 +235,7 @@ bool ThreadPlanStepThrough::MischiefManaged() {
if (!IsPlanComplete()) {
return false;
} else {
- if (log)
- log->Printf("Completed step through step plan.");
+ LLDB_LOGF(log, "Completed step through step plan.");
ClearBackstopBreakpoint();
ThreadPlan::MischiefManaged();
diff --git a/source/Target/ThreadPlanStepUntil.cpp b/source/Target/ThreadPlanStepUntil.cpp
index d4109c3d38da..54d276337488 100644
--- a/source/Target/ThreadPlanStepUntil.cpp
+++ b/source/Target/ThreadPlanStepUntil.cpp
@@ -326,8 +326,7 @@ bool ThreadPlanStepUntil::MischiefManaged() {
bool done = false;
if (IsPlanComplete()) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("Completed step until plan.");
+ LLDB_LOGF(log, "Completed step until plan.");
Clear();
done = true;
diff --git a/source/Target/ThreadPlanTracer.cpp b/source/Target/ThreadPlanTracer.cpp
index 4e79b6b1e59d..5782fe8e6443 100644
--- a/source/Target/ThreadPlanTracer.cpp
+++ b/source/Target/ThreadPlanTracer.cpp
@@ -46,7 +46,7 @@ Stream *ThreadPlanTracer::GetLogStream() {
else {
TargetSP target_sp(m_thread.CalculateTarget());
if (target_sp)
- return target_sp->GetDebugger().GetOutputFile().get();
+ return &(target_sp->GetDebugger().GetOutputStream());
}
return nullptr;
}
@@ -93,15 +93,20 @@ Disassembler *ThreadPlanAssemblyTracer::GetDisassembler() {
TypeFromUser ThreadPlanAssemblyTracer::GetIntPointerType() {
if (!m_intptr_type.IsValid()) {
- TargetSP target_sp(m_thread.CalculateTarget());
- if (target_sp) {
- TypeSystem *type_system =
- target_sp->GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC);
- if (type_system)
- m_intptr_type =
- TypeFromUser(type_system->GetBuiltinTypeForEncodingAndBitSize(
+ if (auto target_sp = m_thread.CalculateTarget()) {
+ auto type_system_or_err =
+ target_sp->GetScratchTypeSystemForLanguage(eLanguageTypeC);
+ if (auto err = type_system_or_err.takeError()) {
+ LLDB_LOG_ERROR(
+ lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TYPES),
+ std::move(err),
+ "Unable to get integer pointer type from TypeSystem");
+ } else {
+ m_intptr_type = TypeFromUser(
+ type_system_or_err->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint,
target_sp->GetArchitecture().GetAddressByteSize() * 8));
+ }
}
}
return m_intptr_type;