[Lldb-commits] [lldb] r280751 - *** This commit represents a complete reformatting of the LLDB source code
Kate Stone via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 6 13:58:36 PDT 2016
Modified: lldb/trunk/source/API/SBPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBPlatform.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBPlatform.cpp (original)
+++ lldb/trunk/source/API/SBPlatform.cpp Tue Sep 6 15:57:50 2016
@@ -16,8 +16,8 @@
#include "lldb/Core/Error.h"
#include "lldb/Host/File.h"
#include "lldb/Interpreter/Args.h"
-#include "lldb/Target/Target.h"
#include "lldb/Target/Platform.h"
+#include "lldb/Target/Target.h"
#include <functional>
@@ -28,622 +28,454 @@ using namespace lldb_private;
// PlatformConnectOptions
//----------------------------------------------------------------------
struct PlatformConnectOptions {
- PlatformConnectOptions(const char *url = NULL) :
- m_url(),
- m_rsync_options(),
- m_rsync_remote_path_prefix(),
- m_rsync_enabled(false),
- m_rsync_omit_hostname_from_remote_path(false),
- m_local_cache_directory ()
- {
- if (url && url[0])
- m_url = url;
- }
-
- ~PlatformConnectOptions()
- {
- }
+ PlatformConnectOptions(const char *url = NULL)
+ : m_url(), m_rsync_options(), m_rsync_remote_path_prefix(),
+ m_rsync_enabled(false), m_rsync_omit_hostname_from_remote_path(false),
+ m_local_cache_directory() {
+ if (url && url[0])
+ m_url = url;
+ }
+
+ ~PlatformConnectOptions() {}
- std::string m_url;
- std::string m_rsync_options;
- std::string m_rsync_remote_path_prefix;
- bool m_rsync_enabled;
- bool m_rsync_omit_hostname_from_remote_path;
- ConstString m_local_cache_directory;
+ std::string m_url;
+ std::string m_rsync_options;
+ std::string m_rsync_remote_path_prefix;
+ bool m_rsync_enabled;
+ bool m_rsync_omit_hostname_from_remote_path;
+ ConstString m_local_cache_directory;
};
//----------------------------------------------------------------------
// PlatformShellCommand
//----------------------------------------------------------------------
struct PlatformShellCommand {
- PlatformShellCommand(const char *shell_command = NULL) :
- m_command(),
- m_working_dir(),
- m_status(0),
- m_signo(0),
- m_timeout_sec(UINT32_MAX)
- {
- if (shell_command && shell_command[0])
- m_command = shell_command;
- }
-
- ~PlatformShellCommand()
- {
- }
-
- std::string m_command;
- std::string m_working_dir;
- std::string m_output;
- int m_status;
- int m_signo;
- uint32_t m_timeout_sec;
+ PlatformShellCommand(const char *shell_command = NULL)
+ : m_command(), m_working_dir(), m_status(0), m_signo(0),
+ m_timeout_sec(UINT32_MAX) {
+ if (shell_command && shell_command[0])
+ m_command = shell_command;
+ }
+
+ ~PlatformShellCommand() {}
+
+ std::string m_command;
+ std::string m_working_dir;
+ std::string m_output;
+ int m_status;
+ int m_signo;
+ uint32_t m_timeout_sec;
};
//----------------------------------------------------------------------
// SBPlatformConnectOptions
//----------------------------------------------------------------------
-SBPlatformConnectOptions::SBPlatformConnectOptions (const char *url) :
- m_opaque_ptr(new PlatformConnectOptions(url))
-{
-
-}
-
-SBPlatformConnectOptions::SBPlatformConnectOptions(const SBPlatformConnectOptions &rhs) :
- m_opaque_ptr(new PlatformConnectOptions())
-{
- *m_opaque_ptr = *rhs.m_opaque_ptr;
-}
-
-SBPlatformConnectOptions::~SBPlatformConnectOptions ()
-{
- delete m_opaque_ptr;
-}
-
-void
-SBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs)
-{
- *m_opaque_ptr = *rhs.m_opaque_ptr;
-}
-
-const char *
-SBPlatformConnectOptions::GetURL()
-{
- if (m_opaque_ptr->m_url.empty())
- return NULL;
- return m_opaque_ptr->m_url.c_str();
-}
-
-void
-SBPlatformConnectOptions::SetURL(const char *url)
-{
- if (url && url[0])
- m_opaque_ptr->m_url = url;
- else
- m_opaque_ptr->m_url.clear();
-}
+SBPlatformConnectOptions::SBPlatformConnectOptions(const char *url)
+ : m_opaque_ptr(new PlatformConnectOptions(url)) {}
-bool
-SBPlatformConnectOptions::GetRsyncEnabled()
-{
- return m_opaque_ptr->m_rsync_enabled;
-}
-
-void
-SBPlatformConnectOptions::EnableRsync (const char *options,
- const char *remote_path_prefix,
- bool omit_hostname_from_remote_path)
-{
- m_opaque_ptr->m_rsync_enabled = true;
- m_opaque_ptr->m_rsync_omit_hostname_from_remote_path = omit_hostname_from_remote_path;
- if (remote_path_prefix && remote_path_prefix[0])
- m_opaque_ptr->m_rsync_remote_path_prefix = remote_path_prefix;
- else
- m_opaque_ptr->m_rsync_remote_path_prefix.clear();
+SBPlatformConnectOptions::SBPlatformConnectOptions(
+ const SBPlatformConnectOptions &rhs)
+ : m_opaque_ptr(new PlatformConnectOptions()) {
+ *m_opaque_ptr = *rhs.m_opaque_ptr;
+}
- if (options && options[0])
- m_opaque_ptr->m_rsync_options = options;
- else
- m_opaque_ptr->m_rsync_options.clear();
+SBPlatformConnectOptions::~SBPlatformConnectOptions() { delete m_opaque_ptr; }
+void SBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs) {
+ *m_opaque_ptr = *rhs.m_opaque_ptr;
}
-void
-SBPlatformConnectOptions::DisableRsync ()
-{
- m_opaque_ptr->m_rsync_enabled = false;
-}
-
-const char *
-SBPlatformConnectOptions::GetLocalCacheDirectory()
-{
- return m_opaque_ptr->m_local_cache_directory.GetCString();
-}
-
-void
-SBPlatformConnectOptions::SetLocalCacheDirectory(const char *path)
-{
- if (path && path[0])
- m_opaque_ptr->m_local_cache_directory.SetCString(path);
- else
- m_opaque_ptr->m_local_cache_directory = ConstString();
+const char *SBPlatformConnectOptions::GetURL() {
+ if (m_opaque_ptr->m_url.empty())
+ return NULL;
+ return m_opaque_ptr->m_url.c_str();
}
-//----------------------------------------------------------------------
-// SBPlatformShellCommand
-//----------------------------------------------------------------------
-SBPlatformShellCommand::SBPlatformShellCommand (const char *shell_command) :
- m_opaque_ptr(new PlatformShellCommand(shell_command))
-{
+void SBPlatformConnectOptions::SetURL(const char *url) {
+ if (url && url[0])
+ m_opaque_ptr->m_url = url;
+ else
+ m_opaque_ptr->m_url.clear();
}
-SBPlatformShellCommand::SBPlatformShellCommand (const SBPlatformShellCommand &rhs) :
- m_opaque_ptr(new PlatformShellCommand())
-{
- *m_opaque_ptr = *rhs.m_opaque_ptr;
+bool SBPlatformConnectOptions::GetRsyncEnabled() {
+ return m_opaque_ptr->m_rsync_enabled;
}
-SBPlatformShellCommand::~SBPlatformShellCommand()
-{
- delete m_opaque_ptr;
-}
+void SBPlatformConnectOptions::EnableRsync(
+ const char *options, const char *remote_path_prefix,
+ bool omit_hostname_from_remote_path) {
+ m_opaque_ptr->m_rsync_enabled = true;
+ m_opaque_ptr->m_rsync_omit_hostname_from_remote_path =
+ omit_hostname_from_remote_path;
+ if (remote_path_prefix && remote_path_prefix[0])
+ m_opaque_ptr->m_rsync_remote_path_prefix = remote_path_prefix;
+ else
+ m_opaque_ptr->m_rsync_remote_path_prefix.clear();
-void
-SBPlatformShellCommand::Clear()
-{
- m_opaque_ptr->m_output = std::string();
- m_opaque_ptr->m_status = 0;
- m_opaque_ptr->m_signo = 0;
+ if (options && options[0])
+ m_opaque_ptr->m_rsync_options = options;
+ else
+ m_opaque_ptr->m_rsync_options.clear();
}
-const char *
-SBPlatformShellCommand::GetCommand()
-{
- if (m_opaque_ptr->m_command.empty())
- return NULL;
- return m_opaque_ptr->m_command.c_str();
+void SBPlatformConnectOptions::DisableRsync() {
+ m_opaque_ptr->m_rsync_enabled = false;
}
-void
-SBPlatformShellCommand::SetCommand(const char *shell_command)
-{
- if (shell_command && shell_command[0])
- m_opaque_ptr->m_command = shell_command;
- else
- m_opaque_ptr->m_command.clear();
+const char *SBPlatformConnectOptions::GetLocalCacheDirectory() {
+ return m_opaque_ptr->m_local_cache_directory.GetCString();
}
-const char *
-SBPlatformShellCommand::GetWorkingDirectory ()
-{
- if (m_opaque_ptr->m_working_dir.empty())
- return NULL;
- return m_opaque_ptr->m_working_dir.c_str();
-}
-
-void
-SBPlatformShellCommand::SetWorkingDirectory (const char *path)
-{
- if (path && path[0])
- m_opaque_ptr->m_working_dir = path;
- else
- m_opaque_ptr->m_working_dir.clear();
+void SBPlatformConnectOptions::SetLocalCacheDirectory(const char *path) {
+ if (path && path[0])
+ m_opaque_ptr->m_local_cache_directory.SetCString(path);
+ else
+ m_opaque_ptr->m_local_cache_directory = ConstString();
}
-uint32_t
-SBPlatformShellCommand::GetTimeoutSeconds ()
-{
- return m_opaque_ptr->m_timeout_sec;
-}
+//----------------------------------------------------------------------
+// SBPlatformShellCommand
+//----------------------------------------------------------------------
+SBPlatformShellCommand::SBPlatformShellCommand(const char *shell_command)
+ : m_opaque_ptr(new PlatformShellCommand(shell_command)) {}
-void
-SBPlatformShellCommand::SetTimeoutSeconds (uint32_t sec)
-{
- m_opaque_ptr->m_timeout_sec = sec;
+SBPlatformShellCommand::SBPlatformShellCommand(
+ const SBPlatformShellCommand &rhs)
+ : m_opaque_ptr(new PlatformShellCommand()) {
+ *m_opaque_ptr = *rhs.m_opaque_ptr;
}
-int
-SBPlatformShellCommand::GetSignal ()
-{
- return m_opaque_ptr->m_signo;
-}
+SBPlatformShellCommand::~SBPlatformShellCommand() { delete m_opaque_ptr; }
-int
-SBPlatformShellCommand::GetStatus ()
-{
- return m_opaque_ptr->m_status;
+void SBPlatformShellCommand::Clear() {
+ m_opaque_ptr->m_output = std::string();
+ m_opaque_ptr->m_status = 0;
+ m_opaque_ptr->m_signo = 0;
}
-const char *
-SBPlatformShellCommand::GetOutput ()
-{
- if (m_opaque_ptr->m_output.empty())
- return NULL;
- return m_opaque_ptr->m_output.c_str();
+const char *SBPlatformShellCommand::GetCommand() {
+ if (m_opaque_ptr->m_command.empty())
+ return NULL;
+ return m_opaque_ptr->m_command.c_str();
}
-//----------------------------------------------------------------------
-// SBPlatform
-//----------------------------------------------------------------------
-SBPlatform::SBPlatform () :
- m_opaque_sp ()
-{
-
+void SBPlatformShellCommand::SetCommand(const char *shell_command) {
+ if (shell_command && shell_command[0])
+ m_opaque_ptr->m_command = shell_command;
+ else
+ m_opaque_ptr->m_command.clear();
}
-SBPlatform::SBPlatform (const char *platform_name) :
- m_opaque_sp ()
-{
- Error error;
- if (platform_name && platform_name[0])
- m_opaque_sp = Platform::Create (ConstString(platform_name), error);
+const char *SBPlatformShellCommand::GetWorkingDirectory() {
+ if (m_opaque_ptr->m_working_dir.empty())
+ return NULL;
+ return m_opaque_ptr->m_working_dir.c_str();
}
-SBPlatform::~SBPlatform()
-{
+void SBPlatformShellCommand::SetWorkingDirectory(const char *path) {
+ if (path && path[0])
+ m_opaque_ptr->m_working_dir = path;
+ else
+ m_opaque_ptr->m_working_dir.clear();
}
-bool
-SBPlatform::IsValid () const
-{
- return m_opaque_sp.get() != NULL;
+uint32_t SBPlatformShellCommand::GetTimeoutSeconds() {
+ return m_opaque_ptr->m_timeout_sec;
}
-void
-SBPlatform::Clear ()
-{
- m_opaque_sp.reset();
+void SBPlatformShellCommand::SetTimeoutSeconds(uint32_t sec) {
+ m_opaque_ptr->m_timeout_sec = sec;
}
-const char *
-SBPlatform::GetName ()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- return platform_sp->GetName().GetCString();
- return NULL;
-}
+int SBPlatformShellCommand::GetSignal() { return m_opaque_ptr->m_signo; }
+
+int SBPlatformShellCommand::GetStatus() { return m_opaque_ptr->m_status; }
-lldb::PlatformSP
-SBPlatform::GetSP () const
-{
- return m_opaque_sp;
-}
-
-void
-SBPlatform::SetSP (const lldb::PlatformSP& platform_sp)
-{
- m_opaque_sp = platform_sp;
-}
-
-const char *
-SBPlatform::GetWorkingDirectory()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- return platform_sp->GetWorkingDirectory().GetCString();
+const char *SBPlatformShellCommand::GetOutput() {
+ if (m_opaque_ptr->m_output.empty())
return NULL;
+ return m_opaque_ptr->m_output.c_str();
}
-bool
-SBPlatform::SetWorkingDirectory(const char *path)
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- if (path)
- platform_sp->SetWorkingDirectory(FileSpec{path, false});
- else
- platform_sp->SetWorkingDirectory(FileSpec{});
- return true;
- }
- return false;
+//----------------------------------------------------------------------
+// SBPlatform
+//----------------------------------------------------------------------
+SBPlatform::SBPlatform() : m_opaque_sp() {}
+
+SBPlatform::SBPlatform(const char *platform_name) : m_opaque_sp() {
+ Error error;
+ if (platform_name && platform_name[0])
+ m_opaque_sp = Platform::Create(ConstString(platform_name), error);
}
-SBError
-SBPlatform::ConnectRemote (SBPlatformConnectOptions &connect_options)
-{
- SBError sb_error;
- PlatformSP platform_sp(GetSP());
- if (platform_sp && connect_options.GetURL())
- {
- Args args;
- args.AppendArgument(connect_options.GetURL());
- sb_error.ref() = platform_sp->ConnectRemote(args);
- }
- else
- {
- sb_error.SetErrorString("invalid platform");
- }
- return sb_error;
+SBPlatform::~SBPlatform() {}
+
+bool SBPlatform::IsValid() const { return m_opaque_sp.get() != NULL; }
+
+void SBPlatform::Clear() { m_opaque_sp.reset(); }
+
+const char *SBPlatform::GetName() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp)
+ return platform_sp->GetName().GetCString();
+ return NULL;
}
-void
-SBPlatform::DisconnectRemote ()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- platform_sp->DisconnectRemote();
-}
-
-bool
-SBPlatform::IsConnected()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- platform_sp->IsConnected();
- return false;
-}
-
-const char *
-SBPlatform::GetTriple()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- ArchSpec arch(platform_sp->GetSystemArchitecture());
- if (arch.IsValid())
- {
- // Const-ify the string so we don't need to worry about the lifetime of the string
- return ConstString(arch.GetTriple().getTriple().c_str()).GetCString();
- }
- }
- return NULL;
+lldb::PlatformSP SBPlatform::GetSP() const { return m_opaque_sp; }
+
+void SBPlatform::SetSP(const lldb::PlatformSP &platform_sp) {
+ m_opaque_sp = platform_sp;
}
-const char *
-SBPlatform::GetOSBuild()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- std::string s;
- if (platform_sp->GetOSBuildString(s))
- {
- if (!s.empty())
- {
- // Const-ify the string so we don't need to worry about the lifetime of the string
- return ConstString(s.c_str()).GetCString();
- }
- }
- }
- return NULL;
+const char *SBPlatform::GetWorkingDirectory() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp)
+ return platform_sp->GetWorkingDirectory().GetCString();
+ return NULL;
}
-const char *
-SBPlatform::GetOSDescription()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- std::string s;
- if (platform_sp->GetOSKernelDescription(s))
- {
- if (!s.empty())
- {
- // Const-ify the string so we don't need to worry about the lifetime of the string
- return ConstString(s.c_str()).GetCString();
- }
- }
- }
- return NULL;
+bool SBPlatform::SetWorkingDirectory(const char *path) {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ if (path)
+ platform_sp->SetWorkingDirectory(FileSpec{path, false});
+ else
+ platform_sp->SetWorkingDirectory(FileSpec{});
+ return true;
+ }
+ return false;
}
-const char *
-SBPlatform::GetHostname ()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- return platform_sp->GetHostname();
- return NULL;
+SBError SBPlatform::ConnectRemote(SBPlatformConnectOptions &connect_options) {
+ SBError sb_error;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp && connect_options.GetURL()) {
+ Args args;
+ args.AppendArgument(connect_options.GetURL());
+ sb_error.ref() = platform_sp->ConnectRemote(args);
+ } else {
+ sb_error.SetErrorString("invalid platform");
+ }
+ return sb_error;
}
-uint32_t
-SBPlatform::GetOSMajorVersion ()
-{
- uint32_t major, minor, update;
- PlatformSP platform_sp(GetSP());
- if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
- return major;
- return UINT32_MAX;
-
-}
-
-uint32_t
-SBPlatform::GetOSMinorVersion ()
-{
- uint32_t major, minor, update;
- PlatformSP platform_sp(GetSP());
- if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
- return minor;
- return UINT32_MAX;
-}
-
-uint32_t
-SBPlatform::GetOSUpdateVersion ()
-{
- uint32_t major, minor, update;
- PlatformSP platform_sp(GetSP());
- if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
- return update;
- return UINT32_MAX;
-}
-
-SBError
-SBPlatform::Get (SBFileSpec &src,
- SBFileSpec &dst)
-{
- SBError sb_error;
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- sb_error.ref() = platform_sp->GetFile(src.ref(), dst.ref());
- }
- else
- {
- sb_error.SetErrorString("invalid platform");
- }
- return sb_error;
+void SBPlatform::DisconnectRemote() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp)
+ platform_sp->DisconnectRemote();
+}
+
+bool SBPlatform::IsConnected() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp)
+ platform_sp->IsConnected();
+ return false;
+}
+
+const char *SBPlatform::GetTriple() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ ArchSpec arch(platform_sp->GetSystemArchitecture());
+ if (arch.IsValid()) {
+ // Const-ify the string so we don't need to worry about the lifetime of
+ // the string
+ return ConstString(arch.GetTriple().getTriple().c_str()).GetCString();
+ }
+ }
+ return NULL;
+}
+
+const char *SBPlatform::GetOSBuild() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ std::string s;
+ if (platform_sp->GetOSBuildString(s)) {
+ if (!s.empty()) {
+ // Const-ify the string so we don't need to worry about the lifetime of
+ // the string
+ return ConstString(s.c_str()).GetCString();
+ }
+ }
+ }
+ return NULL;
+}
+
+const char *SBPlatform::GetOSDescription() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ std::string s;
+ if (platform_sp->GetOSKernelDescription(s)) {
+ if (!s.empty()) {
+ // Const-ify the string so we don't need to worry about the lifetime of
+ // the string
+ return ConstString(s.c_str()).GetCString();
+ }
+ }
+ }
+ return NULL;
+}
+
+const char *SBPlatform::GetHostname() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp)
+ return platform_sp->GetHostname();
+ return NULL;
+}
+
+uint32_t SBPlatform::GetOSMajorVersion() {
+ uint32_t major, minor, update;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
+ return major;
+ return UINT32_MAX;
+}
+
+uint32_t SBPlatform::GetOSMinorVersion() {
+ uint32_t major, minor, update;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
+ return minor;
+ return UINT32_MAX;
+}
+
+uint32_t SBPlatform::GetOSUpdateVersion() {
+ uint32_t major, minor, update;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
+ return update;
+ return UINT32_MAX;
+}
+
+SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) {
+ SBError sb_error;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ sb_error.ref() = platform_sp->GetFile(src.ref(), dst.ref());
+ } else {
+ sb_error.SetErrorString("invalid platform");
+ }
+ return sb_error;
}
-SBError
-SBPlatform::Put (SBFileSpec &src,
- SBFileSpec &dst)
-{
- return ExecuteConnected(
- [&](const lldb::PlatformSP& platform_sp)
- {
- if (src.Exists())
- {
- uint32_t permissions = src.ref().GetPermissions();
- if (permissions == 0)
- {
- if (src.ref().GetFileType() == FileSpec::eFileTypeDirectory)
- permissions = eFilePermissionsDirectoryDefault;
- else
- permissions = eFilePermissionsFileDefault;
- }
-
- return platform_sp->PutFile(src.ref(), dst.ref(), permissions);
- }
-
- Error error;
- error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", src.ref().GetPath().c_str());
- return error;
- });
-}
-
-SBError
-SBPlatform::Install (SBFileSpec &src,
- SBFileSpec &dst)
-{
- return ExecuteConnected(
- [&](const lldb::PlatformSP& platform_sp)
- {
- if (src.Exists())
- return platform_sp->Install(src.ref(), dst.ref());
-
- Error error;
- error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", src.ref().GetPath().c_str());
- return error;
- });
-}
-
-
-SBError
-SBPlatform::Run (SBPlatformShellCommand &shell_command)
-{
- return ExecuteConnected(
- [&](const lldb::PlatformSP& platform_sp)
- {
- const char *command = shell_command.GetCommand();
- if (!command)
- return Error("invalid shell command (empty)");
-
- const char *working_dir = shell_command.GetWorkingDirectory();
- if (working_dir == NULL)
- {
- working_dir = platform_sp->GetWorkingDirectory().GetCString();
- if (working_dir)
- shell_command.SetWorkingDirectory(working_dir);
- }
- return platform_sp->RunShellCommand(command,
- FileSpec{working_dir, false},
- &shell_command.m_opaque_ptr->m_status,
- &shell_command.m_opaque_ptr->m_signo,
- &shell_command.m_opaque_ptr->m_output,
- shell_command.m_opaque_ptr->m_timeout_sec);
- });
-}
-
-SBError
-SBPlatform::Launch (SBLaunchInfo &launch_info)
-{
- return ExecuteConnected(
- [&](const lldb::PlatformSP& platform_sp)
- {
- return platform_sp->LaunchProcess(launch_info.ref());
- });
-}
-
-SBError
-SBPlatform::Kill (const lldb::pid_t pid)
-{
- return ExecuteConnected(
- [&](const lldb::PlatformSP& platform_sp)
- {
- return platform_sp->KillProcess(pid);
- });
-}
-
-SBError
-SBPlatform::ExecuteConnected (const std::function<Error(const lldb::PlatformSP&)>& func)
-{
- SBError sb_error;
- const auto platform_sp(GetSP());
- if (platform_sp)
- {
- if (platform_sp->IsConnected())
- sb_error.ref() = func(platform_sp);
+SBError SBPlatform::Put(SBFileSpec &src, SBFileSpec &dst) {
+ return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ if (src.Exists()) {
+ uint32_t permissions = src.ref().GetPermissions();
+ if (permissions == 0) {
+ if (src.ref().GetFileType() == FileSpec::eFileTypeDirectory)
+ permissions = eFilePermissionsDirectoryDefault;
else
- sb_error.SetErrorString("not connected");
+ permissions = eFilePermissionsFileDefault;
+ }
+
+ return platform_sp->PutFile(src.ref(), dst.ref(), permissions);
}
- else
- sb_error.SetErrorString("invalid platform");
- return sb_error;
+ Error error;
+ error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'",
+ src.ref().GetPath().c_str());
+ return error;
+ });
}
-SBError
-SBPlatform::MakeDirectory (const char *path, uint32_t file_permissions)
-{
- SBError sb_error;
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- sb_error.ref() = platform_sp->MakeDirectory(FileSpec{path, false}, file_permissions);
- }
- else
- {
- sb_error.SetErrorString("invalid platform");
- }
- return sb_error;
+SBError SBPlatform::Install(SBFileSpec &src, SBFileSpec &dst) {
+ return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ if (src.Exists())
+ return platform_sp->Install(src.ref(), dst.ref());
+
+ Error error;
+ error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'",
+ src.ref().GetPath().c_str());
+ return error;
+ });
+}
+
+SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) {
+ return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ const char *command = shell_command.GetCommand();
+ if (!command)
+ return Error("invalid shell command (empty)");
+
+ const char *working_dir = shell_command.GetWorkingDirectory();
+ if (working_dir == NULL) {
+ working_dir = platform_sp->GetWorkingDirectory().GetCString();
+ if (working_dir)
+ shell_command.SetWorkingDirectory(working_dir);
+ }
+ return platform_sp->RunShellCommand(
+ command, FileSpec{working_dir, false},
+ &shell_command.m_opaque_ptr->m_status,
+ &shell_command.m_opaque_ptr->m_signo,
+ &shell_command.m_opaque_ptr->m_output,
+ shell_command.m_opaque_ptr->m_timeout_sec);
+ });
+}
+
+SBError SBPlatform::Launch(SBLaunchInfo &launch_info) {
+ return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ return platform_sp->LaunchProcess(launch_info.ref());
+ });
+}
+
+SBError SBPlatform::Kill(const lldb::pid_t pid) {
+ return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ return platform_sp->KillProcess(pid);
+ });
+}
+
+SBError SBPlatform::ExecuteConnected(
+ const std::function<Error(const lldb::PlatformSP &)> &func) {
+ SBError sb_error;
+ const auto platform_sp(GetSP());
+ if (platform_sp) {
+ if (platform_sp->IsConnected())
+ sb_error.ref() = func(platform_sp);
+ else
+ sb_error.SetErrorString("not connected");
+ } else
+ sb_error.SetErrorString("invalid platform");
+
+ return sb_error;
}
-uint32_t
-SBPlatform::GetFilePermissions (const char *path)
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- uint32_t file_permissions = 0;
- platform_sp->GetFilePermissions(FileSpec{path, false}, file_permissions);
- return file_permissions;
- }
- return 0;
-
+SBError SBPlatform::MakeDirectory(const char *path, uint32_t file_permissions) {
+ SBError sb_error;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ sb_error.ref() =
+ platform_sp->MakeDirectory(FileSpec{path, false}, file_permissions);
+ } else {
+ sb_error.SetErrorString("invalid platform");
+ }
+ return sb_error;
}
-SBError
-SBPlatform::SetFilePermissions (const char *path, uint32_t file_permissions)
-{
- SBError sb_error;
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- sb_error.ref() = platform_sp->SetFilePermissions(FileSpec{path, false}, file_permissions);
- }
- else
- {
- sb_error.SetErrorString("invalid platform");
- }
- return sb_error;
-
+uint32_t SBPlatform::GetFilePermissions(const char *path) {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ uint32_t file_permissions = 0;
+ platform_sp->GetFilePermissions(FileSpec{path, false}, file_permissions);
+ return file_permissions;
+ }
+ return 0;
+}
+
+SBError SBPlatform::SetFilePermissions(const char *path,
+ uint32_t file_permissions) {
+ SBError sb_error;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ sb_error.ref() = platform_sp->SetFilePermissions(FileSpec{path, false},
+ file_permissions);
+ } else {
+ sb_error.SetErrorString("invalid platform");
+ }
+ return sb_error;
}
-SBUnixSignals
-SBPlatform::GetUnixSignals() const
-{
- if (auto platform_sp = GetSP())
- return SBUnixSignals{platform_sp};
+SBUnixSignals SBPlatform::GetUnixSignals() const {
+ if (auto platform_sp = GetSP())
+ return SBUnixSignals{platform_sp};
- return {};
+ return {};
}
Modified: lldb/trunk/source/API/SBProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBProcess.cpp (original)
+++ lldb/trunk/source/API/SBProcess.cpp Tue Sep 6 15:57:50 2016
@@ -15,7 +15,6 @@
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
-#include "lldb/Interpreter/Args.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
@@ -23,6 +22,7 @@
#include "lldb/Core/State.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Interpreter/Args.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
@@ -39,1539 +39,1300 @@
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBMemoryRegionInfo.h"
#include "lldb/API/SBMemoryRegionInfoList.h"
+#include "lldb/API/SBStream.h"
+#include "lldb/API/SBStringList.h"
#include "lldb/API/SBStructuredData.h"
#include "lldb/API/SBThread.h"
#include "lldb/API/SBThreadCollection.h"
-#include "lldb/API/SBStream.h"
-#include "lldb/API/SBStringList.h"
#include "lldb/API/SBUnixSignals.h"
using namespace lldb;
using namespace lldb_private;
-
-SBProcess::SBProcess () :
- m_opaque_wp()
-{
-}
-
+SBProcess::SBProcess() : m_opaque_wp() {}
//----------------------------------------------------------------------
// SBProcess constructor
//----------------------------------------------------------------------
-SBProcess::SBProcess (const SBProcess& rhs) :
- m_opaque_wp (rhs.m_opaque_wp)
-{
-}
-
+SBProcess::SBProcess(const SBProcess &rhs) : m_opaque_wp(rhs.m_opaque_wp) {}
-SBProcess::SBProcess (const lldb::ProcessSP &process_sp) :
- m_opaque_wp (process_sp)
-{
-}
+SBProcess::SBProcess(const lldb::ProcessSP &process_sp)
+ : m_opaque_wp(process_sp) {}
-const SBProcess&
-SBProcess::operator = (const SBProcess& rhs)
-{
- if (this != &rhs)
- m_opaque_wp = rhs.m_opaque_wp;
- return *this;
+const SBProcess &SBProcess::operator=(const SBProcess &rhs) {
+ if (this != &rhs)
+ m_opaque_wp = rhs.m_opaque_wp;
+ return *this;
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-SBProcess::~SBProcess()
-{
-}
-
-const char *
-SBProcess::GetBroadcasterClassName ()
-{
- return Process::GetStaticBroadcasterClass().AsCString();
-}
-
-const char *
-SBProcess::GetPluginName ()
-{
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- return process_sp->GetPluginName().GetCString();
- }
- return "<Unknown>";
-}
-
-const char *
-SBProcess::GetShortPluginName ()
-{
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- return process_sp->GetPluginName().GetCString();
- }
- return "<Unknown>";
-}
-
-
-lldb::ProcessSP
-SBProcess::GetSP() const
-{
- return m_opaque_wp.lock();
-}
-
-void
-SBProcess::SetSP (const ProcessSP &process_sp)
-{
- m_opaque_wp = process_sp;
-}
+SBProcess::~SBProcess() {}
-void
-SBProcess::Clear ()
-{
- m_opaque_wp.reset();
+const char *SBProcess::GetBroadcasterClassName() {
+ return Process::GetStaticBroadcasterClass().AsCString();
}
-
-bool
-SBProcess::IsValid() const
-{
- ProcessSP process_sp(m_opaque_wp.lock());
- return ((bool) process_sp && process_sp->IsValid());
-}
-
-bool
-SBProcess::RemoteLaunch (char const **argv,
- char const **envp,
- const char *stdin_path,
- const char *stdout_path,
- const char *stderr_path,
- const char *working_directory,
- uint32_t launch_flags,
- bool stop_at_entry,
- lldb::SBError& error)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::RemoteLaunch (argv=%p, envp=%p, stdin=%s, stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, stop_at_entry=%i, &error (%p))...",
- static_cast<void*>(m_opaque_wp.lock().get()),
- static_cast<void*>(argv), static_cast<void*>(envp),
- stdin_path ? stdin_path : "NULL",
- stdout_path ? stdout_path : "NULL",
- stderr_path ? stderr_path : "NULL",
- working_directory ? working_directory : "NULL",
- launch_flags, stop_at_entry,
- static_cast<void*>(error.get()));
-
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- if (process_sp->GetState() == eStateConnected)
- {
- if (stop_at_entry)
- launch_flags |= eLaunchFlagStopAtEntry;
- ProcessLaunchInfo launch_info(FileSpec{stdin_path, false},
- FileSpec{stdout_path, false},
- FileSpec{stderr_path, false},
- FileSpec{working_directory, false},
- launch_flags);
- Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
- if (exe_module)
- launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
- if (argv)
- launch_info.GetArguments().AppendArguments (argv);
- if (envp)
- launch_info.GetEnvironmentEntries ().SetArguments (envp);
- error.SetError (process_sp->Launch (launch_info));
- }
- else
- {
- error.SetErrorString ("must be in eStateConnected to call RemoteLaunch");
- }
- }
+const char *SBProcess::GetPluginName() {
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ return process_sp->GetPluginName().GetCString();
+ }
+ return "<Unknown>";
+}
+
+const char *SBProcess::GetShortPluginName() {
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ return process_sp->GetPluginName().GetCString();
+ }
+ return "<Unknown>";
+}
+
+lldb::ProcessSP SBProcess::GetSP() const { return m_opaque_wp.lock(); }
+
+void SBProcess::SetSP(const ProcessSP &process_sp) { m_opaque_wp = process_sp; }
+
+void SBProcess::Clear() { m_opaque_wp.reset(); }
+
+bool SBProcess::IsValid() const {
+ ProcessSP process_sp(m_opaque_wp.lock());
+ return ((bool)process_sp && process_sp->IsValid());
+}
+
+bool SBProcess::RemoteLaunch(char const **argv, char const **envp,
+ const char *stdin_path, const char *stdout_path,
+ const char *stderr_path,
+ const char *working_directory,
+ uint32_t launch_flags, bool stop_at_entry,
+ lldb::SBError &error) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::RemoteLaunch (argv=%p, envp=%p, stdin=%s, "
+ "stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, "
+ "stop_at_entry=%i, &error (%p))...",
+ static_cast<void *>(m_opaque_wp.lock().get()),
+ static_cast<void *>(argv), static_cast<void *>(envp),
+ stdin_path ? stdin_path : "NULL",
+ stdout_path ? stdout_path : "NULL",
+ stderr_path ? stderr_path : "NULL",
+ working_directory ? working_directory : "NULL", launch_flags,
+ stop_at_entry, static_cast<void *>(error.get()));
+
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ if (process_sp->GetState() == eStateConnected) {
+ if (stop_at_entry)
+ launch_flags |= eLaunchFlagStopAtEntry;
+ ProcessLaunchInfo launch_info(
+ FileSpec{stdin_path, false}, FileSpec{stdout_path, false},
+ FileSpec{stderr_path, false}, FileSpec{working_directory, false},
+ launch_flags);
+ Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
+ if (exe_module)
+ launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
+ if (argv)
+ launch_info.GetArguments().AppendArguments(argv);
+ if (envp)
+ launch_info.GetEnvironmentEntries().SetArguments(envp);
+ error.SetError(process_sp->Launch(launch_info));
+ } else {
+ error.SetErrorString("must be in eStateConnected to call RemoteLaunch");
+ }
+ } else {
+ error.SetErrorString("unable to attach pid");
+ }
+
+ if (log) {
+ SBStream sstr;
+ error.GetDescription(sstr);
+ log->Printf("SBProcess(%p)::RemoteLaunch (...) => SBError (%p): %s",
+ static_cast<void *>(process_sp.get()),
+ static_cast<void *>(error.get()), sstr.GetData());
+ }
+
+ return error.Success();
+}
+
+bool SBProcess::RemoteAttachToProcessWithID(lldb::pid_t pid,
+ lldb::SBError &error) {
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ if (process_sp->GetState() == eStateConnected) {
+ ProcessAttachInfo attach_info;
+ attach_info.SetProcessID(pid);
+ error.SetError(process_sp->Attach(attach_info));
+ } else {
+ error.SetErrorString(
+ "must be in eStateConnected to call RemoteAttachToProcessWithID");
+ }
+ } else {
+ error.SetErrorString("unable to attach pid");
+ }
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ SBStream sstr;
+ error.GetDescription(sstr);
+ log->Printf("SBProcess(%p)::RemoteAttachToProcessWithID (%" PRIu64
+ ") => SBError (%p): %s",
+ static_cast<void *>(process_sp.get()), pid,
+ static_cast<void *>(error.get()), sstr.GetData());
+ }
+
+ return error.Success();
+}
+
+uint32_t SBProcess::GetNumThreads() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ uint32_t num_threads = 0;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+
+ const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ num_threads = process_sp->GetThreadList().GetSize(can_update);
+ }
+
+ if (log)
+ log->Printf("SBProcess(%p)::GetNumThreads () => %d",
+ static_cast<void *>(process_sp.get()), num_threads);
+
+ return num_threads;
+}
+
+SBThread SBProcess::GetSelectedThread() const {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBThread sb_thread;
+ ThreadSP thread_sp;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ thread_sp = process_sp->GetThreadList().GetSelectedThread();
+ sb_thread.SetThread(thread_sp);
+ }
+
+ if (log)
+ log->Printf("SBProcess(%p)::GetSelectedThread () => SBThread(%p)",
+ static_cast<void *>(process_sp.get()),
+ static_cast<void *>(thread_sp.get()));
+
+ return sb_thread;
+}
+
+SBThread SBProcess::CreateOSPluginThread(lldb::tid_t tid,
+ lldb::addr_t context) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBThread sb_thread;
+ ThreadSP thread_sp;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ thread_sp = process_sp->CreateOSPluginThread(tid, context);
+ sb_thread.SetThread(thread_sp);
+ }
+
+ if (log)
+ log->Printf("SBProcess(%p)::CreateOSPluginThread (tid=0x%" PRIx64
+ ", context=0x%" PRIx64 ") => SBThread(%p)",
+ static_cast<void *>(process_sp.get()), tid, context,
+ static_cast<void *>(thread_sp.get()));
+
+ return sb_thread;
+}
+
+SBTarget SBProcess::GetTarget() const {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBTarget sb_target;
+ TargetSP target_sp;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ target_sp = process_sp->GetTarget().shared_from_this();
+ sb_target.SetSP(target_sp);
+ }
+
+ if (log)
+ log->Printf("SBProcess(%p)::GetTarget () => SBTarget(%p)",
+ static_cast<void *>(process_sp.get()),
+ static_cast<void *>(target_sp.get()));
+
+ return sb_target;
+}
+
+size_t SBProcess::PutSTDIN(const char *src, size_t src_len) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ size_t ret_val = 0;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Error error;
+ ret_val = process_sp->PutSTDIN(src, src_len, error);
+ }
+
+ if (log)
+ log->Printf("SBProcess(%p)::PutSTDIN (src=\"%s\", src_len=%" PRIu64
+ ") => %" PRIu64,
+ static_cast<void *>(process_sp.get()), src,
+ static_cast<uint64_t>(src_len), static_cast<uint64_t>(ret_val));
+
+ return ret_val;
+}
+
+size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const {
+ size_t bytes_read = 0;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Error error;
+ bytes_read = process_sp->GetSTDOUT(dst, dst_len, error);
+ }
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf(
+ "SBProcess(%p)::GetSTDOUT (dst=\"%.*s\", dst_len=%" PRIu64
+ ") => %" PRIu64,
+ static_cast<void *>(process_sp.get()), static_cast<int>(bytes_read),
+ dst, static_cast<uint64_t>(dst_len), static_cast<uint64_t>(bytes_read));
+
+ return bytes_read;
+}
+
+size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const {
+ size_t bytes_read = 0;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Error error;
+ bytes_read = process_sp->GetSTDERR(dst, dst_len, error);
+ }
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf(
+ "SBProcess(%p)::GetSTDERR (dst=\"%.*s\", dst_len=%" PRIu64
+ ") => %" PRIu64,
+ static_cast<void *>(process_sp.get()), static_cast<int>(bytes_read),
+ dst, static_cast<uint64_t>(dst_len), static_cast<uint64_t>(bytes_read));
+
+ return bytes_read;
+}
+
+size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const {
+ size_t bytes_read = 0;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Error error;
+ bytes_read = process_sp->GetAsyncProfileData(dst, dst_len, error);
+ }
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf(
+ "SBProcess(%p)::GetAsyncProfileData (dst=\"%.*s\", dst_len=%" PRIu64
+ ") => %" PRIu64,
+ static_cast<void *>(process_sp.get()), static_cast<int>(bytes_read),
+ dst, static_cast<uint64_t>(dst_len), static_cast<uint64_t>(bytes_read));
+
+ return bytes_read;
+}
+
+void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const {
+ if (out == NULL)
+ return;
+
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ const StateType event_state = SBProcess::GetStateFromEvent(event);
+ char message[1024];
+ int message_len = ::snprintf(
+ message, sizeof(message), "Process %" PRIu64 " %s\n",
+ process_sp->GetID(), SBDebugger::StateAsCString(event_state));
+
+ if (message_len > 0)
+ ::fwrite(message, 1, message_len, out);
+ }
+}
+
+void SBProcess::AppendEventStateReport(const SBEvent &event,
+ SBCommandReturnObject &result) {
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ const StateType event_state = SBProcess::GetStateFromEvent(event);
+ char message[1024];
+ ::snprintf(message, sizeof(message), "Process %" PRIu64 " %s\n",
+ process_sp->GetID(), SBDebugger::StateAsCString(event_state));
+
+ result.AppendMessage(message);
+ }
+}
+
+bool SBProcess::SetSelectedThread(const SBThread &thread) {
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ return process_sp->GetThreadList().SetSelectedThreadByID(
+ thread.GetThreadID());
+ }
+ return false;
+}
+
+bool SBProcess::SetSelectedThreadByID(lldb::tid_t tid) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ bool ret_val = false;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ ret_val = process_sp->GetThreadList().SetSelectedThreadByID(tid);
+ }
+
+ if (log)
+ log->Printf("SBProcess(%p)::SetSelectedThreadByID (tid=0x%4.4" PRIx64
+ ") => %s",
+ static_cast<void *>(process_sp.get()), tid,
+ (ret_val ? "true" : "false"));
+
+ return ret_val;
+}
+
+bool SBProcess::SetSelectedThreadByIndexID(uint32_t index_id) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ bool ret_val = false;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID(index_id);
+ }
+
+ if (log)
+ log->Printf("SBProcess(%p)::SetSelectedThreadByID (tid=0x%x) => %s",
+ static_cast<void *>(process_sp.get()), index_id,
+ (ret_val ? "true" : "false"));
+
+ return ret_val;
+}
+
+SBThread SBProcess::GetThreadAtIndex(size_t index) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBThread sb_thread;
+ ThreadSP thread_sp;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, can_update);
+ sb_thread.SetThread(thread_sp);
+ }
+
+ if (log)
+ log->Printf("SBProcess(%p)::GetThreadAtIndex (index=%d) => SBThread(%p)",
+ static_cast<void *>(process_sp.get()),
+ static_cast<uint32_t>(index),
+ static_cast<void *>(thread_sp.get()));
+
+ return sb_thread;
+}
+
+uint32_t SBProcess::GetNumQueues() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ uint32_t num_queues = 0;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ num_queues = process_sp->GetQueueList().GetSize();
+ }
+ }
+
+ if (log)
+ log->Printf("SBProcess(%p)::GetNumQueues () => %d",
+ static_cast<void *>(process_sp.get()), num_queues);
+
+ return num_queues;
+}
+
+SBQueue SBProcess::GetQueueAtIndex(size_t index) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBQueue sb_queue;
+ QueueSP queue_sp;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ queue_sp = process_sp->GetQueueList().GetQueueAtIndex(index);
+ sb_queue.SetQueue(queue_sp);
+ }
+ }
+
+ if (log)
+ log->Printf("SBProcess(%p)::GetQueueAtIndex (index=%d) => SBQueue(%p)",
+ static_cast<void *>(process_sp.get()),
+ static_cast<uint32_t>(index),
+ static_cast<void *>(queue_sp.get()));
+
+ return sb_queue;
+}
+
+uint32_t SBProcess::GetStopID(bool include_expression_stops) {
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ if (include_expression_stops)
+ return process_sp->GetStopID();
else
- {
- error.SetErrorString ("unable to attach pid");
- }
-
- if (log) {
- SBStream sstr;
- error.GetDescription (sstr);
- log->Printf ("SBProcess(%p)::RemoteLaunch (...) => SBError (%p): %s",
- static_cast<void*>(process_sp.get()),
- static_cast<void*>(error.get()), sstr.GetData());
- }
-
- return error.Success();
-}
+ return process_sp->GetLastNaturalStopID();
+ }
+ return 0;
+}
+
+SBEvent SBProcess::GetStopEventForStopID(uint32_t stop_id) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBEvent sb_event;
+ EventSP event_sp;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ event_sp = process_sp->GetStopEventForStopID(stop_id);
+ sb_event.reset(event_sp);
+ }
+
+ if (log)
+ log->Printf("SBProcess(%p)::GetStopEventForStopID (stop_id=%" PRIu32
+ ") => SBEvent(%p)",
+ static_cast<void *>(process_sp.get()), stop_id,
+ static_cast<void *>(event_sp.get()));
+
+ return sb_event;
+}
+
+StateType SBProcess::GetState() {
+
+ StateType ret_val = eStateInvalid;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ ret_val = process_sp->GetState();
+ }
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::GetState () => %s",
+ static_cast<void *>(process_sp.get()),
+ lldb_private::StateAsCString(ret_val));
+
+ return ret_val;
+}
+
+int SBProcess::GetExitStatus() {
+ int exit_status = 0;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ exit_status = process_sp->GetExitStatus();
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::GetExitStatus () => %i (0x%8.8x)",
+ static_cast<void *>(process_sp.get()), exit_status,
+ exit_status);
+
+ return exit_status;
+}
+
+const char *SBProcess::GetExitDescription() {
+ const char *exit_desc = NULL;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ exit_desc = process_sp->GetExitDescription();
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::GetExitDescription () => %s",
+ static_cast<void *>(process_sp.get()), exit_desc);
+ return exit_desc;
+}
+
+lldb::pid_t SBProcess::GetProcessID() {
+ lldb::pid_t ret_val = LLDB_INVALID_PROCESS_ID;
+ ProcessSP process_sp(GetSP());
+ if (process_sp)
+ ret_val = process_sp->GetID();
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::GetProcessID () => %" PRIu64,
+ static_cast<void *>(process_sp.get()), ret_val);
+
+ return ret_val;
+}
+
+uint32_t SBProcess::GetUniqueID() {
+ uint32_t ret_val = 0;
+ ProcessSP process_sp(GetSP());
+ if (process_sp)
+ ret_val = process_sp->GetUniqueID();
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::GetUniqueID () => %" PRIu32,
+ static_cast<void *>(process_sp.get()), ret_val);
+ return ret_val;
+}
+
+ByteOrder SBProcess::GetByteOrder() const {
+ ByteOrder byteOrder = eByteOrderInvalid;
+ ProcessSP process_sp(GetSP());
+ if (process_sp)
+ byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder();
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::GetByteOrder () => %d",
+ static_cast<void *>(process_sp.get()), byteOrder);
+
+ return byteOrder;
+}
+
+uint32_t SBProcess::GetAddressByteSize() const {
+ uint32_t size = 0;
+ ProcessSP process_sp(GetSP());
+ if (process_sp)
+ size = process_sp->GetTarget().GetArchitecture().GetAddressByteSize();
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::GetAddressByteSize () => %d",
+ static_cast<void *>(process_sp.get()), size);
+
+ return size;
+}
+
+SBError SBProcess::Continue() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBError sb_error;
+ ProcessSP process_sp(GetSP());
+
+ if (log)
+ log->Printf("SBProcess(%p)::Continue ()...",
+ static_cast<void *>(process_sp.get()));
+
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
-bool
-SBProcess::RemoteAttachToProcessWithID (lldb::pid_t pid, lldb::SBError& error)
-{
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- if (process_sp->GetState() == eStateConnected)
- {
- ProcessAttachInfo attach_info;
- attach_info.SetProcessID (pid);
- error.SetError (process_sp->Attach (attach_info));
- }
- else
- {
- error.SetErrorString ("must be in eStateConnected to call RemoteAttachToProcessWithID");
- }
- }
+ if (process_sp->GetTarget().GetDebugger().GetAsyncExecution())
+ sb_error.ref() = process_sp->Resume();
else
- {
- error.SetErrorString ("unable to attach pid");
- }
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log) {
- SBStream sstr;
- error.GetDescription (sstr);
- log->Printf ("SBProcess(%p)::RemoteAttachToProcessWithID (%" PRIu64 ") => SBError (%p): %s",
- static_cast<void*>(process_sp.get()), pid,
- static_cast<void*>(error.get()), sstr.GetData());
- }
-
- return error.Success();
-}
-
-
-uint32_t
-SBProcess::GetNumThreads ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- uint32_t num_threads = 0;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Process::StopLocker stop_locker;
-
- const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- num_threads = process_sp->GetThreadList().GetSize(can_update);
- }
-
- if (log)
- log->Printf ("SBProcess(%p)::GetNumThreads () => %d",
- static_cast<void*>(process_sp.get()), num_threads);
-
- return num_threads;
-}
-
-SBThread
-SBProcess::GetSelectedThread () const
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBThread sb_thread;
- ThreadSP thread_sp;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- thread_sp = process_sp->GetThreadList().GetSelectedThread();
- sb_thread.SetThread (thread_sp);
- }
-
- if (log)
- log->Printf ("SBProcess(%p)::GetSelectedThread () => SBThread(%p)",
- static_cast<void*>(process_sp.get()),
- static_cast<void*>(thread_sp.get()));
-
- return sb_thread;
-}
-
-SBThread
-SBProcess::CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBThread sb_thread;
- ThreadSP thread_sp;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- thread_sp = process_sp->CreateOSPluginThread(tid, context);
- sb_thread.SetThread (thread_sp);
- }
-
- if (log)
- log->Printf ("SBProcess(%p)::CreateOSPluginThread (tid=0x%" PRIx64 ", context=0x%" PRIx64 ") => SBThread(%p)",
- static_cast<void*>(process_sp.get()), tid, context,
- static_cast<void*>(thread_sp.get()));
-
- return sb_thread;
-}
-
-SBTarget
-SBProcess::GetTarget() const
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBTarget sb_target;
- TargetSP target_sp;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- target_sp = process_sp->GetTarget().shared_from_this();
- sb_target.SetSP (target_sp);
- }
-
- if (log)
- log->Printf ("SBProcess(%p)::GetTarget () => SBTarget(%p)",
- static_cast<void*>(process_sp.get()),
- static_cast<void*>(target_sp.get()));
-
- return sb_target;
-}
-
-
-size_t
-SBProcess::PutSTDIN (const char *src, size_t src_len)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- size_t ret_val = 0;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Error error;
- ret_val = process_sp->PutSTDIN (src, src_len, error);
- }
-
- if (log)
- log->Printf("SBProcess(%p)::PutSTDIN (src=\"%s\", src_len=%" PRIu64 ") => %" PRIu64,
- static_cast<void*>(process_sp.get()), src,
- static_cast<uint64_t>(src_len),
- static_cast<uint64_t>(ret_val));
-
- return ret_val;
-}
-
-size_t
-SBProcess::GetSTDOUT (char *dst, size_t dst_len) const
-{
- size_t bytes_read = 0;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Error error;
- bytes_read = process_sp->GetSTDOUT (dst, dst_len, error);
- }
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetSTDOUT (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64,
- static_cast<void*>(process_sp.get()),
- static_cast<int>(bytes_read), dst,
- static_cast<uint64_t>(dst_len),
- static_cast<uint64_t>(bytes_read));
-
- return bytes_read;
-}
-
-size_t
-SBProcess::GetSTDERR (char *dst, size_t dst_len) const
-{
- size_t bytes_read = 0;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Error error;
- bytes_read = process_sp->GetSTDERR (dst, dst_len, error);
- }
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetSTDERR (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64,
- static_cast<void*>(process_sp.get()),
- static_cast<int>(bytes_read), dst,
- static_cast<uint64_t>(dst_len),
- static_cast<uint64_t>(bytes_read));
-
- return bytes_read;
-}
-
-size_t
-SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const
-{
- size_t bytes_read = 0;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Error error;
- bytes_read = process_sp->GetAsyncProfileData (dst, dst_len, error);
- }
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetAsyncProfileData (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64,
- static_cast<void*>(process_sp.get()),
- static_cast<int>(bytes_read), dst,
- static_cast<uint64_t>(dst_len),
- static_cast<uint64_t>(bytes_read));
-
- return bytes_read;
-}
-
-void
-SBProcess::ReportEventState (const SBEvent &event, FILE *out) const
-{
- if (out == NULL)
- return;
-
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- const StateType event_state = SBProcess::GetStateFromEvent (event);
- char message[1024];
- int message_len = ::snprintf (message,
- sizeof (message),
- "Process %" PRIu64 " %s\n",
- process_sp->GetID(),
- SBDebugger::StateAsCString (event_state));
-
- if (message_len > 0)
- ::fwrite (message, 1, message_len, out);
- }
-}
-
-void
-SBProcess::AppendEventStateReport (const SBEvent &event, SBCommandReturnObject &result)
-{
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- const StateType event_state = SBProcess::GetStateFromEvent (event);
- char message[1024];
- ::snprintf (message,
- sizeof (message),
- "Process %" PRIu64 " %s\n",
- process_sp->GetID(),
- SBDebugger::StateAsCString (event_state));
-
- result.AppendMessage (message);
- }
-}
+ sb_error.ref() = process_sp->ResumeSynchronous(NULL);
+ } else
+ sb_error.SetErrorString("SBProcess is invalid");
+
+ if (log) {
+ SBStream sstr;
+ sb_error.GetDescription(sstr);
+ log->Printf("SBProcess(%p)::Continue () => SBError (%p): %s",
+ static_cast<void *>(process_sp.get()),
+ static_cast<void *>(sb_error.get()), sstr.GetData());
+ }
+
+ return sb_error;
+}
+
+SBError SBProcess::Destroy() {
+ SBError sb_error;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ sb_error.SetError(process_sp->Destroy(false));
+ } else
+ sb_error.SetErrorString("SBProcess is invalid");
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ SBStream sstr;
+ sb_error.GetDescription(sstr);
+ log->Printf("SBProcess(%p)::Destroy () => SBError (%p): %s",
+ static_cast<void *>(process_sp.get()),
+ static_cast<void *>(sb_error.get()), sstr.GetData());
+ }
+
+ return sb_error;
+}
+
+SBError SBProcess::Stop() {
+ SBError sb_error;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ sb_error.SetError(process_sp->Halt());
+ } else
+ sb_error.SetErrorString("SBProcess is invalid");
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ SBStream sstr;
+ sb_error.GetDescription(sstr);
+ log->Printf("SBProcess(%p)::Stop () => SBError (%p): %s",
+ static_cast<void *>(process_sp.get()),
+ static_cast<void *>(sb_error.get()), sstr.GetData());
+ }
+
+ return sb_error;
+}
+
+SBError SBProcess::Kill() {
+ SBError sb_error;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ sb_error.SetError(process_sp->Destroy(true));
+ } else
+ sb_error.SetErrorString("SBProcess is invalid");
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ SBStream sstr;
+ sb_error.GetDescription(sstr);
+ log->Printf("SBProcess(%p)::Kill () => SBError (%p): %s",
+ static_cast<void *>(process_sp.get()),
+ static_cast<void *>(sb_error.get()), sstr.GetData());
+ }
+
+ return sb_error;
+}
+
+SBError SBProcess::Detach() {
+ // FIXME: This should come from a process default.
+ bool keep_stopped = false;
+ return Detach(keep_stopped);
+}
+
+SBError SBProcess::Detach(bool keep_stopped) {
+ SBError sb_error;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ sb_error.SetError(process_sp->Detach(keep_stopped));
+ } else
+ sb_error.SetErrorString("SBProcess is invalid");
+
+ return sb_error;
+}
+
+SBError SBProcess::Signal(int signo) {
+ SBError sb_error;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ sb_error.SetError(process_sp->Signal(signo));
+ } else
+ sb_error.SetErrorString("SBProcess is invalid");
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ SBStream sstr;
+ sb_error.GetDescription(sstr);
+ log->Printf("SBProcess(%p)::Signal (signo=%i) => SBError (%p): %s",
+ static_cast<void *>(process_sp.get()), signo,
+ static_cast<void *>(sb_error.get()), sstr.GetData());
+ }
+ return sb_error;
+}
+
+SBUnixSignals SBProcess::GetUnixSignals() {
+ if (auto process_sp = GetSP())
+ return SBUnixSignals{process_sp};
+
+ return {};
+}
+
+void SBProcess::SendAsyncInterrupt() {
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ process_sp->SendAsyncInterrupt();
+ }
+}
+
+SBThread SBProcess::GetThreadByID(tid_t tid) {
+ SBThread sb_thread;
+ ThreadSP thread_sp;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ thread_sp = process_sp->GetThreadList().FindThreadByID(tid, can_update);
+ sb_thread.SetThread(thread_sp);
+ }
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::GetThreadByID (tid=0x%4.4" PRIx64
+ ") => SBThread (%p)",
+ static_cast<void *>(process_sp.get()), tid,
+ static_cast<void *>(thread_sp.get()));
+
+ return sb_thread;
+}
+
+SBThread SBProcess::GetThreadByIndexID(uint32_t index_id) {
+ SBThread sb_thread;
+ ThreadSP thread_sp;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ thread_sp =
+ process_sp->GetThreadList().FindThreadByIndexID(index_id, can_update);
+ sb_thread.SetThread(thread_sp);
+ }
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::GetThreadByID (tid=0x%x) => SBThread (%p)",
+ static_cast<void *>(process_sp.get()), index_id,
+ static_cast<void *>(thread_sp.get()));
+
+ return sb_thread;
+}
+
+StateType SBProcess::GetStateFromEvent(const SBEvent &event) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ StateType ret_val = Process::ProcessEventData::GetStateFromEvent(event.get());
+
+ if (log)
+ log->Printf("SBProcess::GetStateFromEvent (event.sp=%p) => %s",
+ static_cast<void *>(event.get()),
+ lldb_private::StateAsCString(ret_val));
+
+ return ret_val;
+}
+
+bool SBProcess::GetRestartedFromEvent(const SBEvent &event) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ bool ret_val = Process::ProcessEventData::GetRestartedFromEvent(event.get());
+
+ if (log)
+ log->Printf("SBProcess::%s (event.sp=%p) => %d", __FUNCTION__,
+ static_cast<void *>(event.get()), ret_val);
-bool
-SBProcess::SetSelectedThread (const SBThread &thread)
-{
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- return process_sp->GetThreadList().SetSelectedThreadByID (thread.GetThreadID());
- }
- return false;
-}
-
-bool
-SBProcess::SetSelectedThreadByID (lldb::tid_t tid)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- bool ret_val = false;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- ret_val = process_sp->GetThreadList().SetSelectedThreadByID (tid);
- }
-
- if (log)
- log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=0x%4.4" PRIx64 ") => %s",
- static_cast<void*>(process_sp.get()), tid,
- (ret_val ? "true" : "false"));
-
- return ret_val;
-}
-
-bool
-SBProcess::SetSelectedThreadByIndexID (uint32_t index_id)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- bool ret_val = false;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID (index_id);
- }
-
- if (log)
- log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=0x%x) => %s",
- static_cast<void*>(process_sp.get()), index_id,
- (ret_val ? "true" : "false"));
-
- return ret_val;
-}
-
-SBThread
-SBProcess::GetThreadAtIndex (size_t index)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBThread sb_thread;
- ThreadSP thread_sp;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, can_update);
- sb_thread.SetThread (thread_sp);
- }
-
- if (log)
- log->Printf ("SBProcess(%p)::GetThreadAtIndex (index=%d) => SBThread(%p)",
- static_cast<void*>(process_sp.get()),
- static_cast<uint32_t>(index),
- static_cast<void*>(thread_sp.get()));
-
- return sb_thread;
-}
-
-uint32_t
-SBProcess::GetNumQueues ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- uint32_t num_queues = 0;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&process_sp->GetRunLock()))
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- num_queues = process_sp->GetQueueList().GetSize();
- }
- }
-
- if (log)
- log->Printf ("SBProcess(%p)::GetNumQueues () => %d",
- static_cast<void*>(process_sp.get()), num_queues);
-
- return num_queues;
-}
-
-SBQueue
-SBProcess::GetQueueAtIndex (size_t index)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBQueue sb_queue;
- QueueSP queue_sp;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&process_sp->GetRunLock()))
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- queue_sp = process_sp->GetQueueList().GetQueueAtIndex(index);
- sb_queue.SetQueue (queue_sp);
- }
- }
-
- if (log)
- log->Printf ("SBProcess(%p)::GetQueueAtIndex (index=%d) => SBQueue(%p)",
- static_cast<void*>(process_sp.get()),
- static_cast<uint32_t>(index),
- static_cast<void*>(queue_sp.get()));
-
- return sb_queue;
+ return ret_val;
}
-
-uint32_t
-SBProcess::GetStopID(bool include_expression_stops)
-{
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- if (include_expression_stops)
- return process_sp->GetStopID();
- else
- return process_sp->GetLastNaturalStopID();
- }
- return 0;
-}
-
-SBEvent
-SBProcess::GetStopEventForStopID(uint32_t stop_id)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBEvent sb_event;
- EventSP event_sp;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- event_sp = process_sp->GetStopEventForStopID(stop_id);
- sb_event.reset(event_sp);
- }
-
- if (log)
- log->Printf ("SBProcess(%p)::GetStopEventForStopID (stop_id=%" PRIu32 ") => SBEvent(%p)",
- static_cast<void*>(process_sp.get()),
- stop_id,
- static_cast<void*>(event_sp.get()));
-
- return sb_event;
-}
-
-StateType
-SBProcess::GetState ()
-{
-
- StateType ret_val = eStateInvalid;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- ret_val = process_sp->GetState();
- }
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetState () => %s",
- static_cast<void*>(process_sp.get()),
- lldb_private::StateAsCString (ret_val));
-
- return ret_val;
-}
-
-
-int
-SBProcess::GetExitStatus ()
-{
- int exit_status = 0;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- exit_status = process_sp->GetExitStatus ();
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetExitStatus () => %i (0x%8.8x)",
- static_cast<void*>(process_sp.get()), exit_status,
- exit_status);
-
- return exit_status;
+size_t SBProcess::GetNumRestartedReasonsFromEvent(const lldb::SBEvent &event) {
+ return Process::ProcessEventData::GetNumRestartedReasons(event.get());
}
const char *
-SBProcess::GetExitDescription ()
-{
- const char *exit_desc = NULL;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- exit_desc = process_sp->GetExitDescription ();
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetExitDescription () => %s",
- static_cast<void*>(process_sp.get()), exit_desc);
- return exit_desc;
+SBProcess::GetRestartedReasonAtIndexFromEvent(const lldb::SBEvent &event,
+ size_t idx) {
+ return Process::ProcessEventData::GetRestartedReasonAtIndex(event.get(), idx);
}
-lldb::pid_t
-SBProcess::GetProcessID ()
-{
- lldb::pid_t ret_val = LLDB_INVALID_PROCESS_ID;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- ret_val = process_sp->GetID();
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetProcessID () => %" PRIu64,
- static_cast<void*>(process_sp.get()), ret_val);
-
- return ret_val;
-}
+SBProcess SBProcess::GetProcessFromEvent(const SBEvent &event) {
+ ProcessSP process_sp =
+ Process::ProcessEventData::GetProcessFromEvent(event.get());
+ if (!process_sp) {
+ // StructuredData events also know the process they come from.
+ // Try that.
+ process_sp = EventDataStructuredData::GetProcessFromEvent(event.get());
+ }
-uint32_t
-SBProcess::GetUniqueID()
-{
- uint32_t ret_val = 0;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- ret_val = process_sp->GetUniqueID();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetUniqueID () => %" PRIu32,
- static_cast<void*>(process_sp.get()), ret_val);
- return ret_val;
+ return SBProcess(process_sp);
}
-ByteOrder
-SBProcess::GetByteOrder () const
-{
- ByteOrder byteOrder = eByteOrderInvalid;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder();
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetByteOrder () => %d",
- static_cast<void*>(process_sp.get()), byteOrder);
-
- return byteOrder;
-}
-
-uint32_t
-SBProcess::GetAddressByteSize () const
-{
- uint32_t size = 0;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- size = process_sp->GetTarget().GetArchitecture().GetAddressByteSize();
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetAddressByteSize () => %d",
- static_cast<void*>(process_sp.get()), size);
-
- return size;
-}
-
-SBError
-SBProcess::Continue ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBError sb_error;
- ProcessSP process_sp(GetSP());
-
- if (log)
- log->Printf ("SBProcess(%p)::Continue ()...",
- static_cast<void*>(process_sp.get()));
-
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
-
- if (process_sp->GetTarget().GetDebugger().GetAsyncExecution ())
- sb_error.ref() = process_sp->Resume ();
- else
- sb_error.ref() = process_sp->ResumeSynchronous (NULL);
- }
- else
- sb_error.SetErrorString ("SBProcess is invalid");
-
- if (log)
- {
- SBStream sstr;
- sb_error.GetDescription (sstr);
- log->Printf ("SBProcess(%p)::Continue () => SBError (%p): %s",
- static_cast<void*>(process_sp.get()),
- static_cast<void*>(sb_error.get()), sstr.GetData());
- }
-
- return sb_error;
-}
-
-
-SBError
-SBProcess::Destroy ()
-{
- SBError sb_error;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- sb_error.SetError(process_sp->Destroy(false));
- }
- else
- sb_error.SetErrorString ("SBProcess is invalid");
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- SBStream sstr;
- sb_error.GetDescription (sstr);
- log->Printf ("SBProcess(%p)::Destroy () => SBError (%p): %s",
- static_cast<void*>(process_sp.get()),
- static_cast<void*>(sb_error.get()), sstr.GetData());
- }
-
- return sb_error;
-}
-
-
-SBError
-SBProcess::Stop ()
-{
- SBError sb_error;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- sb_error.SetError (process_sp->Halt());
- }
- else
- sb_error.SetErrorString ("SBProcess is invalid");
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- SBStream sstr;
- sb_error.GetDescription (sstr);
- log->Printf ("SBProcess(%p)::Stop () => SBError (%p): %s",
- static_cast<void*>(process_sp.get()),
- static_cast<void*>(sb_error.get()), sstr.GetData());
- }
-
- return sb_error;
-}
-
-SBError
-SBProcess::Kill ()
-{
- SBError sb_error;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- sb_error.SetError (process_sp->Destroy(true));
- }
- else
- sb_error.SetErrorString ("SBProcess is invalid");
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- SBStream sstr;
- sb_error.GetDescription (sstr);
- log->Printf ("SBProcess(%p)::Kill () => SBError (%p): %s",
- static_cast<void*>(process_sp.get()),
- static_cast<void*>(sb_error.get()), sstr.GetData());
- }
-
- return sb_error;
-}
-
-SBError
-SBProcess::Detach ()
-{
- // FIXME: This should come from a process default.
- bool keep_stopped = false;
- return Detach (keep_stopped);
-}
-
-SBError
-SBProcess::Detach (bool keep_stopped)
-{
- SBError sb_error;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- sb_error.SetError (process_sp->Detach(keep_stopped));
- }
- else
- sb_error.SetErrorString ("SBProcess is invalid");
-
- return sb_error;
-}
-
-SBError
-SBProcess::Signal (int signo)
-{
- SBError sb_error;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- sb_error.SetError (process_sp->Signal (signo));
- }
- else
- sb_error.SetErrorString ("SBProcess is invalid");
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- SBStream sstr;
- sb_error.GetDescription (sstr);
- log->Printf ("SBProcess(%p)::Signal (signo=%i) => SBError (%p): %s",
- static_cast<void*>(process_sp.get()), signo,
- static_cast<void*>(sb_error.get()), sstr.GetData());
- }
- return sb_error;
-}
-
-SBUnixSignals
-SBProcess::GetUnixSignals()
-{
- if (auto process_sp = GetSP())
- return SBUnixSignals{process_sp};
-
- return {};
-}
-
-void
-SBProcess::SendAsyncInterrupt ()
-{
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- process_sp->SendAsyncInterrupt ();
- }
-}
-
-SBThread
-SBProcess::GetThreadByID (tid_t tid)
-{
- SBThread sb_thread;
- ThreadSP thread_sp;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- thread_sp = process_sp->GetThreadList().FindThreadByID (tid, can_update);
- sb_thread.SetThread (thread_sp);
- }
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%4.4" PRIx64 ") => SBThread (%p)",
- static_cast<void*>(process_sp.get()), tid,
- static_cast<void*>(thread_sp.get()));
-
- return sb_thread;
-}
-
-SBThread
-SBProcess::GetThreadByIndexID (uint32_t index_id)
-{
- SBThread sb_thread;
- ThreadSP thread_sp;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- thread_sp = process_sp->GetThreadList().FindThreadByIndexID (index_id, can_update);
- sb_thread.SetThread (thread_sp);
- }
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%x) => SBThread (%p)",
- static_cast<void*>(process_sp.get()), index_id,
- static_cast<void*>(thread_sp.get()));
-
- return sb_thread;
-}
-
-StateType
-SBProcess::GetStateFromEvent (const SBEvent &event)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- StateType ret_val = Process::ProcessEventData::GetStateFromEvent (event.get());
-
- if (log)
- log->Printf ("SBProcess::GetStateFromEvent (event.sp=%p) => %s",
- static_cast<void*>(event.get()),
- lldb_private::StateAsCString (ret_val));
-
- return ret_val;
-}
-
-bool
-SBProcess::GetRestartedFromEvent (const SBEvent &event)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- bool ret_val = Process::ProcessEventData::GetRestartedFromEvent (event.get());
-
- if (log)
- log->Printf ("SBProcess::%s (event.sp=%p) => %d", __FUNCTION__,
- static_cast<void*>(event.get()), ret_val);
-
- return ret_val;
-}
-
-size_t
-SBProcess::GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event)
-{
- return Process::ProcessEventData::GetNumRestartedReasons(event.get());
-}
-
-const char *
-SBProcess::GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx)
-{
- return Process::ProcessEventData::GetRestartedReasonAtIndex(event.get(), idx);
-}
-
-SBProcess
-SBProcess::GetProcessFromEvent (const SBEvent &event)
-{
- ProcessSP process_sp =
- Process::ProcessEventData::GetProcessFromEvent (event.get());
- if (!process_sp)
- {
- // StructuredData events also know the process they come from.
- // Try that.
- process_sp = EventDataStructuredData::GetProcessFromEvent(event.get());
- }
-
- return SBProcess(process_sp);
-}
-
-bool
-SBProcess::GetInterruptedFromEvent (const SBEvent &event)
-{
- return Process::ProcessEventData::GetInterruptedFromEvent(event.get());
+bool SBProcess::GetInterruptedFromEvent(const SBEvent &event) {
+ return Process::ProcessEventData::GetInterruptedFromEvent(event.get());
}
lldb::SBStructuredData
-SBProcess::GetStructuredDataFromEvent (const lldb::SBEvent &event)
-{
- return SBStructuredData(event.GetSP());
+SBProcess::GetStructuredDataFromEvent(const lldb::SBEvent &event) {
+ return SBStructuredData(event.GetSP());
}
-bool
-SBProcess::EventIsProcessEvent (const SBEvent &event)
-{
- return (event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass()) &&
- !EventIsStructuredDataEvent (event);
-}
+bool SBProcess::EventIsProcessEvent(const SBEvent &event) {
+ return (event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass()) &&
+ !EventIsStructuredDataEvent(event);
+}
+
+bool SBProcess::EventIsStructuredDataEvent(const lldb::SBEvent &event) {
+ EventSP event_sp = event.GetSP();
+ EventData *event_data = event_sp ? event_sp->GetData() : nullptr;
+ return event_data && (event_data->GetFlavor() ==
+ EventDataStructuredData::GetFlavorString());
+}
+
+SBBroadcaster SBProcess::GetBroadcaster() const {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ ProcessSP process_sp(GetSP());
+
+ SBBroadcaster broadcaster(process_sp.get(), false);
+
+ if (log)
+ log->Printf("SBProcess(%p)::GetBroadcaster () => SBBroadcaster (%p)",
+ static_cast<void *>(process_sp.get()),
+ static_cast<void *>(broadcaster.get()));
+
+ return broadcaster;
+}
+
+const char *SBProcess::GetBroadcasterClass() {
+ return Process::GetStaticBroadcasterClass().AsCString();
+}
+
+size_t SBProcess::ReadMemory(addr_t addr, void *dst, size_t dst_len,
+ SBError &sb_error) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ size_t bytes_read = 0;
+
+ ProcessSP process_sp(GetSP());
+
+ if (log)
+ log->Printf("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64
+ ", dst=%p, dst_len=%" PRIu64 ", SBError (%p))...",
+ static_cast<void *>(process_sp.get()), addr,
+ static_cast<void *>(dst), static_cast<uint64_t>(dst_len),
+ static_cast<void *>(sb_error.get()));
+
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ bytes_read = process_sp->ReadMemory(addr, dst, dst_len, sb_error.ref());
+ } else {
+ if (log)
+ log->Printf("SBProcess(%p)::ReadMemory() => error: process is running",
+ static_cast<void *>(process_sp.get()));
+ sb_error.SetErrorString("process is running");
+ }
+ } else {
+ sb_error.SetErrorString("SBProcess is invalid");
+ }
+
+ if (log) {
+ SBStream sstr;
+ sb_error.GetDescription(sstr);
+ log->Printf("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64
+ ", dst=%p, dst_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64,
+ static_cast<void *>(process_sp.get()), addr,
+ static_cast<void *>(dst), static_cast<uint64_t>(dst_len),
+ static_cast<void *>(sb_error.get()), sstr.GetData(),
+ static_cast<uint64_t>(bytes_read));
+ }
+
+ return bytes_read;
+}
+
+size_t SBProcess::ReadCStringFromMemory(addr_t addr, void *buf, size_t size,
+ lldb::SBError &sb_error) {
+ size_t bytes_read = 0;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ bytes_read = process_sp->ReadCStringFromMemory(addr, (char *)buf, size,
+ sb_error.ref());
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::ReadCStringFromMemory() => error: process "
+ "is running",
+ static_cast<void *>(process_sp.get()));
+ sb_error.SetErrorString("process is running");
+ }
+ } else {
+ sb_error.SetErrorString("SBProcess is invalid");
+ }
+ return bytes_read;
+}
+
+uint64_t SBProcess::ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size,
+ lldb::SBError &sb_error) {
+ uint64_t value = 0;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ value = process_sp->ReadUnsignedIntegerFromMemory(addr, byte_size, 0,
+ sb_error.ref());
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::ReadUnsignedFromMemory() => error: process "
+ "is running",
+ static_cast<void *>(process_sp.get()));
+ sb_error.SetErrorString("process is running");
+ }
+ } else {
+ sb_error.SetErrorString("SBProcess is invalid");
+ }
+ return value;
+}
+
+lldb::addr_t SBProcess::ReadPointerFromMemory(addr_t addr,
+ lldb::SBError &sb_error) {
+ lldb::addr_t ptr = LLDB_INVALID_ADDRESS;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ ptr = process_sp->ReadPointerFromMemory(addr, sb_error.ref());
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::ReadPointerFromMemory() => error: process "
+ "is running",
+ static_cast<void *>(process_sp.get()));
+ sb_error.SetErrorString("process is running");
+ }
+ } else {
+ sb_error.SetErrorString("SBProcess is invalid");
+ }
+ return ptr;
+}
+
+size_t SBProcess::WriteMemory(addr_t addr, const void *src, size_t src_len,
+ SBError &sb_error) {
+ size_t bytes_written = 0;
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ ProcessSP process_sp(GetSP());
+
+ if (log)
+ log->Printf("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64
+ ", src=%p, src_len=%" PRIu64 ", SBError (%p))...",
+ static_cast<void *>(process_sp.get()), addr,
+ static_cast<const void *>(src), static_cast<uint64_t>(src_len),
+ static_cast<void *>(sb_error.get()));
+
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ bytes_written =
+ process_sp->WriteMemory(addr, src, src_len, sb_error.ref());
+ } else {
+ if (log)
+ log->Printf("SBProcess(%p)::WriteMemory() => error: process is running",
+ static_cast<void *>(process_sp.get()));
+ sb_error.SetErrorString("process is running");
+ }
+ }
+
+ if (log) {
+ SBStream sstr;
+ sb_error.GetDescription(sstr);
+ log->Printf("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64
+ ", src=%p, src_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64,
+ static_cast<void *>(process_sp.get()), addr,
+ static_cast<const void *>(src), static_cast<uint64_t>(src_len),
+ static_cast<void *>(sb_error.get()), sstr.GetData(),
+ static_cast<uint64_t>(bytes_written));
+ }
+
+ return bytes_written;
+}
+
+bool SBProcess::GetDescription(SBStream &description) {
+ Stream &strm = description.ref();
+
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ char path[PATH_MAX];
+ GetTarget().GetExecutable().GetPath(path, sizeof(path));
+ Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
+ const char *exe_name = NULL;
+ if (exe_module)
+ exe_name = exe_module->GetFileSpec().GetFilename().AsCString();
+
+ strm.Printf("SBProcess: pid = %" PRIu64 ", state = %s, threads = %d%s%s",
+ process_sp->GetID(), lldb_private::StateAsCString(GetState()),
+ GetNumThreads(), exe_name ? ", executable = " : "",
+ exe_name ? exe_name : "");
+ } else
+ strm.PutCString("No value");
-bool
-SBProcess::EventIsStructuredDataEvent (const lldb::SBEvent &event)
-{
- EventSP event_sp = event.GetSP();
- EventData *event_data = event_sp ? event_sp->GetData() : nullptr;
- return event_data &&
- (event_data->GetFlavor() == EventDataStructuredData::GetFlavorString());
-}
-
-SBBroadcaster
-SBProcess::GetBroadcaster () const
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- ProcessSP process_sp(GetSP());
-
- SBBroadcaster broadcaster(process_sp.get(), false);
-
- if (log)
- log->Printf ("SBProcess(%p)::GetBroadcaster () => SBBroadcaster (%p)",
- static_cast<void*>(process_sp.get()),
- static_cast<void*>(broadcaster.get()));
-
- return broadcaster;
-}
-
-const char *
-SBProcess::GetBroadcasterClass ()
-{
- return Process::GetStaticBroadcasterClass().AsCString();
-}
-
-size_t
-SBProcess::ReadMemory (addr_t addr, void *dst, size_t dst_len, SBError &sb_error)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- size_t bytes_read = 0;
-
- ProcessSP process_sp(GetSP());
-
- if (log)
- log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64 ", dst=%p, dst_len=%" PRIu64 ", SBError (%p))...",
- static_cast<void*>(process_sp.get()), addr,
- static_cast<void*>(dst), static_cast<uint64_t>(dst_len),
- static_cast<void*>(sb_error.get()));
-
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&process_sp->GetRunLock()))
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- bytes_read = process_sp->ReadMemory (addr, dst, dst_len, sb_error.ref());
- }
- else
- {
- if (log)
- log->Printf ("SBProcess(%p)::ReadMemory() => error: process is running",
- static_cast<void*>(process_sp.get()));
- sb_error.SetErrorString("process is running");
- }
- }
- else
- {
- sb_error.SetErrorString ("SBProcess is invalid");
- }
-
- if (log)
- {
- SBStream sstr;
- sb_error.GetDescription (sstr);
- log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64 ", dst=%p, dst_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64,
- static_cast<void*>(process_sp.get()), addr,
- static_cast<void*>(dst), static_cast<uint64_t>(dst_len),
- static_cast<void*>(sb_error.get()), sstr.GetData(),
- static_cast<uint64_t>(bytes_read));
- }
-
- return bytes_read;
-}
-
-size_t
-SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &sb_error)
-{
- size_t bytes_read = 0;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&process_sp->GetRunLock()))
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- bytes_read = process_sp->ReadCStringFromMemory (addr, (char *)buf, size, sb_error.ref());
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::ReadCStringFromMemory() => error: process is running",
- static_cast<void*>(process_sp.get()));
- sb_error.SetErrorString("process is running");
- }
- }
- else
- {
- sb_error.SetErrorString ("SBProcess is invalid");
- }
- return bytes_read;
-}
-
-uint64_t
-SBProcess::ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &sb_error)
-{
- uint64_t value = 0;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&process_sp->GetRunLock()))
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- value = process_sp->ReadUnsignedIntegerFromMemory (addr, byte_size, 0, sb_error.ref());
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::ReadUnsignedFromMemory() => error: process is running",
- static_cast<void*>(process_sp.get()));
- sb_error.SetErrorString("process is running");
- }
- }
- else
- {
- sb_error.SetErrorString ("SBProcess is invalid");
- }
- return value;
-}
-
-lldb::addr_t
-SBProcess::ReadPointerFromMemory (addr_t addr, lldb::SBError &sb_error)
-{
- lldb::addr_t ptr = LLDB_INVALID_ADDRESS;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&process_sp->GetRunLock()))
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- ptr = process_sp->ReadPointerFromMemory (addr, sb_error.ref());
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::ReadPointerFromMemory() => error: process is running",
- static_cast<void*>(process_sp.get()));
- sb_error.SetErrorString("process is running");
- }
- }
- else
- {
- sb_error.SetErrorString ("SBProcess is invalid");
- }
- return ptr;
-}
-
-size_t
-SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &sb_error)
-{
- size_t bytes_written = 0;
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- ProcessSP process_sp(GetSP());
-
- if (log)
- log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64 ", src=%p, src_len=%" PRIu64 ", SBError (%p))...",
- static_cast<void*>(process_sp.get()), addr,
- static_cast<const void*>(src),
- static_cast<uint64_t>(src_len),
- static_cast<void*>(sb_error.get()));
-
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&process_sp->GetRunLock()))
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- bytes_written = process_sp->WriteMemory (addr, src, src_len, sb_error.ref());
- }
- else
- {
- if (log)
- log->Printf ("SBProcess(%p)::WriteMemory() => error: process is running",
- static_cast<void*>(process_sp.get()));
- sb_error.SetErrorString("process is running");
- }
- }
-
- if (log)
- {
- SBStream sstr;
- sb_error.GetDescription (sstr);
- log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64 ", src=%p, src_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64,
- static_cast<void*>(process_sp.get()), addr,
- static_cast<const void*>(src),
- static_cast<uint64_t>(src_len),
- static_cast<void*>(sb_error.get()), sstr.GetData(),
- static_cast<uint64_t>(bytes_written));
- }
-
- return bytes_written;
-}
-
-bool
-SBProcess::GetDescription (SBStream &description)
-{
- Stream &strm = description.ref();
-
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- char path[PATH_MAX];
- GetTarget().GetExecutable().GetPath (path, sizeof(path));
- Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
- const char *exe_name = NULL;
- if (exe_module)
- exe_name = exe_module->GetFileSpec().GetFilename().AsCString();
-
- strm.Printf ("SBProcess: pid = %" PRIu64 ", state = %s, threads = %d%s%s",
- process_sp->GetID(),
- lldb_private::StateAsCString (GetState()),
- GetNumThreads(),
- exe_name ? ", executable = " : "",
- exe_name ? exe_name : "");
- }
- else
- strm.PutCString ("No value");
-
- return true;
-}
-
-uint32_t
-SBProcess::GetNumSupportedHardwareWatchpoints (lldb::SBError &sb_error) const
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- uint32_t num = 0;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- sb_error.SetError(process_sp->GetWatchpointSupportInfo (num));
- if (log)
- log->Printf ("SBProcess(%p)::GetNumSupportedHardwareWatchpoints () => %u",
- static_cast<void*>(process_sp.get()), num);
- }
- else
- {
- sb_error.SetErrorString ("SBProcess is invalid");
- }
- return num;
+ return true;
}
uint32_t
-SBProcess::LoadImage (lldb::SBFileSpec &sb_remote_image_spec, lldb::SBError &sb_error)
-{
- return LoadImage(SBFileSpec(), sb_remote_image_spec, sb_error);
-}
-
-uint32_t
-SBProcess::LoadImage (const lldb::SBFileSpec &sb_local_image_spec,
- const lldb::SBFileSpec &sb_remote_image_spec,
- lldb::SBError &sb_error)
-{
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&process_sp->GetRunLock()))
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
- return platform_sp->LoadImage (process_sp.get(),
- *sb_local_image_spec,
- *sb_remote_image_spec,
- sb_error.ref());
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::LoadImage() => error: process is running",
- static_cast<void*>(process_sp.get()));
- sb_error.SetErrorString("process is running");
- }
- }
- return LLDB_INVALID_IMAGE_TOKEN;
-}
-
-lldb::SBError
-SBProcess::UnloadImage (uint32_t image_token)
-{
- lldb::SBError sb_error;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&process_sp->GetRunLock()))
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
- sb_error.SetError (platform_sp->UnloadImage (process_sp.get(), image_token));
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::UnloadImage() => error: process is running",
- static_cast<void*>(process_sp.get()));
- sb_error.SetErrorString("process is running");
- }
- }
- else
- sb_error.SetErrorString("invalid process");
- return sb_error;
-}
+SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-lldb::SBError
-SBProcess::SendEventData (const char *event_data)
-{
- lldb::SBError sb_error;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&process_sp->GetRunLock()))
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- sb_error.SetError (process_sp->SendEventData (event_data));
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::SendEventData() => error: process is running",
- static_cast<void*>(process_sp.get()));
- sb_error.SetErrorString("process is running");
- }
- }
- else
- sb_error.SetErrorString("invalid process");
- return sb_error;
-}
+ uint32_t num = 0;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ sb_error.SetError(process_sp->GetWatchpointSupportInfo(num));
+ if (log)
+ log->Printf("SBProcess(%p)::GetNumSupportedHardwareWatchpoints () => %u",
+ static_cast<void *>(process_sp.get()), num);
+ } else {
+ sb_error.SetErrorString("SBProcess is invalid");
+ }
+ return num;
+}
+
+uint32_t SBProcess::LoadImage(lldb::SBFileSpec &sb_remote_image_spec,
+ lldb::SBError &sb_error) {
+ return LoadImage(SBFileSpec(), sb_remote_image_spec, sb_error);
+}
+
+uint32_t SBProcess::LoadImage(const lldb::SBFileSpec &sb_local_image_spec,
+ const lldb::SBFileSpec &sb_remote_image_spec,
+ lldb::SBError &sb_error) {
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
+ return platform_sp->LoadImage(process_sp.get(), *sb_local_image_spec,
+ *sb_remote_image_spec, sb_error.ref());
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::LoadImage() => error: process is running",
+ static_cast<void *>(process_sp.get()));
+ sb_error.SetErrorString("process is running");
+ }
+ }
+ return LLDB_INVALID_IMAGE_TOKEN;
+}
+
+lldb::SBError SBProcess::UnloadImage(uint32_t image_token) {
+ lldb::SBError sb_error;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
+ sb_error.SetError(
+ platform_sp->UnloadImage(process_sp.get(), image_token));
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::UnloadImage() => error: process is running",
+ static_cast<void *>(process_sp.get()));
+ sb_error.SetErrorString("process is running");
+ }
+ } else
+ sb_error.SetErrorString("invalid process");
+ return sb_error;
+}
+
+lldb::SBError SBProcess::SendEventData(const char *event_data) {
+ lldb::SBError sb_error;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ sb_error.SetError(process_sp->SendEventData(event_data));
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf(
+ "SBProcess(%p)::SendEventData() => error: process is running",
+ static_cast<void *>(process_sp.get()));
+ sb_error.SetErrorString("process is running");
+ }
+ } else
+ sb_error.SetErrorString("invalid process");
+ return sb_error;
+}
+
+uint32_t SBProcess::GetNumExtendedBacktraceTypes() {
+ ProcessSP process_sp(GetSP());
+ if (process_sp && process_sp->GetSystemRuntime()) {
+ SystemRuntime *runtime = process_sp->GetSystemRuntime();
+ return runtime->GetExtendedBacktraceTypes().size();
+ }
+ return 0;
+}
+
+const char *SBProcess::GetExtendedBacktraceTypeAtIndex(uint32_t idx) {
+ ProcessSP process_sp(GetSP());
+ if (process_sp && process_sp->GetSystemRuntime()) {
+ SystemRuntime *runtime = process_sp->GetSystemRuntime();
+ const std::vector<ConstString> &names =
+ runtime->GetExtendedBacktraceTypes();
+ if (idx < names.size()) {
+ return names[idx].AsCString();
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBProcess(%p)::GetExtendedBacktraceTypeAtIndex() => "
+ "error: requested extended backtrace name out of bounds",
+ static_cast<void *>(process_sp.get()));
+ }
+ }
+ return NULL;
+}
+
+SBThreadCollection SBProcess::GetHistoryThreads(addr_t addr) {
+ ProcessSP process_sp(GetSP());
+ SBThreadCollection threads;
+ if (process_sp) {
+ threads = SBThreadCollection(process_sp->GetHistoryThreads(addr));
+ }
+ return threads;
+}
+
+bool SBProcess::IsInstrumentationRuntimePresent(
+ InstrumentationRuntimeType type) {
+ ProcessSP process_sp(GetSP());
+ if (!process_sp)
+ return false;
-uint32_t
-SBProcess::GetNumExtendedBacktraceTypes ()
-{
- ProcessSP process_sp(GetSP());
- if (process_sp && process_sp->GetSystemRuntime())
- {
- SystemRuntime *runtime = process_sp->GetSystemRuntime();
- return runtime->GetExtendedBacktraceTypes().size();
- }
- return 0;
-}
+ InstrumentationRuntimeSP runtime_sp =
+ process_sp->GetInstrumentationRuntime(type);
-const char *
-SBProcess::GetExtendedBacktraceTypeAtIndex (uint32_t idx)
-{
- ProcessSP process_sp(GetSP());
- if (process_sp && process_sp->GetSystemRuntime())
- {
- SystemRuntime *runtime = process_sp->GetSystemRuntime();
- const std::vector<ConstString> &names = runtime->GetExtendedBacktraceTypes();
- if (idx < names.size())
- {
- return names[idx].AsCString();
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::GetExtendedBacktraceTypeAtIndex() => error: requested extended backtrace name out of bounds",
- static_cast<void*>(process_sp.get()));
- }
- }
- return NULL;
-}
-
-SBThreadCollection
-SBProcess::GetHistoryThreads (addr_t addr)
-{
- ProcessSP process_sp(GetSP());
- SBThreadCollection threads;
- if (process_sp)
- {
- threads = SBThreadCollection(process_sp->GetHistoryThreads(addr));
- }
- return threads;
-}
+ if (!runtime_sp.get())
+ return false;
-bool
-SBProcess::IsInstrumentationRuntimePresent(InstrumentationRuntimeType type)
-{
- ProcessSP process_sp(GetSP());
- if (! process_sp)
- return false;
-
- InstrumentationRuntimeSP runtime_sp = process_sp->GetInstrumentationRuntime(type);
-
- if (! runtime_sp.get())
- return false;
-
- return runtime_sp->IsActive();
+ return runtime_sp->IsActive();
}
-lldb::SBError
-SBProcess::SaveCore(const char *file_name)
-{
- lldb::SBError error;
- ProcessSP process_sp(GetSP());
- if (!process_sp)
- {
- error.SetErrorString("SBProcess is invalid");
- return error;
- }
-
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
+lldb::SBError SBProcess::SaveCore(const char *file_name) {
+ lldb::SBError error;
+ ProcessSP process_sp(GetSP());
+ if (!process_sp) {
+ error.SetErrorString("SBProcess is invalid");
+ return error;
+ }
- if (process_sp->GetState() != eStateStopped)
- {
- error.SetErrorString("the process is not stopped");
- return error;
- }
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
- FileSpec core_file(file_name, false);
- error.ref() = PluginManager::SaveCore(process_sp, core_file);
+ if (process_sp->GetState() != eStateStopped) {
+ error.SetErrorString("the process is not stopped");
return error;
-}
+ }
-lldb::SBError
-SBProcess::GetMemoryRegionInfo (lldb::addr_t load_addr, SBMemoryRegionInfo &sb_region_info)
-{
- lldb::SBError sb_error;
- ProcessSP process_sp(GetSP());
- MemoryRegionInfoSP region_info_sp = std::make_shared<lldb_private::MemoryRegionInfo>();
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&process_sp->GetRunLock()))
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- sb_error.ref() = process_sp->GetMemoryRegionInfo(load_addr, *region_info_sp);
- if( sb_error.Success() ) {
- sb_region_info.ref() = *region_info_sp;
- }
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetMemoryRegionInfo() => error: process is running",
- static_cast<void*>(process_sp.get()));
- sb_error.SetErrorString("process is running");
- }
- }
- else
- {
- sb_error.SetErrorString ("SBProcess is invalid");
- }
- return sb_error;
+ FileSpec core_file(file_name, false);
+ error.ref() = PluginManager::SaveCore(process_sp, core_file);
+ return error;
}
-lldb::SBMemoryRegionInfoList
-SBProcess::GetMemoryRegions()
-{
- lldb::SBError sb_error;
- lldb::SBMemoryRegionInfoList sb_region_list;
- ProcessSP process_sp(GetSP());
- if (process_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&process_sp->GetRunLock()))
- {
- std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
- std::vector<MemoryRegionInfoSP> region_list;
- sb_error.ref() = process_sp->GetMemoryRegions(region_list);
- if( sb_error.Success() ) {
- std::vector<MemoryRegionInfoSP>::iterator end = region_list.end();
- for( std::vector<MemoryRegionInfoSP>::iterator it = region_list.begin(); it != end; it++ ) {
- SBMemoryRegionInfo sb_region_info(it->get());
- sb_region_list.Append(sb_region_info);
- }
- }
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBProcess(%p)::GetMemoryRegionInfo() => error: process is running",
- static_cast<void*>(process_sp.get()));
- sb_error.SetErrorString("process is running");
- }
- }
- else
- {
- sb_error.SetErrorString ("SBProcess is invalid");
- }
- return sb_region_list;
+lldb::SBError
+SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr,
+ SBMemoryRegionInfo &sb_region_info) {
+ lldb::SBError sb_error;
+ ProcessSP process_sp(GetSP());
+ MemoryRegionInfoSP region_info_sp =
+ std::make_shared<lldb_private::MemoryRegionInfo>();
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ sb_error.ref() =
+ process_sp->GetMemoryRegionInfo(load_addr, *region_info_sp);
+ if (sb_error.Success()) {
+ sb_region_info.ref() = *region_info_sp;
+ }
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf(
+ "SBProcess(%p)::GetMemoryRegionInfo() => error: process is running",
+ static_cast<void *>(process_sp.get()));
+ sb_error.SetErrorString("process is running");
+ }
+ } else {
+ sb_error.SetErrorString("SBProcess is invalid");
+ }
+ return sb_error;
+}
+
+lldb::SBMemoryRegionInfoList SBProcess::GetMemoryRegions() {
+ lldb::SBError sb_error;
+ lldb::SBMemoryRegionInfoList sb_region_list;
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ std::vector<MemoryRegionInfoSP> region_list;
+ sb_error.ref() = process_sp->GetMemoryRegions(region_list);
+ if (sb_error.Success()) {
+ std::vector<MemoryRegionInfoSP>::iterator end = region_list.end();
+ for (std::vector<MemoryRegionInfoSP>::iterator it = region_list.begin();
+ it != end; it++) {
+ SBMemoryRegionInfo sb_region_info(it->get());
+ sb_region_list.Append(sb_region_info);
+ }
+ }
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf(
+ "SBProcess(%p)::GetMemoryRegionInfo() => error: process is running",
+ static_cast<void *>(process_sp.get()));
+ sb_error.SetErrorString("process is running");
+ }
+ } else {
+ sb_error.SetErrorString("SBProcess is invalid");
+ }
+ return sb_region_list;
}
Modified: lldb/trunk/source/API/SBQueue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBQueue.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBQueue.cpp (original)
+++ lldb/trunk/source/API/SBQueue.cpp Tue Sep 6 15:57:50 2016
@@ -12,8 +12,8 @@
#include "lldb/API/SBQueue.h"
#include "lldb/API/SBProcess.h"
-#include "lldb/API/SBThread.h"
#include "lldb/API/SBQueueItem.h"
+#include "lldb/API/SBThread.h"
#include "lldb/Core/Log.h"
#include "lldb/Target/Process.h"
@@ -24,427 +24,324 @@
using namespace lldb;
using namespace lldb_private;
-namespace lldb_private
-{
-
- class QueueImpl
- {
- public:
- QueueImpl () :
- m_queue_wp(),
- m_threads(),
- m_thread_list_fetched(false),
- m_pending_items(),
- m_pending_items_fetched(false)
- {
- }
-
- QueueImpl (const lldb::QueueSP &queue_sp) :
- m_queue_wp(),
- m_threads(),
- m_thread_list_fetched(false),
- m_pending_items(),
- m_pending_items_fetched(false)
- {
- m_queue_wp = queue_sp;
- }
-
- QueueImpl (const QueueImpl &rhs)
- {
- if (&rhs == this)
- return;
- m_queue_wp = rhs.m_queue_wp;
- m_threads = rhs.m_threads;
- m_thread_list_fetched = rhs.m_thread_list_fetched;
- m_pending_items = rhs.m_pending_items;
- m_pending_items_fetched = rhs.m_pending_items_fetched;
- }
-
- ~QueueImpl ()
- {
- }
-
- bool
- IsValid ()
- {
- return m_queue_wp.lock() != NULL;
- }
-
- void
- Clear ()
- {
- m_queue_wp.reset();
- m_thread_list_fetched = false;
- m_threads.clear();
- m_pending_items_fetched = false;
- m_pending_items.clear();
- }
-
- void
- SetQueue (const lldb::QueueSP &queue_sp)
- {
- Clear();
- m_queue_wp = queue_sp;
- }
-
- lldb::queue_id_t
- GetQueueID () const
- {
- lldb::queue_id_t result = LLDB_INVALID_QUEUE_ID;
- lldb::QueueSP queue_sp = m_queue_wp.lock();
- if (queue_sp)
- {
- result = queue_sp->GetID();
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBQueue(%p)::GetQueueID () => 0x%" PRIx64,
- static_cast<const void*>(this), result);
- return result;
- }
-
- uint32_t
- GetIndexID () const
- {
- uint32_t result = LLDB_INVALID_INDEX32;
- lldb::QueueSP queue_sp = m_queue_wp.lock();
- if (queue_sp)
- {
- result = queue_sp->GetIndexID();
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBQueueImpl(%p)::GetIndexID () => %d",
- static_cast<const void*>(this), result);
- return result;
- }
-
- const char *
- GetName () const
- {
- const char *name = NULL;
- lldb::QueueSP queue_sp = m_queue_wp.lock ();
- if (queue_sp.get())
- {
- name = queue_sp->GetName();
- }
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBQueueImpl(%p)::GetName () => %s",
- static_cast<const void*>(this),
- name ? name : "NULL");
-
- return name;
- }
-
- void
- FetchThreads ()
- {
- if (m_thread_list_fetched == false)
- {
- lldb::QueueSP queue_sp = m_queue_wp.lock();
- if (queue_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock (&queue_sp->GetProcess()->GetRunLock()))
- {
- const std::vector<ThreadSP> thread_list(queue_sp->GetThreads());
- m_thread_list_fetched = true;
- const uint32_t num_threads = thread_list.size();
- for (uint32_t idx = 0; idx < num_threads; ++idx)
- {
- ThreadSP thread_sp = thread_list[idx];
- if (thread_sp && thread_sp->IsValid())
- {
- m_threads.push_back (thread_sp);
- }
- }
- }
- }
- }
- }
-
- void
- FetchItems ()
- {
- if (m_pending_items_fetched == false)
- {
- QueueSP queue_sp = m_queue_wp.lock();
- if (queue_sp)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock (&queue_sp->GetProcess()->GetRunLock()))
- {
- const std::vector<QueueItemSP> queue_items(queue_sp->GetPendingItems());
- m_pending_items_fetched = true;
- const uint32_t num_pending_items = queue_items.size();
- for (uint32_t idx = 0; idx < num_pending_items; ++idx)
- {
- QueueItemSP item = queue_items[idx];
- if (item && item->IsValid())
- {
- m_pending_items.push_back (item);
- }
- }
- }
- }
- }
- }
-
- uint32_t
- GetNumThreads ()
- {
- uint32_t result = 0;
-
- FetchThreads();
- if (m_thread_list_fetched)
- {
- result = m_threads.size();
- }
- return result;
- }
-
- lldb::SBThread
- GetThreadAtIndex (uint32_t idx)
- {
- FetchThreads();
-
- SBThread sb_thread;
- QueueSP queue_sp = m_queue_wp.lock();
- if (queue_sp && idx < m_threads.size())
- {
- ProcessSP process_sp = queue_sp->GetProcess();
- if (process_sp)
- {
- ThreadSP thread_sp = m_threads[idx].lock();
- if (thread_sp)
- {
- sb_thread.SetThread (thread_sp);
- }
- }
- }
- return sb_thread;
- }
-
- uint32_t
- GetNumPendingItems ()
- {
- uint32_t result = 0;
-
- QueueSP queue_sp = m_queue_wp.lock();
- if (m_pending_items_fetched == false && queue_sp)
- {
- result = queue_sp->GetNumPendingWorkItems();
- }
- else
- {
- result = m_pending_items.size();
- }
- return result;
- }
-
- lldb::SBQueueItem
- GetPendingItemAtIndex (uint32_t idx)
- {
- SBQueueItem result;
- FetchItems();
- if (m_pending_items_fetched && idx < m_pending_items.size())
- {
- result.SetQueueItem (m_pending_items[idx]);
- }
- return result;
- }
-
- uint32_t
- GetNumRunningItems ()
- {
- uint32_t result = 0;
- QueueSP queue_sp = m_queue_wp.lock();
- if (queue_sp)
- result = queue_sp->GetNumRunningWorkItems();
- return result;
- }
-
- lldb::SBProcess
- GetProcess ()
- {
- SBProcess result;
- QueueSP queue_sp = m_queue_wp.lock();
- if (queue_sp)
- {
- result.SetSP (queue_sp->GetProcess());
- }
- return result;
- }
-
- lldb::QueueKind
- GetKind ()
- {
- lldb::QueueKind kind = eQueueKindUnknown;
- QueueSP queue_sp = m_queue_wp.lock();
- if (queue_sp)
- kind = queue_sp->GetKind();
-
- return kind;
- }
-
- private:
- lldb::QueueWP m_queue_wp;
- std::vector<lldb::ThreadWP> m_threads; // threads currently executing this queue's items
- bool m_thread_list_fetched; // have we tried to fetch the threads list already?
- std::vector<lldb::QueueItemSP> m_pending_items; // items currently enqueued
- bool m_pending_items_fetched; // have we tried to fetch the item list already?
- };
-
-}
-
-SBQueue::SBQueue () :
- m_opaque_sp (new QueueImpl())
-{
-}
+namespace lldb_private {
-SBQueue::SBQueue (const QueueSP& queue_sp) :
- m_opaque_sp (new QueueImpl (queue_sp))
-{
-}
+class QueueImpl {
+public:
+ QueueImpl()
+ : m_queue_wp(), m_threads(), m_thread_list_fetched(false),
+ m_pending_items(), m_pending_items_fetched(false) {}
+
+ QueueImpl(const lldb::QueueSP &queue_sp)
+ : m_queue_wp(), m_threads(), m_thread_list_fetched(false),
+ m_pending_items(), m_pending_items_fetched(false) {
+ m_queue_wp = queue_sp;
+ }
-SBQueue::SBQueue (const SBQueue &rhs)
-{
+ QueueImpl(const QueueImpl &rhs) {
if (&rhs == this)
- return;
-
- m_opaque_sp = rhs.m_opaque_sp;
-}
-
-const lldb::SBQueue &
-SBQueue::operator = (const lldb::SBQueue &rhs)
-{
- m_opaque_sp = rhs.m_opaque_sp;
- return *this;
-}
-
-SBQueue::~SBQueue()
-{
-}
-
-bool
-SBQueue::IsValid() const
-{
- bool is_valid = m_opaque_sp->IsValid ();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::IsValid() == %s", m_opaque_sp->GetQueueID(),
- is_valid ? "true" : "false");
- return is_valid;
-}
-
-
-void
-SBQueue::Clear ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ return;
+ m_queue_wp = rhs.m_queue_wp;
+ m_threads = rhs.m_threads;
+ m_thread_list_fetched = rhs.m_thread_list_fetched;
+ m_pending_items = rhs.m_pending_items;
+ m_pending_items_fetched = rhs.m_pending_items_fetched;
+ }
+
+ ~QueueImpl() {}
+
+ bool IsValid() { return m_queue_wp.lock() != NULL; }
+
+ void Clear() {
+ m_queue_wp.reset();
+ m_thread_list_fetched = false;
+ m_threads.clear();
+ m_pending_items_fetched = false;
+ m_pending_items.clear();
+ }
+
+ void SetQueue(const lldb::QueueSP &queue_sp) {
+ Clear();
+ m_queue_wp = queue_sp;
+ }
+
+ lldb::queue_id_t GetQueueID() const {
+ lldb::queue_id_t result = LLDB_INVALID_QUEUE_ID;
+ lldb::QueueSP queue_sp = m_queue_wp.lock();
+ if (queue_sp) {
+ result = queue_sp->GetID();
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::Clear()", m_opaque_sp->GetQueueID());
- m_opaque_sp->Clear();
-}
-
-
-void
-SBQueue::SetQueue (const QueueSP& queue_sp)
-{
- m_opaque_sp->SetQueue (queue_sp);
-}
-
-lldb::queue_id_t
-SBQueue::GetQueueID () const
-{
- lldb::queue_id_t qid = m_opaque_sp->GetQueueID ();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ log->Printf("SBQueue(%p)::GetQueueID () => 0x%" PRIx64,
+ static_cast<const void *>(this), result);
+ return result;
+ }
+
+ uint32_t GetIndexID() const {
+ uint32_t result = LLDB_INVALID_INDEX32;
+ lldb::QueueSP queue_sp = m_queue_wp.lock();
+ if (queue_sp) {
+ result = queue_sp->GetIndexID();
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetQueueID() == 0x%" PRIx64, m_opaque_sp->GetQueueID(), (uint64_t) qid);
- return qid;
-}
+ log->Printf("SBQueueImpl(%p)::GetIndexID () => %d",
+ static_cast<const void *>(this), result);
+ return result;
+ }
+
+ const char *GetName() const {
+ const char *name = NULL;
+ lldb::QueueSP queue_sp = m_queue_wp.lock();
+ if (queue_sp.get()) {
+ name = queue_sp->GetName();
+ }
-uint32_t
-SBQueue::GetIndexID () const
-{
- uint32_t index_id = m_opaque_sp->GetIndexID ();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetIndexID() == 0x%" PRIx32, m_opaque_sp->GetQueueID(), index_id);
- return index_id;
-}
+ log->Printf("SBQueueImpl(%p)::GetName () => %s",
+ static_cast<const void *>(this), name ? name : "NULL");
-const char *
-SBQueue::GetName () const
-{
- const char *name = m_opaque_sp->GetName ();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetName() == %s", m_opaque_sp->GetQueueID(),
- name ? name : "");
return name;
-}
-
-uint32_t
-SBQueue::GetNumThreads ()
-{
- uint32_t numthreads = m_opaque_sp->GetNumThreads ();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetNumThreads() == %d", m_opaque_sp->GetQueueID(), numthreads);
- return numthreads;
-}
-
-SBThread
-SBQueue::GetThreadAtIndex (uint32_t idx)
-{
- SBThread th = m_opaque_sp->GetThreadAtIndex (idx);
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetThreadAtIndex(%d)", m_opaque_sp->GetQueueID(), idx);
- return th;
-}
-
-
-uint32_t
-SBQueue::GetNumPendingItems ()
-{
- uint32_t pending_items = m_opaque_sp->GetNumPendingItems ();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetNumPendingItems() == %d", m_opaque_sp->GetQueueID(), pending_items);
- return pending_items;
-}
+ }
-SBQueueItem
-SBQueue::GetPendingItemAtIndex (uint32_t idx)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetPendingItemAtIndex(%d)", m_opaque_sp->GetQueueID(), idx);
- return m_opaque_sp->GetPendingItemAtIndex (idx);
-}
-
-uint32_t
-SBQueue::GetNumRunningItems ()
-{
- uint32_t running_items = m_opaque_sp->GetNumRunningItems ();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetNumRunningItems() == %d", m_opaque_sp->GetQueueID(), running_items);
- return running_items;
+ void FetchThreads() {
+ if (m_thread_list_fetched == false) {
+ lldb::QueueSP queue_sp = m_queue_wp.lock();
+ if (queue_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&queue_sp->GetProcess()->GetRunLock())) {
+ const std::vector<ThreadSP> thread_list(queue_sp->GetThreads());
+ m_thread_list_fetched = true;
+ const uint32_t num_threads = thread_list.size();
+ for (uint32_t idx = 0; idx < num_threads; ++idx) {
+ ThreadSP thread_sp = thread_list[idx];
+ if (thread_sp && thread_sp->IsValid()) {
+ m_threads.push_back(thread_sp);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ void FetchItems() {
+ if (m_pending_items_fetched == false) {
+ QueueSP queue_sp = m_queue_wp.lock();
+ if (queue_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&queue_sp->GetProcess()->GetRunLock())) {
+ const std::vector<QueueItemSP> queue_items(
+ queue_sp->GetPendingItems());
+ m_pending_items_fetched = true;
+ const uint32_t num_pending_items = queue_items.size();
+ for (uint32_t idx = 0; idx < num_pending_items; ++idx) {
+ QueueItemSP item = queue_items[idx];
+ if (item && item->IsValid()) {
+ m_pending_items.push_back(item);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ uint32_t GetNumThreads() {
+ uint32_t result = 0;
+
+ FetchThreads();
+ if (m_thread_list_fetched) {
+ result = m_threads.size();
+ }
+ return result;
+ }
+
+ lldb::SBThread GetThreadAtIndex(uint32_t idx) {
+ FetchThreads();
+
+ SBThread sb_thread;
+ QueueSP queue_sp = m_queue_wp.lock();
+ if (queue_sp && idx < m_threads.size()) {
+ ProcessSP process_sp = queue_sp->GetProcess();
+ if (process_sp) {
+ ThreadSP thread_sp = m_threads[idx].lock();
+ if (thread_sp) {
+ sb_thread.SetThread(thread_sp);
+ }
+ }
+ }
+ return sb_thread;
+ }
+
+ uint32_t GetNumPendingItems() {
+ uint32_t result = 0;
+
+ QueueSP queue_sp = m_queue_wp.lock();
+ if (m_pending_items_fetched == false && queue_sp) {
+ result = queue_sp->GetNumPendingWorkItems();
+ } else {
+ result = m_pending_items.size();
+ }
+ return result;
+ }
+
+ lldb::SBQueueItem GetPendingItemAtIndex(uint32_t idx) {
+ SBQueueItem result;
+ FetchItems();
+ if (m_pending_items_fetched && idx < m_pending_items.size()) {
+ result.SetQueueItem(m_pending_items[idx]);
+ }
+ return result;
+ }
+
+ uint32_t GetNumRunningItems() {
+ uint32_t result = 0;
+ QueueSP queue_sp = m_queue_wp.lock();
+ if (queue_sp)
+ result = queue_sp->GetNumRunningWorkItems();
+ return result;
+ }
+
+ lldb::SBProcess GetProcess() {
+ SBProcess result;
+ QueueSP queue_sp = m_queue_wp.lock();
+ if (queue_sp) {
+ result.SetSP(queue_sp->GetProcess());
+ }
+ return result;
+ }
+
+ lldb::QueueKind GetKind() {
+ lldb::QueueKind kind = eQueueKindUnknown;
+ QueueSP queue_sp = m_queue_wp.lock();
+ if (queue_sp)
+ kind = queue_sp->GetKind();
+
+ return kind;
+ }
+
+private:
+ lldb::QueueWP m_queue_wp;
+ std::vector<lldb::ThreadWP>
+ m_threads; // threads currently executing this queue's items
+ bool
+ m_thread_list_fetched; // have we tried to fetch the threads list already?
+ std::vector<lldb::QueueItemSP> m_pending_items; // items currently enqueued
+ bool m_pending_items_fetched; // have we tried to fetch the item list already?
+};
+}
+
+SBQueue::SBQueue() : m_opaque_sp(new QueueImpl()) {}
+
+SBQueue::SBQueue(const QueueSP &queue_sp)
+ : m_opaque_sp(new QueueImpl(queue_sp)) {}
+
+SBQueue::SBQueue(const SBQueue &rhs) {
+ if (&rhs == this)
+ return;
+
+ m_opaque_sp = rhs.m_opaque_sp;
+}
+
+const lldb::SBQueue &SBQueue::operator=(const lldb::SBQueue &rhs) {
+ m_opaque_sp = rhs.m_opaque_sp;
+ return *this;
+}
+
+SBQueue::~SBQueue() {}
+
+bool SBQueue::IsValid() const {
+ bool is_valid = m_opaque_sp->IsValid();
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBQueue(0x%" PRIx64 ")::IsValid() == %s",
+ m_opaque_sp->GetQueueID(), is_valid ? "true" : "false");
+ return is_valid;
+}
+
+void SBQueue::Clear() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBQueue(0x%" PRIx64 ")::Clear()", m_opaque_sp->GetQueueID());
+ m_opaque_sp->Clear();
+}
+
+void SBQueue::SetQueue(const QueueSP &queue_sp) {
+ m_opaque_sp->SetQueue(queue_sp);
+}
+
+lldb::queue_id_t SBQueue::GetQueueID() const {
+ lldb::queue_id_t qid = m_opaque_sp->GetQueueID();
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBQueue(0x%" PRIx64 ")::GetQueueID() == 0x%" PRIx64,
+ m_opaque_sp->GetQueueID(), (uint64_t)qid);
+ return qid;
+}
+
+uint32_t SBQueue::GetIndexID() const {
+ uint32_t index_id = m_opaque_sp->GetIndexID();
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBQueue(0x%" PRIx64 ")::GetIndexID() == 0x%" PRIx32,
+ m_opaque_sp->GetQueueID(), index_id);
+ return index_id;
+}
+
+const char *SBQueue::GetName() const {
+ const char *name = m_opaque_sp->GetName();
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBQueue(0x%" PRIx64 ")::GetName() == %s",
+ m_opaque_sp->GetQueueID(), name ? name : "");
+ return name;
+}
+
+uint32_t SBQueue::GetNumThreads() {
+ uint32_t numthreads = m_opaque_sp->GetNumThreads();
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBQueue(0x%" PRIx64 ")::GetNumThreads() == %d",
+ m_opaque_sp->GetQueueID(), numthreads);
+ return numthreads;
+}
+
+SBThread SBQueue::GetThreadAtIndex(uint32_t idx) {
+ SBThread th = m_opaque_sp->GetThreadAtIndex(idx);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBQueue(0x%" PRIx64 ")::GetThreadAtIndex(%d)",
+ m_opaque_sp->GetQueueID(), idx);
+ return th;
+}
+
+uint32_t SBQueue::GetNumPendingItems() {
+ uint32_t pending_items = m_opaque_sp->GetNumPendingItems();
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBQueue(0x%" PRIx64 ")::GetNumPendingItems() == %d",
+ m_opaque_sp->GetQueueID(), pending_items);
+ return pending_items;
+}
+
+SBQueueItem SBQueue::GetPendingItemAtIndex(uint32_t idx) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBQueue(0x%" PRIx64 ")::GetPendingItemAtIndex(%d)",
+ m_opaque_sp->GetQueueID(), idx);
+ return m_opaque_sp->GetPendingItemAtIndex(idx);
+}
+
+uint32_t SBQueue::GetNumRunningItems() {
+ uint32_t running_items = m_opaque_sp->GetNumRunningItems();
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBQueue(0x%" PRIx64 ")::GetNumRunningItems() == %d",
+ m_opaque_sp->GetQueueID(), running_items);
+ return running_items;
}
-SBProcess
-SBQueue::GetProcess ()
-{
- return m_opaque_sp->GetProcess();
-}
+SBProcess SBQueue::GetProcess() { return m_opaque_sp->GetProcess(); }
-lldb::QueueKind
-SBQueue::GetKind ()
-{
- return m_opaque_sp->GetKind();
-}
+lldb::QueueKind SBQueue::GetKind() { return m_opaque_sp->GetKind(); }
Modified: lldb/trunk/source/API/SBQueueItem.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBQueueItem.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBQueueItem.cpp (original)
+++ lldb/trunk/source/API/SBQueueItem.cpp Tue Sep 6 15:57:50 2016
@@ -24,144 +24,111 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// Constructors
//----------------------------------------------------------------------
-SBQueueItem::SBQueueItem () :
- m_queue_item_sp()
-{
-}
+SBQueueItem::SBQueueItem() : m_queue_item_sp() {}
-SBQueueItem::SBQueueItem (const QueueItemSP& queue_item_sp) :
- m_queue_item_sp (queue_item_sp)
-{
-}
+SBQueueItem::SBQueueItem(const QueueItemSP &queue_item_sp)
+ : m_queue_item_sp(queue_item_sp) {}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-SBQueueItem::~SBQueueItem()
-{
- m_queue_item_sp.reset();
-}
-
-bool
-SBQueueItem::IsValid() const
-{
- bool is_valid = m_queue_item_sp.get() != NULL;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueueItem(%p)::IsValid() == %s",
- static_cast<void*>(m_queue_item_sp.get()),
- is_valid ? "true" : "false");
- return is_valid;
-}
-
-
-void
-SBQueueItem::Clear ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueueItem(%p)::Clear()",
- static_cast<void*>(m_queue_item_sp.get()));
- m_queue_item_sp.reset();
-}
-
-
-void
-SBQueueItem::SetQueueItem (const QueueItemSP& queue_item_sp)
-{
- m_queue_item_sp = queue_item_sp;
-}
-
-
-lldb::QueueItemKind
-SBQueueItem::GetKind () const
-{
- QueueItemKind result = eQueueItemKindUnknown;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (m_queue_item_sp)
- {
- result = m_queue_item_sp->GetKind ();
- }
- if (log)
- log->Printf("SBQueueItem(%p)::GetKind() == %d",
- static_cast<void*>(m_queue_item_sp.get()),
- static_cast<int>(result));
- return result;
-}
-
-void
-SBQueueItem::SetKind (lldb::QueueItemKind kind)
-{
- if (m_queue_item_sp)
- {
- m_queue_item_sp->SetKind (kind);
- }
-}
-
-SBAddress
-SBQueueItem::GetAddress () const
-{
- SBAddress result;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (m_queue_item_sp)
- {
- result.SetAddress (&m_queue_item_sp->GetAddress());
- }
- if (log)
- {
- StreamString sstr;
- const Address *addr = result.get();
- if (addr)
- addr->Dump (&sstr, NULL, Address::DumpStyleModuleWithFileAddress, Address::DumpStyleInvalid, 4);
- log->Printf ("SBQueueItem(%p)::GetAddress() == SBAddress(%p): %s",
- static_cast<void*>(m_queue_item_sp.get()),
- static_cast<void*>(result.get()), sstr.GetData());
- }
- return result;
-}
-
-void
-SBQueueItem::SetAddress (SBAddress addr)
-{
- if (m_queue_item_sp)
- {
- m_queue_item_sp->SetAddress (addr.ref());
- }
-}
+SBQueueItem::~SBQueueItem() { m_queue_item_sp.reset(); }
-SBThread
-SBQueueItem::GetExtendedBacktraceThread (const char *type)
-{
- SBThread result;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (m_queue_item_sp)
- {
- ProcessSP process_sp = m_queue_item_sp->GetProcessSP();
- Process::StopLocker stop_locker;
- if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock()))
- {
- ThreadSP thread_sp;
- ConstString type_const (type);
- thread_sp = m_queue_item_sp->GetExtendedBacktraceThread (type_const);
- if (thread_sp)
- {
- // Save this in the Process' ExtendedThreadList so a strong pointer retains the
- // object
- process_sp->GetExtendedThreadList().AddThread (thread_sp);
- result.SetThread (thread_sp);
- if (log)
- {
- const char *queue_name = thread_sp->GetQueueName();
- if (queue_name == NULL)
- queue_name = "";
- log->Printf ("SBQueueItem(%p)::GetExtendedBacktraceThread() = new extended Thread created (%p) with queue_id 0x%" PRIx64 " queue name '%s'",
- static_cast<void*>(m_queue_item_sp.get()),
- static_cast<void*>(thread_sp.get()),
- static_cast<uint64_t>(thread_sp->GetQueueID()),
- queue_name);
- }
- }
+bool SBQueueItem::IsValid() const {
+ bool is_valid = m_queue_item_sp.get() != NULL;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBQueueItem(%p)::IsValid() == %s",
+ static_cast<void *>(m_queue_item_sp.get()),
+ is_valid ? "true" : "false");
+ return is_valid;
+}
+
+void SBQueueItem::Clear() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBQueueItem(%p)::Clear()",
+ static_cast<void *>(m_queue_item_sp.get()));
+ m_queue_item_sp.reset();
+}
+
+void SBQueueItem::SetQueueItem(const QueueItemSP &queue_item_sp) {
+ m_queue_item_sp = queue_item_sp;
+}
+
+lldb::QueueItemKind SBQueueItem::GetKind() const {
+ QueueItemKind result = eQueueItemKindUnknown;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (m_queue_item_sp) {
+ result = m_queue_item_sp->GetKind();
+ }
+ if (log)
+ log->Printf("SBQueueItem(%p)::GetKind() == %d",
+ static_cast<void *>(m_queue_item_sp.get()),
+ static_cast<int>(result));
+ return result;
+}
+
+void SBQueueItem::SetKind(lldb::QueueItemKind kind) {
+ if (m_queue_item_sp) {
+ m_queue_item_sp->SetKind(kind);
+ }
+}
+
+SBAddress SBQueueItem::GetAddress() const {
+ SBAddress result;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (m_queue_item_sp) {
+ result.SetAddress(&m_queue_item_sp->GetAddress());
+ }
+ if (log) {
+ StreamString sstr;
+ const Address *addr = result.get();
+ if (addr)
+ addr->Dump(&sstr, NULL, Address::DumpStyleModuleWithFileAddress,
+ Address::DumpStyleInvalid, 4);
+ log->Printf("SBQueueItem(%p)::GetAddress() == SBAddress(%p): %s",
+ static_cast<void *>(m_queue_item_sp.get()),
+ static_cast<void *>(result.get()), sstr.GetData());
+ }
+ return result;
+}
+
+void SBQueueItem::SetAddress(SBAddress addr) {
+ if (m_queue_item_sp) {
+ m_queue_item_sp->SetAddress(addr.ref());
+ }
+}
+
+SBThread SBQueueItem::GetExtendedBacktraceThread(const char *type) {
+ SBThread result;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (m_queue_item_sp) {
+ ProcessSP process_sp = m_queue_item_sp->GetProcessSP();
+ Process::StopLocker stop_locker;
+ if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock())) {
+ ThreadSP thread_sp;
+ ConstString type_const(type);
+ thread_sp = m_queue_item_sp->GetExtendedBacktraceThread(type_const);
+ if (thread_sp) {
+ // Save this in the Process' ExtendedThreadList so a strong pointer
+ // retains the
+ // object
+ process_sp->GetExtendedThreadList().AddThread(thread_sp);
+ result.SetThread(thread_sp);
+ if (log) {
+ const char *queue_name = thread_sp->GetQueueName();
+ if (queue_name == NULL)
+ queue_name = "";
+ log->Printf(
+ "SBQueueItem(%p)::GetExtendedBacktraceThread() = new extended "
+ "Thread created (%p) with queue_id 0x%" PRIx64 " queue name '%s'",
+ static_cast<void *>(m_queue_item_sp.get()),
+ static_cast<void *>(thread_sp.get()),
+ static_cast<uint64_t>(thread_sp->GetQueueID()), queue_name);
}
+ }
}
- return result;
+ }
+ return result;
}
Modified: lldb/trunk/source/API/SBSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSection.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSection.cpp (original)
+++ lldb/trunk/source/API/SBSection.cpp Tue Sep 6 15:57:50 2016
@@ -18,282 +18,209 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/ObjectFile.h"
-
using namespace lldb;
using namespace lldb_private;
+SBSection::SBSection() : m_opaque_wp() {}
-SBSection::SBSection () :
- m_opaque_wp ()
-{
-}
-
-SBSection::SBSection (const SBSection &rhs) :
- m_opaque_wp (rhs.m_opaque_wp)
-{
-}
-
-
-
-SBSection::SBSection (const lldb::SectionSP §ion_sp) :
- m_opaque_wp () // Don't init with section_sp otherwise this will throw if section_sp doesn't contain a valid Section *
-{
- if (section_sp)
- m_opaque_wp = section_sp;
-}
-
-const SBSection &
-SBSection::operator = (const SBSection &rhs)
-{
- m_opaque_wp = rhs.m_opaque_wp;
- return *this;
-}
-
-SBSection::~SBSection ()
-{
-}
-
-bool
-SBSection::IsValid () const
-{
- SectionSP section_sp (GetSP());
- return section_sp && section_sp->GetModule().get() != NULL;
-}
-
-const char *
-SBSection::GetName ()
-{
- SectionSP section_sp (GetSP());
- if (section_sp)
- return section_sp->GetName().GetCString();
- return NULL;
-}
-
-lldb::SBSection
-SBSection::GetParent()
-{
- lldb::SBSection sb_section;
- SectionSP section_sp (GetSP());
- if (section_sp)
- {
- SectionSP parent_section_sp (section_sp->GetParent());
- if (parent_section_sp)
- sb_section.SetSP(parent_section_sp);
- }
- return sb_section;
-}
-
-
-lldb::SBSection
-SBSection::FindSubSection (const char *sect_name)
-{
- lldb::SBSection sb_section;
- if (sect_name)
- {
- SectionSP section_sp (GetSP());
- if (section_sp)
- {
- ConstString const_sect_name(sect_name);
- sb_section.SetSP(section_sp->GetChildren ().FindSectionByName(const_sect_name));
- }
- }
- return sb_section;
-}
-
-size_t
-SBSection::GetNumSubSections ()
-{
- SectionSP section_sp (GetSP());
- if (section_sp)
- return section_sp->GetChildren ().GetSize();
- return 0;
-}
-
-lldb::SBSection
-SBSection::GetSubSectionAtIndex (size_t idx)
-{
- lldb::SBSection sb_section;
- SectionSP section_sp (GetSP());
- if (section_sp)
- sb_section.SetSP (section_sp->GetChildren ().GetSectionAtIndex(idx));
- return sb_section;
-}
-
-lldb::SectionSP
-SBSection::GetSP() const
-{
- return m_opaque_wp.lock();
-}
+SBSection::SBSection(const SBSection &rhs) : m_opaque_wp(rhs.m_opaque_wp) {}
-void
-SBSection::SetSP(const lldb::SectionSP §ion_sp)
+SBSection::SBSection(const lldb::SectionSP §ion_sp)
+ : m_opaque_wp() // Don't init with section_sp otherwise this will throw if
+ // section_sp doesn't contain a valid Section *
{
+ if (section_sp)
m_opaque_wp = section_sp;
}
-lldb::addr_t
-SBSection::GetFileAddress ()
-{
- lldb::addr_t file_addr = LLDB_INVALID_ADDRESS;
- SectionSP section_sp (GetSP());
- if (section_sp)
- return section_sp->GetFileAddress();
- return file_addr;
-}
-
-lldb::addr_t
-SBSection::GetLoadAddress (lldb::SBTarget &sb_target)
-{
- TargetSP target_sp(sb_target.GetSP());
- if (target_sp)
- {
- SectionSP section_sp (GetSP());
- if (section_sp)
- return section_sp->GetLoadBaseAddress(target_sp.get());
- }
- return LLDB_INVALID_ADDRESS;
-
-}
-
-
-
-lldb::addr_t
-SBSection::GetByteSize ()
-{
- SectionSP section_sp (GetSP());
- if (section_sp)
- return section_sp->GetByteSize();
- return 0;
-}
-
-uint64_t
-SBSection::GetFileOffset ()
-{
- SectionSP section_sp (GetSP());
- if (section_sp)
- {
- ModuleSP module_sp (section_sp->GetModule());
- if (module_sp)
- {
- ObjectFile *objfile = module_sp->GetObjectFile();
- if (objfile)
- return objfile->GetFileOffset() + section_sp->GetFileOffset();
- }
- }
- return UINT64_MAX;
-}
-
-uint64_t
-SBSection::GetFileByteSize ()
-{
- SectionSP section_sp (GetSP());
- if (section_sp)
- return section_sp->GetFileSize();
- return 0;
-}
+const SBSection &SBSection::operator=(const SBSection &rhs) {
+ m_opaque_wp = rhs.m_opaque_wp;
+ return *this;
+}
+
+SBSection::~SBSection() {}
+
+bool SBSection::IsValid() const {
+ SectionSP section_sp(GetSP());
+ return section_sp && section_sp->GetModule().get() != NULL;
+}
+
+const char *SBSection::GetName() {
+ SectionSP section_sp(GetSP());
+ if (section_sp)
+ return section_sp->GetName().GetCString();
+ return NULL;
+}
+
+lldb::SBSection SBSection::GetParent() {
+ lldb::SBSection sb_section;
+ SectionSP section_sp(GetSP());
+ if (section_sp) {
+ SectionSP parent_section_sp(section_sp->GetParent());
+ if (parent_section_sp)
+ sb_section.SetSP(parent_section_sp);
+ }
+ return sb_section;
+}
+
+lldb::SBSection SBSection::FindSubSection(const char *sect_name) {
+ lldb::SBSection sb_section;
+ if (sect_name) {
+ SectionSP section_sp(GetSP());
+ if (section_sp) {
+ ConstString const_sect_name(sect_name);
+ sb_section.SetSP(
+ section_sp->GetChildren().FindSectionByName(const_sect_name));
+ }
+ }
+ return sb_section;
+}
+
+size_t SBSection::GetNumSubSections() {
+ SectionSP section_sp(GetSP());
+ if (section_sp)
+ return section_sp->GetChildren().GetSize();
+ return 0;
+}
+
+lldb::SBSection SBSection::GetSubSectionAtIndex(size_t idx) {
+ lldb::SBSection sb_section;
+ SectionSP section_sp(GetSP());
+ if (section_sp)
+ sb_section.SetSP(section_sp->GetChildren().GetSectionAtIndex(idx));
+ return sb_section;
+}
+
+lldb::SectionSP SBSection::GetSP() const { return m_opaque_wp.lock(); }
+
+void SBSection::SetSP(const lldb::SectionSP §ion_sp) {
+ m_opaque_wp = section_sp;
+}
+
+lldb::addr_t SBSection::GetFileAddress() {
+ lldb::addr_t file_addr = LLDB_INVALID_ADDRESS;
+ SectionSP section_sp(GetSP());
+ if (section_sp)
+ return section_sp->GetFileAddress();
+ return file_addr;
+}
+
+lldb::addr_t SBSection::GetLoadAddress(lldb::SBTarget &sb_target) {
+ TargetSP target_sp(sb_target.GetSP());
+ if (target_sp) {
+ SectionSP section_sp(GetSP());
+ if (section_sp)
+ return section_sp->GetLoadBaseAddress(target_sp.get());
+ }
+ return LLDB_INVALID_ADDRESS;
+}
+
+lldb::addr_t SBSection::GetByteSize() {
+ SectionSP section_sp(GetSP());
+ if (section_sp)
+ return section_sp->GetByteSize();
+ return 0;
+}
+
+uint64_t SBSection::GetFileOffset() {
+ SectionSP section_sp(GetSP());
+ if (section_sp) {
+ ModuleSP module_sp(section_sp->GetModule());
+ if (module_sp) {
+ ObjectFile *objfile = module_sp->GetObjectFile();
+ if (objfile)
+ return objfile->GetFileOffset() + section_sp->GetFileOffset();
+ }
+ }
+ return UINT64_MAX;
+}
+
+uint64_t SBSection::GetFileByteSize() {
+ SectionSP section_sp(GetSP());
+ if (section_sp)
+ return section_sp->GetFileSize();
+ return 0;
+}
+
+SBData SBSection::GetSectionData() { return GetSectionData(0, UINT64_MAX); }
+
+SBData SBSection::GetSectionData(uint64_t offset, uint64_t size) {
+ SBData sb_data;
+ SectionSP section_sp(GetSP());
+ if (section_sp) {
+ const uint64_t sect_file_size = section_sp->GetFileSize();
+ if (sect_file_size > 0) {
+ ModuleSP module_sp(section_sp->GetModule());
+ if (module_sp) {
+ ObjectFile *objfile = module_sp->GetObjectFile();
+ if (objfile) {
+ const uint64_t sect_file_offset =
+ objfile->GetFileOffset() + section_sp->GetFileOffset();
+ const uint64_t file_offset = sect_file_offset + offset;
+ uint64_t file_size = size;
+ if (file_size == UINT64_MAX) {
+ file_size = section_sp->GetByteSize();
+ if (file_size > offset)
+ file_size -= offset;
+ else
+ file_size = 0;
+ }
+ DataBufferSP data_buffer_sp(
+ objfile->GetFileSpec().ReadFileContents(file_offset, file_size));
+ if (data_buffer_sp && data_buffer_sp->GetByteSize() > 0) {
+ DataExtractorSP data_extractor_sp(
+ new DataExtractor(data_buffer_sp, objfile->GetByteOrder(),
+ objfile->GetAddressByteSize()));
-SBData
-SBSection::GetSectionData ()
-{
- return GetSectionData (0, UINT64_MAX);
-}
-
-SBData
-SBSection::GetSectionData (uint64_t offset, uint64_t size)
-{
- SBData sb_data;
- SectionSP section_sp (GetSP());
- if (section_sp)
- {
- const uint64_t sect_file_size = section_sp->GetFileSize();
- if (sect_file_size > 0)
- {
- ModuleSP module_sp (section_sp->GetModule());
- if (module_sp)
- {
- ObjectFile *objfile = module_sp->GetObjectFile();
- if (objfile)
- {
- const uint64_t sect_file_offset = objfile->GetFileOffset() + section_sp->GetFileOffset();
- const uint64_t file_offset = sect_file_offset + offset;
- uint64_t file_size = size;
- if (file_size == UINT64_MAX)
- {
- file_size = section_sp->GetByteSize();
- if (file_size > offset)
- file_size -= offset;
- else
- file_size = 0;
- }
- DataBufferSP data_buffer_sp (objfile->GetFileSpec().ReadFileContents (file_offset, file_size));
- if (data_buffer_sp && data_buffer_sp->GetByteSize() > 0)
- {
- DataExtractorSP data_extractor_sp (new DataExtractor (data_buffer_sp,
- objfile->GetByteOrder(),
- objfile->GetAddressByteSize()));
-
- sb_data.SetOpaque (data_extractor_sp);
- }
- }
- }
+ sb_data.SetOpaque(data_extractor_sp);
+ }
}
+ }
}
- return sb_data;
+ }
+ return sb_data;
}
-SectionType
-SBSection::GetSectionType ()
-{
- SectionSP section_sp (GetSP());
- if (section_sp.get())
- return section_sp->GetType();
- return eSectionTypeInvalid;
+SectionType SBSection::GetSectionType() {
+ SectionSP section_sp(GetSP());
+ if (section_sp.get())
+ return section_sp->GetType();
+ return eSectionTypeInvalid;
}
-uint32_t
-SBSection::GetTargetByteSize ()
-{
- SectionSP section_sp (GetSP());
- if (section_sp.get())
- return section_sp->GetTargetByteSize();
- return 0;
+uint32_t SBSection::GetTargetByteSize() {
+ SectionSP section_sp(GetSP());
+ if (section_sp.get())
+ return section_sp->GetTargetByteSize();
+ return 0;
}
-bool
-SBSection::operator == (const SBSection &rhs)
-{
- SectionSP lhs_section_sp (GetSP());
- SectionSP rhs_section_sp (rhs.GetSP());
- if (lhs_section_sp && rhs_section_sp)
- return lhs_section_sp == rhs_section_sp;
- return false;
+bool SBSection::operator==(const SBSection &rhs) {
+ SectionSP lhs_section_sp(GetSP());
+ SectionSP rhs_section_sp(rhs.GetSP());
+ if (lhs_section_sp && rhs_section_sp)
+ return lhs_section_sp == rhs_section_sp;
+ return false;
}
-bool
-SBSection::operator != (const SBSection &rhs)
-{
- SectionSP lhs_section_sp (GetSP());
- SectionSP rhs_section_sp (rhs.GetSP());
- return lhs_section_sp != rhs_section_sp;
+bool SBSection::operator!=(const SBSection &rhs) {
+ SectionSP lhs_section_sp(GetSP());
+ SectionSP rhs_section_sp(rhs.GetSP());
+ return lhs_section_sp != rhs_section_sp;
}
-bool
-SBSection::GetDescription (SBStream &description)
-{
- Stream &strm = description.ref();
+bool SBSection::GetDescription(SBStream &description) {
+ Stream &strm = description.ref();
- SectionSP section_sp (GetSP());
- if (section_sp)
- {
- const addr_t file_addr = section_sp->GetFileAddress();
- strm.Printf ("[0x%16.16" PRIx64 "-0x%16.16" PRIx64 ") ", file_addr, file_addr + section_sp->GetByteSize());
- section_sp->DumpName(&strm);
- }
- else
- {
- strm.PutCString ("No value");
- }
+ SectionSP section_sp(GetSP());
+ if (section_sp) {
+ const addr_t file_addr = section_sp->GetFileAddress();
+ strm.Printf("[0x%16.16" PRIx64 "-0x%16.16" PRIx64 ") ", file_addr,
+ file_addr + section_sp->GetByteSize());
+ section_sp->DumpName(&strm);
+ } else {
+ strm.PutCString("No value");
+ }
- return true;
+ return true;
}
-
Modified: lldb/trunk/source/API/SBSourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSourceManager.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSourceManager.cpp (original)
+++ lldb/trunk/source/API/SBSourceManager.cpp Tue Sep 6 15:57:50 2016
@@ -7,138 +7,99 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBSourceManager.h"
-#include "lldb/API/SBTarget.h"
+#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBTarget.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/Core/Debugger.h"
+#include "lldb/Core/SourceManager.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/SourceManager.h"
#include "lldb/Target/Target.h"
-namespace lldb_private
-{
- class SourceManagerImpl
- {
- public:
- SourceManagerImpl (const lldb::DebuggerSP &debugger_sp) :
- m_debugger_wp (debugger_sp),
- m_target_wp ()
- {
- }
-
- SourceManagerImpl (const lldb::TargetSP &target_sp) :
- m_debugger_wp (),
- m_target_wp (target_sp)
- {
- }
-
- SourceManagerImpl (const SourceManagerImpl &rhs)
- {
- if (&rhs == this)
- return;
- m_debugger_wp = rhs.m_debugger_wp;
- m_target_wp = rhs.m_target_wp;
- }
-
- size_t
- DisplaySourceLinesWithLineNumbers (const lldb_private::FileSpec &file,
+namespace lldb_private {
+class SourceManagerImpl {
+public:
+ SourceManagerImpl(const lldb::DebuggerSP &debugger_sp)
+ : m_debugger_wp(debugger_sp), m_target_wp() {}
+
+ SourceManagerImpl(const lldb::TargetSP &target_sp)
+ : m_debugger_wp(), m_target_wp(target_sp) {}
+
+ SourceManagerImpl(const SourceManagerImpl &rhs) {
+ if (&rhs == this)
+ return;
+ m_debugger_wp = rhs.m_debugger_wp;
+ m_target_wp = rhs.m_target_wp;
+ }
+
+ size_t DisplaySourceLinesWithLineNumbers(const lldb_private::FileSpec &file,
uint32_t line,
uint32_t context_before,
uint32_t context_after,
const char *current_line_cstr,
- lldb_private::Stream *s)
- {
- if (!file)
- return 0;
-
- lldb::TargetSP target_sp (m_target_wp.lock());
- if (target_sp)
- {
- return target_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (file,
- line,
- context_before,
- context_after,
- current_line_cstr,
- s);
- }
- else
- {
- lldb::DebuggerSP debugger_sp (m_debugger_wp.lock());
- if (debugger_sp)
- {
- return debugger_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (file,
- line,
- context_before,
- context_after,
- current_line_cstr,
- s);
- }
- }
- return 0;
- }
-
- private:
- lldb::DebuggerWP m_debugger_wp;
- lldb::TargetWP m_target_wp;
-
- };
+ lldb_private::Stream *s) {
+ if (!file)
+ return 0;
+
+ lldb::TargetSP target_sp(m_target_wp.lock());
+ if (target_sp) {
+ return target_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers(
+ file, line, context_before, context_after, current_line_cstr, s);
+ } else {
+ lldb::DebuggerSP debugger_sp(m_debugger_wp.lock());
+ if (debugger_sp) {
+ return debugger_sp->GetSourceManager()
+ .DisplaySourceLinesWithLineNumbers(file, line, context_before,
+ context_after, current_line_cstr,
+ s);
+ }
+ }
+ return 0;
+ }
+
+private:
+ lldb::DebuggerWP m_debugger_wp;
+ lldb::TargetWP m_target_wp;
+};
}
using namespace lldb;
using namespace lldb_private;
-SBSourceManager::SBSourceManager (const SBDebugger &debugger)
-{
- m_opaque_ap.reset(new SourceManagerImpl (debugger.get_sp()));
+SBSourceManager::SBSourceManager(const SBDebugger &debugger) {
+ m_opaque_ap.reset(new SourceManagerImpl(debugger.get_sp()));
}
-SBSourceManager::SBSourceManager (const SBTarget &target)
-{
- m_opaque_ap.reset(new SourceManagerImpl (target.GetSP()));
+SBSourceManager::SBSourceManager(const SBTarget &target) {
+ m_opaque_ap.reset(new SourceManagerImpl(target.GetSP()));
}
-SBSourceManager::SBSourceManager (const SBSourceManager &rhs)
-{
- if (&rhs == this)
- return;
-
- m_opaque_ap.reset(new SourceManagerImpl (*(rhs.m_opaque_ap.get())));
-}
-
-const lldb::SBSourceManager &
-SBSourceManager::operator = (const lldb::SBSourceManager &rhs)
-{
- m_opaque_ap.reset (new SourceManagerImpl (*(rhs.m_opaque_ap.get())));
- return *this;
-}
-
-SBSourceManager::~SBSourceManager()
-{
-}
-
-size_t
-SBSourceManager::DisplaySourceLinesWithLineNumbers
-(
- const SBFileSpec &file,
- uint32_t line,
- uint32_t context_before,
- uint32_t context_after,
- const char *current_line_cstr,
- SBStream &s
-)
-{
- if (m_opaque_ap.get() == NULL)
- return 0;
-
- return m_opaque_ap->DisplaySourceLinesWithLineNumbers (file.ref(),
- line,
- context_before,
- context_after,
- current_line_cstr,
- s.get());
+SBSourceManager::SBSourceManager(const SBSourceManager &rhs) {
+ if (&rhs == this)
+ return;
+
+ m_opaque_ap.reset(new SourceManagerImpl(*(rhs.m_opaque_ap.get())));
+}
+
+const lldb::SBSourceManager &SBSourceManager::
+operator=(const lldb::SBSourceManager &rhs) {
+ m_opaque_ap.reset(new SourceManagerImpl(*(rhs.m_opaque_ap.get())));
+ return *this;
+}
+
+SBSourceManager::~SBSourceManager() {}
+
+size_t SBSourceManager::DisplaySourceLinesWithLineNumbers(
+ const SBFileSpec &file, uint32_t line, uint32_t context_before,
+ uint32_t context_after, const char *current_line_cstr, SBStream &s) {
+ if (m_opaque_ap.get() == NULL)
+ return 0;
+
+ return m_opaque_ap->DisplaySourceLinesWithLineNumbers(
+ file.ref(), line, context_before, context_after, current_line_cstr,
+ s.get());
}
Modified: lldb/trunk/source/API/SBStream.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBStream.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBStream.cpp (original)
+++ lldb/trunk/source/API/SBStream.cpp Tue Sep 6 15:57:50 2016
@@ -17,186 +17,141 @@
using namespace lldb;
using namespace lldb_private;
-SBStream::SBStream () :
- m_opaque_ap (new StreamString()),
- m_is_file (false)
-{
-}
+SBStream::SBStream() : m_opaque_ap(new StreamString()), m_is_file(false) {}
-SBStream::SBStream (SBStream &&rhs) :
- m_opaque_ap (std::move(rhs.m_opaque_ap)),
- m_is_file (rhs.m_is_file)
-{
-}
+SBStream::SBStream(SBStream &&rhs)
+ : m_opaque_ap(std::move(rhs.m_opaque_ap)), m_is_file(rhs.m_is_file) {}
+SBStream::~SBStream() {}
-SBStream::~SBStream ()
-{
-}
-
-bool
-SBStream::IsValid() const
-{
- return (m_opaque_ap.get() != NULL);
-}
+bool SBStream::IsValid() const { return (m_opaque_ap.get() != NULL); }
// If this stream is not redirected to a file, it will maintain a local
// cache for the stream data which can be accessed using this accessor.
-const char *
-SBStream::GetData ()
-{
- if (m_is_file || m_opaque_ap.get() == NULL)
- return NULL;
-
- return static_cast<StreamString *>(m_opaque_ap.get())->GetData();
+const char *SBStream::GetData() {
+ if (m_is_file || m_opaque_ap.get() == NULL)
+ return NULL;
+
+ return static_cast<StreamString *>(m_opaque_ap.get())->GetData();
}
// If this stream is not redirected to a file, it will maintain a local
-// cache for the stream output whose length can be accessed using this
+// cache for the stream output whose length can be accessed using this
// accessor.
-size_t
-SBStream::GetSize()
-{
- if (m_is_file || m_opaque_ap.get() == NULL)
- return 0;
-
- return static_cast<StreamString *>(m_opaque_ap.get())->GetSize();
-}
-
-void
-SBStream::Printf (const char *format, ...)
-{
- if (!format)
- return;
- va_list args;
- va_start (args, format);
- ref().PrintfVarArg (format, args);
- va_end (args);
-}
-
-void
-SBStream::RedirectToFile (const char *path, bool append)
-{
- if (path == nullptr)
- return;
-
- std::string local_data;
- if (m_opaque_ap.get())
- {
- // See if we have any locally backed data. If so, copy it so we can then
- // redirect it to the file so we don't lose the data
- if (!m_is_file)
- local_data.swap(static_cast<StreamString *>(m_opaque_ap.get())->GetString());
- }
- StreamFile *stream_file = new StreamFile;
- uint32_t open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate;
- if (append)
- open_options |= File::eOpenOptionAppend;
- else
- open_options |= File::eOpenOptionTruncate;
- stream_file->GetFile().Open (path, open_options, lldb::eFilePermissionsFileDefault);
-
- m_opaque_ap.reset (stream_file);
-
- if (m_opaque_ap.get())
- {
- m_is_file = true;
-
- // If we had any data locally in our StreamString, then pass that along to
- // the to new file we are redirecting to.
- if (!local_data.empty())
- m_opaque_ap->Write (&local_data[0], local_data.size());
- }
+size_t SBStream::GetSize() {
+ if (m_is_file || m_opaque_ap.get() == NULL)
+ return 0;
+
+ return static_cast<StreamString *>(m_opaque_ap.get())->GetSize();
+}
+
+void SBStream::Printf(const char *format, ...) {
+ if (!format)
+ return;
+ va_list args;
+ va_start(args, format);
+ ref().PrintfVarArg(format, args);
+ va_end(args);
+}
+
+void SBStream::RedirectToFile(const char *path, bool append) {
+ if (path == nullptr)
+ return;
+
+ std::string local_data;
+ if (m_opaque_ap.get()) {
+ // See if we have any locally backed data. If so, copy it so we can then
+ // redirect it to the file so we don't lose the data
+ if (!m_is_file)
+ local_data.swap(
+ static_cast<StreamString *>(m_opaque_ap.get())->GetString());
+ }
+ StreamFile *stream_file = new StreamFile;
+ uint32_t open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate;
+ if (append)
+ open_options |= File::eOpenOptionAppend;
+ else
+ open_options |= File::eOpenOptionTruncate;
+ stream_file->GetFile().Open(path, open_options,
+ lldb::eFilePermissionsFileDefault);
+
+ m_opaque_ap.reset(stream_file);
+
+ if (m_opaque_ap.get()) {
+ m_is_file = true;
+
+ // If we had any data locally in our StreamString, then pass that along to
+ // the to new file we are redirecting to.
+ if (!local_data.empty())
+ m_opaque_ap->Write(&local_data[0], local_data.size());
+ } else
+ m_is_file = false;
+}
+
+void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) {
+ if (fh == nullptr)
+ return;
+
+ std::string local_data;
+ if (m_opaque_ap.get()) {
+ // See if we have any locally backed data. If so, copy it so we can then
+ // redirect it to the file so we don't lose the data
+ if (!m_is_file)
+ local_data.swap(
+ static_cast<StreamString *>(m_opaque_ap.get())->GetString());
+ }
+ m_opaque_ap.reset(new StreamFile(fh, transfer_fh_ownership));
+
+ if (m_opaque_ap.get()) {
+ m_is_file = true;
+
+ // If we had any data locally in our StreamString, then pass that along to
+ // the to new file we are redirecting to.
+ if (!local_data.empty())
+ m_opaque_ap->Write(&local_data[0], local_data.size());
+ } else
+ m_is_file = false;
+}
+
+void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) {
+ std::string local_data;
+ if (m_opaque_ap.get()) {
+ // See if we have any locally backed data. If so, copy it so we can then
+ // redirect it to the file so we don't lose the data
+ if (!m_is_file)
+ local_data.swap(
+ static_cast<StreamString *>(m_opaque_ap.get())->GetString());
+ }
+
+ m_opaque_ap.reset(new StreamFile(::fdopen(fd, "w"), transfer_fh_ownership));
+ if (m_opaque_ap.get()) {
+ m_is_file = true;
+
+ // If we had any data locally in our StreamString, then pass that along to
+ // the to new file we are redirecting to.
+ if (!local_data.empty())
+ m_opaque_ap->Write(&local_data[0], local_data.size());
+ } else
+ m_is_file = false;
+}
+
+lldb_private::Stream *SBStream::operator->() { return m_opaque_ap.get(); }
+
+lldb_private::Stream *SBStream::get() { return m_opaque_ap.get(); }
+
+lldb_private::Stream &SBStream::ref() {
+ if (m_opaque_ap.get() == NULL)
+ m_opaque_ap.reset(new StreamString());
+ return *m_opaque_ap.get();
+}
+
+void SBStream::Clear() {
+ if (m_opaque_ap.get()) {
+ // See if we have any locally backed data. If so, copy it so we can then
+ // redirect it to the file so we don't lose the data
+ if (m_is_file)
+ m_opaque_ap.reset();
else
- m_is_file = false;
-}
-
-void
-SBStream::RedirectToFileHandle (FILE *fh, bool transfer_fh_ownership)
-{
- if (fh == nullptr)
- return;
-
- std::string local_data;
- if (m_opaque_ap.get())
- {
- // See if we have any locally backed data. If so, copy it so we can then
- // redirect it to the file so we don't lose the data
- if (!m_is_file)
- local_data.swap(static_cast<StreamString *>(m_opaque_ap.get())->GetString());
- }
- m_opaque_ap.reset (new StreamFile (fh, transfer_fh_ownership));
-
- if (m_opaque_ap.get())
- {
- m_is_file = true;
-
- // If we had any data locally in our StreamString, then pass that along to
- // the to new file we are redirecting to.
- if (!local_data.empty())
- m_opaque_ap->Write (&local_data[0], local_data.size());
- }
- else
- m_is_file = false;
-}
-
-void
-SBStream::RedirectToFileDescriptor (int fd, bool transfer_fh_ownership)
-{
- std::string local_data;
- if (m_opaque_ap.get())
- {
- // See if we have any locally backed data. If so, copy it so we can then
- // redirect it to the file so we don't lose the data
- if (!m_is_file)
- local_data.swap(static_cast<StreamString *>(m_opaque_ap.get())->GetString());
- }
-
- m_opaque_ap.reset (new StreamFile (::fdopen (fd, "w"), transfer_fh_ownership));
- if (m_opaque_ap.get())
- {
- m_is_file = true;
-
- // If we had any data locally in our StreamString, then pass that along to
- // the to new file we are redirecting to.
- if (!local_data.empty())
- m_opaque_ap->Write (&local_data[0], local_data.size());
- }
- else
- m_is_file = false;
-
-}
-
-lldb_private::Stream *
-SBStream::operator->()
-{
- return m_opaque_ap.get();
-}
-
-lldb_private::Stream *
-SBStream::get()
-{
- return m_opaque_ap.get();
-}
-
-lldb_private::Stream &
-SBStream::ref()
-{
- if (m_opaque_ap.get() == NULL)
- m_opaque_ap.reset (new StreamString());
- return *m_opaque_ap.get();
-}
-
-void
-SBStream::Clear ()
-{
- if (m_opaque_ap.get())
- {
- // See if we have any locally backed data. If so, copy it so we can then
- // redirect it to the file so we don't lose the data
- if (m_is_file)
- m_opaque_ap.reset();
- else
- static_cast<StreamString *>(m_opaque_ap.get())->GetString().clear();
- }
+ static_cast<StreamString *>(m_opaque_ap.get())->GetString().clear();
+ }
}
Modified: lldb/trunk/source/API/SBStringList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBStringList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBStringList.cpp (original)
+++ lldb/trunk/source/API/SBStringList.cpp Tue Sep 6 15:57:50 2016
@@ -14,133 +14,90 @@
using namespace lldb;
using namespace lldb_private;
-SBStringList::SBStringList () :
- m_opaque_ap ()
-{
-}
+SBStringList::SBStringList() : m_opaque_ap() {}
-SBStringList::SBStringList (const lldb_private::StringList *lldb_strings_ptr) :
- m_opaque_ap ()
-{
- if (lldb_strings_ptr)
- m_opaque_ap.reset (new lldb_private::StringList (*lldb_strings_ptr));
+SBStringList::SBStringList(const lldb_private::StringList *lldb_strings_ptr)
+ : m_opaque_ap() {
+ if (lldb_strings_ptr)
+ m_opaque_ap.reset(new lldb_private::StringList(*lldb_strings_ptr));
}
-SBStringList::SBStringList (const SBStringList &rhs) :
- m_opaque_ap ()
-{
- if (rhs.IsValid())
- m_opaque_ap.reset (new lldb_private::StringList(*rhs));
+SBStringList::SBStringList(const SBStringList &rhs) : m_opaque_ap() {
+ if (rhs.IsValid())
+ m_opaque_ap.reset(new lldb_private::StringList(*rhs));
}
-
-const SBStringList &
-SBStringList::operator = (const SBStringList &rhs)
-{
- if (this != &rhs)
- {
- if (rhs.IsValid())
- m_opaque_ap.reset(new lldb_private::StringList(*rhs));
- else
- m_opaque_ap.reset();
- }
- return *this;
-}
-
-SBStringList::~SBStringList ()
-{
+const SBStringList &SBStringList::operator=(const SBStringList &rhs) {
+ if (this != &rhs) {
+ if (rhs.IsValid())
+ m_opaque_ap.reset(new lldb_private::StringList(*rhs));
+ else
+ m_opaque_ap.reset();
+ }
+ return *this;
}
-const lldb_private::StringList *
-SBStringList::operator->() const
-{
- return m_opaque_ap.get();
-}
+SBStringList::~SBStringList() {}
-const lldb_private::StringList &
-SBStringList::operator*() const
-{
- return *m_opaque_ap;
+const lldb_private::StringList *SBStringList::operator->() const {
+ return m_opaque_ap.get();
}
-bool
-SBStringList::IsValid() const
-{
- return (m_opaque_ap.get() != NULL);
+const lldb_private::StringList &SBStringList::operator*() const {
+ return *m_opaque_ap;
}
-void
-SBStringList::AppendString (const char *str)
-{
- if (str != NULL)
- {
- if (IsValid())
- m_opaque_ap->AppendString (str);
- else
- m_opaque_ap.reset (new lldb_private::StringList (str));
- }
+bool SBStringList::IsValid() const { return (m_opaque_ap.get() != NULL); }
+void SBStringList::AppendString(const char *str) {
+ if (str != NULL) {
+ if (IsValid())
+ m_opaque_ap->AppendString(str);
+ else
+ m_opaque_ap.reset(new lldb_private::StringList(str));
+ }
}
-void
-SBStringList::AppendList (const char **strv, int strc)
-{
- if ((strv != NULL)
- && (strc > 0))
- {
- if (IsValid())
- m_opaque_ap->AppendList (strv, strc);
- else
- m_opaque_ap.reset (new lldb_private::StringList (strv, strc));
- }
+void SBStringList::AppendList(const char **strv, int strc) {
+ if ((strv != NULL) && (strc > 0)) {
+ if (IsValid())
+ m_opaque_ap->AppendList(strv, strc);
+ else
+ m_opaque_ap.reset(new lldb_private::StringList(strv, strc));
+ }
}
-void
-SBStringList::AppendList (const SBStringList &strings)
-{
- if (strings.IsValid())
- {
- if (! IsValid())
- m_opaque_ap.reset (new lldb_private::StringList());
- m_opaque_ap->AppendList (*(strings.m_opaque_ap));
- }
+void SBStringList::AppendList(const SBStringList &strings) {
+ if (strings.IsValid()) {
+ if (!IsValid())
+ m_opaque_ap.reset(new lldb_private::StringList());
+ m_opaque_ap->AppendList(*(strings.m_opaque_ap));
+ }
}
-uint32_t
-SBStringList::GetSize () const
-{
- if (IsValid())
- {
- return m_opaque_ap->GetSize();
- }
- return 0;
+uint32_t SBStringList::GetSize() const {
+ if (IsValid()) {
+ return m_opaque_ap->GetSize();
+ }
+ return 0;
}
-const char *
-SBStringList::GetStringAtIndex (size_t idx)
-{
- if (IsValid())
- {
- return m_opaque_ap->GetStringAtIndex (idx);
- }
- return NULL;
+const char *SBStringList::GetStringAtIndex(size_t idx) {
+ if (IsValid()) {
+ return m_opaque_ap->GetStringAtIndex(idx);
+ }
+ return NULL;
}
-const char *
-SBStringList::GetStringAtIndex (size_t idx) const
-{
- if (IsValid())
- {
- return m_opaque_ap->GetStringAtIndex (idx);
- }
- return NULL;
+const char *SBStringList::GetStringAtIndex(size_t idx) const {
+ if (IsValid()) {
+ return m_opaque_ap->GetStringAtIndex(idx);
+ }
+ return NULL;
}
-void
-SBStringList::Clear ()
-{
- if (IsValid())
- {
- m_opaque_ap->Clear();
- }
+void SBStringList::Clear() {
+ if (IsValid()) {
+ m_opaque_ap->Clear();
+ }
}
Modified: lldb/trunk/source/API/SBStructuredData.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBStructuredData.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBStructuredData.cpp (original)
+++ lldb/trunk/source/API/SBStructuredData.cpp Tue Sep 6 15:57:50 2016
@@ -19,147 +19,101 @@
using namespace lldb;
using namespace lldb_private;
-#pragma mark --
+#pragma mark--
#pragma mark Impl
-class SBStructuredData::Impl
-{
+class SBStructuredData::Impl {
public:
+ Impl() : m_plugin_wp(), m_data_sp() {}
- Impl() :
- m_plugin_wp(),
- m_data_sp()
- {
- }
+ Impl(const Impl &rhs) = default;
- Impl(const Impl &rhs) = default;
+ Impl(const EventSP &event_sp)
+ : m_plugin_wp(
+ EventDataStructuredData::GetPluginFromEvent(event_sp.get())),
+ m_data_sp(EventDataStructuredData::GetObjectFromEvent(event_sp.get())) {
+ }
- Impl(const EventSP &event_sp) :
- m_plugin_wp(EventDataStructuredData::GetPluginFromEvent(event_sp.get())),
- m_data_sp(EventDataStructuredData::GetObjectFromEvent(event_sp.get()))
- {
- }
+ ~Impl() = default;
- ~Impl() = default;
+ Impl &operator=(const Impl &rhs) = default;
- Impl&
- operator =(const Impl &rhs) = default;
+ bool IsValid() const { return m_data_sp.get() != nullptr; }
- bool
- IsValid() const
- {
- return m_data_sp.get() != nullptr;
- }
+ void Clear() {
+ m_plugin_wp.reset();
+ m_data_sp.reset();
+ }
+
+ SBError GetAsJSON(lldb::SBStream &stream) const {
+ SBError sb_error;
- void
- Clear()
- {
- m_plugin_wp.reset();
- m_data_sp.reset();
+ if (!m_data_sp) {
+ sb_error.SetErrorString("No structured data.");
+ return sb_error;
}
- SBError
- GetAsJSON(lldb::SBStream &stream) const
- {
- SBError sb_error;
-
- if (!m_data_sp)
- {
- sb_error.SetErrorString("No structured data.");
- return sb_error;
- }
+ m_data_sp->Dump(stream.ref());
+ return sb_error;
+ }
- m_data_sp->Dump(stream.ref());
- return sb_error;
- }
+ lldb::SBError GetDescription(lldb::SBStream &stream) const {
+ SBError sb_error;
- lldb::SBError
- GetDescription(lldb::SBStream &stream) const
- {
- SBError sb_error;
-
- if (!m_data_sp)
- {
- sb_error.SetErrorString("Cannot pretty print structured data: "
- "no data to print.");
- return sb_error;
- }
-
- // Grab the plugin.
- auto plugin_sp = StructuredDataPluginSP(m_plugin_wp);
- if (!plugin_sp)
- {
- sb_error.SetErrorString("Cannot pretty print structured data: "
- "plugin doesn't exist.");
- return sb_error;
- }
-
- // Get the data's description.
- auto error = plugin_sp->GetDescription(m_data_sp, stream.ref());
- if (!error.Success())
- sb_error.SetError(error);
+ if (!m_data_sp) {
+ sb_error.SetErrorString("Cannot pretty print structured data: "
+ "no data to print.");
+ return sb_error;
+ }
- return sb_error;
+ // Grab the plugin.
+ auto plugin_sp = StructuredDataPluginSP(m_plugin_wp);
+ if (!plugin_sp) {
+ sb_error.SetErrorString("Cannot pretty print structured data: "
+ "plugin doesn't exist.");
+ return sb_error;
}
-private:
+ // Get the data's description.
+ auto error = plugin_sp->GetDescription(m_data_sp, stream.ref());
+ if (!error.Success())
+ sb_error.SetError(error);
- StructuredDataPluginWP m_plugin_wp;
- StructuredData::ObjectSP m_data_sp;
+ return sb_error;
+ }
+private:
+ StructuredDataPluginWP m_plugin_wp;
+ StructuredData::ObjectSP m_data_sp;
};
-#pragma mark --
+#pragma mark--
#pragma mark SBStructuredData
+SBStructuredData::SBStructuredData() : m_impl_up(new Impl()) {}
-SBStructuredData::SBStructuredData() :
- m_impl_up(new Impl())
-{
-}
-
-SBStructuredData::SBStructuredData(const lldb::SBStructuredData &rhs) :
- m_impl_up(new Impl(*rhs.m_impl_up.get()))
-{
-}
+SBStructuredData::SBStructuredData(const lldb::SBStructuredData &rhs)
+ : m_impl_up(new Impl(*rhs.m_impl_up.get())) {}
-SBStructuredData::SBStructuredData(const lldb::EventSP &event_sp) :
- m_impl_up(new Impl(event_sp))
-{
-}
+SBStructuredData::SBStructuredData(const lldb::EventSP &event_sp)
+ : m_impl_up(new Impl(event_sp)) {}
-SBStructuredData::~SBStructuredData()
-{
-}
+SBStructuredData::~SBStructuredData() {}
-SBStructuredData &
-SBStructuredData::operator =(const lldb::SBStructuredData &rhs)
-{
- *m_impl_up = *rhs.m_impl_up;
- return *this;
+SBStructuredData &SBStructuredData::
+operator=(const lldb::SBStructuredData &rhs) {
+ *m_impl_up = *rhs.m_impl_up;
+ return *this;
}
-bool
-SBStructuredData::IsValid() const
-{
- return m_impl_up->IsValid();
-}
+bool SBStructuredData::IsValid() const { return m_impl_up->IsValid(); }
-void
-SBStructuredData::Clear()
-{
- m_impl_up->Clear();
-}
+void SBStructuredData::Clear() { m_impl_up->Clear(); }
-SBError
-SBStructuredData::GetAsJSON(lldb::SBStream &stream) const
-{
- return m_impl_up->GetAsJSON(stream);
+SBError SBStructuredData::GetAsJSON(lldb::SBStream &stream) const {
+ return m_impl_up->GetAsJSON(stream);
}
-lldb::SBError
-SBStructuredData::GetDescription(lldb::SBStream &stream) const
-{
- return m_impl_up->GetDescription(stream);
+lldb::SBError SBStructuredData::GetDescription(lldb::SBStream &stream) const {
+ return m_impl_up->GetDescription(stream);
}
-
Modified: lldb/trunk/source/API/SBSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbol.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSymbol.cpp (original)
+++ lldb/trunk/source/API/SBSymbol.cpp Tue Sep 6 15:57:50 2016
@@ -19,225 +19,159 @@
using namespace lldb;
using namespace lldb_private;
-SBSymbol::SBSymbol () :
- m_opaque_ptr (NULL)
-{
-}
+SBSymbol::SBSymbol() : m_opaque_ptr(NULL) {}
-SBSymbol::SBSymbol (lldb_private::Symbol *lldb_object_ptr) :
- m_opaque_ptr (lldb_object_ptr)
-{
-}
+SBSymbol::SBSymbol(lldb_private::Symbol *lldb_object_ptr)
+ : m_opaque_ptr(lldb_object_ptr) {}
-SBSymbol::SBSymbol (const lldb::SBSymbol &rhs) :
- m_opaque_ptr (rhs.m_opaque_ptr)
-{
-}
+SBSymbol::SBSymbol(const lldb::SBSymbol &rhs)
+ : m_opaque_ptr(rhs.m_opaque_ptr) {}
-const SBSymbol &
-SBSymbol::operator = (const SBSymbol &rhs)
-{
- m_opaque_ptr = rhs.m_opaque_ptr;
- return *this;
+const SBSymbol &SBSymbol::operator=(const SBSymbol &rhs) {
+ m_opaque_ptr = rhs.m_opaque_ptr;
+ return *this;
}
-SBSymbol::~SBSymbol ()
-{
- m_opaque_ptr = NULL;
-}
+SBSymbol::~SBSymbol() { m_opaque_ptr = NULL; }
-void
-SBSymbol::SetSymbol (lldb_private::Symbol *lldb_object_ptr)
-{
- m_opaque_ptr = lldb_object_ptr;
+void SBSymbol::SetSymbol(lldb_private::Symbol *lldb_object_ptr) {
+ m_opaque_ptr = lldb_object_ptr;
}
-bool
-SBSymbol::IsValid () const
-{
- return m_opaque_ptr != NULL;
+bool SBSymbol::IsValid() const { return m_opaque_ptr != NULL; }
+
+const char *SBSymbol::GetName() const {
+ const char *name = NULL;
+ if (m_opaque_ptr)
+ name = m_opaque_ptr->GetName().AsCString();
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBSymbol(%p)::GetName () => \"%s\"",
+ static_cast<void *>(m_opaque_ptr), name ? name : "");
+ return name;
}
-const char *
-SBSymbol::GetName() const
-{
- const char *name = NULL;
- if (m_opaque_ptr)
- name = m_opaque_ptr->GetName().AsCString();
+const char *SBSymbol::GetDisplayName() const {
+ const char *name = NULL;
+ if (m_opaque_ptr)
+ name = m_opaque_ptr->GetMangled()
+ .GetDisplayDemangledName(m_opaque_ptr->GetLanguage())
+ .AsCString();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBSymbol(%p)::GetName () => \"%s\"",
- static_cast<void*>(m_opaque_ptr), name ? name : "");
- return name;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBSymbol(%p)::GetDisplayName () => \"%s\"",
+ static_cast<void *>(m_opaque_ptr), name ? name : "");
+ return name;
}
-const char *
-SBSymbol::GetDisplayName() const
-{
- const char *name = NULL;
- if (m_opaque_ptr)
- name = m_opaque_ptr->GetMangled().GetDisplayDemangledName(m_opaque_ptr->GetLanguage()).AsCString();
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBSymbol(%p)::GetDisplayName () => \"%s\"",
- static_cast<void*>(m_opaque_ptr), name ? name : "");
- return name;
+const char *SBSymbol::GetMangledName() const {
+ const char *name = NULL;
+ if (m_opaque_ptr)
+ name = m_opaque_ptr->GetMangled().GetMangledName().AsCString();
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBSymbol(%p)::GetMangledName () => \"%s\"",
+ static_cast<void *>(m_opaque_ptr), name ? name : "");
+
+ return name;
}
-const char *
-SBSymbol::GetMangledName () const
-{
- const char *name = NULL;
- if (m_opaque_ptr)
- name = m_opaque_ptr->GetMangled().GetMangledName().AsCString();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBSymbol(%p)::GetMangledName () => \"%s\"",
- static_cast<void*>(m_opaque_ptr), name ? name : "");
+bool SBSymbol::operator==(const SBSymbol &rhs) const {
+ return m_opaque_ptr == rhs.m_opaque_ptr;
+}
- return name;
+bool SBSymbol::operator!=(const SBSymbol &rhs) const {
+ return m_opaque_ptr != rhs.m_opaque_ptr;
}
+bool SBSymbol::GetDescription(SBStream &description) {
+ Stream &strm = description.ref();
-bool
-SBSymbol::operator == (const SBSymbol &rhs) const
-{
- return m_opaque_ptr == rhs.m_opaque_ptr;
+ if (m_opaque_ptr) {
+ m_opaque_ptr->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL);
+ } else
+ strm.PutCString("No value");
+
+ return true;
}
-bool
-SBSymbol::operator != (const SBSymbol &rhs) const
-{
- return m_opaque_ptr != rhs.m_opaque_ptr;
+SBInstructionList SBSymbol::GetInstructions(SBTarget target) {
+ return GetInstructions(target, NULL);
}
-bool
-SBSymbol::GetDescription (SBStream &description)
-{
- Stream &strm = description.ref();
+SBInstructionList SBSymbol::GetInstructions(SBTarget target,
+ const char *flavor_string) {
+ SBInstructionList sb_instructions;
+ if (m_opaque_ptr) {
+ ExecutionContext exe_ctx;
+ TargetSP target_sp(target.GetSP());
+ std::unique_lock<std::recursive_mutex> lock;
+ if (target_sp) {
+ lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
- if (m_opaque_ptr)
- {
- m_opaque_ptr->GetDescription (&strm,
- lldb::eDescriptionLevelFull, NULL);
+ target_sp->CalculateExecutionContext(exe_ctx);
}
- else
- strm.PutCString ("No value");
-
- return true;
-}
-
-SBInstructionList
-SBSymbol::GetInstructions (SBTarget target)
-{
- return GetInstructions (target, NULL);
-}
-
-SBInstructionList
-SBSymbol::GetInstructions (SBTarget target, const char *flavor_string)
-{
- SBInstructionList sb_instructions;
- if (m_opaque_ptr)
- {
- ExecutionContext exe_ctx;
- TargetSP target_sp (target.GetSP());
- std::unique_lock<std::recursive_mutex> lock;
- if (target_sp)
- {
- lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
-
- target_sp->CalculateExecutionContext (exe_ctx);
- }
- if (m_opaque_ptr->ValueIsAddress())
- {
- const Address &symbol_addr = m_opaque_ptr->GetAddressRef();
- ModuleSP module_sp = symbol_addr.GetModule();
- if (module_sp)
- {
- AddressRange symbol_range (symbol_addr, m_opaque_ptr->GetByteSize());
- const bool prefer_file_cache = false;
- sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module_sp->GetArchitecture (),
- NULL,
- flavor_string,
- exe_ctx,
- symbol_range,
- prefer_file_cache));
- }
- }
+ if (m_opaque_ptr->ValueIsAddress()) {
+ const Address &symbol_addr = m_opaque_ptr->GetAddressRef();
+ ModuleSP module_sp = symbol_addr.GetModule();
+ if (module_sp) {
+ AddressRange symbol_range(symbol_addr, m_opaque_ptr->GetByteSize());
+ const bool prefer_file_cache = false;
+ sb_instructions.SetDisassembler(Disassembler::DisassembleRange(
+ module_sp->GetArchitecture(), NULL, flavor_string, exe_ctx,
+ symbol_range, prefer_file_cache));
+ }
}
- return sb_instructions;
+ }
+ return sb_instructions;
}
-lldb_private::Symbol *
-SBSymbol::get ()
-{
- return m_opaque_ptr;
-}
+lldb_private::Symbol *SBSymbol::get() { return m_opaque_ptr; }
-void
-SBSymbol::reset (lldb_private::Symbol *symbol)
-{
- m_opaque_ptr = symbol;
+void SBSymbol::reset(lldb_private::Symbol *symbol) { m_opaque_ptr = symbol; }
+
+SBAddress SBSymbol::GetStartAddress() {
+ SBAddress addr;
+ if (m_opaque_ptr && m_opaque_ptr->ValueIsAddress()) {
+ addr.SetAddress(&m_opaque_ptr->GetAddressRef());
+ }
+ return addr;
}
-SBAddress
-SBSymbol::GetStartAddress ()
-{
- SBAddress addr;
- if (m_opaque_ptr && m_opaque_ptr->ValueIsAddress())
- {
- addr.SetAddress (&m_opaque_ptr->GetAddressRef());
+SBAddress SBSymbol::GetEndAddress() {
+ SBAddress addr;
+ if (m_opaque_ptr && m_opaque_ptr->ValueIsAddress()) {
+ lldb::addr_t range_size = m_opaque_ptr->GetByteSize();
+ if (range_size > 0) {
+ addr.SetAddress(&m_opaque_ptr->GetAddressRef());
+ addr->Slide(m_opaque_ptr->GetByteSize());
}
- return addr;
+ }
+ return addr;
}
-SBAddress
-SBSymbol::GetEndAddress ()
-{
- SBAddress addr;
- if (m_opaque_ptr && m_opaque_ptr->ValueIsAddress())
- {
- lldb::addr_t range_size = m_opaque_ptr->GetByteSize();
- if (range_size > 0)
- {
- addr.SetAddress (&m_opaque_ptr->GetAddressRef());
- addr->Slide (m_opaque_ptr->GetByteSize());
- }
- }
- return addr;
+uint32_t SBSymbol::GetPrologueByteSize() {
+ if (m_opaque_ptr)
+ return m_opaque_ptr->GetPrologueByteSize();
+ return 0;
}
-uint32_t
-SBSymbol::GetPrologueByteSize ()
-{
- if (m_opaque_ptr)
- return m_opaque_ptr->GetPrologueByteSize();
- return 0;
-}
-
-SymbolType
-SBSymbol::GetType ()
-{
- if (m_opaque_ptr)
- return m_opaque_ptr->GetType();
- return eSymbolTypeInvalid;
-}
-
-bool
-SBSymbol::IsExternal()
-{
- if (m_opaque_ptr)
- return m_opaque_ptr->IsExternal();
- return false;
-}
-
-bool
-SBSymbol::IsSynthetic()
-{
- if (m_opaque_ptr)
- return m_opaque_ptr->IsSynthetic();
- return false;
+SymbolType SBSymbol::GetType() {
+ if (m_opaque_ptr)
+ return m_opaque_ptr->GetType();
+ return eSymbolTypeInvalid;
}
+bool SBSymbol::IsExternal() {
+ if (m_opaque_ptr)
+ return m_opaque_ptr->IsExternal();
+ return false;
+}
+
+bool SBSymbol::IsSynthetic() {
+ if (m_opaque_ptr)
+ return m_opaque_ptr->IsSynthetic();
+ return false;
+}
Modified: lldb/trunk/source/API/SBSymbolContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbolContext.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSymbolContext.cpp (original)
+++ lldb/trunk/source/API/SBSymbolContext.cpp Tue Sep 6 15:57:50 2016
@@ -18,270 +18,199 @@
using namespace lldb;
using namespace lldb_private;
+SBSymbolContext::SBSymbolContext() : m_opaque_ap() {}
-
-SBSymbolContext::SBSymbolContext () :
- m_opaque_ap ()
-{
+SBSymbolContext::SBSymbolContext(const SymbolContext *sc_ptr) : m_opaque_ap() {
+ if (sc_ptr)
+ m_opaque_ap.reset(new SymbolContext(*sc_ptr));
}
-SBSymbolContext::SBSymbolContext (const SymbolContext *sc_ptr) :
- m_opaque_ap ()
-{
- if (sc_ptr)
- m_opaque_ap.reset (new SymbolContext (*sc_ptr));
+SBSymbolContext::SBSymbolContext(const SBSymbolContext &rhs) : m_opaque_ap() {
+ if (rhs.IsValid()) {
+ if (m_opaque_ap.get())
+ *m_opaque_ap = *rhs.m_opaque_ap;
+ else
+ ref() = *rhs.m_opaque_ap;
+ }
}
-SBSymbolContext::SBSymbolContext (const SBSymbolContext& rhs) :
- m_opaque_ap ()
-{
+SBSymbolContext::~SBSymbolContext() {}
+
+const SBSymbolContext &SBSymbolContext::operator=(const SBSymbolContext &rhs) {
+ if (this != &rhs) {
if (rhs.IsValid())
- {
- if (m_opaque_ap.get())
- *m_opaque_ap = *rhs.m_opaque_ap;
- else
- ref() = *rhs.m_opaque_ap;
- }
-}
-
-SBSymbolContext::~SBSymbolContext ()
-{
-}
-
-const SBSymbolContext &
-SBSymbolContext::operator = (const SBSymbolContext &rhs)
-{
- if (this != &rhs)
- {
- if (rhs.IsValid())
- m_opaque_ap.reset (new lldb_private::SymbolContext(*rhs.m_opaque_ap.get()));
- }
- return *this;
-}
-
-void
-SBSymbolContext::SetSymbolContext (const SymbolContext *sc_ptr)
-{
- if (sc_ptr)
- {
- if (m_opaque_ap.get())
- *m_opaque_ap = *sc_ptr;
- else
- m_opaque_ap.reset (new SymbolContext (*sc_ptr));
- }
- else
- {
- if (m_opaque_ap.get())
- m_opaque_ap->Clear(true);
- }
+ m_opaque_ap.reset(
+ new lldb_private::SymbolContext(*rhs.m_opaque_ap.get()));
+ }
+ return *this;
}
-bool
-SBSymbolContext::IsValid () const
-{
- return m_opaque_ap.get() != NULL;
+void SBSymbolContext::SetSymbolContext(const SymbolContext *sc_ptr) {
+ if (sc_ptr) {
+ if (m_opaque_ap.get())
+ *m_opaque_ap = *sc_ptr;
+ else
+ m_opaque_ap.reset(new SymbolContext(*sc_ptr));
+ } else {
+ if (m_opaque_ap.get())
+ m_opaque_ap->Clear(true);
+ }
}
+bool SBSymbolContext::IsValid() const { return m_opaque_ap.get() != NULL; }
+SBModule SBSymbolContext::GetModule() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-SBModule
-SBSymbolContext::GetModule ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ SBModule sb_module;
+ ModuleSP module_sp;
+ if (m_opaque_ap.get()) {
+ module_sp = m_opaque_ap->module_sp;
+ sb_module.SetSP(module_sp);
+ }
- SBModule sb_module;
- ModuleSP module_sp;
- if (m_opaque_ap.get())
- {
- module_sp = m_opaque_ap->module_sp;
- sb_module.SetSP (module_sp);
- }
-
- if (log)
- {
- SBStream sstr;
- sb_module.GetDescription (sstr);
- log->Printf ("SBSymbolContext(%p)::GetModule () => SBModule(%p): %s",
- static_cast<void*>(m_opaque_ap.get()),
- static_cast<void*>(module_sp.get()), sstr.GetData());
- }
-
- return sb_module;
-}
-
-SBCompileUnit
-SBSymbolContext::GetCompileUnit ()
-{
- return SBCompileUnit (m_opaque_ap.get() ? m_opaque_ap->comp_unit : NULL);
-}
-
-SBFunction
-SBSymbolContext::GetFunction ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (log) {
+ SBStream sstr;
+ sb_module.GetDescription(sstr);
+ log->Printf("SBSymbolContext(%p)::GetModule () => SBModule(%p): %s",
+ static_cast<void *>(m_opaque_ap.get()),
+ static_cast<void *>(module_sp.get()), sstr.GetData());
+ }
- Function *function = NULL;
+ return sb_module;
+}
- if (m_opaque_ap.get())
- function = m_opaque_ap->function;
+SBCompileUnit SBSymbolContext::GetCompileUnit() {
+ return SBCompileUnit(m_opaque_ap.get() ? m_opaque_ap->comp_unit : NULL);
+}
- SBFunction sb_function (function);
+SBFunction SBSymbolContext::GetFunction() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBSymbolContext(%p)::GetFunction () => SBFunction(%p)",
- static_cast<void*>(m_opaque_ap.get()),
- static_cast<void*>(function));
+ Function *function = NULL;
- return sb_function;
+ if (m_opaque_ap.get())
+ function = m_opaque_ap->function;
+
+ SBFunction sb_function(function);
+
+ if (log)
+ log->Printf("SBSymbolContext(%p)::GetFunction () => SBFunction(%p)",
+ static_cast<void *>(m_opaque_ap.get()),
+ static_cast<void *>(function));
+
+ return sb_function;
}
-SBBlock
-SBSymbolContext::GetBlock ()
-{
- return SBBlock (m_opaque_ap.get() ? m_opaque_ap->block : NULL);
+SBBlock SBSymbolContext::GetBlock() {
+ return SBBlock(m_opaque_ap.get() ? m_opaque_ap->block : NULL);
}
-SBLineEntry
-SBSymbolContext::GetLineEntry ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+SBLineEntry SBSymbolContext::GetLineEntry() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- SBLineEntry sb_line_entry;
- if (m_opaque_ap.get())
- sb_line_entry.SetLineEntry (m_opaque_ap->line_entry);
+ SBLineEntry sb_line_entry;
+ if (m_opaque_ap.get())
+ sb_line_entry.SetLineEntry(m_opaque_ap->line_entry);
- if (log)
- {
- log->Printf ("SBSymbolContext(%p)::GetLineEntry () => SBLineEntry(%p)",
- static_cast<void*>(m_opaque_ap.get()),
- static_cast<void*>(sb_line_entry.get()));
- }
+ if (log) {
+ log->Printf("SBSymbolContext(%p)::GetLineEntry () => SBLineEntry(%p)",
+ static_cast<void *>(m_opaque_ap.get()),
+ static_cast<void *>(sb_line_entry.get()));
+ }
- return sb_line_entry;
+ return sb_line_entry;
}
-SBSymbol
-SBSymbolContext::GetSymbol ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+SBSymbol SBSymbolContext::GetSymbol() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- Symbol *symbol = NULL;
+ Symbol *symbol = NULL;
- if (m_opaque_ap.get())
- symbol = m_opaque_ap->symbol;
+ if (m_opaque_ap.get())
+ symbol = m_opaque_ap->symbol;
- SBSymbol sb_symbol (symbol);
+ SBSymbol sb_symbol(symbol);
- if (log)
- log->Printf ("SBSymbolContext(%p)::GetSymbol () => SBSymbol(%p)",
- static_cast<void*>(m_opaque_ap.get()),
- static_cast<void*>(symbol));
+ if (log)
+ log->Printf("SBSymbolContext(%p)::GetSymbol () => SBSymbol(%p)",
+ static_cast<void *>(m_opaque_ap.get()),
+ static_cast<void *>(symbol));
- return sb_symbol;
+ return sb_symbol;
}
-void
-SBSymbolContext::SetModule (lldb::SBModule module)
-{
- ref().module_sp = module.GetSP();
+void SBSymbolContext::SetModule(lldb::SBModule module) {
+ ref().module_sp = module.GetSP();
}
-void
-SBSymbolContext::SetCompileUnit (lldb::SBCompileUnit compile_unit)
-{
- ref().comp_unit = compile_unit.get();
+void SBSymbolContext::SetCompileUnit(lldb::SBCompileUnit compile_unit) {
+ ref().comp_unit = compile_unit.get();
}
-void
-SBSymbolContext::SetFunction (lldb::SBFunction function)
-{
- ref().function = function.get();
+void SBSymbolContext::SetFunction(lldb::SBFunction function) {
+ ref().function = function.get();
}
-void
-SBSymbolContext::SetBlock (lldb::SBBlock block)
-{
- ref().block = block.GetPtr();
+void SBSymbolContext::SetBlock(lldb::SBBlock block) {
+ ref().block = block.GetPtr();
}
-void
-SBSymbolContext::SetLineEntry (lldb::SBLineEntry line_entry)
-{
- if (line_entry.IsValid())
- ref().line_entry = line_entry.ref();
- else
- ref().line_entry.Clear();
+void SBSymbolContext::SetLineEntry(lldb::SBLineEntry line_entry) {
+ if (line_entry.IsValid())
+ ref().line_entry = line_entry.ref();
+ else
+ ref().line_entry.Clear();
}
-void
-SBSymbolContext::SetSymbol (lldb::SBSymbol symbol)
-{
- ref().symbol = symbol.get();
+void SBSymbolContext::SetSymbol(lldb::SBSymbol symbol) {
+ ref().symbol = symbol.get();
}
-
-lldb_private::SymbolContext*
-SBSymbolContext::operator->() const
-{
- return m_opaque_ap.get();
+lldb_private::SymbolContext *SBSymbolContext::operator->() const {
+ return m_opaque_ap.get();
}
-
-const lldb_private::SymbolContext&
-SBSymbolContext::operator*() const
-{
- assert (m_opaque_ap.get());
- return *m_opaque_ap.get();
+const lldb_private::SymbolContext &SBSymbolContext::operator*() const {
+ assert(m_opaque_ap.get());
+ return *m_opaque_ap.get();
}
-
-lldb_private::SymbolContext&
-SBSymbolContext::operator*()
-{
- if (m_opaque_ap.get() == NULL)
- m_opaque_ap.reset (new SymbolContext);
- return *m_opaque_ap.get();
+lldb_private::SymbolContext &SBSymbolContext::operator*() {
+ if (m_opaque_ap.get() == NULL)
+ m_opaque_ap.reset(new SymbolContext);
+ return *m_opaque_ap.get();
}
-lldb_private::SymbolContext&
-SBSymbolContext::ref()
-{
- if (m_opaque_ap.get() == NULL)
- m_opaque_ap.reset (new SymbolContext);
- return *m_opaque_ap.get();
+lldb_private::SymbolContext &SBSymbolContext::ref() {
+ if (m_opaque_ap.get() == NULL)
+ m_opaque_ap.reset(new SymbolContext);
+ return *m_opaque_ap.get();
}
-lldb_private::SymbolContext *
-SBSymbolContext::get() const
-{
- return m_opaque_ap.get();
+lldb_private::SymbolContext *SBSymbolContext::get() const {
+ return m_opaque_ap.get();
}
-bool
-SBSymbolContext::GetDescription (SBStream &description)
-{
- Stream &strm = description.ref();
+bool SBSymbolContext::GetDescription(SBStream &description) {
+ Stream &strm = description.ref();
- if (m_opaque_ap.get())
- {
- m_opaque_ap->GetDescription (&strm, lldb::eDescriptionLevelFull, NULL);
- }
- else
- strm.PutCString ("No value");
+ if (m_opaque_ap.get()) {
+ m_opaque_ap->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL);
+ } else
+ strm.PutCString("No value");
- return true;
+ return true;
}
SBSymbolContext
-SBSymbolContext::GetParentOfInlinedScope (const SBAddress &curr_frame_pc,
- SBAddress &parent_frame_addr) const
-{
- SBSymbolContext sb_sc;
- if (m_opaque_ap.get() && curr_frame_pc.IsValid())
- {
- if (m_opaque_ap->GetParentOfInlinedScope (curr_frame_pc.ref(), sb_sc.ref(), parent_frame_addr.ref()))
- return sb_sc;
- }
- return SBSymbolContext();
+SBSymbolContext::GetParentOfInlinedScope(const SBAddress &curr_frame_pc,
+ SBAddress &parent_frame_addr) const {
+ SBSymbolContext sb_sc;
+ if (m_opaque_ap.get() && curr_frame_pc.IsValid()) {
+ if (m_opaque_ap->GetParentOfInlinedScope(curr_frame_pc.ref(), sb_sc.ref(),
+ parent_frame_addr.ref()))
+ return sb_sc;
+ }
+ return SBSymbolContext();
}
-
Modified: lldb/trunk/source/API/SBSymbolContextList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbolContextList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSymbolContextList.cpp (original)
+++ lldb/trunk/source/API/SBSymbolContextList.cpp Tue Sep 6 15:57:50 2016
@@ -14,104 +14,68 @@
using namespace lldb;
using namespace lldb_private;
-SBSymbolContextList::SBSymbolContextList () :
- m_opaque_ap (new SymbolContextList())
-{
-}
+SBSymbolContextList::SBSymbolContextList()
+ : m_opaque_ap(new SymbolContextList()) {}
-SBSymbolContextList::SBSymbolContextList (const SBSymbolContextList& rhs) :
- m_opaque_ap (new SymbolContextList(*rhs.m_opaque_ap))
-{
-}
+SBSymbolContextList::SBSymbolContextList(const SBSymbolContextList &rhs)
+ : m_opaque_ap(new SymbolContextList(*rhs.m_opaque_ap)) {}
-SBSymbolContextList::~SBSymbolContextList ()
-{
-}
+SBSymbolContextList::~SBSymbolContextList() {}
-const SBSymbolContextList &
-SBSymbolContextList::operator = (const SBSymbolContextList &rhs)
-{
- if (this != &rhs)
- {
- *m_opaque_ap = *rhs.m_opaque_ap;
+const SBSymbolContextList &SBSymbolContextList::
+operator=(const SBSymbolContextList &rhs) {
+ if (this != &rhs) {
+ *m_opaque_ap = *rhs.m_opaque_ap;
+ }
+ return *this;
+}
+
+uint32_t SBSymbolContextList::GetSize() const {
+ if (m_opaque_ap.get())
+ return m_opaque_ap->GetSize();
+ return 0;
+}
+
+SBSymbolContext SBSymbolContextList::GetContextAtIndex(uint32_t idx) {
+ SBSymbolContext sb_sc;
+ if (m_opaque_ap.get()) {
+ SymbolContext sc;
+ if (m_opaque_ap->GetContextAtIndex(idx, sc)) {
+ sb_sc.SetSymbolContext(&sc);
}
- return *this;
+ }
+ return sb_sc;
}
-uint32_t
-SBSymbolContextList::GetSize() const
-{
- if (m_opaque_ap.get())
- return m_opaque_ap->GetSize();
- return 0;
-}
-
-SBSymbolContext
-SBSymbolContextList::GetContextAtIndex (uint32_t idx)
-{
- SBSymbolContext sb_sc;
- if (m_opaque_ap.get())
- {
- SymbolContext sc;
- if (m_opaque_ap->GetContextAtIndex (idx, sc))
- {
- sb_sc.SetSymbolContext(&sc);
- }
- }
- return sb_sc;
+void SBSymbolContextList::Clear() {
+ if (m_opaque_ap.get())
+ m_opaque_ap->Clear();
}
-void
-SBSymbolContextList::Clear()
-{
- if (m_opaque_ap.get())
- m_opaque_ap->Clear();
+void SBSymbolContextList::Append(SBSymbolContext &sc) {
+ if (sc.IsValid() && m_opaque_ap.get())
+ m_opaque_ap->Append(*sc);
}
-void
-SBSymbolContextList::Append(SBSymbolContext &sc)
-{
- if (sc.IsValid() && m_opaque_ap.get())
- m_opaque_ap->Append(*sc);
-}
-
-void
-SBSymbolContextList::Append(SBSymbolContextList &sc_list)
-{
- if (sc_list.IsValid() && m_opaque_ap.get())
- m_opaque_ap->Append(*sc_list);
+void SBSymbolContextList::Append(SBSymbolContextList &sc_list) {
+ if (sc_list.IsValid() && m_opaque_ap.get())
+ m_opaque_ap->Append(*sc_list);
}
+bool SBSymbolContextList::IsValid() const { return m_opaque_ap.get() != NULL; }
-bool
-SBSymbolContextList::IsValid () const
-{
- return m_opaque_ap.get() != NULL;
+lldb_private::SymbolContextList *SBSymbolContextList::operator->() const {
+ return m_opaque_ap.get();
}
-
-
-lldb_private::SymbolContextList*
-SBSymbolContextList::operator->() const
-{
- return m_opaque_ap.get();
-}
-
-
-lldb_private::SymbolContextList&
-SBSymbolContextList::operator*() const
-{
- assert (m_opaque_ap.get());
- return *m_opaque_ap.get();
+lldb_private::SymbolContextList &SBSymbolContextList::operator*() const {
+ assert(m_opaque_ap.get());
+ return *m_opaque_ap.get();
}
-bool
-SBSymbolContextList::GetDescription (lldb::SBStream &description)
-{
- Stream &strm = description.ref();
- if (m_opaque_ap.get())
- m_opaque_ap->GetDescription (&strm, lldb::eDescriptionLevelFull, NULL);
- return true;
+bool SBSymbolContextList::GetDescription(lldb::SBStream &description) {
+ Stream &strm = description.ref();
+ if (m_opaque_ap.get())
+ m_opaque_ap->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL);
+ return true;
}
-
-
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Tue Sep 6 15:57:50 2016
@@ -19,8 +19,8 @@
#include "lldb/API/SBListener.h"
#include "lldb/API/SBModule.h"
#include "lldb/API/SBModuleSpec.h"
-#include "lldb/API/SBSourceManager.h"
#include "lldb/API/SBProcess.h"
+#include "lldb/API/SBSourceManager.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBStringList.h"
#include "lldb/API/SBSymbolContextList.h"
@@ -38,9 +38,9 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/RegularExpression.h"
+#include "lldb/Core/STLUtils.h"
#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/STLUtils.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Core/ValueObjectVariable.h"
@@ -62,11 +62,10 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/TargetList.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
#include "../source/Commands/CommandObjectBreakpoint.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
#include "llvm/Support/Regex.h"
-
using namespace lldb;
using namespace lldb_private;
@@ -74,2444 +73,2025 @@ using namespace lldb_private;
namespace {
-Error
-AttachToProcess (ProcessAttachInfo &attach_info, Target &target)
-{
- std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex());
+Error AttachToProcess(ProcessAttachInfo &attach_info, Target &target) {
+ std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex());
- auto process_sp = target.GetProcessSP ();
- if (process_sp)
- {
- const auto state = process_sp->GetState ();
- if (process_sp->IsAlive () && state == eStateConnected)
- {
- // If we are already connected, then we have already specified the
- // listener, so if a valid listener is supplied, we need to error out
- // to let the client know.
- if (attach_info.GetListener ())
- return Error ("process is connected and already has a listener, pass empty listener");
- }
+ auto process_sp = target.GetProcessSP();
+ if (process_sp) {
+ const auto state = process_sp->GetState();
+ if (process_sp->IsAlive() && state == eStateConnected) {
+ // If we are already connected, then we have already specified the
+ // listener, so if a valid listener is supplied, we need to error out
+ // to let the client know.
+ if (attach_info.GetListener())
+ return Error("process is connected and already has a listener, pass "
+ "empty listener");
}
+ }
- return target.Attach (attach_info, nullptr);
+ return target.Attach(attach_info, nullptr);
}
-} // namespace
+} // namespace
//----------------------------------------------------------------------
// SBTarget constructor
//----------------------------------------------------------------------
-SBTarget::SBTarget () :
- m_opaque_sp ()
-{
-}
+SBTarget::SBTarget() : m_opaque_sp() {}
-SBTarget::SBTarget (const SBTarget& rhs) :
- m_opaque_sp (rhs.m_opaque_sp)
-{
-}
+SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) {}
-SBTarget::SBTarget(const TargetSP& target_sp) :
- m_opaque_sp (target_sp)
-{
-}
+SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) {}
-const SBTarget&
-SBTarget::operator = (const SBTarget& rhs)
-{
- if (this != &rhs)
- m_opaque_sp = rhs.m_opaque_sp;
- return *this;
+const SBTarget &SBTarget::operator=(const SBTarget &rhs) {
+ if (this != &rhs)
+ m_opaque_sp = rhs.m_opaque_sp;
+ return *this;
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-SBTarget::~SBTarget()
-{
-}
+SBTarget::~SBTarget() {}
-bool
-SBTarget::EventIsTargetEvent (const SBEvent &event)
-{
- return Target::TargetEventData::GetEventDataFromEvent(event.get()) != NULL;
+bool SBTarget::EventIsTargetEvent(const SBEvent &event) {
+ return Target::TargetEventData::GetEventDataFromEvent(event.get()) != NULL;
}
-SBTarget
-SBTarget::GetTargetFromEvent (const SBEvent &event)
-{
- return Target::TargetEventData::GetTargetFromEvent (event.get());
+SBTarget SBTarget::GetTargetFromEvent(const SBEvent &event) {
+ return Target::TargetEventData::GetTargetFromEvent(event.get());
}
-uint32_t
-SBTarget::GetNumModulesFromEvent (const SBEvent &event)
-{
- const ModuleList module_list = Target::TargetEventData::GetModuleListFromEvent (event.get());
- return module_list.GetSize();
+uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent &event) {
+ const ModuleList module_list =
+ Target::TargetEventData::GetModuleListFromEvent(event.get());
+ return module_list.GetSize();
}
-SBModule
-SBTarget::GetModuleAtIndexFromEvent (const uint32_t idx, const SBEvent &event)
-{
- const ModuleList module_list = Target::TargetEventData::GetModuleListFromEvent (event.get());
- return SBModule(module_list.GetModuleAtIndex(idx));
+SBModule SBTarget::GetModuleAtIndexFromEvent(const uint32_t idx,
+ const SBEvent &event) {
+ const ModuleList module_list =
+ Target::TargetEventData::GetModuleListFromEvent(event.get());
+ return SBModule(module_list.GetModuleAtIndex(idx));
}
-const char *
-SBTarget::GetBroadcasterClassName ()
-{
- return Target::GetStaticBroadcasterClass().AsCString();
+const char *SBTarget::GetBroadcasterClassName() {
+ return Target::GetStaticBroadcasterClass().AsCString();
}
-bool
-SBTarget::IsValid () const
-{
- return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
+bool SBTarget::IsValid() const {
+ return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
}
-SBProcess
-SBTarget::GetProcess ()
-{
- SBProcess sb_process;
- ProcessSP process_sp;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- process_sp = target_sp->GetProcessSP();
- sb_process.SetSP (process_sp);
- }
+SBProcess SBTarget::GetProcess() {
+ SBProcess sb_process;
+ ProcessSP process_sp;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ process_sp = target_sp->GetProcessSP();
+ sb_process.SetSP(process_sp);
+ }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBTarget(%p)::GetProcess () => SBProcess(%p)",
- static_cast<void*>(target_sp.get()),
- static_cast<void*>(process_sp.get()));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBTarget(%p)::GetProcess () => SBProcess(%p)",
+ static_cast<void *>(target_sp.get()),
+ static_cast<void *>(process_sp.get()));
- return sb_process;
+ return sb_process;
}
-SBPlatform
-SBTarget::GetPlatform ()
-{
- TargetSP target_sp(GetSP());
- if (!target_sp)
- return SBPlatform();
+SBPlatform SBTarget::GetPlatform() {
+ TargetSP target_sp(GetSP());
+ if (!target_sp)
+ return SBPlatform();
- SBPlatform platform;
- platform.m_opaque_sp = target_sp->GetPlatform();
+ SBPlatform platform;
+ platform.m_opaque_sp = target_sp->GetPlatform();
- return platform;
+ return platform;
}
-SBDebugger
-SBTarget::GetDebugger () const
-{
- SBDebugger debugger;
- TargetSP target_sp(GetSP());
- if (target_sp)
- debugger.reset (target_sp->GetDebugger().shared_from_this());
- return debugger;
+SBDebugger SBTarget::GetDebugger() const {
+ SBDebugger debugger;
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ debugger.reset(target_sp->GetDebugger().shared_from_this());
+ return debugger;
}
-SBProcess
-SBTarget::LoadCore (const char *core_file)
-{
- SBProcess sb_process;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- FileSpec filespec(core_file, true);
- ProcessSP process_sp (target_sp->CreateProcess(target_sp->GetDebugger().GetListener(),
- NULL,
- &filespec));
- if (process_sp)
- {
- process_sp->LoadCore();
- sb_process.SetSP (process_sp);
- }
+SBProcess SBTarget::LoadCore(const char *core_file) {
+ SBProcess sb_process;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ FileSpec filespec(core_file, true);
+ ProcessSP process_sp(target_sp->CreateProcess(
+ target_sp->GetDebugger().GetListener(), NULL, &filespec));
+ if (process_sp) {
+ process_sp->LoadCore();
+ sb_process.SetSP(process_sp);
}
- return sb_process;
+ }
+ return sb_process;
}
-SBProcess
-SBTarget::LaunchSimple
-(
- char const **argv,
- char const **envp,
- const char *working_directory
-)
-{
- char *stdin_path = NULL;
- char *stdout_path = NULL;
- char *stderr_path = NULL;
- uint32_t launch_flags = 0;
- bool stop_at_entry = false;
- SBError error;
- SBListener listener = GetDebugger().GetListener();
- return Launch (listener,
- argv,
- envp,
- stdin_path,
- stdout_path,
- stderr_path,
- working_directory,
- launch_flags,
- stop_at_entry,
- error);
-}
-
-SBError
-SBTarget::Install()
-{
- SBError sb_error;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- sb_error.ref() = target_sp->Install(NULL);
- }
- return sb_error;
+SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp,
+ const char *working_directory) {
+ char *stdin_path = NULL;
+ char *stdout_path = NULL;
+ char *stderr_path = NULL;
+ uint32_t launch_flags = 0;
+ bool stop_at_entry = false;
+ SBError error;
+ SBListener listener = GetDebugger().GetListener();
+ return Launch(listener, argv, envp, stdin_path, stdout_path, stderr_path,
+ working_directory, launch_flags, stop_at_entry, error);
}
-SBProcess
-SBTarget::Launch
-(
- SBListener &listener,
- char const **argv,
- char const **envp,
- const char *stdin_path,
- const char *stdout_path,
- const char *stderr_path,
- const char *working_directory,
- uint32_t launch_flags, // See LaunchFlags
- bool stop_at_entry,
- lldb::SBError& error
-)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBProcess sb_process;
- ProcessSP process_sp;
- TargetSP target_sp(GetSP());
-
- if (log)
- log->Printf ("SBTarget(%p)::Launch (argv=%p, envp=%p, stdin=%s, stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, stop_at_entry=%i, &error (%p))...",
- static_cast<void*>(target_sp.get()),
- static_cast<void*>(argv), static_cast<void*>(envp),
- stdin_path ? stdin_path : "NULL",
- stdout_path ? stdout_path : "NULL",
- stderr_path ? stderr_path : "NULL",
- working_directory ? working_directory : "NULL",
- launch_flags, stop_at_entry,
- static_cast<void*>(error.get()));
-
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
-
- if (stop_at_entry)
- launch_flags |= eLaunchFlagStopAtEntry;
+SBError SBTarget::Install() {
+ SBError sb_error;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ sb_error.ref() = target_sp->Install(NULL);
+ }
+ return sb_error;
+}
- if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
- launch_flags |= eLaunchFlagDisableASLR;
+SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
+ char const **envp, const char *stdin_path,
+ const char *stdout_path, const char *stderr_path,
+ const char *working_directory,
+ uint32_t launch_flags, // See LaunchFlags
+ bool stop_at_entry, lldb::SBError &error) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- StateType state = eStateInvalid;
- process_sp = target_sp->GetProcessSP();
- if (process_sp)
- {
- state = process_sp->GetState();
-
- if (process_sp->IsAlive() && state != eStateConnected)
- {
- if (state == eStateAttaching)
- error.SetErrorString ("process attach is in progress");
- else
- error.SetErrorString ("a process is already being debugged");
- return sb_process;
- }
- }
+ SBProcess sb_process;
+ ProcessSP process_sp;
+ TargetSP target_sp(GetSP());
- if (state == eStateConnected)
- {
- // If we are already connected, then we have already specified the
- // listener, so if a valid listener is supplied, we need to error out
- // to let the client know.
- if (listener.IsValid())
- {
- error.SetErrorString ("process is connected and already has a listener, pass empty listener");
- return sb_process;
- }
- }
+ if (log)
+ log->Printf("SBTarget(%p)::Launch (argv=%p, envp=%p, stdin=%s, stdout=%s, "
+ "stderr=%s, working-dir=%s, launch_flags=0x%x, "
+ "stop_at_entry=%i, &error (%p))...",
+ static_cast<void *>(target_sp.get()), static_cast<void *>(argv),
+ static_cast<void *>(envp), stdin_path ? stdin_path : "NULL",
+ stdout_path ? stdout_path : "NULL",
+ stderr_path ? stderr_path : "NULL",
+ working_directory ? working_directory : "NULL", launch_flags,
+ stop_at_entry, static_cast<void *>(error.get()));
- if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
- launch_flags |= eLaunchFlagDisableSTDIO;
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- ProcessLaunchInfo launch_info(FileSpec{stdin_path, false},
- FileSpec{stdout_path, false},
- FileSpec{stderr_path, false},
- FileSpec{working_directory, false},
- launch_flags);
-
- Module *exe_module = target_sp->GetExecutableModulePointer();
- if (exe_module)
- launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
- if (argv)
- launch_info.GetArguments().AppendArguments (argv);
- if (envp)
- launch_info.GetEnvironmentEntries ().SetArguments (envp);
+ if (stop_at_entry)
+ launch_flags |= eLaunchFlagStopAtEntry;
- if (listener.IsValid())
- launch_info.SetListener(listener.GetSP());
+ if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
+ launch_flags |= eLaunchFlagDisableASLR;
- error.SetError (target_sp->Launch(launch_info, NULL));
+ StateType state = eStateInvalid;
+ process_sp = target_sp->GetProcessSP();
+ if (process_sp) {
+ state = process_sp->GetState();
- sb_process.SetSP(target_sp->GetProcessSP());
- }
- else
- {
- error.SetErrorString ("SBTarget is invalid");
+ if (process_sp->IsAlive() && state != eStateConnected) {
+ if (state == eStateAttaching)
+ error.SetErrorString("process attach is in progress");
+ else
+ error.SetErrorString("a process is already being debugged");
+ return sb_process;
+ }
}
- log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
- if (log)
- log->Printf("SBTarget(%p)::Launch (...) => SBProcess(%p), SBError(%s)", static_cast<void *>(target_sp.get()),
- static_cast<void *>(sb_process.GetSP().get()), error.GetCString());
-
- return sb_process;
-}
-
-SBProcess
-SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBProcess sb_process;
- TargetSP target_sp(GetSP());
+ if (state == eStateConnected) {
+ // If we are already connected, then we have already specified the
+ // listener, so if a valid listener is supplied, we need to error out
+ // to let the client know.
+ if (listener.IsValid()) {
+ error.SetErrorString("process is connected and already has a listener, "
+ "pass empty listener");
+ return sb_process;
+ }
+ }
- if (log)
- log->Printf ("SBTarget(%p)::Launch (launch_info, error)...",
- static_cast<void*>(target_sp.get()));
+ if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
+ launch_flags |= eLaunchFlagDisableSTDIO;
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- StateType state = eStateInvalid;
- {
- ProcessSP process_sp = target_sp->GetProcessSP();
- if (process_sp)
- {
- state = process_sp->GetState();
-
- if (process_sp->IsAlive() && state != eStateConnected)
- {
- if (state == eStateAttaching)
- error.SetErrorString ("process attach is in progress");
- else
- error.SetErrorString ("a process is already being debugged");
- return sb_process;
- }
- }
- }
+ ProcessLaunchInfo launch_info(
+ FileSpec{stdin_path, false}, FileSpec{stdout_path, false},
+ FileSpec{stderr_path, false}, FileSpec{working_directory, false},
+ launch_flags);
- lldb_private::ProcessLaunchInfo &launch_info = sb_launch_info.ref();
+ Module *exe_module = target_sp->GetExecutableModulePointer();
+ if (exe_module)
+ launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
+ if (argv)
+ launch_info.GetArguments().AppendArguments(argv);
+ if (envp)
+ launch_info.GetEnvironmentEntries().SetArguments(envp);
- if (!launch_info.GetExecutableFile())
- {
- Module *exe_module = target_sp->GetExecutableModulePointer();
- if (exe_module)
- launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
- }
+ if (listener.IsValid())
+ launch_info.SetListener(listener.GetSP());
- const ArchSpec &arch_spec = target_sp->GetArchitecture();
- if (arch_spec.IsValid())
- launch_info.GetArchitecture () = arch_spec;
+ error.SetError(target_sp->Launch(launch_info, NULL));
- error.SetError (target_sp->Launch (launch_info, NULL));
- sb_process.SetSP(target_sp->GetProcessSP());
- }
- else
- {
- error.SetErrorString ("SBTarget is invalid");
- }
+ sb_process.SetSP(target_sp->GetProcessSP());
+ } else {
+ error.SetErrorString("SBTarget is invalid");
+ }
- log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
- if (log)
- log->Printf ("SBTarget(%p)::Launch (...) => SBProcess(%p)",
- static_cast<void*>(target_sp.get()),
- static_cast<void*>(sb_process.GetSP().get()));
+ log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API);
+ if (log)
+ log->Printf("SBTarget(%p)::Launch (...) => SBProcess(%p), SBError(%s)",
+ static_cast<void *>(target_sp.get()),
+ static_cast<void *>(sb_process.GetSP().get()),
+ error.GetCString());
- return sb_process;
+ return sb_process;
}
-lldb::SBProcess
-SBTarget::Attach (SBAttachInfo &sb_attach_info, SBError& error)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- SBProcess sb_process;
- TargetSP target_sp(GetSP());
+ SBProcess sb_process;
+ TargetSP target_sp(GetSP());
- if (log)
- log->Printf ("SBTarget(%p)::Attach (sb_attach_info, error)...",
- static_cast<void*>(target_sp.get()));
+ if (log)
+ log->Printf("SBTarget(%p)::Launch (launch_info, error)...",
+ static_cast<void *>(target_sp.get()));
- if (target_sp)
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ StateType state = eStateInvalid;
{
- ProcessAttachInfo &attach_info = sb_attach_info.ref();
- if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid())
- {
- PlatformSP platform_sp = target_sp->GetPlatform();
- // See if we can pre-verify if a process exists or not
- if (platform_sp && platform_sp->IsConnected())
- {
- lldb::pid_t attach_pid = attach_info.GetProcessID();
- ProcessInstanceInfo instance_info;
- if (platform_sp->GetProcessInfo(attach_pid, instance_info))
- {
- attach_info.SetUserID(instance_info.GetEffectiveUserID());
- }
- else
- {
- error.ref().SetErrorStringWithFormat("no process found with process ID %" PRIu64, attach_pid);
- if (log)
- {
- log->Printf ("SBTarget(%p)::Attach (...) => error %s",
- static_cast<void*>(target_sp.get()), error.GetCString());
- }
- return sb_process;
- }
- }
+ ProcessSP process_sp = target_sp->GetProcessSP();
+ if (process_sp) {
+ state = process_sp->GetState();
+
+ if (process_sp->IsAlive() && state != eStateConnected) {
+ if (state == eStateAttaching)
+ error.SetErrorString("process attach is in progress");
+ else
+ error.SetErrorString("a process is already being debugged");
+ return sb_process;
}
- error.SetError(AttachToProcess(attach_info, *target_sp));
- if (error.Success())
- sb_process.SetSP(target_sp->GetProcessSP());
- }
- else
- {
- error.SetErrorString ("SBTarget is invalid");
+ }
}
- if (log)
- log->Printf ("SBTarget(%p)::Attach (...) => SBProcess(%p)",
- static_cast<void*>(target_sp.get()),
- static_cast<void*>(sb_process.GetSP().get()));
-
- return sb_process;
-}
+ lldb_private::ProcessLaunchInfo &launch_info = sb_launch_info.ref();
+ if (!launch_info.GetExecutableFile()) {
+ Module *exe_module = target_sp->GetExecutableModulePointer();
+ if (exe_module)
+ launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
+ }
-#if defined(__APPLE__)
+ const ArchSpec &arch_spec = target_sp->GetArchitecture();
+ if (arch_spec.IsValid())
+ launch_info.GetArchitecture() = arch_spec;
-lldb::SBProcess
-SBTarget::AttachToProcessWithID (SBListener &listener,
- ::pid_t pid,
- lldb::SBError& error)
-{
- return AttachToProcessWithID (listener, (lldb::pid_t)pid, error);
-}
+ error.SetError(target_sp->Launch(launch_info, NULL));
+ sb_process.SetSP(target_sp->GetProcessSP());
+ } else {
+ error.SetErrorString("SBTarget is invalid");
+ }
-#endif // #if defined(__APPLE__)
+ log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API);
+ if (log)
+ log->Printf("SBTarget(%p)::Launch (...) => SBProcess(%p)",
+ static_cast<void *>(target_sp.get()),
+ static_cast<void *>(sb_process.GetSP().get()));
-lldb::SBProcess
-SBTarget::AttachToProcessWithID
-(
- SBListener &listener,
- lldb::pid_t pid,// The process ID to attach to
- SBError& error // An error explaining what went wrong if attach fails
-)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ return sb_process;
+}
- SBProcess sb_process;
- TargetSP target_sp(GetSP());
+lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBTarget(%p)::%s (listener, pid=%" PRId64 ", error)...",
- static_cast<void*>(target_sp.get()),
- __FUNCTION__,
- pid);
+ SBProcess sb_process;
+ TargetSP target_sp(GetSP());
- if (target_sp)
- {
- ProcessAttachInfo attach_info;
- attach_info.SetProcessID (pid);
- if (listener.IsValid())
- attach_info.SetListener(listener.GetSP());
+ if (log)
+ log->Printf("SBTarget(%p)::Attach (sb_attach_info, error)...",
+ static_cast<void *>(target_sp.get()));
+ if (target_sp) {
+ ProcessAttachInfo &attach_info = sb_attach_info.ref();
+ if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid()) {
+ PlatformSP platform_sp = target_sp->GetPlatform();
+ // See if we can pre-verify if a process exists or not
+ if (platform_sp && platform_sp->IsConnected()) {
+ lldb::pid_t attach_pid = attach_info.GetProcessID();
ProcessInstanceInfo instance_info;
- if (target_sp->GetPlatform ()->GetProcessInfo (pid, instance_info))
- attach_info.SetUserID (instance_info.GetEffectiveUserID ());
-
- error.SetError (AttachToProcess (attach_info, *target_sp));
- if (error.Success ())
- sb_process.SetSP (target_sp->GetProcessSP ());
- }
- else
- error.SetErrorString ("SBTarget is invalid");
+ if (platform_sp->GetProcessInfo(attach_pid, instance_info)) {
+ attach_info.SetUserID(instance_info.GetEffectiveUserID());
+ } else {
+ error.ref().SetErrorStringWithFormat(
+ "no process found with process ID %" PRIu64, attach_pid);
+ if (log) {
+ log->Printf("SBTarget(%p)::Attach (...) => error %s",
+ static_cast<void *>(target_sp.get()),
+ error.GetCString());
+ }
+ return sb_process;
+ }
+ }
+ }
+ error.SetError(AttachToProcess(attach_info, *target_sp));
+ if (error.Success())
+ sb_process.SetSP(target_sp->GetProcessSP());
+ } else {
+ error.SetErrorString("SBTarget is invalid");
+ }
+
+ if (log)
+ log->Printf("SBTarget(%p)::Attach (...) => SBProcess(%p)",
+ static_cast<void *>(target_sp.get()),
+ static_cast<void *>(sb_process.GetSP().get()));
- if (log)
- log->Printf ("SBTarget(%p)::%s (...) => SBProcess(%p)",
- static_cast<void*>(target_sp.get ()),
- __FUNCTION__,
- static_cast<void*>(sb_process.GetSP().get ()));
- return sb_process;
-}
-
-lldb::SBProcess
-SBTarget::AttachToProcessWithName
-(
- SBListener &listener,
- const char *name, // basename of process to attach to
- bool wait_for, // if true wait for a new instance of "name" to be launched
- SBError& error // An error explaining what went wrong if attach fails
-)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ return sb_process;
+}
- SBProcess sb_process;
- TargetSP target_sp(GetSP());
+#if defined(__APPLE__)
- if (log)
- log->Printf ("SBTarget(%p)::%s (listener, name=%s, wait_for=%s, error)...",
- static_cast<void*>(target_sp.get()),
- __FUNCTION__,
- name,
- wait_for ? "true" : "false");
+lldb::SBProcess SBTarget::AttachToProcessWithID(SBListener &listener,
+ ::pid_t pid,
+ lldb::SBError &error) {
+ return AttachToProcessWithID(listener, (lldb::pid_t)pid, error);
+}
- if (name && target_sp)
- {
- ProcessAttachInfo attach_info;
- attach_info.GetExecutableFile().SetFile(name, false);
- attach_info.SetWaitForLaunch(wait_for);
- if (listener.IsValid())
- attach_info.SetListener(listener.GetSP());
-
- error.SetError (AttachToProcess (attach_info, *target_sp));
- if (error.Success ())
- sb_process.SetSP (target_sp->GetProcessSP ());
- }
- else
- error.SetErrorString ("SBTarget is invalid");
+#endif // #if defined(__APPLE__)
- if (log)
- log->Printf ("SBTarget(%p)::%s (...) => SBProcess(%p)",
- static_cast<void*>(target_sp.get()),
- __FUNCTION__,
- static_cast<void*>(sb_process.GetSP().get()));
- return sb_process;
+lldb::SBProcess SBTarget::AttachToProcessWithID(
+ SBListener &listener,
+ lldb::pid_t pid, // The process ID to attach to
+ SBError &error // An error explaining what went wrong if attach fails
+ ) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBProcess sb_process;
+ TargetSP target_sp(GetSP());
+
+ if (log)
+ log->Printf("SBTarget(%p)::%s (listener, pid=%" PRId64 ", error)...",
+ static_cast<void *>(target_sp.get()), __FUNCTION__, pid);
+
+ if (target_sp) {
+ ProcessAttachInfo attach_info;
+ attach_info.SetProcessID(pid);
+ if (listener.IsValid())
+ attach_info.SetListener(listener.GetSP());
+
+ ProcessInstanceInfo instance_info;
+ if (target_sp->GetPlatform()->GetProcessInfo(pid, instance_info))
+ attach_info.SetUserID(instance_info.GetEffectiveUserID());
+
+ error.SetError(AttachToProcess(attach_info, *target_sp));
+ if (error.Success())
+ sb_process.SetSP(target_sp->GetProcessSP());
+ } else
+ error.SetErrorString("SBTarget is invalid");
+
+ if (log)
+ log->Printf("SBTarget(%p)::%s (...) => SBProcess(%p)",
+ static_cast<void *>(target_sp.get()), __FUNCTION__,
+ static_cast<void *>(sb_process.GetSP().get()));
+ return sb_process;
}
-lldb::SBProcess
-SBTarget::ConnectRemote
-(
+lldb::SBProcess SBTarget::AttachToProcessWithName(
SBListener &listener,
- const char *url,
- const char *plugin_name,
- SBError& error
-)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBProcess sb_process;
- ProcessSP process_sp;
- TargetSP target_sp(GetSP());
-
- if (log)
- log->Printf ("SBTarget(%p)::ConnectRemote (listener, url=%s, plugin_name=%s, error)...",
- static_cast<void*>(target_sp.get()), url, plugin_name);
-
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- if (listener.IsValid())
- process_sp = target_sp->CreateProcess (listener.m_opaque_sp, plugin_name, NULL);
- else
- process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), plugin_name, NULL);
-
- if (process_sp)
- {
- sb_process.SetSP (process_sp);
- error.SetError (process_sp->ConnectRemote (NULL, url));
- }
- else
- {
- error.SetErrorString ("unable to create lldb_private::Process");
- }
- }
+ const char *name, // basename of process to attach to
+ bool wait_for, // if true wait for a new instance of "name" to be launched
+ SBError &error // An error explaining what went wrong if attach fails
+ ) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBProcess sb_process;
+ TargetSP target_sp(GetSP());
+
+ if (log)
+ log->Printf("SBTarget(%p)::%s (listener, name=%s, wait_for=%s, error)...",
+ static_cast<void *>(target_sp.get()), __FUNCTION__, name,
+ wait_for ? "true" : "false");
+
+ if (name && target_sp) {
+ ProcessAttachInfo attach_info;
+ attach_info.GetExecutableFile().SetFile(name, false);
+ attach_info.SetWaitForLaunch(wait_for);
+ if (listener.IsValid())
+ attach_info.SetListener(listener.GetSP());
+
+ error.SetError(AttachToProcess(attach_info, *target_sp));
+ if (error.Success())
+ sb_process.SetSP(target_sp->GetProcessSP());
+ } else
+ error.SetErrorString("SBTarget is invalid");
+
+ if (log)
+ log->Printf("SBTarget(%p)::%s (...) => SBProcess(%p)",
+ static_cast<void *>(target_sp.get()), __FUNCTION__,
+ static_cast<void *>(sb_process.GetSP().get()));
+ return sb_process;
+}
+
+lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url,
+ const char *plugin_name,
+ SBError &error) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBProcess sb_process;
+ ProcessSP process_sp;
+ TargetSP target_sp(GetSP());
+
+ if (log)
+ log->Printf("SBTarget(%p)::ConnectRemote (listener, url=%s, "
+ "plugin_name=%s, error)...",
+ static_cast<void *>(target_sp.get()), url, plugin_name);
+
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ if (listener.IsValid())
+ process_sp =
+ target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, NULL);
else
- {
- error.SetErrorString ("SBTarget is invalid");
- }
+ process_sp = target_sp->CreateProcess(
+ target_sp->GetDebugger().GetListener(), plugin_name, NULL);
- if (log)
- log->Printf ("SBTarget(%p)::ConnectRemote (...) => SBProcess(%p)",
- static_cast<void*>(target_sp.get()),
- static_cast<void*>(process_sp.get()));
- return sb_process;
+ if (process_sp) {
+ sb_process.SetSP(process_sp);
+ error.SetError(process_sp->ConnectRemote(NULL, url));
+ } else {
+ error.SetErrorString("unable to create lldb_private::Process");
+ }
+ } else {
+ error.SetErrorString("SBTarget is invalid");
+ }
+
+ if (log)
+ log->Printf("SBTarget(%p)::ConnectRemote (...) => SBProcess(%p)",
+ static_cast<void *>(target_sp.get()),
+ static_cast<void *>(process_sp.get()));
+ return sb_process;
+}
+
+SBFileSpec SBTarget::GetExecutable() {
+
+ SBFileSpec exe_file_spec;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ Module *exe_module = target_sp->GetExecutableModulePointer();
+ if (exe_module)
+ exe_file_spec.SetFileSpec(exe_module->GetFileSpec());
+ }
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ log->Printf("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)",
+ static_cast<void *>(target_sp.get()),
+ static_cast<const void *>(exe_file_spec.get()));
+ }
+
+ return exe_file_spec;
+}
+
+bool SBTarget::operator==(const SBTarget &rhs) const {
+ return m_opaque_sp.get() == rhs.m_opaque_sp.get();
+}
+
+bool SBTarget::operator!=(const SBTarget &rhs) const {
+ return m_opaque_sp.get() != rhs.m_opaque_sp.get();
+}
+
+lldb::TargetSP SBTarget::GetSP() const { return m_opaque_sp; }
+
+void SBTarget::SetSP(const lldb::TargetSP &target_sp) {
+ m_opaque_sp = target_sp;
+}
+
+lldb::SBAddress SBTarget::ResolveLoadAddress(lldb::addr_t vm_addr) {
+ lldb::SBAddress sb_addr;
+ Address &addr = sb_addr.ref();
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ if (target_sp->ResolveLoadAddress(vm_addr, addr))
+ return sb_addr;
+ }
+
+ // We have a load address that isn't in a section, just return an address
+ // with the offset filled in (the address) and the section set to NULL
+ addr.SetRawAddress(vm_addr);
+ return sb_addr;
+}
+
+lldb::SBAddress SBTarget::ResolveFileAddress(lldb::addr_t file_addr) {
+ lldb::SBAddress sb_addr;
+ Address &addr = sb_addr.ref();
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ if (target_sp->ResolveFileAddress(file_addr, addr))
+ return sb_addr;
+ }
+
+ addr.SetRawAddress(file_addr);
+ return sb_addr;
+}
+
+lldb::SBAddress SBTarget::ResolvePastLoadAddress(uint32_t stop_id,
+ lldb::addr_t vm_addr) {
+ lldb::SBAddress sb_addr;
+ Address &addr = sb_addr.ref();
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ if (target_sp->ResolveLoadAddress(vm_addr, addr))
+ return sb_addr;
+ }
+
+ // We have a load address that isn't in a section, just return an address
+ // with the offset filled in (the address) and the section set to NULL
+ addr.SetRawAddress(vm_addr);
+ return sb_addr;
}
-SBFileSpec
-SBTarget::GetExecutable ()
-{
+SBSymbolContext
+SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr,
+ uint32_t resolve_scope) {
+ SBSymbolContext sc;
+ if (addr.IsValid()) {
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ target_sp->GetImages().ResolveSymbolContextForAddress(
+ addr.ref(), resolve_scope, sc.ref());
+ }
+ return sc;
+}
+
+size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size,
+ lldb::SBError &error) {
+ SBError sb_error;
+ size_t bytes_read = 0;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ bytes_read =
+ target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref());
+ } else {
+ sb_error.SetErrorString("invalid target");
+ }
+
+ return bytes_read;
+}
+
+SBBreakpoint SBTarget::BreakpointCreateByLocation(const char *file,
+ uint32_t line) {
+ return SBBreakpoint(
+ BreakpointCreateByLocation(SBFileSpec(file, false), line));
+}
- SBFileSpec exe_file_spec;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- Module *exe_module = target_sp->GetExecutableModulePointer();
- if (exe_module)
- exe_file_spec.SetFileSpec (exe_module->GetFileSpec());
- }
+SBBreakpoint
+SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
+ uint32_t line) {
+ return BreakpointCreateByLocation(sb_file_spec, line, 0);
+}
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)",
- static_cast<void*>(target_sp.get()),
- static_cast<const void*>(exe_file_spec.get()));
- }
+SBBreakpoint
+SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
+ uint32_t line, lldb::addr_t offset) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBBreakpoint sb_bp;
+ TargetSP target_sp(GetSP());
+ if (target_sp && line != 0) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+
+ const LazyBool check_inlines = eLazyBoolCalculate;
+ const LazyBool skip_prologue = eLazyBoolCalculate;
+ const bool internal = false;
+ const bool hardware = false;
+ const LazyBool move_to_nearest_code = eLazyBoolCalculate;
+ *sb_bp = target_sp->CreateBreakpoint(NULL, *sb_file_spec, line, offset,
+ check_inlines, skip_prologue, internal,
+ hardware, move_to_nearest_code);
+ }
+
+ if (log) {
+ SBStream sstr;
+ sb_bp.GetDescription(sstr);
+ char path[PATH_MAX];
+ sb_file_spec->GetPath(path, sizeof(path));
+ log->Printf("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => "
+ "SBBreakpoint(%p): %s",
+ static_cast<void *>(target_sp.get()), path, line,
+ static_cast<void *>(sb_bp.get()), sstr.GetData());
+ }
+
+ return sb_bp;
+}
+
+SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name,
+ const char *module_name) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBBreakpoint sb_bp;
+ TargetSP target_sp(GetSP());
+ if (target_sp.get()) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+
+ const bool internal = false;
+ const bool hardware = false;
+ const LazyBool skip_prologue = eLazyBoolCalculate;
+ const lldb::addr_t offset = 0;
+ if (module_name && module_name[0]) {
+ FileSpecList module_spec_list;
+ module_spec_list.Append(FileSpec(module_name, false));
+ *sb_bp = target_sp->CreateBreakpoint(
+ &module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto,
+ eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
+ } else {
+ *sb_bp = target_sp->CreateBreakpoint(
+ NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown,
+ offset, skip_prologue, internal, hardware);
+ }
+ }
+
+ if (log)
+ log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", "
+ "module=\"%s\") => SBBreakpoint(%p)",
+ static_cast<void *>(target_sp.get()), symbol_name, module_name,
+ static_cast<void *>(sb_bp.get()));
- return exe_file_spec;
+ return sb_bp;
}
-bool
-SBTarget::operator == (const SBTarget &rhs) const
-{
- return m_opaque_sp.get() == rhs.m_opaque_sp.get();
+lldb::SBBreakpoint
+SBTarget::BreakpointCreateByName(const char *symbol_name,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list) {
+ uint32_t name_type_mask = eFunctionNameTypeAuto;
+ return BreakpointCreateByName(symbol_name, name_type_mask,
+ eLanguageTypeUnknown, module_list,
+ comp_unit_list);
+}
+
+lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
+ const char *symbol_name, uint32_t name_type_mask,
+ const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
+ return BreakpointCreateByName(symbol_name, name_type_mask,
+ eLanguageTypeUnknown, module_list,
+ comp_unit_list);
+}
+
+lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
+ const char *symbol_name, uint32_t name_type_mask,
+ LanguageType symbol_language, const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBBreakpoint sb_bp;
+ TargetSP target_sp(GetSP());
+ if (target_sp && symbol_name && symbol_name[0]) {
+ const bool internal = false;
+ const bool hardware = false;
+ const LazyBool skip_prologue = eLazyBoolCalculate;
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ *sb_bp = target_sp->CreateBreakpoint(
+ module_list.get(), comp_unit_list.get(), symbol_name, name_type_mask,
+ symbol_language, 0, skip_prologue, internal, hardware);
+ }
+
+ if (log)
+ log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", "
+ "name_type: %d) => SBBreakpoint(%p)",
+ static_cast<void *>(target_sp.get()), symbol_name,
+ name_type_mask, static_cast<void *>(sb_bp.get()));
+
+ return sb_bp;
+}
+
+lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
+ const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
+ const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
+ return BreakpointCreateByNames(symbol_names, num_names, name_type_mask,
+ eLanguageTypeUnknown, module_list,
+ comp_unit_list);
+}
+
+lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
+ const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
+ LanguageType symbol_language, const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list) {
+ return BreakpointCreateByNames(symbol_names, num_names, name_type_mask,
+ eLanguageTypeUnknown, 0, module_list,
+ comp_unit_list);
+}
+
+lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
+ const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
+ LanguageType symbol_language, lldb::addr_t offset,
+ const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBBreakpoint sb_bp;
+ TargetSP target_sp(GetSP());
+ if (target_sp && num_names > 0) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ const bool internal = false;
+ const bool hardware = false;
+ const LazyBool skip_prologue = eLazyBoolCalculate;
+ *sb_bp = target_sp->CreateBreakpoint(
+ module_list.get(), comp_unit_list.get(), symbol_names, num_names,
+ name_type_mask, symbol_language, offset, skip_prologue, internal,
+ hardware);
+ }
+
+ if (log) {
+ log->Printf("SBTarget(%p)::BreakpointCreateByName (symbols={",
+ static_cast<void *>(target_sp.get()));
+ for (uint32_t i = 0; i < num_names; i++) {
+ char sep;
+ if (i < num_names - 1)
+ sep = ',';
+ else
+ sep = '}';
+ if (symbol_names[i] != NULL)
+ log->Printf("\"%s\"%c ", symbol_names[i], sep);
+ else
+ log->Printf("\"<NULL>\"%c ", sep);
+ }
+ log->Printf("name_type: %d) => SBBreakpoint(%p)", name_type_mask,
+ static_cast<void *>(sb_bp.get()));
+ }
+
+ return sb_bp;
+}
+
+SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
+ const char *module_name) {
+ SBFileSpecList module_spec_list;
+ SBFileSpecList comp_unit_list;
+ if (module_name && module_name[0]) {
+ module_spec_list.Append(FileSpec(module_name, false));
+ }
+ return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown,
+ module_spec_list, comp_unit_list);
}
-bool
-SBTarget::operator != (const SBTarget &rhs) const
-{
- return m_opaque_sp.get() != rhs.m_opaque_sp.get();
-}
+lldb::SBBreakpoint
+SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list) {
+ return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown,
+ module_list, comp_unit_list);
+}
+
+lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(
+ const char *symbol_name_regex, LanguageType symbol_language,
+ const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBBreakpoint sb_bp;
+ TargetSP target_sp(GetSP());
+ if (target_sp && symbol_name_regex && symbol_name_regex[0]) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ RegularExpression regexp(symbol_name_regex);
+ const bool internal = false;
+ const bool hardware = false;
+ const LazyBool skip_prologue = eLazyBoolCalculate;
+
+ *sb_bp = target_sp->CreateFuncRegexBreakpoint(
+ module_list.get(), comp_unit_list.get(), regexp, symbol_language,
+ skip_prologue, internal, hardware);
+ }
+
+ if (log)
+ log->Printf("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") "
+ "=> SBBreakpoint(%p)",
+ static_cast<void *>(target_sp.get()), symbol_name_regex,
+ static_cast<void *>(sb_bp.get()));
+
+ return sb_bp;
+}
+
+SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBBreakpoint sb_bp;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ const bool hardware = false;
+ *sb_bp = target_sp->CreateBreakpoint(address, false, hardware);
+ }
+
+ if (log)
+ log->Printf("SBTarget(%p)::BreakpointCreateByAddress (address=%" PRIu64
+ ") => SBBreakpoint(%p)",
+ static_cast<void *>(target_sp.get()),
+ static_cast<uint64_t>(address),
+ static_cast<void *>(sb_bp.get()));
+
+ return sb_bp;
+}
+
+SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBBreakpoint sb_bp;
+ TargetSP target_sp(GetSP());
+ if (!sb_address.IsValid()) {
+ if (log)
+ log->Printf("SBTarget(%p)::BreakpointCreateBySBAddress called with "
+ "invalid address",
+ static_cast<void *>(target_sp.get()));
+ return sb_bp;
+ }
-lldb::TargetSP
-SBTarget::GetSP () const
-{
- return m_opaque_sp;
-}
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ const bool hardware = false;
+ *sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware);
+ }
+
+ if (log) {
+ SBStream s;
+ sb_address.GetDescription(s);
+ log->Printf("SBTarget(%p)::BreakpointCreateBySBAddress (address=%s) => "
+ "SBBreakpoint(%p)",
+ static_cast<void *>(target_sp.get()), s.GetData(),
+ static_cast<void *>(sb_bp.get()));
+ }
-void
-SBTarget::SetSP (const lldb::TargetSP& target_sp)
-{
- m_opaque_sp = target_sp;
+ return sb_bp;
}
-lldb::SBAddress
-SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr)
-{
- lldb::SBAddress sb_addr;
- Address &addr = sb_addr.ref();
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- if (target_sp->ResolveLoadAddress (vm_addr, addr))
- return sb_addr;
- }
-
- // We have a load address that isn't in a section, just return an address
- // with the offset filled in (the address) and the section set to NULL
- addr.SetRawAddress(vm_addr);
- return sb_addr;
-}
-
-lldb::SBAddress
-SBTarget::ResolveFileAddress (lldb::addr_t file_addr)
-{
- lldb::SBAddress sb_addr;
- Address &addr = sb_addr.ref();
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- if (target_sp->ResolveFileAddress (file_addr, addr))
- return sb_addr;
- }
+lldb::SBBreakpoint
+SBTarget::BreakpointCreateBySourceRegex(const char *source_regex,
+ const lldb::SBFileSpec &source_file,
+ const char *module_name) {
+ SBFileSpecList module_spec_list;
+
+ if (module_name && module_name[0]) {
+ module_spec_list.Append(FileSpec(module_name, false));
+ }
+
+ SBFileSpecList source_file_list;
+ if (source_file.IsValid()) {
+ source_file_list.Append(source_file);
+ }
+
+ return BreakpointCreateBySourceRegex(source_regex, module_spec_list,
+ source_file_list);
+}
+
+lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
+ const char *source_regex, const SBFileSpecList &module_list,
+ const lldb::SBFileSpecList &source_file_list) {
+ return BreakpointCreateBySourceRegex(source_regex, module_list,
+ source_file_list, SBStringList());
+}
+
+lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
+ const char *source_regex, const SBFileSpecList &module_list,
+ const lldb::SBFileSpecList &source_file_list,
+ const SBStringList &func_names) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBBreakpoint sb_bp;
+ TargetSP target_sp(GetSP());
+ if (target_sp && source_regex && source_regex[0]) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ const bool hardware = false;
+ const LazyBool move_to_nearest_code = eLazyBoolCalculate;
+ RegularExpression regexp(source_regex);
+ std::unordered_set<std::string> func_names_set;
+ for (size_t i = 0; i < func_names.GetSize(); i++) {
+ func_names_set.insert(func_names.GetStringAtIndex(i));
+ }
+
+ *sb_bp = target_sp->CreateSourceRegexBreakpoint(
+ module_list.get(), source_file_list.get(), func_names_set, regexp,
+ false, hardware, move_to_nearest_code);
+ }
+
+ if (log)
+ log->Printf("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") "
+ "=> SBBreakpoint(%p)",
+ static_cast<void *>(target_sp.get()), source_regex,
+ static_cast<void *>(sb_bp.get()));
- addr.SetRawAddress(file_addr);
- return sb_addr;
+ return sb_bp;
}
-lldb::SBAddress
-SBTarget::ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr)
-{
- lldb::SBAddress sb_addr;
- Address &addr = sb_addr.ref();
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- if (target_sp->ResolveLoadAddress (vm_addr, addr))
- return sb_addr;
- }
-
- // We have a load address that isn't in a section, just return an address
- // with the offset filled in (the address) and the section set to NULL
- addr.SetRawAddress(vm_addr);
- return sb_addr;
+lldb::SBBreakpoint
+SBTarget::BreakpointCreateForException(lldb::LanguageType language,
+ bool catch_bp, bool throw_bp) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBBreakpoint sb_bp;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ const bool hardware = false;
+ *sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp,
+ hardware);
+ }
+
+ if (log)
+ log->Printf("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: "
+ "%s throw: %s) => SBBreakpoint(%p)",
+ static_cast<void *>(target_sp.get()),
+ Language::GetNameForLanguageType(language),
+ catch_bp ? "on" : "off", throw_bp ? "on" : "off",
+ static_cast<void *>(sb_bp.get()));
+
+ return sb_bp;
+}
+
+uint32_t SBTarget::GetNumBreakpoints() const {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ // The breakpoint list is thread safe, no need to lock
+ return target_sp->GetBreakpointList().GetSize();
+ }
+ return 0;
+}
+
+SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const {
+ SBBreakpoint sb_breakpoint;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ // The breakpoint list is thread safe, no need to lock
+ *sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
+ }
+ return sb_breakpoint;
+}
+
+bool SBTarget::BreakpointDelete(break_id_t bp_id) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ bool result = false;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ result = target_sp->RemoveBreakpointByID(bp_id);
+ }
+
+ if (log)
+ log->Printf("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i",
+ static_cast<void *>(target_sp.get()),
+ static_cast<uint32_t>(bp_id), result);
+
+ return result;
+}
+
+SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBBreakpoint sb_breakpoint;
+ TargetSP target_sp(GetSP());
+ if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ *sb_breakpoint = target_sp->GetBreakpointByID(bp_id);
+ }
+
+ if (log)
+ log->Printf(
+ "SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)",
+ static_cast<void *>(target_sp.get()), static_cast<uint32_t>(bp_id),
+ static_cast<void *>(sb_breakpoint.get()));
+
+ return sb_breakpoint;
+}
+
+bool SBTarget::EnableAllBreakpoints() {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ target_sp->EnableAllBreakpoints();
+ return true;
+ }
+ return false;
}
-SBSymbolContext
-SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr,
- uint32_t resolve_scope)
-{
- SBSymbolContext sc;
- if (addr.IsValid())
- {
- TargetSP target_sp(GetSP());
- if (target_sp)
- target_sp->GetImages().ResolveSymbolContextForAddress (addr.ref(), resolve_scope, sc.ref());
- }
- return sc;
+bool SBTarget::DisableAllBreakpoints() {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ target_sp->DisableAllBreakpoints();
+ return true;
+ }
+ return false;
}
-size_t
-SBTarget::ReadMemory (const SBAddress addr,
- void *buf,
- size_t size,
- lldb::SBError &error)
-{
- SBError sb_error;
- size_t bytes_read = 0;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- bytes_read = target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref());
- }
- else
- {
- sb_error.SetErrorString("invalid target");
- }
+bool SBTarget::DeleteAllBreakpoints() {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ target_sp->RemoveAllBreakpoints();
+ return true;
+ }
+ return false;
+}
- return bytes_read;
+uint32_t SBTarget::GetNumWatchpoints() const {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ // The watchpoint list is thread safe, no need to lock
+ return target_sp->GetWatchpointList().GetSize();
+ }
+ return 0;
+}
+
+SBWatchpoint SBTarget::GetWatchpointAtIndex(uint32_t idx) const {
+ SBWatchpoint sb_watchpoint;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ // The watchpoint list is thread safe, no need to lock
+ sb_watchpoint.SetSP(target_sp->GetWatchpointList().GetByIndex(idx));
+ }
+ return sb_watchpoint;
+}
+
+bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ bool result = false;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ std::unique_lock<std::recursive_mutex> lock;
+ target_sp->GetWatchpointList().GetListMutex(lock);
+ result = target_sp->RemoveWatchpointByID(wp_id);
+ }
+
+ if (log)
+ log->Printf("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i",
+ static_cast<void *>(target_sp.get()),
+ static_cast<uint32_t>(wp_id), result);
+
+ return result;
+}
+
+SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBWatchpoint sb_watchpoint;
+ lldb::WatchpointSP watchpoint_sp;
+ TargetSP target_sp(GetSP());
+ if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ std::unique_lock<std::recursive_mutex> lock;
+ target_sp->GetWatchpointList().GetListMutex(lock);
+ watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id);
+ sb_watchpoint.SetSP(watchpoint_sp);
+ }
+
+ if (log)
+ log->Printf(
+ "SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)",
+ static_cast<void *>(target_sp.get()), static_cast<uint32_t>(wp_id),
+ static_cast<void *>(watchpoint_sp.get()));
+
+ return sb_watchpoint;
+}
+
+lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size,
+ bool read, bool write,
+ SBError &error) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBWatchpoint sb_watchpoint;
+ lldb::WatchpointSP watchpoint_sp;
+ TargetSP target_sp(GetSP());
+ if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS &&
+ size > 0) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ uint32_t watch_type = 0;
+ if (read)
+ watch_type |= LLDB_WATCH_TYPE_READ;
+ if (write)
+ watch_type |= LLDB_WATCH_TYPE_WRITE;
+ if (watch_type == 0) {
+ error.SetErrorString(
+ "Can't create a watchpoint that is neither read nor write.");
+ return sb_watchpoint;
+ }
+
+ // Target::CreateWatchpoint() is thread safe.
+ Error cw_error;
+ // This API doesn't take in a type, so we can't figure out what it is.
+ CompilerType *type = NULL;
+ watchpoint_sp =
+ target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
+ error.SetError(cw_error);
+ sb_watchpoint.SetSP(watchpoint_sp);
+ }
+
+ if (log)
+ log->Printf("SBTarget(%p)::WatchAddress (addr=0x%" PRIx64
+ ", 0x%u) => SBWatchpoint(%p)",
+ static_cast<void *>(target_sp.get()), addr,
+ static_cast<uint32_t>(size),
+ static_cast<void *>(watchpoint_sp.get()));
+
+ return sb_watchpoint;
+}
+
+bool SBTarget::EnableAllWatchpoints() {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ std::unique_lock<std::recursive_mutex> lock;
+ target_sp->GetWatchpointList().GetListMutex(lock);
+ target_sp->EnableAllWatchpoints();
+ return true;
+ }
+ return false;
}
-SBBreakpoint
-SBTarget::BreakpointCreateByLocation (const char *file,
- uint32_t line)
-{
- return SBBreakpoint(BreakpointCreateByLocation (SBFileSpec (file, false), line));
+bool SBTarget::DisableAllWatchpoints() {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ std::unique_lock<std::recursive_mutex> lock;
+ target_sp->GetWatchpointList().GetListMutex(lock);
+ target_sp->DisableAllWatchpoints();
+ return true;
+ }
+ return false;
}
-SBBreakpoint
-SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec,
- uint32_t line)
-{
- return BreakpointCreateByLocation(sb_file_spec, line, 0);
+SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr,
+ SBType type) {
+ SBValue sb_value;
+ lldb::ValueObjectSP new_value_sp;
+ if (IsValid() && name && *name && addr.IsValid() && type.IsValid()) {
+ lldb::addr_t load_addr(addr.GetLoadAddress(*this));
+ ExecutionContext exe_ctx(
+ ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
+ CompilerType ast_type(type.GetSP()->GetCompilerType(true));
+ new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr,
+ exe_ctx, ast_type);
+ }
+ sb_value.SetSP(new_value_sp);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ if (new_value_sp)
+ log->Printf("SBTarget(%p)::CreateValueFromAddress => \"%s\"",
+ static_cast<void *>(m_opaque_sp.get()),
+ new_value_sp->GetName().AsCString());
+ else
+ log->Printf("SBTarget(%p)::CreateValueFromAddress => NULL",
+ static_cast<void *>(m_opaque_sp.get()));
+ }
+ return sb_value;
+}
+
+lldb::SBValue SBTarget::CreateValueFromData(const char *name, lldb::SBData data,
+ lldb::SBType type) {
+ SBValue sb_value;
+ lldb::ValueObjectSP new_value_sp;
+ if (IsValid() && name && *name && data.IsValid() && type.IsValid()) {
+ DataExtractorSP extractor(*data);
+ ExecutionContext exe_ctx(
+ ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
+ CompilerType ast_type(type.GetSP()->GetCompilerType(true));
+ new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor,
+ exe_ctx, ast_type);
+ }
+ sb_value.SetSP(new_value_sp);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ if (new_value_sp)
+ log->Printf("SBTarget(%p)::CreateValueFromData => \"%s\"",
+ static_cast<void *>(m_opaque_sp.get()),
+ new_value_sp->GetName().AsCString());
+ else
+ log->Printf("SBTarget(%p)::CreateValueFromData => NULL",
+ static_cast<void *>(m_opaque_sp.get()));
+ }
+ return sb_value;
+}
+
+lldb::SBValue SBTarget::CreateValueFromExpression(const char *name,
+ const char *expr) {
+ SBValue sb_value;
+ lldb::ValueObjectSP new_value_sp;
+ if (IsValid() && name && *name && expr && *expr) {
+ ExecutionContext exe_ctx(
+ ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
+ new_value_sp =
+ ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx);
+ }
+ sb_value.SetSP(new_value_sp);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ if (new_value_sp)
+ log->Printf("SBTarget(%p)::CreateValueFromExpression => \"%s\"",
+ static_cast<void *>(m_opaque_sp.get()),
+ new_value_sp->GetName().AsCString());
+ else
+ log->Printf("SBTarget(%p)::CreateValueFromExpression => NULL",
+ static_cast<void *>(m_opaque_sp.get()));
+ }
+ return sb_value;
}
-SBBreakpoint
-SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec,
- uint32_t line,
- lldb::addr_t offset)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+bool SBTarget::DeleteAllWatchpoints() {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ std::unique_lock<std::recursive_mutex> lock;
+ target_sp->GetWatchpointList().GetListMutex(lock);
+ target_sp->RemoveAllWatchpoints();
+ return true;
+ }
+ return false;
+}
- SBBreakpoint sb_bp;
- TargetSP target_sp(GetSP());
- if (target_sp && line != 0)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
+ const char *uuid_cstr) {
+ return AddModule(path, triple, uuid_cstr, NULL);
+}
+
+lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
+ const char *uuid_cstr, const char *symfile) {
+ lldb::SBModule sb_module;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ ModuleSpec module_spec;
+ if (path)
+ module_spec.GetFileSpec().SetFile(path, false);
+
+ if (uuid_cstr)
+ module_spec.GetUUID().SetFromCString(uuid_cstr);
+
+ if (triple)
+ module_spec.GetArchitecture().SetTriple(triple,
+ target_sp->GetPlatform().get());
+ else
+ module_spec.GetArchitecture() = target_sp->GetArchitecture();
- const LazyBool check_inlines = eLazyBoolCalculate;
- const LazyBool skip_prologue = eLazyBoolCalculate;
- const bool internal = false;
- const bool hardware = false;
- const LazyBool move_to_nearest_code = eLazyBoolCalculate;
- *sb_bp = target_sp->CreateBreakpoint (NULL,
- *sb_file_spec,
- line,
- offset,
- check_inlines,
- skip_prologue,
- internal,
- hardware,
- move_to_nearest_code);
- }
+ if (symfile)
+ module_spec.GetSymbolFileSpec().SetFile(symfile, false);
- if (log)
- {
- SBStream sstr;
- sb_bp.GetDescription (sstr);
- char path[PATH_MAX];
- sb_file_spec->GetPath (path, sizeof(path));
- log->Printf ("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => SBBreakpoint(%p): %s",
- static_cast<void*>(target_sp.get()), path, line,
- static_cast<void*>(sb_bp.get()), sstr.GetData());
- }
+ sb_module.SetSP(target_sp->GetSharedModule(module_spec));
+ }
+ return sb_module;
+}
- return sb_bp;
+lldb::SBModule SBTarget::AddModule(const SBModuleSpec &module_spec) {
+ lldb::SBModule sb_module;
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ sb_module.SetSP(target_sp->GetSharedModule(*module_spec.m_opaque_ap));
+ return sb_module;
}
-SBBreakpoint
-SBTarget::BreakpointCreateByName (const char *symbol_name,
- const char *module_name)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+bool SBTarget::AddModule(lldb::SBModule &module) {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ target_sp->GetImages().AppendIfNeeded(module.GetSP());
+ return true;
+ }
+ return false;
+}
- SBBreakpoint sb_bp;
- TargetSP target_sp(GetSP());
- if (target_sp.get())
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+uint32_t SBTarget::GetNumModules() const {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- const bool internal = false;
- const bool hardware = false;
- const LazyBool skip_prologue = eLazyBoolCalculate;
- const lldb::addr_t offset = 0;
- if (module_name && module_name[0])
- {
- FileSpecList module_spec_list;
- module_spec_list.Append (FileSpec (module_name, false));
- *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
- }
- else
- {
- *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
+ uint32_t num = 0;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ // The module list is thread safe, no need to lock
+ num = target_sp->GetImages().GetSize();
+ }
+
+ if (log)
+ log->Printf("SBTarget(%p)::GetNumModules () => %d",
+ static_cast<void *>(target_sp.get()), num);
+
+ return num;
+}
+
+void SBTarget::Clear() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ if (log)
+ log->Printf("SBTarget(%p)::Clear ()",
+ static_cast<void *>(m_opaque_sp.get()));
+
+ m_opaque_sp.reset();
+}
+
+SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) {
+ SBModule sb_module;
+ TargetSP target_sp(GetSP());
+ if (target_sp && sb_file_spec.IsValid()) {
+ ModuleSpec module_spec(*sb_file_spec);
+ // The module list is thread safe, no need to lock
+ sb_module.SetSP(target_sp->GetImages().FindFirstModule(module_spec));
+ }
+ return sb_module;
+}
+
+lldb::ByteOrder SBTarget::GetByteOrder() {
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ return target_sp->GetArchitecture().GetByteOrder();
+ return eByteOrderInvalid;
+}
+
+const char *SBTarget::GetTriple() {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::string triple(target_sp->GetArchitecture().GetTriple().str());
+ // Unique the string so we don't run into ownership issues since
+ // the const strings put the string into the string pool once and
+ // the strings never comes out
+ ConstString const_triple(triple.c_str());
+ return const_triple.GetCString();
+ }
+ return NULL;
+}
+
+uint32_t SBTarget::GetDataByteSize() {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ return target_sp->GetArchitecture().GetDataByteSize();
+ }
+ return 0;
+}
+
+uint32_t SBTarget::GetCodeByteSize() {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ return target_sp->GetArchitecture().GetCodeByteSize();
+ }
+ return 0;
+}
+
+uint32_t SBTarget::GetAddressByteSize() {
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ return target_sp->GetArchitecture().GetAddressByteSize();
+ return sizeof(void *);
+}
+
+SBModule SBTarget::GetModuleAtIndex(uint32_t idx) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBModule sb_module;
+ ModuleSP module_sp;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ // The module list is thread safe, no need to lock
+ module_sp = target_sp->GetImages().GetModuleAtIndex(idx);
+ sb_module.SetSP(module_sp);
+ }
+
+ if (log)
+ log->Printf("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)",
+ static_cast<void *>(target_sp.get()), idx,
+ static_cast<void *>(module_sp.get()));
+
+ return sb_module;
+}
+
+bool SBTarget::RemoveModule(lldb::SBModule module) {
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ return target_sp->GetImages().Remove(module.GetSP());
+ return false;
+}
+
+SBBroadcaster SBTarget::GetBroadcaster() const {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ TargetSP target_sp(GetSP());
+ SBBroadcaster broadcaster(target_sp.get(), false);
+
+ if (log)
+ log->Printf("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)",
+ static_cast<void *>(target_sp.get()),
+ static_cast<void *>(broadcaster.get()));
+
+ return broadcaster;
+}
+
+bool SBTarget::GetDescription(SBStream &description,
+ lldb::DescriptionLevel description_level) {
+ Stream &strm = description.ref();
+
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ target_sp->Dump(&strm, description_level);
+ } else
+ strm.PutCString("No value");
+
+ return true;
+}
+
+lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name,
+ uint32_t name_type_mask) {
+ lldb::SBSymbolContextList sb_sc_list;
+ if (name && name[0]) {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ const bool symbols_ok = true;
+ const bool inlines_ok = true;
+ const bool append = true;
+ target_sp->GetImages().FindFunctions(ConstString(name), name_type_mask,
+ symbols_ok, inlines_ok, append,
+ *sb_sc_list);
+ }
+ }
+ return sb_sc_list;
+}
+
+lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name,
+ uint32_t max_matches,
+ MatchType matchtype) {
+ lldb::SBSymbolContextList sb_sc_list;
+ if (name && name[0]) {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::string regexstr;
+ switch (matchtype) {
+ case eMatchTypeRegex:
+ target_sp->GetImages().FindFunctions(RegularExpression(name), true,
+ true, true, *sb_sc_list);
+ break;
+ case eMatchTypeStartsWith:
+ regexstr = llvm::Regex::escape(name) + ".*";
+ target_sp->GetImages().FindFunctions(
+ RegularExpression(regexstr.c_str()), true, true, true, *sb_sc_list);
+ break;
+ default:
+ target_sp->GetImages().FindFunctions(ConstString(name),
+ eFunctionNameTypeAny, true, true,
+ true, *sb_sc_list);
+ break;
+ }
+ }
+ }
+ return sb_sc_list;
+}
+
+lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
+ TargetSP target_sp(GetSP());
+ if (typename_cstr && typename_cstr[0] && target_sp) {
+ ConstString const_typename(typename_cstr);
+ SymbolContext sc;
+ const bool exact_match = false;
+
+ const ModuleList &module_list = target_sp->GetImages();
+ size_t count = module_list.GetSize();
+ for (size_t idx = 0; idx < count; idx++) {
+ ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
+ if (module_sp) {
+ TypeSP type_sp(
+ module_sp->FindFirstType(sc, const_typename, exact_match));
+ if (type_sp)
+ return SBType(type_sp);
+ }
+ }
+
+ // Didn't find the type in the symbols; try the Objective-C runtime
+ // if one is installed
+
+ ProcessSP process_sp(target_sp->GetProcessSP());
+
+ if (process_sp) {
+ ObjCLanguageRuntime *objc_language_runtime =
+ process_sp->GetObjCLanguageRuntime();
+
+ if (objc_language_runtime) {
+ DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
+
+ if (objc_decl_vendor) {
+ std::vector<clang::NamedDecl *> decls;
+
+ if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) {
+ if (CompilerType type = ClangASTContext::GetTypeForDecl(decls[0])) {
+ return SBType(type);
+ }
+ }
}
+ }
}
- if (log)
- log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", module=\"%s\") => SBBreakpoint(%p)",
- static_cast<void*>(target_sp.get()), symbol_name,
- module_name, static_cast<void*>(sb_bp.get()));
-
- return sb_bp;
-}
+ // No matches, search for basic typename matches
+ ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
+ if (clang_ast)
+ return SBType(ClangASTContext::GetBasicType(clang_ast->getASTContext(),
+ const_typename));
+ }
+ return SBType();
+}
+
+SBType SBTarget::GetBasicType(lldb::BasicType type) {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
+ if (clang_ast)
+ return SBType(
+ ClangASTContext::GetBasicType(clang_ast->getASTContext(), type));
+ }
+ return SBType();
+}
+
+lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
+ SBTypeList sb_type_list;
+ TargetSP target_sp(GetSP());
+ if (typename_cstr && typename_cstr[0] && target_sp) {
+ ModuleList &images = target_sp->GetImages();
+ ConstString const_typename(typename_cstr);
+ bool exact_match = false;
+ SymbolContext sc;
+ TypeList type_list;
+ llvm::DenseSet<SymbolFile *> searched_symbol_files;
+ uint32_t num_matches =
+ images.FindTypes(sc, const_typename, exact_match, UINT32_MAX,
+ searched_symbol_files, type_list);
+
+ if (num_matches > 0) {
+ for (size_t idx = 0; idx < num_matches; idx++) {
+ TypeSP type_sp(type_list.GetTypeAtIndex(idx));
+ if (type_sp)
+ sb_type_list.Append(SBType(type_sp));
+ }
+ }
+
+ // Try the Objective-C runtime if one is installed
+
+ ProcessSP process_sp(target_sp->GetProcessSP());
+
+ if (process_sp) {
+ ObjCLanguageRuntime *objc_language_runtime =
+ process_sp->GetObjCLanguageRuntime();
+
+ if (objc_language_runtime) {
+ DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
+
+ if (objc_decl_vendor) {
+ std::vector<clang::NamedDecl *> decls;
+
+ if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) {
+ for (clang::NamedDecl *decl : decls) {
+ if (CompilerType type = ClangASTContext::GetTypeForDecl(decl)) {
+ sb_type_list.Append(SBType(type));
+ }
+ }
+ }
+ }
+ }
+ }
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateByName (const char *symbol_name,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list)
-{
- uint32_t name_type_mask = eFunctionNameTypeAuto;
- return BreakpointCreateByName (symbol_name, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list);
+ if (sb_type_list.GetSize() == 0) {
+ // No matches, search for basic typename matches
+ ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
+ if (clang_ast)
+ sb_type_list.Append(SBType(ClangASTContext::GetBasicType(
+ clang_ast->getASTContext(), const_typename)));
+ }
+ }
+ return sb_type_list;
+}
+
+SBValueList SBTarget::FindGlobalVariables(const char *name,
+ uint32_t max_matches) {
+ SBValueList sb_value_list;
+
+ TargetSP target_sp(GetSP());
+ if (name && target_sp) {
+ VariableList variable_list;
+ const bool append = true;
+ const uint32_t match_count = target_sp->GetImages().FindGlobalVariables(
+ ConstString(name), append, max_matches, variable_list);
+
+ if (match_count > 0) {
+ ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
+ if (exe_scope == NULL)
+ exe_scope = target_sp.get();
+ for (uint32_t i = 0; i < match_count; ++i) {
+ lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
+ exe_scope, variable_list.GetVariableAtIndex(i)));
+ if (valobj_sp)
+ sb_value_list.Append(SBValue(valobj_sp));
+ }
+ }
+ }
+
+ return sb_value_list;
+}
+
+SBValueList SBTarget::FindGlobalVariables(const char *name,
+ uint32_t max_matches,
+ MatchType matchtype) {
+ SBValueList sb_value_list;
+
+ TargetSP target_sp(GetSP());
+ if (name && target_sp) {
+ VariableList variable_list;
+ const bool append = true;
+
+ std::string regexstr;
+ uint32_t match_count;
+ switch (matchtype) {
+ case eMatchTypeNormal:
+ match_count = target_sp->GetImages().FindGlobalVariables(
+ ConstString(name), append, max_matches, variable_list);
+ break;
+ case eMatchTypeRegex:
+ match_count = target_sp->GetImages().FindGlobalVariables(
+ RegularExpression(name), append, max_matches, variable_list);
+ break;
+ case eMatchTypeStartsWith:
+ regexstr = llvm::Regex::escape(name) + ".*";
+ match_count = target_sp->GetImages().FindGlobalVariables(
+ RegularExpression(regexstr.c_str()), append, max_matches,
+ variable_list);
+ break;
+ }
+
+ if (match_count > 0) {
+ ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
+ if (exe_scope == NULL)
+ exe_scope = target_sp.get();
+ for (uint32_t i = 0; i < match_count; ++i) {
+ lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
+ exe_scope, variable_list.GetVariableAtIndex(i)));
+ if (valobj_sp)
+ sb_value_list.Append(SBValue(valobj_sp));
+ }
+ }
+ }
+
+ return sb_value_list;
+}
+
+lldb::SBValue SBTarget::FindFirstGlobalVariable(const char *name) {
+ SBValueList sb_value_list(FindGlobalVariables(name, 1));
+ if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
+ return sb_value_list.GetValueAtIndex(0);
+ return SBValue();
+}
+
+SBSourceManager SBTarget::GetSourceManager() {
+ SBSourceManager source_manager(*this);
+ return source_manager;
+}
+
+lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
+ uint32_t count) {
+ return ReadInstructions(base_addr, count, NULL);
+}
+
+lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
+ uint32_t count,
+ const char *flavor_string) {
+ SBInstructionList sb_instructions;
+
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ Address *addr_ptr = base_addr.get();
+
+ if (addr_ptr) {
+ DataBufferHeap data(
+ target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0);
+ bool prefer_file_cache = false;
+ lldb_private::Error error;
+ lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
+ const size_t bytes_read =
+ target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(),
+ data.GetByteSize(), error, &load_addr);
+ const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
+ sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
+ target_sp->GetArchitecture(), NULL, flavor_string, *addr_ptr,
+ data.GetBytes(), bytes_read, count, data_from_file));
+ }
+ }
+
+ return sb_instructions;
+}
+
+lldb::SBInstructionList SBTarget::GetInstructions(lldb::SBAddress base_addr,
+ const void *buf,
+ size_t size) {
+ return GetInstructionsWithFlavor(base_addr, NULL, buf, size);
}
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateByName (const char *symbol_name,
- uint32_t name_type_mask,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list)
-{
- return BreakpointCreateByName (symbol_name, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list);
-}
+lldb::SBInstructionList
+SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr,
+ const char *flavor_string, const void *buf,
+ size_t size) {
+ SBInstructionList sb_instructions;
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateByName (const char *symbol_name,
- uint32_t name_type_mask,
- LanguageType symbol_language,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ Address addr;
- SBBreakpoint sb_bp;
- TargetSP target_sp(GetSP());
- if (target_sp && symbol_name && symbol_name[0])
- {
- const bool internal = false;
- const bool hardware = false;
- const LazyBool skip_prologue = eLazyBoolCalculate;
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- *sb_bp = target_sp->CreateBreakpoint (module_list.get(),
- comp_unit_list.get(),
- symbol_name,
- name_type_mask,
- symbol_language,
- 0,
- skip_prologue,
- internal,
- hardware);
- }
+ if (base_addr.get())
+ addr = *base_addr.get();
- if (log)
- log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", name_type: %d) => SBBreakpoint(%p)",
- static_cast<void*>(target_sp.get()), symbol_name,
- name_type_mask, static_cast<void*>(sb_bp.get()));
+ const bool data_from_file = true;
- return sb_bp;
-}
+ sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
+ target_sp->GetArchitecture(), NULL, flavor_string, addr, buf, size,
+ UINT32_MAX, data_from_file));
+ }
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateByNames (const char *symbol_names[],
- uint32_t num_names,
- uint32_t name_type_mask,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list)
-{
- return BreakpointCreateByNames(symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list);
+ return sb_instructions;
}
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateByNames (const char *symbol_names[],
- uint32_t num_names,
- uint32_t name_type_mask,
- LanguageType symbol_language,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list)
-{
- return BreakpointCreateByNames(symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 0, module_list, comp_unit_list);
+lldb::SBInstructionList SBTarget::GetInstructions(lldb::addr_t base_addr,
+ const void *buf,
+ size_t size) {
+ return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), NULL, buf,
+ size);
}
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateByNames (const char *symbol_names[],
- uint32_t num_names,
- uint32_t name_type_mask,
- LanguageType symbol_language,
- lldb::addr_t offset,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBBreakpoint sb_bp;
- TargetSP target_sp(GetSP());
- if (target_sp && num_names > 0)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- const bool internal = false;
- const bool hardware = false;
- const LazyBool skip_prologue = eLazyBoolCalculate;
- *sb_bp = target_sp->CreateBreakpoint (module_list.get(),
- comp_unit_list.get(),
- symbol_names,
- num_names,
- name_type_mask,
- symbol_language,
- offset,
- skip_prologue,
- internal,
- hardware);
- }
-
- if (log)
- {
- log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbols={",
- static_cast<void*>(target_sp.get()));
- for (uint32_t i = 0 ; i < num_names; i++)
- {
- char sep;
- if (i < num_names - 1)
- sep = ',';
- else
- sep = '}';
- if (symbol_names[i] != NULL)
- log->Printf ("\"%s\"%c ", symbol_names[i], sep);
- else
- log->Printf ("\"<NULL>\"%c ", sep);
+lldb::SBInstructionList
+SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr,
+ const char *flavor_string, const void *buf,
+ size_t size) {
+ return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string,
+ buf, size);
+}
+
+SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section,
+ lldb::addr_t section_base_addr) {
+ SBError sb_error;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ if (!section.IsValid()) {
+ sb_error.SetErrorStringWithFormat("invalid section");
+ } else {
+ SectionSP section_sp(section.GetSP());
+ if (section_sp) {
+ if (section_sp->IsThreadSpecific()) {
+ sb_error.SetErrorString(
+ "thread specific sections are not yet supported");
+ } else {
+ ProcessSP process_sp(target_sp->GetProcessSP());
+ if (target_sp->SetSectionLoadAddress(section_sp, section_base_addr)) {
+ ModuleSP module_sp(section_sp->GetModule());
+ if (module_sp) {
+ ModuleList module_list;
+ module_list.Append(module_sp);
+ target_sp->ModulesDidLoad(module_list);
+ }
+ // Flush info in the process (stack frames, etc)
+ if (process_sp)
+ process_sp->Flush();
+ }
}
- log->Printf ("name_type: %d) => SBBreakpoint(%p)", name_type_mask,
- static_cast<void*>(sb_bp.get()));
+ }
}
+ } else {
+ sb_error.SetErrorString("invalid target");
+ }
+ return sb_error;
+}
+
+SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) {
+ SBError sb_error;
+
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ if (!section.IsValid()) {
+ sb_error.SetErrorStringWithFormat("invalid section");
+ } else {
+ SectionSP section_sp(section.GetSP());
+ if (section_sp) {
+ ProcessSP process_sp(target_sp->GetProcessSP());
+ if (target_sp->SetSectionUnloaded(section_sp)) {
+ ModuleSP module_sp(section_sp->GetModule());
+ if (module_sp) {
+ ModuleList module_list;
+ module_list.Append(module_sp);
+ target_sp->ModulesDidUnload(module_list, false);
+ }
+ // Flush info in the process (stack frames, etc)
+ if (process_sp)
+ process_sp->Flush();
+ }
+ } else {
+ sb_error.SetErrorStringWithFormat("invalid section");
+ }
+ }
+ } else {
+ sb_error.SetErrorStringWithFormat("invalid target");
+ }
+ return sb_error;
+}
+
+SBError SBTarget::SetModuleLoadAddress(lldb::SBModule module,
+ int64_t slide_offset) {
+ SBError sb_error;
+
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ ModuleSP module_sp(module.GetSP());
+ if (module_sp) {
+ bool changed = false;
+ if (module_sp->SetLoadAddress(*target_sp, slide_offset, true, changed)) {
+ // The load was successful, make sure that at least some sections
+ // changed before we notify that our module was loaded.
+ if (changed) {
+ ModuleList module_list;
+ module_list.Append(module_sp);
+ target_sp->ModulesDidLoad(module_list);
+ // Flush info in the process (stack frames, etc)
+ ProcessSP process_sp(target_sp->GetProcessSP());
+ if (process_sp)
+ process_sp->Flush();
+ }
+ }
+ } else {
+ sb_error.SetErrorStringWithFormat("invalid module");
+ }
+
+ } else {
+ sb_error.SetErrorStringWithFormat("invalid target");
+ }
+ return sb_error;
+}
+
+SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) {
+ SBError sb_error;
+
+ char path[PATH_MAX];
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ ModuleSP module_sp(module.GetSP());
+ if (module_sp) {
+ ObjectFile *objfile = module_sp->GetObjectFile();
+ if (objfile) {
+ SectionList *section_list = objfile->GetSectionList();
+ if (section_list) {
+ ProcessSP process_sp(target_sp->GetProcessSP());
+
+ bool changed = false;
+ const size_t num_sections = section_list->GetSize();
+ for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
+ SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
+ if (section_sp)
+ changed |= target_sp->SetSectionUnloaded(section_sp);
+ }
+ if (changed) {
+ ModuleList module_list;
+ module_list.Append(module_sp);
+ target_sp->ModulesDidUnload(module_list, false);
+ // Flush info in the process (stack frames, etc)
+ ProcessSP process_sp(target_sp->GetProcessSP());
+ if (process_sp)
+ process_sp->Flush();
+ }
+ } else {
+ module_sp->GetFileSpec().GetPath(path, sizeof(path));
+ sb_error.SetErrorStringWithFormat("no sections in object file '%s'",
+ path);
+ }
+ } else {
+ module_sp->GetFileSpec().GetPath(path, sizeof(path));
+ sb_error.SetErrorStringWithFormat("no object file for module '%s'",
+ path);
+ }
+ } else {
+ sb_error.SetErrorStringWithFormat("invalid module");
+ }
+ } else {
+ sb_error.SetErrorStringWithFormat("invalid target");
+ }
+ return sb_error;
+}
+
+lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name,
+ lldb::SymbolType symbol_type) {
+ SBSymbolContextList sb_sc_list;
+ if (name && name[0]) {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ bool append = true;
+ target_sp->GetImages().FindSymbolsWithNameAndType(
+ ConstString(name), symbol_type, *sb_sc_list, append);
+ }
+ }
+ return sb_sc_list;
+}
+
+lldb::SBValue SBTarget::EvaluateExpression(const char *expr) {
+ TargetSP target_sp(GetSP());
+ if (!target_sp)
+ return SBValue();
- return sb_bp;
+ SBExpressionOptions options;
+ lldb::DynamicValueType fetch_dynamic_value =
+ target_sp->GetPreferDynamicValue();
+ options.SetFetchDynamicValue(fetch_dynamic_value);
+ options.SetUnwindOnError(true);
+ return EvaluateExpression(expr, options);
}
-SBBreakpoint
-SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
- const char *module_name)
-{
- SBFileSpecList module_spec_list;
- SBFileSpecList comp_unit_list;
- if (module_name && module_name[0])
- {
- module_spec_list.Append (FileSpec (module_name, false));
-
+lldb::SBValue SBTarget::EvaluateExpression(const char *expr,
+ const SBExpressionOptions &options) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+#if !defined(LLDB_DISABLE_PYTHON)
+ Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+#endif
+ SBValue expr_result;
+ ExpressionResults exe_results = eExpressionSetupError;
+ ValueObjectSP expr_value_sp;
+ TargetSP target_sp(GetSP());
+ StackFrame *frame = NULL;
+ if (target_sp) {
+ if (expr == NULL || expr[0] == '\0') {
+ if (log)
+ log->Printf(
+ "SBTarget::EvaluateExpression called with an empty expression");
+ return expr_result;
}
- return BreakpointCreateByRegex (symbol_name_regex, eLanguageTypeUnknown, module_spec_list, comp_unit_list);
-}
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list)
-{
- return BreakpointCreateByRegex (symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list);
-}
-
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
- LanguageType symbol_language,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBBreakpoint sb_bp;
- TargetSP target_sp(GetSP());
- if (target_sp && symbol_name_regex && symbol_name_regex[0])
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- RegularExpression regexp(symbol_name_regex);
- const bool internal = false;
- const bool hardware = false;
- const LazyBool skip_prologue = eLazyBoolCalculate;
-
- *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, symbol_language, skip_prologue, internal, hardware);
- }
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ ExecutionContext exe_ctx(m_opaque_sp.get());
if (log)
- log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") => SBBreakpoint(%p)",
- static_cast<void*>(target_sp.get()), symbol_name_regex,
- static_cast<void*>(sb_bp.get()));
+ log->Printf("SBTarget()::EvaluateExpression (expr=\"%s\")...", expr);
- return sb_bp;
-}
+ frame = exe_ctx.GetFramePtr();
+ Target *target = exe_ctx.GetTargetPtr();
-SBBreakpoint
-SBTarget::BreakpointCreateByAddress (addr_t address)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (target) {
+#ifdef LLDB_CONFIGURATION_DEBUG
+ StreamString frame_description;
+ if (frame)
+ frame->DumpUsingSettingsFormat(&frame_description);
+ Host::SetCrashDescriptionWithFormat(
+ "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = "
+ "%u) %s",
+ expr, options.GetFetchDynamicValue(),
+ frame_description.GetString().c_str());
+#endif
+ exe_results =
+ target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
- SBBreakpoint sb_bp;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- const bool hardware = false;
- *sb_bp = target_sp->CreateBreakpoint (address, false, hardware);
+ expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
+#ifdef LLDB_CONFIGURATION_DEBUG
+ Host::SetCrashDescription(NULL);
+#endif
+ } else {
+ if (log)
+ log->Printf("SBTarget::EvaluateExpression () => error: could not "
+ "reconstruct frame object for this SBTarget.");
}
+ }
+#ifndef LLDB_DISABLE_PYTHON
+ if (expr_log)
+ expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is "
+ "%s, summary %s **",
+ expr_result.GetValue(), expr_result.GetSummary());
+
+ if (log)
+ log->Printf("SBTarget(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) "
+ "(execution result=%d)",
+ static_cast<void *>(frame), expr,
+ static_cast<void *>(expr_value_sp.get()), exe_results);
+#endif
- if (log)
- log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%" PRIu64 ") => SBBreakpoint(%p)",
- static_cast<void*>(target_sp.get()),
- static_cast<uint64_t>(address),
- static_cast<void*>(sb_bp.get()));
-
- return sb_bp;
+ return expr_result;
}
-SBBreakpoint
-SBTarget::BreakpointCreateBySBAddress (SBAddress &sb_address)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBBreakpoint sb_bp;
- TargetSP target_sp(GetSP());
- if (!sb_address.IsValid())
- {
- if (log)
- log->Printf ("SBTarget(%p)::BreakpointCreateBySBAddress called with invalid address",
- static_cast<void*>(target_sp.get()));
- return sb_bp;
- }
-
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- const bool hardware = false;
- *sb_bp = target_sp->CreateBreakpoint (sb_address.ref(), false, hardware);
- }
-
- if (log)
- {
- SBStream s;
- sb_address.GetDescription(s);
- log->Printf ("SBTarget(%p)::BreakpointCreateBySBAddress (address=%s) => SBBreakpoint(%p)",
- static_cast<void*>(target_sp.get()),
- s.GetData(),
- static_cast<void*>(sb_bp.get()));
- }
-
- return sb_bp;
-}
-
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
- const lldb::SBFileSpec &source_file,
- const char *module_name)
-{
- SBFileSpecList module_spec_list;
-
- if (module_name && module_name[0])
- {
- module_spec_list.Append (FileSpec (module_name, false));
- }
-
- SBFileSpecList source_file_list;
- if (source_file.IsValid())
- {
- source_file_list.Append(source_file);
- }
-
- return BreakpointCreateBySourceRegex (source_regex, module_spec_list, source_file_list);
-
-}
-
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
- const SBFileSpecList &module_list,
- const lldb::SBFileSpecList &source_file_list)
-{
- return BreakpointCreateBySourceRegex(source_regex, module_list, source_file_list, SBStringList());
-}
-
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
- const SBFileSpecList &module_list,
- const lldb::SBFileSpecList &source_file_list,
- const SBStringList &func_names)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBBreakpoint sb_bp;
- TargetSP target_sp(GetSP());
- if (target_sp && source_regex && source_regex[0])
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- const bool hardware = false;
- const LazyBool move_to_nearest_code = eLazyBoolCalculate;
- RegularExpression regexp(source_regex);
- std::unordered_set<std::string> func_names_set;
- for (size_t i = 0; i < func_names.GetSize(); i++)
- {
- func_names_set.insert(func_names.GetStringAtIndex(i));
- }
-
- *sb_bp = target_sp->CreateSourceRegexBreakpoint (module_list.get(),
- source_file_list.get(),
- func_names_set,
- regexp,
- false,
- hardware,
- move_to_nearest_code);
- }
-
- if (log)
- log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") => SBBreakpoint(%p)",
- static_cast<void*>(target_sp.get()), source_regex,
- static_cast<void*>(sb_bp.get()));
-
- return sb_bp;
-}
-
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateForException (lldb::LanguageType language,
- bool catch_bp,
- bool throw_bp)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBBreakpoint sb_bp;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- const bool hardware = false;
- *sb_bp = target_sp->CreateExceptionBreakpoint (language, catch_bp, throw_bp, hardware);
- }
-
- if (log)
- log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: %s throw: %s) => SBBreakpoint(%p)",
- static_cast<void*>(target_sp.get()),
- Language::GetNameForLanguageType(language),
- catch_bp ? "on" : "off", throw_bp ? "on" : "off",
- static_cast<void*>(sb_bp.get()));
-
- return sb_bp;
-}
-
-uint32_t
-SBTarget::GetNumBreakpoints () const
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- // The breakpoint list is thread safe, no need to lock
- return target_sp->GetBreakpointList().GetSize();
- }
- return 0;
-}
-
-SBBreakpoint
-SBTarget::GetBreakpointAtIndex (uint32_t idx) const
-{
- SBBreakpoint sb_breakpoint;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- // The breakpoint list is thread safe, no need to lock
- *sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
- }
- return sb_breakpoint;
-}
-
-bool
-SBTarget::BreakpointDelete (break_id_t bp_id)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- bool result = false;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- result = target_sp->RemoveBreakpointByID (bp_id);
- }
-
- if (log)
- log->Printf ("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i",
- static_cast<void*>(target_sp.get()),
- static_cast<uint32_t>(bp_id), result);
-
- return result;
-}
-
-SBBreakpoint
-SBTarget::FindBreakpointByID (break_id_t bp_id)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBBreakpoint sb_breakpoint;
- TargetSP target_sp(GetSP());
- if (target_sp && bp_id != LLDB_INVALID_BREAK_ID)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- *sb_breakpoint = target_sp->GetBreakpointByID (bp_id);
- }
-
- if (log)
- log->Printf ("SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)",
- static_cast<void*>(target_sp.get()),
- static_cast<uint32_t>(bp_id),
- static_cast<void*>(sb_breakpoint.get()));
-
- return sb_breakpoint;
-}
-
-bool
-SBTarget::EnableAllBreakpoints ()
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- target_sp->EnableAllBreakpoints ();
- return true;
- }
- return false;
-}
-
-bool
-SBTarget::DisableAllBreakpoints ()
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- target_sp->DisableAllBreakpoints ();
- return true;
- }
- return false;
-}
-
-bool
-SBTarget::DeleteAllBreakpoints ()
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- target_sp->RemoveAllBreakpoints ();
- return true;
- }
- return false;
-}
-
-uint32_t
-SBTarget::GetNumWatchpoints () const
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- // The watchpoint list is thread safe, no need to lock
- return target_sp->GetWatchpointList().GetSize();
- }
- return 0;
-}
-
-SBWatchpoint
-SBTarget::GetWatchpointAtIndex (uint32_t idx) const
-{
- SBWatchpoint sb_watchpoint;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- // The watchpoint list is thread safe, no need to lock
- sb_watchpoint.SetSP (target_sp->GetWatchpointList().GetByIndex(idx));
- }
- return sb_watchpoint;
-}
-
-bool
-SBTarget::DeleteWatchpoint (watch_id_t wp_id)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- bool result = false;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- std::unique_lock<std::recursive_mutex> lock;
- target_sp->GetWatchpointList().GetListMutex(lock);
- result = target_sp->RemoveWatchpointByID (wp_id);
- }
-
- if (log)
- log->Printf ("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i",
- static_cast<void*>(target_sp.get()),
- static_cast<uint32_t>(wp_id), result);
-
- return result;
-}
-
-SBWatchpoint
-SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBWatchpoint sb_watchpoint;
- lldb::WatchpointSP watchpoint_sp;
- TargetSP target_sp(GetSP());
- if (target_sp && wp_id != LLDB_INVALID_WATCH_ID)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- std::unique_lock<std::recursive_mutex> lock;
- target_sp->GetWatchpointList().GetListMutex(lock);
- watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id);
- sb_watchpoint.SetSP (watchpoint_sp);
- }
-
- if (log)
- log->Printf ("SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)",
- static_cast<void*>(target_sp.get()),
- static_cast<uint32_t>(wp_id),
- static_cast<void*>(watchpoint_sp.get()));
-
- return sb_watchpoint;
-}
-
-lldb::SBWatchpoint
-SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, SBError &error)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBWatchpoint sb_watchpoint;
- lldb::WatchpointSP watchpoint_sp;
- TargetSP target_sp(GetSP());
- if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS && size > 0)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- uint32_t watch_type = 0;
- if (read)
- watch_type |= LLDB_WATCH_TYPE_READ;
- if (write)
- watch_type |= LLDB_WATCH_TYPE_WRITE;
- if (watch_type == 0)
- {
- error.SetErrorString("Can't create a watchpoint that is neither read nor write.");
- return sb_watchpoint;
- }
-
- // Target::CreateWatchpoint() is thread safe.
- Error cw_error;
- // This API doesn't take in a type, so we can't figure out what it is.
- CompilerType *type = NULL;
- watchpoint_sp = target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
- error.SetError(cw_error);
- sb_watchpoint.SetSP (watchpoint_sp);
- }
-
- if (log)
- log->Printf ("SBTarget(%p)::WatchAddress (addr=0x%" PRIx64 ", 0x%u) => SBWatchpoint(%p)",
- static_cast<void*>(target_sp.get()), addr,
- static_cast<uint32_t>(size),
- static_cast<void*>(watchpoint_sp.get()));
-
- return sb_watchpoint;
-}
-
-bool
-SBTarget::EnableAllWatchpoints ()
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- std::unique_lock<std::recursive_mutex> lock;
- target_sp->GetWatchpointList().GetListMutex(lock);
- target_sp->EnableAllWatchpoints ();
- return true;
- }
- return false;
-}
-
-bool
-SBTarget::DisableAllWatchpoints ()
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- std::unique_lock<std::recursive_mutex> lock;
- target_sp->GetWatchpointList().GetListMutex(lock);
- target_sp->DisableAllWatchpoints ();
- return true;
- }
- return false;
-}
-
-SBValue
-SBTarget::CreateValueFromAddress (const char *name, SBAddress addr, SBType type)
-{
- SBValue sb_value;
- lldb::ValueObjectSP new_value_sp;
- if (IsValid() && name && *name && addr.IsValid() && type.IsValid())
- {
- lldb::addr_t load_addr(addr.GetLoadAddress(*this));
- ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
- CompilerType ast_type(type.GetSP()->GetCompilerType(true));
- new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr, exe_ctx, ast_type);
- }
- sb_value.SetSP(new_value_sp);
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- if (new_value_sp)
- log->Printf ("SBTarget(%p)::CreateValueFromAddress => \"%s\"",
- static_cast<void*>(m_opaque_sp.get()),
- new_value_sp->GetName().AsCString());
- else
- log->Printf ("SBTarget(%p)::CreateValueFromAddress => NULL",
- static_cast<void*>(m_opaque_sp.get()));
- }
- return sb_value;
-}
-
-lldb::SBValue
-SBTarget::CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType type)
-{
- SBValue sb_value;
- lldb::ValueObjectSP new_value_sp;
- if (IsValid() && name && *name && data.IsValid() && type.IsValid())
- {
- DataExtractorSP extractor(*data);
- ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
- CompilerType ast_type(type.GetSP()->GetCompilerType(true));
- new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor, exe_ctx, ast_type);
- }
- sb_value.SetSP(new_value_sp);
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- if (new_value_sp)
- log->Printf ("SBTarget(%p)::CreateValueFromData => \"%s\"",
- static_cast<void*>(m_opaque_sp.get()),
- new_value_sp->GetName().AsCString());
- else
- log->Printf ("SBTarget(%p)::CreateValueFromData => NULL",
- static_cast<void*>(m_opaque_sp.get()));
- }
- return sb_value;
-}
-
-lldb::SBValue
-SBTarget::CreateValueFromExpression (const char *name, const char* expr)
-{
- SBValue sb_value;
- lldb::ValueObjectSP new_value_sp;
- if (IsValid() && name && *name && expr && *expr)
- {
- ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
- new_value_sp = ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx);
- }
- sb_value.SetSP(new_value_sp);
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- if (new_value_sp)
- log->Printf ("SBTarget(%p)::CreateValueFromExpression => \"%s\"",
- static_cast<void*>(m_opaque_sp.get()),
- new_value_sp->GetName().AsCString());
- else
- log->Printf ("SBTarget(%p)::CreateValueFromExpression => NULL",
- static_cast<void*>(m_opaque_sp.get()));
- }
- return sb_value;
-}
-
-bool
-SBTarget::DeleteAllWatchpoints ()
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- std::unique_lock<std::recursive_mutex> lock;
- target_sp->GetWatchpointList().GetListMutex(lock);
- target_sp->RemoveAllWatchpoints ();
- return true;
- }
- return false;
-}
-
-
-lldb::SBModule
-SBTarget::AddModule (const char *path,
- const char *triple,
- const char *uuid_cstr)
-{
- return AddModule (path, triple, uuid_cstr, NULL);
-}
-
-lldb::SBModule
-SBTarget::AddModule (const char *path,
- const char *triple,
- const char *uuid_cstr,
- const char *symfile)
-{
- lldb::SBModule sb_module;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- ModuleSpec module_spec;
- if (path)
- module_spec.GetFileSpec().SetFile(path, false);
-
- if (uuid_cstr)
- module_spec.GetUUID().SetFromCString(uuid_cstr);
-
- if (triple)
- module_spec.GetArchitecture().SetTriple (triple, target_sp->GetPlatform ().get());
- else
- module_spec.GetArchitecture() = target_sp->GetArchitecture();
-
- if (symfile)
- module_spec.GetSymbolFileSpec ().SetFile(symfile, false);
-
- sb_module.SetSP(target_sp->GetSharedModule (module_spec));
- }
- return sb_module;
-}
-
-lldb::SBModule
-SBTarget::AddModule (const SBModuleSpec &module_spec)
-{
- lldb::SBModule sb_module;
- TargetSP target_sp(GetSP());
- if (target_sp)
- sb_module.SetSP(target_sp->GetSharedModule (*module_spec.m_opaque_ap));
- return sb_module;
-}
-
-bool
-SBTarget::AddModule (lldb::SBModule &module)
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- target_sp->GetImages().AppendIfNeeded (module.GetSP());
- return true;
- }
- return false;
-}
-
-uint32_t
-SBTarget::GetNumModules () const
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- uint32_t num = 0;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- // The module list is thread safe, no need to lock
- num = target_sp->GetImages().GetSize();
- }
-
- if (log)
- log->Printf ("SBTarget(%p)::GetNumModules () => %d",
- static_cast<void*>(target_sp.get()), num);
-
- return num;
-}
-
-void
-SBTarget::Clear ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- if (log)
- log->Printf ("SBTarget(%p)::Clear ()",
- static_cast<void*>(m_opaque_sp.get()));
-
- m_opaque_sp.reset();
-}
-
-
-SBModule
-SBTarget::FindModule (const SBFileSpec &sb_file_spec)
-{
- SBModule sb_module;
- TargetSP target_sp(GetSP());
- if (target_sp && sb_file_spec.IsValid())
- {
- ModuleSpec module_spec(*sb_file_spec);
- // The module list is thread safe, no need to lock
- sb_module.SetSP (target_sp->GetImages().FindFirstModule (module_spec));
- }
- return sb_module;
-}
-
-lldb::ByteOrder
-SBTarget::GetByteOrder ()
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- return target_sp->GetArchitecture().GetByteOrder();
- return eByteOrderInvalid;
-}
-
-const char *
-SBTarget::GetTriple ()
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::string triple (target_sp->GetArchitecture().GetTriple().str());
- // Unique the string so we don't run into ownership issues since
- // the const strings put the string into the string pool once and
- // the strings never comes out
- ConstString const_triple (triple.c_str());
- return const_triple.GetCString();
- }
- return NULL;
-}
-
-uint32_t
-SBTarget::GetDataByteSize ()
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- return target_sp->GetArchitecture().GetDataByteSize() ;
- }
- return 0;
-}
-
-uint32_t
-SBTarget::GetCodeByteSize ()
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- return target_sp->GetArchitecture().GetCodeByteSize() ;
- }
- return 0;
-}
-
-uint32_t
-SBTarget::GetAddressByteSize()
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- return target_sp->GetArchitecture().GetAddressByteSize();
- return sizeof(void*);
-}
-
-
-SBModule
-SBTarget::GetModuleAtIndex (uint32_t idx)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBModule sb_module;
- ModuleSP module_sp;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- // The module list is thread safe, no need to lock
- module_sp = target_sp->GetImages().GetModuleAtIndex(idx);
- sb_module.SetSP (module_sp);
- }
-
- if (log)
- log->Printf ("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)",
- static_cast<void*>(target_sp.get()), idx,
- static_cast<void*>(module_sp.get()));
-
- return sb_module;
-}
-
-bool
-SBTarget::RemoveModule (lldb::SBModule module)
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- return target_sp->GetImages().Remove(module.GetSP());
- return false;
-}
-
-
-SBBroadcaster
-SBTarget::GetBroadcaster () const
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- TargetSP target_sp(GetSP());
- SBBroadcaster broadcaster(target_sp.get(), false);
-
- if (log)
- log->Printf ("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)",
- static_cast<void*>(target_sp.get()),
- static_cast<void*>(broadcaster.get()));
-
- return broadcaster;
-}
-
-bool
-SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel description_level)
-{
- Stream &strm = description.ref();
-
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- target_sp->Dump (&strm, description_level);
- }
- else
- strm.PutCString ("No value");
-
- return true;
-}
-
-lldb::SBSymbolContextList
-SBTarget::FindFunctions (const char *name, uint32_t name_type_mask)
-{
- lldb::SBSymbolContextList sb_sc_list;
- if (name && name[0])
- {
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- const bool symbols_ok = true;
- const bool inlines_ok = true;
- const bool append = true;
- target_sp->GetImages().FindFunctions (ConstString(name),
- name_type_mask,
- symbols_ok,
- inlines_ok,
- append,
- *sb_sc_list);
- }
- }
- return sb_sc_list;
-}
-
-lldb::SBSymbolContextList
-SBTarget::FindGlobalFunctions(const char *name, uint32_t max_matches, MatchType matchtype)
-{
- lldb::SBSymbolContextList sb_sc_list;
- if (name && name[0])
- {
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- std::string regexstr;
- switch (matchtype)
- {
- case eMatchTypeRegex:
- target_sp->GetImages().FindFunctions(RegularExpression(name), true, true, true, *sb_sc_list);
- break;
- case eMatchTypeStartsWith:
- regexstr = llvm::Regex::escape(name) + ".*";
- target_sp->GetImages().FindFunctions(RegularExpression(regexstr.c_str()), true, true, true, *sb_sc_list);
- break;
- default:
- target_sp->GetImages().FindFunctions(ConstString(name), eFunctionNameTypeAny, true, true, true, *sb_sc_list);
- break;
- }
- }
- }
- return sb_sc_list;
-}
-
-lldb::SBType
-SBTarget::FindFirstType (const char* typename_cstr)
-{
- TargetSP target_sp(GetSP());
- if (typename_cstr && typename_cstr[0] && target_sp)
- {
- ConstString const_typename(typename_cstr);
- SymbolContext sc;
- const bool exact_match = false;
-
- const ModuleList &module_list = target_sp->GetImages();
- size_t count = module_list.GetSize();
- for (size_t idx = 0; idx < count; idx++)
- {
- ModuleSP module_sp (module_list.GetModuleAtIndex(idx));
- if (module_sp)
- {
- TypeSP type_sp (module_sp->FindFirstType(sc, const_typename, exact_match));
- if (type_sp)
- return SBType(type_sp);
- }
- }
-
- // Didn't find the type in the symbols; try the Objective-C runtime
- // if one is installed
-
- ProcessSP process_sp(target_sp->GetProcessSP());
-
- if (process_sp)
- {
- ObjCLanguageRuntime *objc_language_runtime = process_sp->GetObjCLanguageRuntime();
-
- if (objc_language_runtime)
- {
- DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
-
- if (objc_decl_vendor)
- {
- std::vector <clang::NamedDecl *> decls;
-
- if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0)
- {
- if (CompilerType type = ClangASTContext::GetTypeForDecl(decls[0]))
- {
- return SBType(type);
- }
- }
- }
- }
- }
-
- // No matches, search for basic typename matches
- ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
- if (clang_ast)
- return SBType (ClangASTContext::GetBasicType (clang_ast->getASTContext(), const_typename));
- }
- return SBType();
-}
-
-SBType
-SBTarget::GetBasicType(lldb::BasicType type)
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
- if (clang_ast)
- return SBType (ClangASTContext::GetBasicType (clang_ast->getASTContext(), type));
- }
- return SBType();
-}
-
-
-lldb::SBTypeList
-SBTarget::FindTypes (const char* typename_cstr)
-{
- SBTypeList sb_type_list;
- TargetSP target_sp(GetSP());
- if (typename_cstr && typename_cstr[0] && target_sp)
- {
- ModuleList& images = target_sp->GetImages();
- ConstString const_typename(typename_cstr);
- bool exact_match = false;
- SymbolContext sc;
- TypeList type_list;
- llvm::DenseSet<SymbolFile *> searched_symbol_files;
- uint32_t num_matches = images.FindTypes (sc,
- const_typename,
- exact_match,
- UINT32_MAX,
- searched_symbol_files,
- type_list);
-
- if (num_matches > 0)
- {
- for (size_t idx = 0; idx < num_matches; idx++)
- {
- TypeSP type_sp (type_list.GetTypeAtIndex(idx));
- if (type_sp)
- sb_type_list.Append(SBType(type_sp));
- }
- }
-
- // Try the Objective-C runtime if one is installed
-
- ProcessSP process_sp(target_sp->GetProcessSP());
-
- if (process_sp)
- {
- ObjCLanguageRuntime *objc_language_runtime = process_sp->GetObjCLanguageRuntime();
-
- if (objc_language_runtime)
- {
- DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
-
- if (objc_decl_vendor)
- {
- std::vector <clang::NamedDecl *> decls;
-
- if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0)
- {
- for (clang::NamedDecl *decl : decls)
- {
- if (CompilerType type = ClangASTContext::GetTypeForDecl(decl))
- {
- sb_type_list.Append(SBType(type));
- }
- }
- }
- }
- }
- }
-
- if (sb_type_list.GetSize() == 0)
- {
- // No matches, search for basic typename matches
- ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
- if (clang_ast)
- sb_type_list.Append (SBType (ClangASTContext::GetBasicType (clang_ast->getASTContext(), const_typename)));
- }
- }
- return sb_type_list;
-}
-
-SBValueList
-SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches)
-{
- SBValueList sb_value_list;
-
- TargetSP target_sp(GetSP());
- if (name && target_sp)
- {
- VariableList variable_list;
- const bool append = true;
- const uint32_t match_count = target_sp->GetImages().FindGlobalVariables (ConstString (name),
- append,
- max_matches,
- variable_list);
-
- if (match_count > 0)
- {
- ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
- if (exe_scope == NULL)
- exe_scope = target_sp.get();
- for (uint32_t i=0; i<match_count; ++i)
- {
- lldb::ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_scope, variable_list.GetVariableAtIndex(i)));
- if (valobj_sp)
- sb_value_list.Append(SBValue(valobj_sp));
- }
- }
- }
-
- return sb_value_list;
-}
-
-SBValueList
-SBTarget::FindGlobalVariables(const char *name, uint32_t max_matches, MatchType matchtype)
-{
- SBValueList sb_value_list;
-
- TargetSP target_sp(GetSP());
- if (name && target_sp)
- {
- VariableList variable_list;
- const bool append = true;
-
- std::string regexstr;
- uint32_t match_count;
- switch (matchtype)
- {
- case eMatchTypeNormal:
- match_count = target_sp->GetImages().FindGlobalVariables(ConstString(name),
- append,
- max_matches,
- variable_list);
- break;
- case eMatchTypeRegex:
- match_count = target_sp->GetImages().FindGlobalVariables(RegularExpression(name),
- append,
- max_matches,
- variable_list);
- break;
- case eMatchTypeStartsWith:
- regexstr = llvm::Regex::escape(name) + ".*";
- match_count = target_sp->GetImages().FindGlobalVariables(RegularExpression(regexstr.c_str()),
- append,
- max_matches,
- variable_list);
- break;
- }
-
-
- if (match_count > 0)
- {
- ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
- if (exe_scope == NULL)
- exe_scope = target_sp.get();
- for (uint32_t i = 0; i<match_count; ++i)
- {
- lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(exe_scope, variable_list.GetVariableAtIndex(i)));
- if (valobj_sp)
- sb_value_list.Append(SBValue(valobj_sp));
- }
- }
- }
-
- return sb_value_list;
-}
-
-
-lldb::SBValue
-SBTarget::FindFirstGlobalVariable (const char* name)
-{
- SBValueList sb_value_list(FindGlobalVariables(name, 1));
- if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
- return sb_value_list.GetValueAtIndex(0);
- return SBValue();
-}
-
-SBSourceManager
-SBTarget::GetSourceManager()
-{
- SBSourceManager source_manager (*this);
- return source_manager;
-}
-
-lldb::SBInstructionList
-SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count)
-{
- return ReadInstructions (base_addr, count, NULL);
-}
-
-lldb::SBInstructionList
-SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string)
-{
- SBInstructionList sb_instructions;
-
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- Address *addr_ptr = base_addr.get();
-
- if (addr_ptr)
- {
- DataBufferHeap data (target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0);
- bool prefer_file_cache = false;
- lldb_private::Error error;
- lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
- const size_t bytes_read = target_sp->ReadMemory(*addr_ptr,
- prefer_file_cache,
- data.GetBytes(),
- data.GetByteSize(),
- error,
- &load_addr);
- const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
- sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
- NULL,
- flavor_string,
- *addr_ptr,
- data.GetBytes(),
- bytes_read,
- count,
- data_from_file));
- }
- }
-
- return sb_instructions;
-
-}
-
-lldb::SBInstructionList
-SBTarget::GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size)
-{
- return GetInstructionsWithFlavor (base_addr, NULL, buf, size);
-}
-
-lldb::SBInstructionList
-SBTarget::GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size)
-{
- SBInstructionList sb_instructions;
-
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- Address addr;
-
- if (base_addr.get())
- addr = *base_addr.get();
-
- const bool data_from_file = true;
-
- sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
- NULL,
- flavor_string,
- addr,
- buf,
- size,
- UINT32_MAX,
- data_from_file));
- }
-
- return sb_instructions;
-}
-
-lldb::SBInstructionList
-SBTarget::GetInstructions (lldb::addr_t base_addr, const void *buf, size_t size)
-{
- return GetInstructionsWithFlavor (ResolveLoadAddress(base_addr), NULL, buf, size);
-}
-
-lldb::SBInstructionList
-SBTarget::GetInstructionsWithFlavor (lldb::addr_t base_addr, const char *flavor_string, const void *buf, size_t size)
-{
- return GetInstructionsWithFlavor (ResolveLoadAddress(base_addr), flavor_string, buf, size);
-}
-
-SBError
-SBTarget::SetSectionLoadAddress (lldb::SBSection section,
- lldb::addr_t section_base_addr)
-{
- SBError sb_error;
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- if (!section.IsValid())
- {
- sb_error.SetErrorStringWithFormat ("invalid section");
- }
- else
- {
- SectionSP section_sp (section.GetSP());
- if (section_sp)
- {
- if (section_sp->IsThreadSpecific())
- {
- sb_error.SetErrorString ("thread specific sections are not yet supported");
- }
- else
- {
- ProcessSP process_sp (target_sp->GetProcessSP());
- if (target_sp->SetSectionLoadAddress (section_sp, section_base_addr))
- {
- ModuleSP module_sp(section_sp->GetModule());
- if (module_sp)
- {
- ModuleList module_list;
- module_list.Append(module_sp);
- target_sp->ModulesDidLoad (module_list);
- }
- // Flush info in the process (stack frames, etc)
- if (process_sp)
- process_sp->Flush();
- }
- }
- }
- }
- }
- else
- {
- sb_error.SetErrorString ("invalid target");
- }
- return sb_error;
-}
-
-SBError
-SBTarget::ClearSectionLoadAddress (lldb::SBSection section)
-{
- SBError sb_error;
-
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- if (!section.IsValid())
- {
- sb_error.SetErrorStringWithFormat ("invalid section");
- }
- else
- {
- SectionSP section_sp (section.GetSP());
- if (section_sp)
- {
- ProcessSP process_sp (target_sp->GetProcessSP());
- if (target_sp->SetSectionUnloaded(section_sp))
- {
- ModuleSP module_sp(section_sp->GetModule());
- if (module_sp)
- {
- ModuleList module_list;
- module_list.Append(module_sp);
- target_sp->ModulesDidUnload(module_list, false);
- }
- // Flush info in the process (stack frames, etc)
- if (process_sp)
- process_sp->Flush();
- }
- }
- else
- {
- sb_error.SetErrorStringWithFormat ("invalid section");
- }
- }
- }
- else
- {
- sb_error.SetErrorStringWithFormat ("invalid target");
- }
- return sb_error;
-}
-
-SBError
-SBTarget::SetModuleLoadAddress (lldb::SBModule module, int64_t slide_offset)
-{
- SBError sb_error;
-
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- ModuleSP module_sp (module.GetSP());
- if (module_sp)
- {
- bool changed = false;
- if (module_sp->SetLoadAddress (*target_sp, slide_offset, true, changed))
- {
- // The load was successful, make sure that at least some sections
- // changed before we notify that our module was loaded.
- if (changed)
- {
- ModuleList module_list;
- module_list.Append(module_sp);
- target_sp->ModulesDidLoad (module_list);
- // Flush info in the process (stack frames, etc)
- ProcessSP process_sp (target_sp->GetProcessSP());
- if (process_sp)
- process_sp->Flush();
- }
- }
- }
- else
- {
- sb_error.SetErrorStringWithFormat ("invalid module");
- }
-
- }
- else
- {
- sb_error.SetErrorStringWithFormat ("invalid target");
- }
- return sb_error;
-}
-
-SBError
-SBTarget::ClearModuleLoadAddress (lldb::SBModule module)
-{
- SBError sb_error;
-
- char path[PATH_MAX];
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- ModuleSP module_sp (module.GetSP());
- if (module_sp)
- {
- ObjectFile *objfile = module_sp->GetObjectFile();
- if (objfile)
- {
- SectionList *section_list = objfile->GetSectionList();
- if (section_list)
- {
- ProcessSP process_sp (target_sp->GetProcessSP());
-
- bool changed = false;
- const size_t num_sections = section_list->GetSize();
- for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx)
- {
- SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx));
- if (section_sp)
- changed |= target_sp->SetSectionUnloaded (section_sp);
- }
- if (changed)
- {
- ModuleList module_list;
- module_list.Append(module_sp);
- target_sp->ModulesDidUnload(module_list, false);
- // Flush info in the process (stack frames, etc)
- ProcessSP process_sp (target_sp->GetProcessSP());
- if (process_sp)
- process_sp->Flush();
- }
- }
- else
- {
- module_sp->GetFileSpec().GetPath (path, sizeof(path));
- sb_error.SetErrorStringWithFormat ("no sections in object file '%s'", path);
- }
- }
- else
- {
- module_sp->GetFileSpec().GetPath (path, sizeof(path));
- sb_error.SetErrorStringWithFormat ("no object file for module '%s'", path);
- }
- }
- else
- {
- sb_error.SetErrorStringWithFormat ("invalid module");
- }
- }
+lldb::addr_t SBTarget::GetStackRedZoneSize() {
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ ABISP abi_sp;
+ ProcessSP process_sp(target_sp->GetProcessSP());
+ if (process_sp)
+ abi_sp = process_sp->GetABI();
else
- {
- sb_error.SetErrorStringWithFormat ("invalid target");
- }
- return sb_error;
-}
-
-
-lldb::SBSymbolContextList
-SBTarget::FindSymbols (const char *name, lldb::SymbolType symbol_type)
-{
- SBSymbolContextList sb_sc_list;
- if (name && name[0])
- {
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- bool append = true;
- target_sp->GetImages().FindSymbolsWithNameAndType (ConstString(name),
- symbol_type,
- *sb_sc_list,
- append);
- }
- }
- return sb_sc_list;
-
-}
-
-lldb::SBValue
-SBTarget::EvaluateExpression (const char *expr)
-{
- TargetSP target_sp(GetSP());
- if (!target_sp)
- return SBValue();
-
- SBExpressionOptions options;
- lldb::DynamicValueType fetch_dynamic_value = target_sp->GetPreferDynamicValue();
- options.SetFetchDynamicValue (fetch_dynamic_value);
- options.SetUnwindOnError (true);
- return EvaluateExpression(expr, options);
-}
-
-lldb::SBValue
-SBTarget::EvaluateExpression (const char *expr, const SBExpressionOptions &options)
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-#if !defined(LLDB_DISABLE_PYTHON)
- Log * expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-#endif
- SBValue expr_result;
- ExpressionResults exe_results = eExpressionSetupError;
- ValueObjectSP expr_value_sp;
- TargetSP target_sp(GetSP());
- StackFrame *frame = NULL;
- if (target_sp)
- {
- if (expr == NULL || expr[0] == '\0')
- {
- if (log)
- log->Printf ("SBTarget::EvaluateExpression called with an empty expression");
- return expr_result;
- }
-
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- ExecutionContext exe_ctx (m_opaque_sp.get());
-
- if (log)
- log->Printf ("SBTarget()::EvaluateExpression (expr=\"%s\")...", expr);
-
- frame = exe_ctx.GetFramePtr();
- Target *target = exe_ctx.GetTargetPtr();
-
- if (target)
- {
-#ifdef LLDB_CONFIGURATION_DEBUG
- StreamString frame_description;
- if (frame)
- frame->DumpUsingSettingsFormat (&frame_description);
- Host::SetCrashDescriptionWithFormat ("SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s",
- expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str());
-#endif
- exe_results = target->EvaluateExpression (expr,
- frame,
- expr_value_sp,
- options.ref());
-
- expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
-#ifdef LLDB_CONFIGURATION_DEBUG
- Host::SetCrashDescription (NULL);
-#endif
- }
- else
- {
- if (log)
- log->Printf ("SBTarget::EvaluateExpression () => error: could not reconstruct frame object for this SBTarget.");
- }
- }
-#ifndef LLDB_DISABLE_PYTHON
- if (expr_log)
- expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is %s, summary %s **",
- expr_result.GetValue(), expr_result.GetSummary());
-
- if (log)
- log->Printf ("SBTarget(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)",
- static_cast<void*>(frame), expr,
- static_cast<void*>(expr_value_sp.get()), exe_results);
-#endif
-
- return expr_result;
-}
-
-
-lldb::addr_t
-SBTarget::GetStackRedZoneSize()
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- {
- ABISP abi_sp;
- ProcessSP process_sp (target_sp->GetProcessSP());
- if (process_sp)
- abi_sp = process_sp->GetABI();
- else
- abi_sp = ABI::FindPlugin(target_sp->GetArchitecture());
- if (abi_sp)
- return abi_sp->GetRedZoneSize();
- }
- return 0;
-}
-
-lldb::SBLaunchInfo
-SBTarget::GetLaunchInfo () const
-{
- lldb::SBLaunchInfo launch_info(NULL);
- TargetSP target_sp(GetSP());
- if (target_sp)
- launch_info.ref() = m_opaque_sp->GetProcessLaunchInfo();
- return launch_info;
-}
-
-void
-SBTarget::SetLaunchInfo (const lldb::SBLaunchInfo &launch_info)
-{
- TargetSP target_sp(GetSP());
- if (target_sp)
- m_opaque_sp->SetProcessLaunchInfo(launch_info.ref());
+ abi_sp = ABI::FindPlugin(target_sp->GetArchitecture());
+ if (abi_sp)
+ return abi_sp->GetRedZoneSize();
+ }
+ return 0;
+}
+
+lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
+ lldb::SBLaunchInfo launch_info(NULL);
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ launch_info.ref() = m_opaque_sp->GetProcessLaunchInfo();
+ return launch_info;
+}
+
+void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) {
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ m_opaque_sp->SetProcessLaunchInfo(launch_info.ref());
}
Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Tue Sep 6 15:57:50 2016
@@ -9,9 +9,9 @@
#include "lldb/API/SBThread.h"
-#include "lldb/API/SBSymbolContext.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBSymbolContext.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/State.h"
@@ -20,20 +20,20 @@
#include "lldb/Core/StructuredData.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/CompileUnit.h"
-#include "lldb/Target/SystemRuntime.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Queue.h"
-#include "lldb/Target/UnixSignals.h"
#include "lldb/Target/StopInfo.h"
+#include "lldb/Target/SystemRuntime.h"
#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
+#include "lldb/Target/ThreadPlanStepInRange.h"
#include "lldb/Target/ThreadPlanStepInstruction.h"
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Target/ThreadPlanStepRange.h"
-#include "lldb/Target/ThreadPlanStepInRange.h"
+#include "lldb/Target/UnixSignals.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBDebugger.h"
@@ -47,1675 +47,1392 @@
using namespace lldb;
using namespace lldb_private;
-const char *
-SBThread::GetBroadcasterClassName ()
-{
- return Thread::GetStaticBroadcasterClass().AsCString();
+const char *SBThread::GetBroadcasterClassName() {
+ return Thread::GetStaticBroadcasterClass().AsCString();
}
//----------------------------------------------------------------------
// Constructors
//----------------------------------------------------------------------
-SBThread::SBThread () :
- m_opaque_sp (new ExecutionContextRef())
-{
-}
+SBThread::SBThread() : m_opaque_sp(new ExecutionContextRef()) {}
-SBThread::SBThread (const ThreadSP& lldb_object_sp) :
- m_opaque_sp (new ExecutionContextRef(lldb_object_sp))
-{
-}
+SBThread::SBThread(const ThreadSP &lldb_object_sp)
+ : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {}
-SBThread::SBThread (const SBThread &rhs) :
- m_opaque_sp (new ExecutionContextRef(*rhs.m_opaque_sp))
-{
-
-}
+SBThread::SBThread(const SBThread &rhs)
+ : m_opaque_sp(new ExecutionContextRef(*rhs.m_opaque_sp)) {}
//----------------------------------------------------------------------
// Assignment operator
//----------------------------------------------------------------------
-const lldb::SBThread &
-SBThread::operator = (const SBThread &rhs)
-{
- if (this != &rhs)
- *m_opaque_sp = *rhs.m_opaque_sp;
- return *this;
+const lldb::SBThread &SBThread::operator=(const SBThread &rhs) {
+ if (this != &rhs)
+ *m_opaque_sp = *rhs.m_opaque_sp;
+ return *this;
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-SBThread::~SBThread()
-{
-}
+SBThread::~SBThread() {}
-lldb::SBQueue
-SBThread::GetQueue () const
-{
- SBQueue sb_queue;
- QueueSP queue_sp;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- queue_sp = exe_ctx.GetThreadPtr()->GetQueue();
- if (queue_sp)
- {
- sb_queue.SetQueue (queue_sp);
+lldb::SBQueue SBThread::GetQueue() const {
+ SBQueue sb_queue;
+ QueueSP queue_sp;
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ queue_sp = exe_ctx.GetThreadPtr()->GetQueue();
+ if (queue_sp) {
+ sb_queue.SetQueue(queue_sp);
+ }
+ } else {
+ if (log)
+ log->Printf("SBThread(%p)::GetQueue() => error: process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+
+ if (log)
+ log->Printf("SBThread(%p)::GetQueue () => SBQueue(%p)",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ static_cast<void *>(queue_sp.get()));
+
+ return sb_queue;
+}
+
+bool SBThread::IsValid() const {
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ Target *target = exe_ctx.GetTargetPtr();
+ Process *process = exe_ctx.GetProcessPtr();
+ if (target && process) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process->GetRunLock()))
+ return m_opaque_sp->GetThreadSP().get() != NULL;
+ }
+ // Without a valid target & process, this thread can't be valid.
+ return false;
+}
+
+void SBThread::Clear() { m_opaque_sp->Clear(); }
+
+StopReason SBThread::GetStopReason() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ StopReason reason = eStopReasonInvalid;
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ return exe_ctx.GetThreadPtr()->GetStopReason();
+ } else {
+ if (log)
+ log->Printf(
+ "SBThread(%p)::GetStopReason() => error: process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+
+ if (log)
+ log->Printf("SBThread(%p)::GetStopReason () => %s",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ Thread::StopReasonAsCString(reason));
+
+ return reason;
+}
+
+size_t SBThread::GetStopReasonDataCount() {
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
+ if (stop_info_sp) {
+ StopReason reason = stop_info_sp->GetStopReason();
+ switch (reason) {
+ case eStopReasonInvalid:
+ case eStopReasonNone:
+ case eStopReasonTrace:
+ case eStopReasonExec:
+ case eStopReasonPlanComplete:
+ case eStopReasonThreadExiting:
+ case eStopReasonInstrumentation:
+ // There is no data for these stop reasons.
+ return 0;
+
+ case eStopReasonBreakpoint: {
+ break_id_t site_id = stop_info_sp->GetValue();
+ lldb::BreakpointSiteSP bp_site_sp(
+ exe_ctx.GetProcessPtr()->GetBreakpointSiteList().FindByID(
+ site_id));
+ if (bp_site_sp)
+ return bp_site_sp->GetNumberOfOwners() * 2;
+ else
+ return 0; // Breakpoint must have cleared itself...
+ } break;
+
+ case eStopReasonWatchpoint:
+ return 1;
+
+ case eStopReasonSignal:
+ return 1;
+
+ case eStopReasonException:
+ return 1;
+ }
+ }
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBThread(%p)::GetStopReasonDataCount() => error: process "
+ "is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+ return 0;
+}
+
+uint64_t SBThread::GetStopReasonDataAtIndex(uint32_t idx) {
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ Thread *thread = exe_ctx.GetThreadPtr();
+ StopInfoSP stop_info_sp = thread->GetStopInfo();
+ if (stop_info_sp) {
+ StopReason reason = stop_info_sp->GetStopReason();
+ switch (reason) {
+ case eStopReasonInvalid:
+ case eStopReasonNone:
+ case eStopReasonTrace:
+ case eStopReasonExec:
+ case eStopReasonPlanComplete:
+ case eStopReasonThreadExiting:
+ case eStopReasonInstrumentation:
+ // There is no data for these stop reasons.
+ return 0;
+
+ case eStopReasonBreakpoint: {
+ break_id_t site_id = stop_info_sp->GetValue();
+ lldb::BreakpointSiteSP bp_site_sp(
+ exe_ctx.GetProcessPtr()->GetBreakpointSiteList().FindByID(
+ site_id));
+ if (bp_site_sp) {
+ uint32_t bp_index = idx / 2;
+ BreakpointLocationSP bp_loc_sp(
+ bp_site_sp->GetOwnerAtIndex(bp_index));
+ if (bp_loc_sp) {
+ if (idx & 1) {
+ // Odd idx, return the breakpoint location ID
+ return bp_loc_sp->GetID();
+ } else {
+ // Even idx, return the breakpoint ID
+ return bp_loc_sp->GetBreakpoint().GetID();
+ }
}
- }
- else
- {
- if (log)
- log->Printf ("SBThread(%p)::GetQueue() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
-
- if (log)
- log->Printf ("SBThread(%p)::GetQueue () => SBQueue(%p)",
- static_cast<void*>(exe_ctx.GetThreadPtr()), static_cast<void*>(queue_sp.get()));
-
- return sb_queue;
-}
+ }
+ return LLDB_INVALID_BREAK_ID;
+ } break;
+ case eStopReasonWatchpoint:
+ return stop_info_sp->GetValue();
-bool
-SBThread::IsValid() const
-{
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+ case eStopReasonSignal:
+ return stop_info_sp->GetValue();
- Target *target = exe_ctx.GetTargetPtr();
- Process *process = exe_ctx.GetProcessPtr();
- if (target && process)
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&process->GetRunLock()))
- return m_opaque_sp->GetThreadSP().get() != NULL;
+ case eStopReasonException:
+ return stop_info_sp->GetValue();
+ }
+ }
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBThread(%p)::GetStopReasonDataAtIndex() => error: "
+ "process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
}
- // Without a valid target & process, this thread can't be valid.
- return false;
+ }
+ return 0;
}
-void
-SBThread::Clear ()
-{
- m_opaque_sp->Clear();
-}
+bool SBThread::GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream) {
+ Stream &strm = stream.ref();
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-StopReason
-SBThread::GetStopReason()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- StopReason reason = eStopReasonInvalid;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- return exe_ctx.GetThreadPtr()->GetStopReason();
- }
- else
- {
- if (log)
- log->Printf ("SBThread(%p)::GetStopReason() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
+ if (!exe_ctx.HasThreadScope())
+ return false;
- if (log)
- log->Printf ("SBThread(%p)::GetStopReason () => %s",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- Thread::StopReasonAsCString (reason));
-
- return reason;
-}
-
-size_t
-SBThread::GetStopReasonDataCount ()
-{
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo ();
- if (stop_info_sp)
- {
- StopReason reason = stop_info_sp->GetStopReason();
- switch (reason)
- {
- case eStopReasonInvalid:
- case eStopReasonNone:
- case eStopReasonTrace:
- case eStopReasonExec:
- case eStopReasonPlanComplete:
- case eStopReasonThreadExiting:
- case eStopReasonInstrumentation:
- // There is no data for these stop reasons.
- return 0;
-
- case eStopReasonBreakpoint:
- {
- break_id_t site_id = stop_info_sp->GetValue();
- lldb::BreakpointSiteSP bp_site_sp (exe_ctx.GetProcessPtr()->GetBreakpointSiteList().FindByID (site_id));
- if (bp_site_sp)
- return bp_site_sp->GetNumberOfOwners () * 2;
- else
- return 0; // Breakpoint must have cleared itself...
- }
- break;
-
- case eStopReasonWatchpoint:
- return 1;
-
- case eStopReasonSignal:
- return 1;
-
- case eStopReasonException:
- return 1;
- }
- }
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBThread(%p)::GetStopReasonDataCount() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
- return 0;
-}
+ StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
+ StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
+ if (!info)
+ return false;
-uint64_t
-SBThread::GetStopReasonDataAtIndex (uint32_t idx)
-{
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- Thread *thread = exe_ctx.GetThreadPtr();
- StopInfoSP stop_info_sp = thread->GetStopInfo ();
- if (stop_info_sp)
- {
- StopReason reason = stop_info_sp->GetStopReason();
- switch (reason)
- {
- case eStopReasonInvalid:
- case eStopReasonNone:
- case eStopReasonTrace:
- case eStopReasonExec:
- case eStopReasonPlanComplete:
- case eStopReasonThreadExiting:
- case eStopReasonInstrumentation:
- // There is no data for these stop reasons.
- return 0;
-
- case eStopReasonBreakpoint:
- {
- break_id_t site_id = stop_info_sp->GetValue();
- lldb::BreakpointSiteSP bp_site_sp (exe_ctx.GetProcessPtr()->GetBreakpointSiteList().FindByID (site_id));
- if (bp_site_sp)
- {
- uint32_t bp_index = idx / 2;
- BreakpointLocationSP bp_loc_sp (bp_site_sp->GetOwnerAtIndex (bp_index));
- if (bp_loc_sp)
- {
- if (idx & 1)
- {
- // Odd idx, return the breakpoint location ID
- return bp_loc_sp->GetID();
- }
- else
- {
- // Even idx, return the breakpoint ID
- return bp_loc_sp->GetBreakpoint().GetID();
- }
- }
- }
- return LLDB_INVALID_BREAK_ID;
- }
- break;
-
- case eStopReasonWatchpoint:
- return stop_info_sp->GetValue();
-
- case eStopReasonSignal:
- return stop_info_sp->GetValue();
-
- case eStopReasonException:
- return stop_info_sp->GetValue();
- }
- }
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBThread(%p)::GetStopReasonDataAtIndex() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
- return 0;
-}
+ info->Dump(strm);
-bool
-SBThread::GetStopReasonExtendedInfoAsJSON (lldb::SBStream &stream)
-{
- Stream &strm = stream.ref();
-
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (! exe_ctx.HasThreadScope())
- return false;
-
-
- StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
- StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
- if (! info)
- return false;
-
- info->Dump(strm);
-
- return true;
+ return true;
}
SBThreadCollection
-SBThread::GetStopReasonExtendedBacktraces (InstrumentationRuntimeType type)
-{
- ThreadCollectionSP threads;
- threads.reset(new ThreadCollection());
-
- // We currently only support ThreadSanitizer.
- if (type != eInstrumentationRuntimeTypeThreadSanitizer)
- return threads;
-
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (! exe_ctx.HasThreadScope())
- return threads;
-
- ProcessSP process_sp = exe_ctx.GetProcessSP();
-
- StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
- StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
- if (! info)
- return threads;
-
- return process_sp->GetInstrumentationRuntime(type)->GetBacktracesFromExtendedStopInfo(info);
-}
-
-size_t
-SBThread::GetStopDescription (char *dst, size_t dst_len)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
-
- StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo ();
- if (stop_info_sp)
- {
- const char *stop_desc = stop_info_sp->GetDescription();
- if (stop_desc)
- {
- if (log)
- log->Printf ("SBThread(%p)::GetStopDescription (dst, dst_len) => \"%s\"",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- stop_desc);
- if (dst)
- return ::snprintf (dst, dst_len, "%s", stop_desc);
- else
- {
- // NULL dst passed in, return the length needed to contain the description
- return ::strlen (stop_desc) + 1; // Include the NULL byte for size
- }
- }
- else
- {
- size_t stop_desc_len = 0;
- switch (stop_info_sp->GetStopReason())
- {
- case eStopReasonTrace:
- case eStopReasonPlanComplete:
- {
- static char trace_desc[] = "step";
- stop_desc = trace_desc;
- stop_desc_len = sizeof(trace_desc); // Include the NULL byte for size
- }
- break;
-
- case eStopReasonBreakpoint:
- {
- static char bp_desc[] = "breakpoint hit";
- stop_desc = bp_desc;
- stop_desc_len = sizeof(bp_desc); // Include the NULL byte for size
- }
- break;
-
- case eStopReasonWatchpoint:
- {
- static char wp_desc[] = "watchpoint hit";
- stop_desc = wp_desc;
- stop_desc_len = sizeof(wp_desc); // Include the NULL byte for size
- }
- break;
-
- case eStopReasonSignal:
- {
- stop_desc = exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString(stop_info_sp->GetValue());
- if (stop_desc == NULL || stop_desc[0] == '\0')
- {
- static char signal_desc[] = "signal";
- stop_desc = signal_desc;
- stop_desc_len = sizeof(signal_desc); // Include the NULL byte for size
- }
- }
- break;
-
- case eStopReasonException:
- {
- char exc_desc[] = "exception";
- stop_desc = exc_desc;
- stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
- }
- break;
-
- case eStopReasonExec:
- {
- char exc_desc[] = "exec";
- stop_desc = exc_desc;
- stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
- }
- break;
-
- case eStopReasonThreadExiting:
- {
- char limbo_desc[] = "thread exiting";
- stop_desc = limbo_desc;
- stop_desc_len = sizeof(limbo_desc);
- }
- break;
- default:
- break;
- }
-
- if (stop_desc && stop_desc[0])
- {
- if (log)
- log->Printf ("SBThread(%p)::GetStopDescription (dst, dst_len) => '%s'",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- stop_desc);
-
- if (dst)
- return ::snprintf (dst, dst_len, "%s", stop_desc) + 1; // Include the NULL byte
-
- if (stop_desc_len == 0)
- stop_desc_len = ::strlen (stop_desc) + 1; // Include the NULL byte
-
- return stop_desc_len;
- }
- }
- }
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBThread(%p)::GetStopDescription() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
- if (dst)
- *dst = 0;
- return 0;
-}
-
-SBValue
-SBThread::GetStopReturnValue ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- ValueObjectSP return_valobj_sp;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo ();
- if (stop_info_sp)
- {
- return_valobj_sp = StopInfo::GetReturnValueObject (stop_info_sp);
+SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) {
+ ThreadCollectionSP threads;
+ threads.reset(new ThreadCollection());
+
+ // We currently only support ThreadSanitizer.
+ if (type != eInstrumentationRuntimeTypeThreadSanitizer)
+ return threads;
+
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (!exe_ctx.HasThreadScope())
+ return threads;
+
+ ProcessSP process_sp = exe_ctx.GetProcessSP();
+
+ StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
+ StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
+ if (!info)
+ return threads;
+
+ return process_sp->GetInstrumentationRuntime(type)
+ ->GetBacktracesFromExtendedStopInfo(info);
+}
+
+size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+
+ StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
+ if (stop_info_sp) {
+ const char *stop_desc = stop_info_sp->GetDescription();
+ if (stop_desc) {
+ if (log)
+ log->Printf(
+ "SBThread(%p)::GetStopDescription (dst, dst_len) => \"%s\"",
+ static_cast<void *>(exe_ctx.GetThreadPtr()), stop_desc);
+ if (dst)
+ return ::snprintf(dst, dst_len, "%s", stop_desc);
+ else {
+ // NULL dst passed in, return the length needed to contain the
+ // description
+ return ::strlen(stop_desc) + 1; // Include the NULL byte for size
+ }
+ } else {
+ size_t stop_desc_len = 0;
+ switch (stop_info_sp->GetStopReason()) {
+ case eStopReasonTrace:
+ case eStopReasonPlanComplete: {
+ static char trace_desc[] = "step";
+ stop_desc = trace_desc;
+ stop_desc_len =
+ sizeof(trace_desc); // Include the NULL byte for size
+ } break;
+
+ case eStopReasonBreakpoint: {
+ static char bp_desc[] = "breakpoint hit";
+ stop_desc = bp_desc;
+ stop_desc_len = sizeof(bp_desc); // Include the NULL byte for size
+ } break;
+
+ case eStopReasonWatchpoint: {
+ static char wp_desc[] = "watchpoint hit";
+ stop_desc = wp_desc;
+ stop_desc_len = sizeof(wp_desc); // Include the NULL byte for size
+ } break;
+
+ case eStopReasonSignal: {
+ stop_desc =
+ exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString(
+ stop_info_sp->GetValue());
+ if (stop_desc == NULL || stop_desc[0] == '\0') {
+ static char signal_desc[] = "signal";
+ stop_desc = signal_desc;
+ stop_desc_len =
+ sizeof(signal_desc); // Include the NULL byte for size
}
- }
- else
- {
- if (log)
- log->Printf ("SBThread(%p)::GetStopReturnValue() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
+ } break;
- if (log)
- log->Printf ("SBThread(%p)::GetStopReturnValue () => %s",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- return_valobj_sp.get()
- ? return_valobj_sp->GetValueAsCString()
- : "<no return value>");
-
- return SBValue (return_valobj_sp);
-}
-
-void
-SBThread::SetThread (const ThreadSP& lldb_object_sp)
-{
- m_opaque_sp->SetThreadSP (lldb_object_sp);
-}
-
-lldb::tid_t
-SBThread::GetThreadID () const
-{
- ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
- if (thread_sp)
- return thread_sp->GetID();
- return LLDB_INVALID_THREAD_ID;
-}
-
-uint32_t
-SBThread::GetIndexID () const
-{
- ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
- if (thread_sp)
- return thread_sp->GetIndexID();
- return LLDB_INVALID_INDEX32;
-}
-
-const char *
-SBThread::GetName () const
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- const char *name = NULL;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- name = exe_ctx.GetThreadPtr()->GetName();
- }
- else
- {
- if (log)
- log->Printf ("SBThread(%p)::GetName() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
+ case eStopReasonException: {
+ char exc_desc[] = "exception";
+ stop_desc = exc_desc;
+ stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
+ } break;
+
+ case eStopReasonExec: {
+ char exc_desc[] = "exec";
+ stop_desc = exc_desc;
+ stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
+ } break;
+
+ case eStopReasonThreadExiting: {
+ char limbo_desc[] = "thread exiting";
+ stop_desc = limbo_desc;
+ stop_desc_len = sizeof(limbo_desc);
+ } break;
+ default:
+ break;
+ }
- if (log)
- log->Printf ("SBThread(%p)::GetName () => %s",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- name ? name : "NULL");
-
- return name;
-}
-
-const char *
-SBThread::GetQueueName () const
-{
- const char *name = NULL;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- name = exe_ctx.GetThreadPtr()->GetQueueName();
- }
- else
- {
+ if (stop_desc && stop_desc[0]) {
if (log)
- log->Printf ("SBThread(%p)::GetQueueName() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
+ log->Printf(
+ "SBThread(%p)::GetStopDescription (dst, dst_len) => '%s'",
+ static_cast<void *>(exe_ctx.GetThreadPtr()), stop_desc);
+
+ if (dst)
+ return ::snprintf(dst, dst_len, "%s", stop_desc) +
+ 1; // Include the NULL byte
+
+ if (stop_desc_len == 0)
+ stop_desc_len = ::strlen(stop_desc) + 1; // Include the NULL byte
+
+ return stop_desc_len;
+ }
+ }
+ }
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf(
+ "SBThread(%p)::GetStopDescription() => error: process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+ if (dst)
+ *dst = 0;
+ return 0;
+}
+
+SBValue SBThread::GetStopReturnValue() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ ValueObjectSP return_valobj_sp;
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
+ if (stop_info_sp) {
+ return_valobj_sp = StopInfo::GetReturnValueObject(stop_info_sp);
+ }
+ } else {
+ if (log)
+ log->Printf(
+ "SBThread(%p)::GetStopReturnValue() => error: process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+
+ if (log)
+ log->Printf("SBThread(%p)::GetStopReturnValue () => %s",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ return_valobj_sp.get() ? return_valobj_sp->GetValueAsCString()
+ : "<no return value>");
+
+ return SBValue(return_valobj_sp);
+}
+
+void SBThread::SetThread(const ThreadSP &lldb_object_sp) {
+ m_opaque_sp->SetThreadSP(lldb_object_sp);
+}
+
+lldb::tid_t SBThread::GetThreadID() const {
+ ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
+ if (thread_sp)
+ return thread_sp->GetID();
+ return LLDB_INVALID_THREAD_ID;
+}
+
+uint32_t SBThread::GetIndexID() const {
+ ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
+ if (thread_sp)
+ return thread_sp->GetIndexID();
+ return LLDB_INVALID_INDEX32;
+}
+
+const char *SBThread::GetName() const {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ const char *name = NULL;
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ name = exe_ctx.GetThreadPtr()->GetName();
+ } else {
+ if (log)
+ log->Printf("SBThread(%p)::GetName() => error: process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+
+ if (log)
+ log->Printf("SBThread(%p)::GetName () => %s",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ name ? name : "NULL");
+
+ return name;
+}
+
+const char *SBThread::GetQueueName() const {
+ const char *name = NULL;
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ name = exe_ctx.GetThreadPtr()->GetQueueName();
+ } else {
+ if (log)
+ log->Printf("SBThread(%p)::GetQueueName() => error: process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+
+ if (log)
+ log->Printf("SBThread(%p)::GetQueueName () => %s",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ name ? name : "NULL");
+
+ return name;
+}
+
+lldb::queue_id_t SBThread::GetQueueID() const {
+ queue_id_t id = LLDB_INVALID_QUEUE_ID;
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ id = exe_ctx.GetThreadPtr()->GetQueueID();
+ } else {
+ if (log)
+ log->Printf("SBThread(%p)::GetQueueID() => error: process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+
+ if (log)
+ log->Printf("SBThread(%p)::GetQueueID () => 0x%" PRIx64,
+ static_cast<void *>(exe_ctx.GetThreadPtr()), id);
+
+ return id;
+}
+
+bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ bool success = false;
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ Thread *thread = exe_ctx.GetThreadPtr();
+ StructuredData::ObjectSP info_root_sp = thread->GetExtendedInfo();
+ if (info_root_sp) {
+ StructuredData::ObjectSP node =
+ info_root_sp->GetObjectForDotSeparatedPath(path);
+ if (node) {
+ if (node->GetType() == StructuredData::Type::eTypeString) {
+ strm.Printf("%s", node->GetAsString()->GetValue().c_str());
+ success = true;
+ }
+ if (node->GetType() == StructuredData::Type::eTypeInteger) {
+ strm.Printf("0x%" PRIx64, node->GetAsInteger()->GetValue());
+ success = true;
+ }
+ if (node->GetType() == StructuredData::Type::eTypeFloat) {
+ strm.Printf("0x%f", node->GetAsFloat()->GetValue());
+ success = true;
+ }
+ if (node->GetType() == StructuredData::Type::eTypeBoolean) {
+ if (node->GetAsBoolean()->GetValue() == true)
+ strm.Printf("true");
+ else
+ strm.Printf("false");
+ success = true;
+ }
+ if (node->GetType() == StructuredData::Type::eTypeNull) {
+ strm.Printf("null");
+ success = true;
+ }
+ }
+ }
+ } else {
+ if (log)
+ log->Printf("SBThread(%p)::GetInfoItemByPathAsString() => error: "
+ "process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+
+ if (log)
+ log->Printf("SBThread(%p)::GetInfoItemByPathAsString () => %s",
+ static_cast<void *>(exe_ctx.GetThreadPtr()), strm.GetData());
+
+ return success;
+}
+
+SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx,
+ ThreadPlan *new_plan) {
+ SBError sb_error;
+
+ Process *process = exe_ctx.GetProcessPtr();
+ if (!process) {
+ sb_error.SetErrorString("No process in SBThread::ResumeNewPlan");
+ return sb_error;
+ }
- if (log)
- log->Printf ("SBThread(%p)::GetQueueName () => %s",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- name ? name : "NULL");
-
- return name;
-}
-
-lldb::queue_id_t
-SBThread::GetQueueID () const
-{
- queue_id_t id = LLDB_INVALID_QUEUE_ID;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- id = exe_ctx.GetThreadPtr()->GetQueueID();
- }
- else
- {
- if (log)
- log->Printf ("SBThread(%p)::GetQueueID() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
+ Thread *thread = exe_ctx.GetThreadPtr();
+ if (!thread) {
+ sb_error.SetErrorString("No thread in SBThread::ResumeNewPlan");
+ return sb_error;
+ }
- if (log)
- log->Printf ("SBThread(%p)::GetQueueID () => 0x%" PRIx64,
- static_cast<void*>(exe_ctx.GetThreadPtr()), id);
+ // User level plans should be Master Plans so they can be interrupted, other
+ // plans executed, and
+ // then a "continue" will resume the plan.
+ if (new_plan != NULL) {
+ new_plan->SetIsMasterPlan(true);
+ new_plan->SetOkayToDiscard(false);
+ }
- return id;
-}
+ // Why do we need to set the current thread by ID here???
+ process->GetThreadList().SetSelectedThreadByID(thread->GetID());
-bool
-SBThread::GetInfoItemByPathAsString (const char *path, SBStream &strm)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- bool success = false;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- Thread *thread = exe_ctx.GetThreadPtr();
- StructuredData::ObjectSP info_root_sp = thread->GetExtendedInfo();
- if (info_root_sp)
- {
- StructuredData::ObjectSP node = info_root_sp->GetObjectForDotSeparatedPath (path);
- if (node)
- {
- if (node->GetType() == StructuredData::Type::eTypeString)
- {
- strm.Printf ("%s", node->GetAsString()->GetValue().c_str());
- success = true;
- }
- if (node->GetType() == StructuredData::Type::eTypeInteger)
- {
- strm.Printf ("0x%" PRIx64, node->GetAsInteger()->GetValue());
- success = true;
- }
- if (node->GetType() == StructuredData::Type::eTypeFloat)
- {
- strm.Printf ("0x%f", node->GetAsFloat()->GetValue());
- success = true;
- }
- if (node->GetType() == StructuredData::Type::eTypeBoolean)
- {
- if (node->GetAsBoolean()->GetValue() == true)
- strm.Printf ("true");
- else
- strm.Printf ("false");
- success = true;
- }
- if (node->GetType() == StructuredData::Type::eTypeNull)
- {
- strm.Printf ("null");
- success = true;
- }
- }
- }
- }
- else
- {
- if (log)
- log->Printf ("SBThread(%p)::GetInfoItemByPathAsString() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
+ if (process->GetTarget().GetDebugger().GetAsyncExecution())
+ sb_error.ref() = process->Resume();
+ else
+ sb_error.ref() = process->ResumeSynchronous(NULL);
- if (log)
- log->Printf ("SBThread(%p)::GetInfoItemByPathAsString () => %s",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- strm.GetData());
-
- return success;
+ return sb_error;
}
+void SBThread::StepOver(lldb::RunMode stop_other_threads) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-SBError
-SBThread::ResumeNewPlan (ExecutionContext &exe_ctx, ThreadPlan *new_plan)
-{
- SBError sb_error;
-
- Process *process = exe_ctx.GetProcessPtr();
- if (!process)
- {
- sb_error.SetErrorString("No process in SBThread::ResumeNewPlan");
- return sb_error;
- }
-
- Thread *thread = exe_ctx.GetThreadPtr();
- if (!thread)
- {
- sb_error.SetErrorString("No thread in SBThread::ResumeNewPlan");
- return sb_error;
- }
-
- // User level plans should be Master Plans so they can be interrupted, other plans executed, and
- // then a "continue" will resume the plan.
- if (new_plan != NULL)
- {
- new_plan->SetIsMasterPlan(true);
- new_plan->SetOkayToDiscard(false);
- }
-
- // Why do we need to set the current thread by ID here???
- process->GetThreadList().SetSelectedThreadByID (thread->GetID());
-
- if (process->GetTarget().GetDebugger().GetAsyncExecution ())
- sb_error.ref() = process->Resume ();
- else
- sb_error.ref() = process->ResumeSynchronous (NULL);
-
- return sb_error;
-}
-
-void
-SBThread::StepOver (lldb::RunMode stop_other_threads)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+ if (log)
+ log->Printf("SBThread(%p)::StepOver (stop_other_threads='%s')",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ Thread::RunModeAsCString(stop_other_threads));
- if (log)
- log->Printf ("SBThread(%p)::StepOver (stop_other_threads='%s')",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- Thread::RunModeAsCString (stop_other_threads));
-
- if (exe_ctx.HasThreadScope())
- {
- Thread *thread = exe_ctx.GetThreadPtr();
- bool abort_other_plans = false;
- StackFrameSP frame_sp(thread->GetStackFrameAtIndex (0));
-
- ThreadPlanSP new_plan_sp;
- if (frame_sp)
- {
- if (frame_sp->HasDebugInformation ())
- {
- const LazyBool avoid_no_debug = eLazyBoolCalculate;
- SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
- new_plan_sp = thread->QueueThreadPlanForStepOverRange (abort_other_plans,
- sc.line_entry,
- sc,
- stop_other_threads,
- avoid_no_debug);
- }
- else
- {
- new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction (true,
- abort_other_plans,
- stop_other_threads);
- }
- }
+ if (exe_ctx.HasThreadScope()) {
+ Thread *thread = exe_ctx.GetThreadPtr();
+ bool abort_other_plans = false;
+ StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
- // This returns an error, we should use it!
- ResumeNewPlan (exe_ctx, new_plan_sp.get());
+ ThreadPlanSP new_plan_sp;
+ if (frame_sp) {
+ if (frame_sp->HasDebugInformation()) {
+ const LazyBool avoid_no_debug = eLazyBoolCalculate;
+ SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
+ new_plan_sp = thread->QueueThreadPlanForStepOverRange(
+ abort_other_plans, sc.line_entry, sc, stop_other_threads,
+ avoid_no_debug);
+ } else {
+ new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
+ true, abort_other_plans, stop_other_threads);
+ }
}
-}
-void
-SBThread::StepInto (lldb::RunMode stop_other_threads)
-{
- StepInto (NULL, stop_other_threads);
+ // This returns an error, we should use it!
+ ResumeNewPlan(exe_ctx, new_plan_sp.get());
+ }
}
-void
-SBThread::StepInto (const char *target_name, lldb::RunMode stop_other_threads)
-{
- SBError error;
- StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads);
+void SBThread::StepInto(lldb::RunMode stop_other_threads) {
+ StepInto(NULL, stop_other_threads);
}
-void
-SBThread::StepInto (const char *target_name, uint32_t end_line, SBError &error, lldb::RunMode stop_other_threads)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (log)
- log->Printf ("SBThread(%p)::StepInto (target_name='%s', stop_other_threads='%s')",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- target_name? target_name: "<NULL>",
- Thread::RunModeAsCString (stop_other_threads));
-
- if (exe_ctx.HasThreadScope())
- {
- bool abort_other_plans = false;
-
- Thread *thread = exe_ctx.GetThreadPtr();
- StackFrameSP frame_sp(thread->GetStackFrameAtIndex (0));
- ThreadPlanSP new_plan_sp;
-
- if (frame_sp && frame_sp->HasDebugInformation ())
- {
- SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
- AddressRange range;
- if (end_line == LLDB_INVALID_LINE_NUMBER)
- range = sc.line_entry.range;
- else
- {
- if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref()))
- return;
- }
-
- const LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate;
- const LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate;
- new_plan_sp = thread->QueueThreadPlanForStepInRange (abort_other_plans,
- range,
- sc,
- target_name,
- stop_other_threads,
- step_in_avoids_code_without_debug_info,
- step_out_avoids_code_without_debug_info);
- }
- else
- {
- new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction (false,
- abort_other_plans,
- stop_other_threads);
- }
-
- error = ResumeNewPlan (exe_ctx, new_plan_sp.get());
- }
+void SBThread::StepInto(const char *target_name,
+ lldb::RunMode stop_other_threads) {
+ SBError error;
+ StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads);
}
-void
-SBThread::StepOut ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+void SBThread::StepInto(const char *target_name, uint32_t end_line,
+ SBError &error, lldb::RunMode stop_other_threads) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- log->Printf ("SBThread(%p)::StepOut ()",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
+ if (log)
+ log->Printf(
+ "SBThread(%p)::StepInto (target_name='%s', stop_other_threads='%s')",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ target_name ? target_name : "<NULL>",
+ Thread::RunModeAsCString(stop_other_threads));
- if (exe_ctx.HasThreadScope())
- {
- bool abort_other_plans = false;
- bool stop_other_threads = false;
+ if (exe_ctx.HasThreadScope()) {
+ bool abort_other_plans = false;
- Thread *thread = exe_ctx.GetThreadPtr();
+ Thread *thread = exe_ctx.GetThreadPtr();
+ StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
+ ThreadPlanSP new_plan_sp;
- const LazyBool avoid_no_debug = eLazyBoolCalculate;
- ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut (abort_other_plans,
- NULL,
- false,
- stop_other_threads,
- eVoteYes,
- eVoteNoOpinion,
- 0,
- avoid_no_debug));
-
- // This returns an error, we should use it!
- ResumeNewPlan (exe_ctx, new_plan_sp.get());
- }
-}
+ if (frame_sp && frame_sp->HasDebugInformation()) {
+ SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
+ AddressRange range;
+ if (end_line == LLDB_INVALID_LINE_NUMBER)
+ range = sc.line_entry.range;
+ else {
+ if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref()))
+ return;
+ }
+
+ const LazyBool step_out_avoids_code_without_debug_info =
+ eLazyBoolCalculate;
+ const LazyBool step_in_avoids_code_without_debug_info =
+ eLazyBoolCalculate;
+ new_plan_sp = thread->QueueThreadPlanForStepInRange(
+ abort_other_plans, range, sc, target_name, stop_other_threads,
+ step_in_avoids_code_without_debug_info,
+ step_out_avoids_code_without_debug_info);
+ } else {
+ new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
+ false, abort_other_plans, stop_other_threads);
+ }
+
+ error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
+ }
+}
+
+void SBThread::StepOut() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (log)
+ log->Printf("SBThread(%p)::StepOut ()",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+
+ if (exe_ctx.HasThreadScope()) {
+ bool abort_other_plans = false;
+ bool stop_other_threads = false;
-void
-SBThread::StepOutOfFrame (lldb::SBFrame &sb_frame)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (!sb_frame.IsValid())
- {
- if (log)
- log->Printf("SBThread(%p)::StepOutOfFrame passed an invalid frame, returning.",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- return;
- }
-
- StackFrameSP frame_sp (sb_frame.GetFrameSP());
- if (log)
- {
- SBStream frame_desc_strm;
- sb_frame.GetDescription (frame_desc_strm);
- log->Printf ("SBThread(%p)::StepOutOfFrame (frame = SBFrame(%p): %s)",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- static_cast<void*>(frame_sp.get()),
- frame_desc_strm.GetData());
- }
-
- if (exe_ctx.HasThreadScope())
- {
- bool abort_other_plans = false;
- bool stop_other_threads = false;
- Thread *thread = exe_ctx.GetThreadPtr();
- if (sb_frame.GetThread().GetThreadID() != thread->GetID())
- {
- log->Printf("SBThread(%p)::StepOutOfFrame passed a frame from another thread (0x%" PRIx64 " vrs. 0x%" PRIx64 ", returning.",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- sb_frame.GetThread().GetThreadID(),
- thread->GetID());
- }
+ Thread *thread = exe_ctx.GetThreadPtr();
- ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut (abort_other_plans,
- NULL,
- false,
- stop_other_threads,
- eVoteYes,
- eVoteNoOpinion,
- frame_sp->GetFrameIndex()));
-
- // This returns an error, we should use it!
- ResumeNewPlan (exe_ctx, new_plan_sp.get());
+ const LazyBool avoid_no_debug = eLazyBoolCalculate;
+ ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
+ abort_other_plans, NULL, false, stop_other_threads, eVoteYes,
+ eVoteNoOpinion, 0, avoid_no_debug));
+
+ // This returns an error, we should use it!
+ ResumeNewPlan(exe_ctx, new_plan_sp.get());
+ }
+}
+
+void SBThread::StepOutOfFrame(lldb::SBFrame &sb_frame) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (!sb_frame.IsValid()) {
+ if (log)
+ log->Printf(
+ "SBThread(%p)::StepOutOfFrame passed an invalid frame, returning.",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ return;
+ }
+
+ StackFrameSP frame_sp(sb_frame.GetFrameSP());
+ if (log) {
+ SBStream frame_desc_strm;
+ sb_frame.GetDescription(frame_desc_strm);
+ log->Printf("SBThread(%p)::StepOutOfFrame (frame = SBFrame(%p): %s)",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData());
+ }
+
+ if (exe_ctx.HasThreadScope()) {
+ bool abort_other_plans = false;
+ bool stop_other_threads = false;
+ Thread *thread = exe_ctx.GetThreadPtr();
+ if (sb_frame.GetThread().GetThreadID() != thread->GetID()) {
+ log->Printf("SBThread(%p)::StepOutOfFrame passed a frame from another "
+ "thread (0x%" PRIx64 " vrs. 0x%" PRIx64 ", returning.",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ sb_frame.GetThread().GetThreadID(), thread->GetID());
}
-}
-
-void
-SBThread::StepInstruction (bool step_over)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- log->Printf ("SBThread(%p)::StepInstruction (step_over=%i)",
- static_cast<void*>(exe_ctx.GetThreadPtr()), step_over);
-
- if (exe_ctx.HasThreadScope())
- {
- Thread *thread = exe_ctx.GetThreadPtr();
- ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepSingleInstruction (step_over, true, true));
+ ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
+ abort_other_plans, NULL, false, stop_other_threads, eVoteYes,
+ eVoteNoOpinion, frame_sp->GetFrameIndex()));
- // This returns an error, we should use it!
- ResumeNewPlan (exe_ctx, new_plan_sp.get());
- }
+ // This returns an error, we should use it!
+ ResumeNewPlan(exe_ctx, new_plan_sp.get());
+ }
}
-void
-SBThread::RunToAddress (lldb::addr_t addr)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+void SBThread::StepInstruction(bool step_over) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- log->Printf ("SBThread(%p)::RunToAddress (addr=0x%" PRIx64 ")",
- static_cast<void*>(exe_ctx.GetThreadPtr()), addr);
+ if (log)
+ log->Printf("SBThread(%p)::StepInstruction (step_over=%i)",
+ static_cast<void *>(exe_ctx.GetThreadPtr()), step_over);
- if (exe_ctx.HasThreadScope())
- {
- bool abort_other_plans = false;
- bool stop_other_threads = true;
+ if (exe_ctx.HasThreadScope()) {
+ Thread *thread = exe_ctx.GetThreadPtr();
+ ThreadPlanSP new_plan_sp(
+ thread->QueueThreadPlanForStepSingleInstruction(step_over, true, true));
- Address target_addr (addr);
+ // This returns an error, we should use it!
+ ResumeNewPlan(exe_ctx, new_plan_sp.get());
+ }
+}
- Thread *thread = exe_ctx.GetThreadPtr();
+void SBThread::RunToAddress(lldb::addr_t addr) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress (abort_other_plans,
- target_addr,
- stop_other_threads));
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- // This returns an error, we should use it!
- ResumeNewPlan (exe_ctx, new_plan_sp.get());
- }
-}
+ if (log)
+ log->Printf("SBThread(%p)::RunToAddress (addr=0x%" PRIx64 ")",
+ static_cast<void *>(exe_ctx.GetThreadPtr()), addr);
-SBError
-SBThread::StepOverUntil (lldb::SBFrame &sb_frame,
- lldb::SBFileSpec &sb_file_spec,
- uint32_t line)
-{
- SBError sb_error;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- char path[PATH_MAX];
+ if (exe_ctx.HasThreadScope()) {
+ bool abort_other_plans = false;
+ bool stop_other_threads = true;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+ Address target_addr(addr);
- StackFrameSP frame_sp (sb_frame.GetFrameSP());
+ Thread *thread = exe_ctx.GetThreadPtr();
- if (log)
- {
- SBStream frame_desc_strm;
- sb_frame.GetDescription (frame_desc_strm);
- sb_file_spec->GetPath (path, sizeof(path));
- log->Printf ("SBThread(%p)::StepOverUntil (frame = SBFrame(%p): %s, file+line = %s:%u)",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- static_cast<void*>(frame_sp.get()),
- frame_desc_strm.GetData(), path, line);
- }
-
- if (exe_ctx.HasThreadScope())
- {
- Target *target = exe_ctx.GetTargetPtr();
- Thread *thread = exe_ctx.GetThreadPtr();
-
- if (line == 0)
- {
- sb_error.SetErrorString("invalid line argument");
- return sb_error;
- }
+ ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress(
+ abort_other_plans, target_addr, stop_other_threads));
- if (!frame_sp)
- {
- frame_sp = thread->GetSelectedFrame ();
- if (!frame_sp)
- frame_sp = thread->GetStackFrameAtIndex (0);
- }
+ // This returns an error, we should use it!
+ ResumeNewPlan(exe_ctx, new_plan_sp.get());
+ }
+}
+
+SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
+ lldb::SBFileSpec &sb_file_spec, uint32_t line) {
+ SBError sb_error;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ char path[PATH_MAX];
+
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ StackFrameSP frame_sp(sb_frame.GetFrameSP());
+
+ if (log) {
+ SBStream frame_desc_strm;
+ sb_frame.GetDescription(frame_desc_strm);
+ sb_file_spec->GetPath(path, sizeof(path));
+ log->Printf("SBThread(%p)::StepOverUntil (frame = SBFrame(%p): %s, "
+ "file+line = %s:%u)",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData(),
+ path, line);
+ }
- SymbolContext frame_sc;
- if (!frame_sp)
- {
- sb_error.SetErrorString("no valid frames in thread to step");
- return sb_error;
- }
+ if (exe_ctx.HasThreadScope()) {
+ Target *target = exe_ctx.GetTargetPtr();
+ Thread *thread = exe_ctx.GetThreadPtr();
- // If we have a frame, get its line
- frame_sc = frame_sp->GetSymbolContext (eSymbolContextCompUnit |
- eSymbolContextFunction |
- eSymbolContextLineEntry |
- eSymbolContextSymbol );
-
- if (frame_sc.comp_unit == NULL)
- {
- sb_error.SetErrorStringWithFormat("frame %u doesn't have debug information", frame_sp->GetFrameIndex());
- return sb_error;
- }
+ if (line == 0) {
+ sb_error.SetErrorString("invalid line argument");
+ return sb_error;
+ }
+
+ if (!frame_sp) {
+ frame_sp = thread->GetSelectedFrame();
+ if (!frame_sp)
+ frame_sp = thread->GetStackFrameAtIndex(0);
+ }
+
+ SymbolContext frame_sc;
+ if (!frame_sp) {
+ sb_error.SetErrorString("no valid frames in thread to step");
+ return sb_error;
+ }
+
+ // If we have a frame, get its line
+ frame_sc = frame_sp->GetSymbolContext(
+ eSymbolContextCompUnit | eSymbolContextFunction |
+ eSymbolContextLineEntry | eSymbolContextSymbol);
+
+ if (frame_sc.comp_unit == NULL) {
+ sb_error.SetErrorStringWithFormat(
+ "frame %u doesn't have debug information", frame_sp->GetFrameIndex());
+ return sb_error;
+ }
+
+ FileSpec step_file_spec;
+ if (sb_file_spec.IsValid()) {
+ // The file spec passed in was valid, so use it
+ step_file_spec = sb_file_spec.ref();
+ } else {
+ if (frame_sc.line_entry.IsValid())
+ step_file_spec = frame_sc.line_entry.file;
+ else {
+ sb_error.SetErrorString("invalid file argument or no file for frame");
+ return sb_error;
+ }
+ }
- FileSpec step_file_spec;
- if (sb_file_spec.IsValid())
- {
- // The file spec passed in was valid, so use it
- step_file_spec = sb_file_spec.ref();
- }
- else
- {
- if (frame_sc.line_entry.IsValid())
- step_file_spec = frame_sc.line_entry.file;
+ // Grab the current function, then we will make sure the "until" address is
+ // within the function. We discard addresses that are out of the current
+ // function, and then if there are no addresses remaining, give an
+ // appropriate
+ // error message.
+
+ bool all_in_function = true;
+ AddressRange fun_range = frame_sc.function->GetAddressRange();
+
+ std::vector<addr_t> step_over_until_addrs;
+ const bool abort_other_plans = false;
+ const bool stop_other_threads = false;
+ const bool check_inlines = true;
+ const bool exact = false;
+
+ SymbolContextList sc_list;
+ const uint32_t num_matches = frame_sc.comp_unit->ResolveSymbolContext(
+ step_file_spec, line, check_inlines, exact, eSymbolContextLineEntry,
+ sc_list);
+ if (num_matches > 0) {
+ SymbolContext sc;
+ for (uint32_t i = 0; i < num_matches; ++i) {
+ if (sc_list.GetContextAtIndex(i, sc)) {
+ addr_t step_addr =
+ sc.line_entry.range.GetBaseAddress().GetLoadAddress(target);
+ if (step_addr != LLDB_INVALID_ADDRESS) {
+ if (fun_range.ContainsLoadAddress(step_addr, target))
+ step_over_until_addrs.push_back(step_addr);
else
- {
- sb_error.SetErrorString("invalid file argument or no file for frame");
- return sb_error;
- }
- }
-
- // Grab the current function, then we will make sure the "until" address is
- // within the function. We discard addresses that are out of the current
- // function, and then if there are no addresses remaining, give an appropriate
- // error message.
-
- bool all_in_function = true;
- AddressRange fun_range = frame_sc.function->GetAddressRange();
-
- std::vector<addr_t> step_over_until_addrs;
- const bool abort_other_plans = false;
- const bool stop_other_threads = false;
- const bool check_inlines = true;
- const bool exact = false;
-
- SymbolContextList sc_list;
- const uint32_t num_matches = frame_sc.comp_unit->ResolveSymbolContext (step_file_spec,
- line,
- check_inlines,
- exact,
- eSymbolContextLineEntry,
- sc_list);
- if (num_matches > 0)
- {
- SymbolContext sc;
- for (uint32_t i=0; i<num_matches; ++i)
- {
- if (sc_list.GetContextAtIndex(i, sc))
- {
- addr_t step_addr = sc.line_entry.range.GetBaseAddress().GetLoadAddress(target);
- if (step_addr != LLDB_INVALID_ADDRESS)
- {
- if (fun_range.ContainsLoadAddress(step_addr, target))
- step_over_until_addrs.push_back(step_addr);
- else
- all_in_function = false;
- }
- }
- }
+ all_in_function = false;
+ }
}
+ }
+ }
- if (step_over_until_addrs.empty())
- {
- if (all_in_function)
- {
- step_file_spec.GetPath (path, sizeof(path));
- sb_error.SetErrorStringWithFormat("No line entries for %s:%u", path, line);
- }
- else
- sb_error.SetErrorString ("step until target not in current function");
- }
- else
- {
- ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepUntil (abort_other_plans,
- &step_over_until_addrs[0],
- step_over_until_addrs.size(),
- stop_other_threads,
- frame_sp->GetFrameIndex()));
+ if (step_over_until_addrs.empty()) {
+ if (all_in_function) {
+ step_file_spec.GetPath(path, sizeof(path));
+ sb_error.SetErrorStringWithFormat("No line entries for %s:%u", path,
+ line);
+ } else
+ sb_error.SetErrorString("step until target not in current function");
+ } else {
+ ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepUntil(
+ abort_other_plans, &step_over_until_addrs[0],
+ step_over_until_addrs.size(), stop_other_threads,
+ frame_sp->GetFrameIndex()));
- sb_error = ResumeNewPlan (exe_ctx, new_plan_sp.get());
- }
- }
- else
- {
- sb_error.SetErrorString("this SBThread object is invalid");
+ sb_error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
}
- return sb_error;
+ } else {
+ sb_error.SetErrorString("this SBThread object is invalid");
+ }
+ return sb_error;
}
-SBError
-SBThread::StepUsingScriptedThreadPlan (const char *script_class_name)
-{
- return StepUsingScriptedThreadPlan(script_class_name, true);
+SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
+ return StepUsingScriptedThreadPlan(script_class_name, true);
}
-SBError
-SBThread::StepUsingScriptedThreadPlan (const char *script_class_name, bool resume_immediately)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- SBError sb_error;
-
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
+ bool resume_immediately) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ SBError sb_error;
- if (log)
- {
- log->Printf ("SBThread(%p)::StepUsingScriptedThreadPlan: class name: %s",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- script_class_name);
- }
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+ if (log) {
+ log->Printf("SBThread(%p)::StepUsingScriptedThreadPlan: class name: %s",
+ static_cast<void *>(exe_ctx.GetThreadPtr()), script_class_name);
+ }
- if (!exe_ctx.HasThreadScope())
- {
- sb_error.SetErrorString("this SBThread object is invalid");
- return sb_error;
- }
-
- Thread *thread = exe_ctx.GetThreadPtr();
- ThreadPlanSP thread_plan_sp = thread->QueueThreadPlanForStepScripted(false, script_class_name, false);
-
- if (!thread_plan_sp)
- {
- sb_error.SetErrorStringWithFormat("Error queueing thread plan for class: %s", script_class_name);
- return sb_error;
- }
-
- if (!resume_immediately)
- {
- return sb_error;
- }
-
- if (thread_plan_sp)
- sb_error = ResumeNewPlan(exe_ctx, thread_plan_sp.get());
- else
- {
- sb_error.SetErrorStringWithFormat("Error resuming thread plan for class: %s.", script_class_name);
- if (log)
- log->Printf ("SBThread(%p)::StepUsingScriptedThreadPlan: Error queuing thread plan for class: %s",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- script_class_name);
- }
-
+ if (!exe_ctx.HasThreadScope()) {
+ sb_error.SetErrorString("this SBThread object is invalid");
return sb_error;
-}
-
-SBError
-SBThread::JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- SBError sb_error;
-
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+ }
- if (log)
- log->Printf ("SBThread(%p)::JumpToLine (file+line = %s:%u)",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- file_spec->GetPath().c_str(), line);
-
- if (!exe_ctx.HasThreadScope())
- {
- sb_error.SetErrorString("this SBThread object is invalid");
- return sb_error;
- }
-
- Thread *thread = exe_ctx.GetThreadPtr();
-
- Error err = thread->JumpToLine (file_spec.get(), line, true);
- sb_error.SetError (err);
+ Thread *thread = exe_ctx.GetThreadPtr();
+ ThreadPlanSP thread_plan_sp =
+ thread->QueueThreadPlanForStepScripted(false, script_class_name, false);
+
+ if (!thread_plan_sp) {
+ sb_error.SetErrorStringWithFormat(
+ "Error queueing thread plan for class: %s", script_class_name);
return sb_error;
-}
+ }
-SBError
-SBThread::ReturnFromFrame (SBFrame &frame, SBValue &return_value)
-{
- SBError sb_error;
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+ if (!resume_immediately) {
+ return sb_error;
+ }
+ if (thread_plan_sp)
+ sb_error = ResumeNewPlan(exe_ctx, thread_plan_sp.get());
+ else {
+ sb_error.SetErrorStringWithFormat(
+ "Error resuming thread plan for class: %s.", script_class_name);
if (log)
- log->Printf ("SBThread(%p)::ReturnFromFrame (frame=%d)",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- frame.GetFrameID());
-
- if (exe_ctx.HasThreadScope())
- {
- Thread *thread = exe_ctx.GetThreadPtr();
- sb_error.SetError (thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP()));
- }
+ log->Printf("SBThread(%p)::StepUsingScriptedThreadPlan: Error queuing "
+ "thread plan for class: %s",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ script_class_name);
+ }
- return sb_error;
+ return sb_error;
}
-SBError
-SBThread::UnwindInnermostExpression()
-{
- SBError sb_error;
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+SBError SBThread::JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ SBError sb_error;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- log->Printf ("SBThread(%p)::UnwindExpressionEvaluation",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
-
- if (exe_ctx.HasThreadScope())
- {
- Thread *thread = exe_ctx.GetThreadPtr();
- sb_error.SetError (thread->UnwindInnermostExpression());
- if (sb_error.Success())
- thread->SetSelectedFrameByIndex(0, false);
- }
+ if (log)
+ log->Printf("SBThread(%p)::JumpToLine (file+line = %s:%u)",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ file_spec->GetPath().c_str(), line);
+ if (!exe_ctx.HasThreadScope()) {
+ sb_error.SetErrorString("this SBThread object is invalid");
return sb_error;
+ }
-}
+ Thread *thread = exe_ctx.GetThreadPtr();
-bool
-SBThread::Suspend()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- bool result = false;
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- exe_ctx.GetThreadPtr()->SetResumeState (eStateSuspended);
- result = true;
- }
- else
- {
- if (log)
- log->Printf ("SBThread(%p)::Suspend() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
- if (log)
- log->Printf ("SBThread(%p)::Suspend() => %i",
- static_cast<void*>(exe_ctx.GetThreadPtr()), result);
- return result;
-}
-
-bool
-SBThread::Resume ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- bool result = false;
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- const bool override_suspend = true;
- exe_ctx.GetThreadPtr()->SetResumeState (eStateRunning, override_suspend);
- result = true;
- }
- else
- {
- if (log)
- log->Printf ("SBThread(%p)::Resume() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
- if (log)
- log->Printf ("SBThread(%p)::Resume() => %i",
- static_cast<void*>(exe_ctx.GetThreadPtr()), result);
- return result;
+ Error err = thread->JumpToLine(file_spec.get(), line, true);
+ sb_error.SetError(err);
+ return sb_error;
}
-bool
-SBThread::IsSuspended()
-{
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- return exe_ctx.GetThreadPtr()->GetResumeState () == eStateSuspended;
- return false;
-}
+SBError SBThread::ReturnFromFrame(SBFrame &frame, SBValue &return_value) {
+ SBError sb_error;
-bool
-SBThread::IsStopped()
-{
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (exe_ctx.HasThreadScope())
- return StateIsStoppedState(exe_ctx.GetThreadPtr()->GetState(), true);
- return false;
-}
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-SBProcess
-SBThread::GetProcess ()
-{
- SBProcess sb_process;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- // Have to go up to the target so we can get a shared pointer to our process...
- sb_process.SetSP (exe_ctx.GetProcessSP());
- }
+ if (log)
+ log->Printf("SBThread(%p)::ReturnFromFrame (frame=%d)",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ frame.GetFrameID());
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- SBStream frame_desc_strm;
- sb_process.GetDescription (frame_desc_strm);
- log->Printf ("SBThread(%p)::GetProcess () => SBProcess(%p): %s",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- static_cast<void*>(sb_process.GetSP().get()),
- frame_desc_strm.GetData());
- }
-
- return sb_process;
-}
-
-uint32_t
-SBThread::GetNumFrames ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- uint32_t num_frames = 0;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- num_frames = exe_ctx.GetThreadPtr()->GetStackFrameCount();
- }
- else
- {
- if (log)
- log->Printf ("SBThread(%p)::GetNumFrames() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
-
- if (log)
- log->Printf ("SBThread(%p)::GetNumFrames () => %u",
- static_cast<void*>(exe_ctx.GetThreadPtr()), num_frames);
+ if (exe_ctx.HasThreadScope()) {
+ Thread *thread = exe_ctx.GetThreadPtr();
+ sb_error.SetError(
+ thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP()));
+ }
- return num_frames;
+ return sb_error;
}
-SBFrame
-SBThread::GetFrameAtIndex (uint32_t idx)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBFrame sb_frame;
- StackFrameSP frame_sp;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- frame_sp = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex (idx);
- sb_frame.SetFrameSP (frame_sp);
- }
- else
- {
- if (log)
- log->Printf ("SBThread(%p)::GetFrameAtIndex() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
+SBError SBThread::UnwindInnermostExpression() {
+ SBError sb_error;
- if (log)
- {
- SBStream frame_desc_strm;
- sb_frame.GetDescription (frame_desc_strm);
- log->Printf ("SBThread(%p)::GetFrameAtIndex (idx=%d) => SBFrame(%p): %s",
- static_cast<void*>(exe_ctx.GetThreadPtr()), idx,
- static_cast<void*>(frame_sp.get()),
- frame_desc_strm.GetData());
- }
-
- return sb_frame;
-}
-
-lldb::SBFrame
-SBThread::GetSelectedFrame ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBFrame sb_frame;
- StackFrameSP frame_sp;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- frame_sp = exe_ctx.GetThreadPtr()->GetSelectedFrame ();
- sb_frame.SetFrameSP (frame_sp);
- }
- else
- {
- if (log)
- log->Printf ("SBThread(%p)::GetSelectedFrame() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- {
- SBStream frame_desc_strm;
- sb_frame.GetDescription (frame_desc_strm);
- log->Printf ("SBThread(%p)::GetSelectedFrame () => SBFrame(%p): %s",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- static_cast<void*>(frame_sp.get()),
- frame_desc_strm.GetData());
- }
-
- return sb_frame;
-}
-
-lldb::SBFrame
-SBThread::SetSelectedFrame (uint32_t idx)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBFrame sb_frame;
- StackFrameSP frame_sp;
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- Thread *thread = exe_ctx.GetThreadPtr();
- frame_sp = thread->GetStackFrameAtIndex (idx);
- if (frame_sp)
- {
- thread->SetSelectedFrame (frame_sp.get());
- sb_frame.SetFrameSP (frame_sp);
- }
- }
- else
- {
- if (log)
- log->Printf ("SBThread(%p)::SetSelectedFrame() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- {
- SBStream frame_desc_strm;
- sb_frame.GetDescription (frame_desc_strm);
- log->Printf ("SBThread(%p)::SetSelectedFrame (idx=%u) => SBFrame(%p): %s",
- static_cast<void*>(exe_ctx.GetThreadPtr()), idx,
- static_cast<void*>(frame_sp.get()),
- frame_desc_strm.GetData());
- }
- return sb_frame;
-}
-
-bool
-SBThread::EventIsThreadEvent (const SBEvent &event)
-{
- return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != NULL;
-}
-
-SBFrame
-SBThread::GetStackFrameFromEvent (const SBEvent &event)
-{
- return Thread::ThreadEventData::GetStackFrameFromEvent (event.get());
-
-}
-
-SBThread
-SBThread::GetThreadFromEvent (const SBEvent &event)
-{
- return Thread::ThreadEventData::GetThreadFromEvent (event.get());
-}
-
-bool
-SBThread::operator == (const SBThread &rhs) const
-{
- return m_opaque_sp->GetThreadSP().get() == rhs.m_opaque_sp->GetThreadSP().get();
-}
-
-bool
-SBThread::operator != (const SBThread &rhs) const
-{
- return m_opaque_sp->GetThreadSP().get() != rhs.m_opaque_sp->GetThreadSP().get();
-}
-
-bool
-SBThread::GetStatus (SBStream &status) const
-{
- Stream &strm = status.ref();
-
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1);
- }
- else
- strm.PutCString ("No status");
-
- return true;
-}
-
-bool
-SBThread::GetDescription (SBStream &description) const
-{
- Stream &strm = description.ref();
-
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
- if (exe_ctx.HasThreadScope())
- {
- exe_ctx.GetThreadPtr()->DumpUsingSettingsFormat(strm, LLDB_INVALID_THREAD_ID);
- //strm.Printf("SBThread: tid = 0x%4.4" PRIx64, exe_ctx.GetThreadPtr()->GetID());
- }
- else
- strm.PutCString ("No value");
-
- return true;
-}
-
-SBThread
-SBThread::GetExtendedBacktraceThread (const char *type)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- std::unique_lock<std::recursive_mutex> lock;
- ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- SBThread sb_origin_thread;
-
- if (exe_ctx.HasThreadScope())
- {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
- {
- ThreadSP real_thread(exe_ctx.GetThreadSP());
- if (real_thread)
- {
- ConstString type_const (type);
- Process *process = exe_ctx.GetProcessPtr();
- if (process)
- {
- SystemRuntime *runtime = process->GetSystemRuntime();
- if (runtime)
- {
- ThreadSP new_thread_sp (runtime->GetExtendedBacktraceThread (real_thread, type_const));
- if (new_thread_sp)
- {
- // Save this in the Process' ExtendedThreadList so a strong pointer retains the
- // object.
- process->GetExtendedThreadList().AddThread (new_thread_sp);
- sb_origin_thread.SetThread (new_thread_sp);
- if (log)
- {
- const char *queue_name = new_thread_sp->GetQueueName();
- if (queue_name == NULL)
- queue_name = "";
- log->Printf ("SBThread(%p)::GetExtendedBacktraceThread() => new extended Thread "
- "created (%p) with queue_id 0x%" PRIx64 " queue name '%s'",
- static_cast<void*>(exe_ctx.GetThreadPtr()),
- static_cast<void*>(new_thread_sp.get()),
- new_thread_sp->GetQueueID(),
- queue_name);
- }
- }
- }
- }
+ if (log)
+ log->Printf("SBThread(%p)::UnwindExpressionEvaluation",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+
+ if (exe_ctx.HasThreadScope()) {
+ Thread *thread = exe_ctx.GetThreadPtr();
+ sb_error.SetError(thread->UnwindInnermostExpression());
+ if (sb_error.Success())
+ thread->SetSelectedFrameByIndex(0, false);
+ }
+
+ return sb_error;
+}
+
+bool SBThread::Suspend() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ bool result = false;
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ exe_ctx.GetThreadPtr()->SetResumeState(eStateSuspended);
+ result = true;
+ } else {
+ if (log)
+ log->Printf("SBThread(%p)::Suspend() => error: process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+ if (log)
+ log->Printf("SBThread(%p)::Suspend() => %i",
+ static_cast<void *>(exe_ctx.GetThreadPtr()), result);
+ return result;
+}
+
+bool SBThread::Resume() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ bool result = false;
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ const bool override_suspend = true;
+ exe_ctx.GetThreadPtr()->SetResumeState(eStateRunning, override_suspend);
+ result = true;
+ } else {
+ if (log)
+ log->Printf("SBThread(%p)::Resume() => error: process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+ if (log)
+ log->Printf("SBThread(%p)::Resume() => %i",
+ static_cast<void *>(exe_ctx.GetThreadPtr()), result);
+ return result;
+}
+
+bool SBThread::IsSuspended() {
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope())
+ return exe_ctx.GetThreadPtr()->GetResumeState() == eStateSuspended;
+ return false;
+}
+
+bool SBThread::IsStopped() {
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope())
+ return StateIsStoppedState(exe_ctx.GetThreadPtr()->GetState(), true);
+ return false;
+}
+
+SBProcess SBThread::GetProcess() {
+ SBProcess sb_process;
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ // Have to go up to the target so we can get a shared pointer to our
+ // process...
+ sb_process.SetSP(exe_ctx.GetProcessSP());
+ }
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ SBStream frame_desc_strm;
+ sb_process.GetDescription(frame_desc_strm);
+ log->Printf("SBThread(%p)::GetProcess () => SBProcess(%p): %s",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ static_cast<void *>(sb_process.GetSP().get()),
+ frame_desc_strm.GetData());
+ }
+
+ return sb_process;
+}
+
+uint32_t SBThread::GetNumFrames() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ uint32_t num_frames = 0;
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ num_frames = exe_ctx.GetThreadPtr()->GetStackFrameCount();
+ } else {
+ if (log)
+ log->Printf("SBThread(%p)::GetNumFrames() => error: process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+
+ if (log)
+ log->Printf("SBThread(%p)::GetNumFrames () => %u",
+ static_cast<void *>(exe_ctx.GetThreadPtr()), num_frames);
+
+ return num_frames;
+}
+
+SBFrame SBThread::GetFrameAtIndex(uint32_t idx) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBFrame sb_frame;
+ StackFrameSP frame_sp;
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ frame_sp = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(idx);
+ sb_frame.SetFrameSP(frame_sp);
+ } else {
+ if (log)
+ log->Printf(
+ "SBThread(%p)::GetFrameAtIndex() => error: process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+
+ if (log) {
+ SBStream frame_desc_strm;
+ sb_frame.GetDescription(frame_desc_strm);
+ log->Printf("SBThread(%p)::GetFrameAtIndex (idx=%d) => SBFrame(%p): %s",
+ static_cast<void *>(exe_ctx.GetThreadPtr()), idx,
+ static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData());
+ }
+
+ return sb_frame;
+}
+
+lldb::SBFrame SBThread::GetSelectedFrame() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBFrame sb_frame;
+ StackFrameSP frame_sp;
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ frame_sp = exe_ctx.GetThreadPtr()->GetSelectedFrame();
+ sb_frame.SetFrameSP(frame_sp);
+ } else {
+ if (log)
+ log->Printf(
+ "SBThread(%p)::GetSelectedFrame() => error: process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+
+ if (log) {
+ SBStream frame_desc_strm;
+ sb_frame.GetDescription(frame_desc_strm);
+ log->Printf("SBThread(%p)::GetSelectedFrame () => SBFrame(%p): %s",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData());
+ }
+
+ return sb_frame;
+}
+
+lldb::SBFrame SBThread::SetSelectedFrame(uint32_t idx) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBFrame sb_frame;
+ StackFrameSP frame_sp;
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ Thread *thread = exe_ctx.GetThreadPtr();
+ frame_sp = thread->GetStackFrameAtIndex(idx);
+ if (frame_sp) {
+ thread->SetSelectedFrame(frame_sp.get());
+ sb_frame.SetFrameSP(frame_sp);
+ }
+ } else {
+ if (log)
+ log->Printf(
+ "SBThread(%p)::SetSelectedFrame() => error: process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+
+ if (log) {
+ SBStream frame_desc_strm;
+ sb_frame.GetDescription(frame_desc_strm);
+ log->Printf("SBThread(%p)::SetSelectedFrame (idx=%u) => SBFrame(%p): %s",
+ static_cast<void *>(exe_ctx.GetThreadPtr()), idx,
+ static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData());
+ }
+ return sb_frame;
+}
+
+bool SBThread::EventIsThreadEvent(const SBEvent &event) {
+ return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != NULL;
+}
+
+SBFrame SBThread::GetStackFrameFromEvent(const SBEvent &event) {
+ return Thread::ThreadEventData::GetStackFrameFromEvent(event.get());
+}
+
+SBThread SBThread::GetThreadFromEvent(const SBEvent &event) {
+ return Thread::ThreadEventData::GetThreadFromEvent(event.get());
+}
+
+bool SBThread::operator==(const SBThread &rhs) const {
+ return m_opaque_sp->GetThreadSP().get() ==
+ rhs.m_opaque_sp->GetThreadSP().get();
+}
+
+bool SBThread::operator!=(const SBThread &rhs) const {
+ return m_opaque_sp->GetThreadSP().get() !=
+ rhs.m_opaque_sp->GetThreadSP().get();
+}
+
+bool SBThread::GetStatus(SBStream &status) const {
+ Stream &strm = status.ref();
+
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1);
+ } else
+ strm.PutCString("No status");
+
+ return true;
+}
+
+bool SBThread::GetDescription(SBStream &description) const {
+ Stream &strm = description.ref();
+
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ if (exe_ctx.HasThreadScope()) {
+ exe_ctx.GetThreadPtr()->DumpUsingSettingsFormat(strm,
+ LLDB_INVALID_THREAD_ID);
+ // strm.Printf("SBThread: tid = 0x%4.4" PRIx64,
+ // exe_ctx.GetThreadPtr()->GetID());
+ } else
+ strm.PutCString("No value");
+
+ return true;
+}
+
+SBThread SBThread::GetExtendedBacktraceThread(const char *type) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+ SBThread sb_origin_thread;
+
+ if (exe_ctx.HasThreadScope()) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ ThreadSP real_thread(exe_ctx.GetThreadSP());
+ if (real_thread) {
+ ConstString type_const(type);
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process) {
+ SystemRuntime *runtime = process->GetSystemRuntime();
+ if (runtime) {
+ ThreadSP new_thread_sp(
+ runtime->GetExtendedBacktraceThread(real_thread, type_const));
+ if (new_thread_sp) {
+ // Save this in the Process' ExtendedThreadList so a strong
+ // pointer retains the
+ // object.
+ process->GetExtendedThreadList().AddThread(new_thread_sp);
+ sb_origin_thread.SetThread(new_thread_sp);
+ if (log) {
+ const char *queue_name = new_thread_sp->GetQueueName();
+ if (queue_name == NULL)
+ queue_name = "";
+ log->Printf("SBThread(%p)::GetExtendedBacktraceThread() => new "
+ "extended Thread "
+ "created (%p) with queue_id 0x%" PRIx64
+ " queue name '%s'",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ static_cast<void *>(new_thread_sp.get()),
+ new_thread_sp->GetQueueID(), queue_name);
+ }
}
+ }
}
- else
- {
- if (log)
- log->Printf ("SBThread(%p)::GetExtendedBacktraceThread() => error: process is running",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- }
- }
-
- if (log && sb_origin_thread.IsValid() == false)
- log->Printf("SBThread(%p)::GetExtendedBacktraceThread() is not returning a Valid thread",
- static_cast<void*>(exe_ctx.GetThreadPtr()));
- return sb_origin_thread;
-}
-
-uint32_t
-SBThread::GetExtendedBacktraceOriginatingIndexID ()
-{
- ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
- if (thread_sp)
- return thread_sp->GetExtendedBacktraceOriginatingIndexID();
- return LLDB_INVALID_INDEX32;
-}
-
-bool
-SBThread::SafeToCallFunctions ()
-{
- ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
- if (thread_sp)
- return thread_sp->SafeToCallFunctions();
- return true;
-}
-
-lldb_private::Thread *
-SBThread::operator->()
-{
- ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
- if (thread_sp)
- return thread_sp.get();
- else
- return NULL;
-}
-
-lldb_private::Thread *
-SBThread::get()
-{
- ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
- if (thread_sp)
- return thread_sp.get();
- else
- return NULL;
+ }
+ } else {
+ if (log)
+ log->Printf("SBThread(%p)::GetExtendedBacktraceThread() => error: "
+ "process is running",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ }
+ }
+
+ if (log && sb_origin_thread.IsValid() == false)
+ log->Printf("SBThread(%p)::GetExtendedBacktraceThread() is not returning a "
+ "Valid thread",
+ static_cast<void *>(exe_ctx.GetThreadPtr()));
+ return sb_origin_thread;
+}
+
+uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID() {
+ ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
+ if (thread_sp)
+ return thread_sp->GetExtendedBacktraceOriginatingIndexID();
+ return LLDB_INVALID_INDEX32;
+}
+
+bool SBThread::SafeToCallFunctions() {
+ ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
+ if (thread_sp)
+ return thread_sp->SafeToCallFunctions();
+ return true;
+}
+
+lldb_private::Thread *SBThread::operator->() {
+ ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
+ if (thread_sp)
+ return thread_sp.get();
+ else
+ return NULL;
+}
+
+lldb_private::Thread *SBThread::get() {
+ ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
+ if (thread_sp)
+ return thread_sp.get();
+ else
+ return NULL;
}
-
Modified: lldb/trunk/source/API/SBThreadCollection.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThreadCollection.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThreadCollection.cpp (original)
+++ lldb/trunk/source/API/SBThreadCollection.cpp Tue Sep 6 15:57:50 2016
@@ -14,84 +14,54 @@
using namespace lldb;
using namespace lldb_private;
+SBThreadCollection::SBThreadCollection() : m_opaque_sp() {}
-SBThreadCollection::SBThreadCollection () :
- m_opaque_sp()
-{
-}
+SBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs)
+ : m_opaque_sp(rhs.m_opaque_sp) {}
-SBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs) :
- m_opaque_sp (rhs.m_opaque_sp)
-{
+const SBThreadCollection &SBThreadCollection::
+operator=(const SBThreadCollection &rhs) {
+ if (this != &rhs)
+ m_opaque_sp = rhs.m_opaque_sp;
+ return *this;
}
-const SBThreadCollection &
-SBThreadCollection::operator = (const SBThreadCollection &rhs)
-{
- if (this != &rhs)
- m_opaque_sp = rhs.m_opaque_sp;
- return *this;
-}
+SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads)
+ : m_opaque_sp(threads) {}
-SBThreadCollection::SBThreadCollection (const ThreadCollectionSP &threads) :
- m_opaque_sp(threads)
-{
-}
+SBThreadCollection::~SBThreadCollection() {}
-SBThreadCollection::~SBThreadCollection ()
-{
+void SBThreadCollection::SetOpaque(const lldb::ThreadCollectionSP &threads) {
+ m_opaque_sp = threads;
}
-void
-SBThreadCollection::SetOpaque (const lldb::ThreadCollectionSP &threads)
-{
- m_opaque_sp = threads;
+lldb_private::ThreadCollection *SBThreadCollection::get() const {
+ return m_opaque_sp.get();
}
-lldb_private::ThreadCollection *
-SBThreadCollection::get() const
-{
- return m_opaque_sp.get();
+lldb_private::ThreadCollection *SBThreadCollection::operator->() const {
+ return m_opaque_sp.operator->();
}
-lldb_private::ThreadCollection *
-SBThreadCollection::operator->() const
-{
- return m_opaque_sp.operator->();
+lldb::ThreadCollectionSP &SBThreadCollection::operator*() {
+ return m_opaque_sp;
}
-lldb::ThreadCollectionSP &
-SBThreadCollection::operator*()
-{
- return m_opaque_sp;
+const lldb::ThreadCollectionSP &SBThreadCollection::operator*() const {
+ return m_opaque_sp;
}
-const lldb::ThreadCollectionSP &
-SBThreadCollection::operator*() const
-{
- return m_opaque_sp;
-}
-
-
-bool
-SBThreadCollection::IsValid () const
-{
- return m_opaque_sp.get() != NULL;
-}
+bool SBThreadCollection::IsValid() const { return m_opaque_sp.get() != NULL; }
-size_t
-SBThreadCollection::GetSize ()
-{
- if (m_opaque_sp)
- return m_opaque_sp->GetSize();
- return 0;
+size_t SBThreadCollection::GetSize() {
+ if (m_opaque_sp)
+ return m_opaque_sp->GetSize();
+ return 0;
}
-SBThread
-SBThreadCollection::GetThreadAtIndex(size_t idx)
-{
- SBThread thread;
- if (m_opaque_sp && idx < m_opaque_sp->GetSize())
- thread = m_opaque_sp->GetThreadAtIndex(idx);
- return thread;
+SBThread SBThreadCollection::GetThreadAtIndex(size_t idx) {
+ SBThread thread;
+ if (m_opaque_sp && idx < m_opaque_sp->GetSize())
+ thread = m_opaque_sp->GetThreadAtIndex(idx);
+ return thread;
}
Modified: lldb/trunk/source/API/SBThreadPlan.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThreadPlan.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThreadPlan.cpp (original)
+++ lldb/trunk/source/API/SBThreadPlan.cpp Tue Sep 6 15:57:50 2016
@@ -9,9 +9,9 @@
#include "lldb/API/SBThread.h"
-#include "lldb/API/SBSymbolContext.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBSymbolContext.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/State.h"
@@ -19,22 +19,21 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Target/SystemRuntime.h"
-#include "lldb/Target/Thread.h"
-#include "lldb/Target/ThreadPlan.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Queue.h"
-#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Target/StopInfo.h"
+#include "lldb/Target/SystemRuntime.h"
#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanPython.h"
+#include "lldb/Target/ThreadPlanStepInRange.h"
#include "lldb/Target/ThreadPlanStepInstruction.h"
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Target/ThreadPlanStepRange.h"
-#include "lldb/Target/ThreadPlanStepInRange.h"
-
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBDebugger.h"
@@ -50,243 +49,163 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// Constructors
//----------------------------------------------------------------------
-SBThreadPlan::SBThreadPlan ()
-{
-}
+SBThreadPlan::SBThreadPlan() {}
-SBThreadPlan::SBThreadPlan (const ThreadPlanSP& lldb_object_sp) :
- m_opaque_sp (lldb_object_sp)
-{
-}
+SBThreadPlan::SBThreadPlan(const ThreadPlanSP &lldb_object_sp)
+ : m_opaque_sp(lldb_object_sp) {}
-SBThreadPlan::SBThreadPlan (const SBThreadPlan &rhs) :
- m_opaque_sp (rhs.m_opaque_sp)
-{
-
-}
+SBThreadPlan::SBThreadPlan(const SBThreadPlan &rhs)
+ : m_opaque_sp(rhs.m_opaque_sp) {}
-SBThreadPlan::SBThreadPlan (lldb::SBThread &sb_thread, const char *class_name)
-{
- Thread *thread = sb_thread.get();
- if (thread)
- m_opaque_sp.reset(new ThreadPlanPython(*thread, class_name));
+SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) {
+ Thread *thread = sb_thread.get();
+ if (thread)
+ m_opaque_sp.reset(new ThreadPlanPython(*thread, class_name));
}
//----------------------------------------------------------------------
// Assignment operator
//----------------------------------------------------------------------
-const lldb::SBThreadPlan &
-SBThreadPlan::operator = (const SBThreadPlan &rhs)
-{
- if (this != &rhs)
- m_opaque_sp = rhs.m_opaque_sp;
- return *this;
+const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) {
+ if (this != &rhs)
+ m_opaque_sp = rhs.m_opaque_sp;
+ return *this;
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-SBThreadPlan::~SBThreadPlan()
-{
-}
+SBThreadPlan::~SBThreadPlan() {}
-lldb_private::ThreadPlan *
-SBThreadPlan::get()
-{
- return m_opaque_sp.get();
-}
+lldb_private::ThreadPlan *SBThreadPlan::get() { return m_opaque_sp.get(); }
-bool
-SBThreadPlan::IsValid() const
-{
- return m_opaque_sp.get() != NULL;
-}
+bool SBThreadPlan::IsValid() const { return m_opaque_sp.get() != NULL; }
-void
-SBThreadPlan::Clear ()
-{
- m_opaque_sp.reset();
+void SBThreadPlan::Clear() { m_opaque_sp.reset(); }
+
+lldb::StopReason SBThreadPlan::GetStopReason() { return eStopReasonNone; }
+
+size_t SBThreadPlan::GetStopReasonDataCount() { return 0; }
+
+uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) { return 0; }
+
+SBThread SBThreadPlan::GetThread() const {
+ if (m_opaque_sp) {
+ return SBThread(m_opaque_sp->GetThread().shared_from_this());
+ } else
+ return SBThread();
}
-lldb::StopReason
-SBThreadPlan::GetStopReason()
-{
- return eStopReasonNone;
+bool SBThreadPlan::GetDescription(lldb::SBStream &description) const {
+ if (m_opaque_sp) {
+ m_opaque_sp->GetDescription(description.get(), eDescriptionLevelFull);
+ } else {
+ description.Printf("Empty SBThreadPlan");
+ }
+ return true;
}
-size_t
-SBThreadPlan::GetStopReasonDataCount()
-{
- return 0;
+void SBThreadPlan::SetThreadPlan(const ThreadPlanSP &lldb_object_sp) {
+ m_opaque_sp = lldb_object_sp;
}
-uint64_t
-SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx)
-{
- return 0;
+void SBThreadPlan::SetPlanComplete(bool success) {
+ if (m_opaque_sp)
+ m_opaque_sp->SetPlanComplete(success);
}
-SBThread
-SBThreadPlan::GetThread () const
-{
- if (m_opaque_sp)
- {
- return SBThread(m_opaque_sp->GetThread().shared_from_this());
- }
- else
- return SBThread();
+bool SBThreadPlan::IsPlanComplete() {
+ if (m_opaque_sp)
+ return m_opaque_sp->IsPlanComplete();
+ else
+ return true;
}
-bool
-SBThreadPlan::GetDescription (lldb::SBStream &description) const
-{
- if (m_opaque_sp)
- {
- m_opaque_sp->GetDescription(description.get(), eDescriptionLevelFull);
- }
- else
- {
- description.Printf("Empty SBThreadPlan");
- }
+bool SBThreadPlan::IsPlanStale() {
+ if (m_opaque_sp)
+ return m_opaque_sp->IsPlanStale();
+ else
return true;
}
-void
-SBThreadPlan::SetThreadPlan (const ThreadPlanSP& lldb_object_sp)
-{
- m_opaque_sp = lldb_object_sp;
-}
-
-void
-SBThreadPlan::SetPlanComplete (bool success)
-{
- if (m_opaque_sp)
- m_opaque_sp->SetPlanComplete (success);
-}
-
-bool
-SBThreadPlan::IsPlanComplete()
-{
- if (m_opaque_sp)
- return m_opaque_sp->IsPlanComplete();
- else
- return true;
-}
-
-bool
-SBThreadPlan::IsPlanStale()
-{
- if (m_opaque_sp)
- return m_opaque_sp->IsPlanStale();
- else
- return true;
-}
-
-bool
-SBThreadPlan::IsValid()
-{
- if (m_opaque_sp)
- return m_opaque_sp->ValidatePlan(nullptr);
- else
- return false;
-}
-
- // This section allows an SBThreadPlan to push another of the common types of plans...
- //
- // FIXME, you should only be able to queue thread plans from inside the methods of a
- // Scripted Thread Plan. Need a way to enforce that.
+bool SBThreadPlan::IsValid() {
+ if (m_opaque_sp)
+ return m_opaque_sp->ValidatePlan(nullptr);
+ else
+ return false;
+}
+
+// This section allows an SBThreadPlan to push another of the common types of
+// plans...
+//
+// FIXME, you should only be able to queue thread plans from inside the methods
+// of a
+// Scripted Thread Plan. Need a way to enforce that.
SBThreadPlan
-SBThreadPlan::QueueThreadPlanForStepOverRange (SBAddress &sb_start_address,
- lldb::addr_t size)
-{
- if (m_opaque_sp)
- {
- Address *start_address = sb_start_address.get();
- if (!start_address)
- {
- return SBThreadPlan();
- }
-
- AddressRange range (*start_address, size);
- SymbolContext sc;
- start_address->CalculateSymbolContext(&sc);
- return SBThreadPlan (m_opaque_sp->GetThread().QueueThreadPlanForStepOverRange (false,
- range,
- sc,
- eAllThreads));
- }
- else
- {
- return SBThreadPlan();
- }
+SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address,
+ lldb::addr_t size) {
+ if (m_opaque_sp) {
+ Address *start_address = sb_start_address.get();
+ if (!start_address) {
+ return SBThreadPlan();
+ }
+
+ AddressRange range(*start_address, size);
+ SymbolContext sc;
+ start_address->CalculateSymbolContext(&sc);
+ return SBThreadPlan(
+ m_opaque_sp->GetThread().QueueThreadPlanForStepOverRange(
+ false, range, sc, eAllThreads));
+ } else {
+ return SBThreadPlan();
+ }
}
SBThreadPlan
-SBThreadPlan::QueueThreadPlanForStepInRange (SBAddress &sb_start_address,
- lldb::addr_t size)
-{
- if (m_opaque_sp)
- {
- Address *start_address = sb_start_address.get();
- if (!start_address)
- {
- return SBThreadPlan();
- }
-
- AddressRange range (*start_address, size);
- SymbolContext sc;
- start_address->CalculateSymbolContext(&sc);
- return SBThreadPlan (m_opaque_sp->GetThread().QueueThreadPlanForStepInRange (false,
- range,
- sc,
- NULL,
- eAllThreads));
- }
- else
- {
- return SBThreadPlan();
- }
+SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
+ lldb::addr_t size) {
+ if (m_opaque_sp) {
+ Address *start_address = sb_start_address.get();
+ if (!start_address) {
+ return SBThreadPlan();
+ }
+
+ AddressRange range(*start_address, size);
+ SymbolContext sc;
+ start_address->CalculateSymbolContext(&sc);
+ return SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepInRange(
+ false, range, sc, NULL, eAllThreads));
+ } else {
+ return SBThreadPlan();
+ }
}
SBThreadPlan
-SBThreadPlan::QueueThreadPlanForStepOut (uint32_t frame_idx_to_step_to, bool first_insn)
-{
- if (m_opaque_sp)
- {
- SymbolContext sc;
- sc = m_opaque_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext(lldb::eSymbolContextEverything);
- return SBThreadPlan (m_opaque_sp->GetThread().QueueThreadPlanForStepOut (false,
- &sc,
- first_insn,
- false,
- eVoteYes,
- eVoteNoOpinion,
- frame_idx_to_step_to));
- }
- else
- {
- return SBThreadPlan();
- }
+SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
+ bool first_insn) {
+ if (m_opaque_sp) {
+ SymbolContext sc;
+ sc = m_opaque_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext(
+ lldb::eSymbolContextEverything);
+ return SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepOut(
+ false, &sc, first_insn, false, eVoteYes, eVoteNoOpinion,
+ frame_idx_to_step_to));
+ } else {
+ return SBThreadPlan();
+ }
}
SBThreadPlan
-SBThreadPlan::QueueThreadPlanForRunToAddress (SBAddress sb_address)
-{
- if (m_opaque_sp)
- {
- Address *address = sb_address.get();
- if (!address)
- return SBThreadPlan();
-
- return SBThreadPlan (m_opaque_sp->GetThread().QueueThreadPlanForRunToAddress (false,
- *address,
- false));
- }
- else
- {
- return SBThreadPlan();
- }
+SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address) {
+ if (m_opaque_sp) {
+ Address *address = sb_address.get();
+ if (!address)
+ return SBThreadPlan();
+
+ return SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForRunToAddress(
+ false, *address, false));
+ } else {
+ return SBThreadPlan();
+ }
}
-
-
Modified: lldb/trunk/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBType.cpp (original)
+++ lldb/trunk/source/API/SBType.cpp Tue Sep 6 15:57:50 2016
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBType.h"
-#include "lldb/API/SBTypeEnumMember.h"
+#include "lldb/API/SBDefines.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBTypeEnumMember.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Mangled.h"
@@ -24,877 +24,646 @@
using namespace lldb;
using namespace lldb_private;
-SBType::SBType() :
- m_opaque_sp()
-{
-}
+SBType::SBType() : m_opaque_sp() {}
-SBType::SBType (const CompilerType &type) :
- m_opaque_sp(new TypeImpl(CompilerType(type.GetTypeSystem(),
- type.GetOpaqueQualType())))
-{
-}
+SBType::SBType(const CompilerType &type)
+ : m_opaque_sp(new TypeImpl(
+ CompilerType(type.GetTypeSystem(), type.GetOpaqueQualType()))) {}
-SBType::SBType (const lldb::TypeSP &type_sp) :
- m_opaque_sp(new TypeImpl(type_sp))
-{
-}
+SBType::SBType(const lldb::TypeSP &type_sp)
+ : m_opaque_sp(new TypeImpl(type_sp)) {}
-SBType::SBType (const lldb::TypeImplSP &type_impl_sp) :
- m_opaque_sp(type_impl_sp)
-{
-}
-
+SBType::SBType(const lldb::TypeImplSP &type_impl_sp)
+ : m_opaque_sp(type_impl_sp) {}
-SBType::SBType (const SBType &rhs) :
- m_opaque_sp()
-{
- if (this != &rhs)
- {
- m_opaque_sp = rhs.m_opaque_sp;
- }
+SBType::SBType(const SBType &rhs) : m_opaque_sp() {
+ if (this != &rhs) {
+ m_opaque_sp = rhs.m_opaque_sp;
+ }
}
-
-//SBType::SBType (TypeImpl* impl) :
+// SBType::SBType (TypeImpl* impl) :
// m_opaque_ap(impl)
//{}
//
-bool
-SBType::operator == (SBType &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
-
- if (rhs.IsValid() == false)
- return false;
-
- return *m_opaque_sp.get() == *rhs.m_opaque_sp.get();
-}
-
-bool
-SBType::operator != (SBType &rhs)
-{
- if (IsValid() == false)
- return rhs.IsValid();
-
- if (rhs.IsValid() == false)
- return true;
-
- return *m_opaque_sp.get() != *rhs.m_opaque_sp.get();
-}
-
-lldb::TypeImplSP
-SBType::GetSP ()
-{
- return m_opaque_sp;
-}
+bool SBType::operator==(SBType &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+ if (rhs.IsValid() == false)
+ return false;
-void
-SBType::SetSP (const lldb::TypeImplSP &type_impl_sp)
-{
- m_opaque_sp = type_impl_sp;
-}
-
-SBType &
-SBType::operator = (const SBType &rhs)
-{
- if (this != &rhs)
- {
- m_opaque_sp = rhs.m_opaque_sp;
- }
- return *this;
+ return *m_opaque_sp.get() == *rhs.m_opaque_sp.get();
}
-SBType::~SBType ()
-{}
+bool SBType::operator!=(SBType &rhs) {
+ if (IsValid() == false)
+ return rhs.IsValid();
-TypeImpl &
-SBType::ref ()
-{
- if (m_opaque_sp.get() == NULL)
- m_opaque_sp.reset (new TypeImpl());
- return *m_opaque_sp;
-}
-
-const TypeImpl &
-SBType::ref () const
-{
- // "const SBAddress &addr" should already have checked "addr.IsValid()"
- // prior to calling this function. In case you didn't we will assert
- // and die to let you know.
- assert (m_opaque_sp.get());
- return *m_opaque_sp;
-}
-
-bool
-SBType::IsValid() const
-{
- if (m_opaque_sp.get() == NULL)
- return false;
-
- return m_opaque_sp->IsValid();
-}
-
-uint64_t
-SBType::GetByteSize()
-{
- if (!IsValid())
- return 0;
-
- return m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr);
-
-}
-
-bool
-SBType::IsPointerType()
-{
- if (!IsValid())
- return false;
- return m_opaque_sp->GetCompilerType(true).IsPointerType();
-}
-
-bool
-SBType::IsArrayType()
-{
- if (!IsValid())
- return false;
- return m_opaque_sp->GetCompilerType(true).IsArrayType(nullptr, nullptr, nullptr);
-}
-
-bool
-SBType::IsVectorType()
-{
- if (!IsValid())
- return false;
- return m_opaque_sp->GetCompilerType(true).IsVectorType(nullptr, nullptr);
-}
-
-bool
-SBType::IsReferenceType()
-{
- if (!IsValid())
- return false;
- return m_opaque_sp->GetCompilerType(true).IsReferenceType();
-}
-
-SBType
-SBType::GetPointerType()
-{
- if (!IsValid())
- return SBType();
-
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointerType())));
-}
-
-SBType
-SBType::GetPointeeType()
-{
- if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointeeType())));
-}
-
-SBType
-SBType::GetReferenceType()
-{
- if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetReferenceType())));
-}
-
-SBType
-SBType::GetTypedefedType()
-{
- if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetTypedefedType())));
-}
-
-SBType
-SBType::GetDereferencedType()
-{
- if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetDereferencedType())));
-}
-
-SBType
-SBType::GetArrayElementType()
-{
- if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayElementType())));
-}
-
-SBType
-SBType::GetArrayType (uint64_t size)
-{
- if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayType(size))));
-}
-
-SBType
-SBType::GetVectorElementType ()
-{
- SBType type_sb;
- if (IsValid())
- {
- CompilerType vector_element_type;
- if (m_opaque_sp->GetCompilerType(true).IsVectorType(&vector_element_type, nullptr))
- type_sb.SetSP(TypeImplSP(new TypeImpl(vector_element_type)));
- }
- return type_sb;
-}
+ if (rhs.IsValid() == false)
+ return true;
-bool
-SBType::IsFunctionType ()
-{
- if (!IsValid())
- return false;
- return m_opaque_sp->GetCompilerType(true).IsFunctionType();
-}
-
-bool
-SBType::IsPolymorphicClass ()
-{
- if (!IsValid())
- return false;
- return m_opaque_sp->GetCompilerType(true).IsPolymorphicClass();
-}
-
-bool
-SBType::IsTypedefType ()
-{
- if (!IsValid())
- return false;
- return m_opaque_sp->GetCompilerType(true).IsTypedefType();
-}
-
-bool
-SBType::IsAnonymousType ()
-{
- if (!IsValid())
- return false;
- return m_opaque_sp->GetCompilerType(true).IsAnonymousType();
-}
-
-lldb::SBType
-SBType::GetFunctionReturnType ()
-{
- if (IsValid())
- {
- CompilerType return_type (m_opaque_sp->GetCompilerType(true).GetFunctionReturnType());
- if (return_type.IsValid())
- return SBType(return_type);
- }
- return lldb::SBType();
+ return *m_opaque_sp.get() != *rhs.m_opaque_sp.get();
}
-lldb::SBTypeList
-SBType::GetFunctionArgumentTypes ()
-{
- SBTypeList sb_type_list;
- if (IsValid())
- {
- CompilerType func_type(m_opaque_sp->GetCompilerType(true));
- size_t count = func_type.GetNumberOfFunctionArguments();
- for (size_t i = 0;
- i < count;
- i++)
- {
- sb_type_list.Append(SBType(func_type.GetFunctionArgumentAtIndex(i)));
- }
- }
- return sb_type_list;
-}
+lldb::TypeImplSP SBType::GetSP() { return m_opaque_sp; }
-uint32_t
-SBType::GetNumberOfMemberFunctions ()
-{
- if (IsValid())
- {
- return m_opaque_sp->GetCompilerType(true).GetNumMemberFunctions();
- }
- return 0;
+void SBType::SetSP(const lldb::TypeImplSP &type_impl_sp) {
+ m_opaque_sp = type_impl_sp;
}
-lldb::SBTypeMemberFunction
-SBType::GetMemberFunctionAtIndex (uint32_t idx)
-{
- SBTypeMemberFunction sb_func_type;
- if (IsValid())
- sb_func_type.reset(new TypeMemberFunctionImpl(m_opaque_sp->GetCompilerType(true).GetMemberFunctionAtIndex(idx)));
- return sb_func_type;
-}
-
-lldb::SBType
-SBType::GetUnqualifiedType()
-{
- if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetUnqualifiedType())));
-}
-
-lldb::SBType
-SBType::GetCanonicalType()
-{
- if (IsValid())
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetCanonicalType())));
- return SBType();
+SBType &SBType::operator=(const SBType &rhs) {
+ if (this != &rhs) {
+ m_opaque_sp = rhs.m_opaque_sp;
+ }
+ return *this;
}
+SBType::~SBType() {}
-lldb::BasicType
-SBType::GetBasicType()
-{
- if (IsValid())
- return m_opaque_sp->GetCompilerType(false).GetBasicTypeEnumeration ();
- return eBasicTypeInvalid;
+TypeImpl &SBType::ref() {
+ if (m_opaque_sp.get() == NULL)
+ m_opaque_sp.reset(new TypeImpl());
+ return *m_opaque_sp;
}
-SBType
-SBType::GetBasicType(lldb::BasicType basic_type)
-{
- if (IsValid() && m_opaque_sp->IsValid())
- return SBType(m_opaque_sp->GetTypeSystem(false)->GetBasicTypeFromAST(basic_type));
- return SBType();
+const TypeImpl &SBType::ref() const {
+ // "const SBAddress &addr" should already have checked "addr.IsValid()"
+ // prior to calling this function. In case you didn't we will assert
+ // and die to let you know.
+ assert(m_opaque_sp.get());
+ return *m_opaque_sp;
}
-uint32_t
-SBType::GetNumberOfDirectBaseClasses ()
-{
- if (IsValid())
- return m_opaque_sp->GetCompilerType(true).GetNumDirectBaseClasses();
- return 0;
+bool SBType::IsValid() const {
+ if (m_opaque_sp.get() == NULL)
+ return false;
+
+ return m_opaque_sp->IsValid();
}
-uint32_t
-SBType::GetNumberOfVirtualBaseClasses ()
-{
- if (IsValid())
- return m_opaque_sp->GetCompilerType(true).GetNumVirtualBaseClasses();
+uint64_t SBType::GetByteSize() {
+ if (!IsValid())
return 0;
+
+ return m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr);
}
-uint32_t
-SBType::GetNumberOfFields ()
-{
- if (IsValid())
- return m_opaque_sp->GetCompilerType(true).GetNumFields();
- return 0;
+bool SBType::IsPointerType() {
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetCompilerType(true).IsPointerType();
}
-bool
-SBType::GetDescription (SBStream &description, lldb::DescriptionLevel description_level)
-{
- Stream &strm = description.ref();
-
- if (m_opaque_sp)
- {
- m_opaque_sp->GetDescription (strm, description_level);
- }
- else
- strm.PutCString ("No value");
-
- return true;
+bool SBType::IsArrayType() {
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetCompilerType(true).IsArrayType(nullptr, nullptr,
+ nullptr);
}
+bool SBType::IsVectorType() {
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetCompilerType(true).IsVectorType(nullptr, nullptr);
+}
+bool SBType::IsReferenceType() {
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetCompilerType(true).IsReferenceType();
+}
-SBTypeMember
-SBType::GetDirectBaseClassAtIndex (uint32_t idx)
-{
- SBTypeMember sb_type_member;
- if (IsValid())
- {
- uint32_t bit_offset = 0;
- CompilerType base_class_type = m_opaque_sp->GetCompilerType (true).GetDirectBaseClassAtIndex(idx, &bit_offset);
- if (base_class_type.IsValid())
- sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset));
- }
- return sb_type_member;
+SBType SBType::GetPointerType() {
+ if (!IsValid())
+ return SBType();
+ return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointerType())));
}
-SBTypeMember
-SBType::GetVirtualBaseClassAtIndex (uint32_t idx)
-{
- SBTypeMember sb_type_member;
- if (IsValid())
- {
- uint32_t bit_offset = 0;
- CompilerType base_class_type = m_opaque_sp->GetCompilerType (true).GetVirtualBaseClassAtIndex(idx, &bit_offset);
- if (base_class_type.IsValid())
- sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset));
- }
- return sb_type_member;
+SBType SBType::GetPointeeType() {
+ if (!IsValid())
+ return SBType();
+ return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointeeType())));
}
-SBTypeEnumMemberList
-SBType::GetEnumMembers ()
-{
- SBTypeEnumMemberList sb_enum_member_list;
- if (IsValid())
- {
- CompilerType this_type (m_opaque_sp->GetCompilerType (true));
- if (this_type.IsValid())
- {
- this_type.ForEachEnumerator([&sb_enum_member_list] (const CompilerType &integer_type, const ConstString &name, const llvm::APSInt &value) -> bool {
- SBTypeEnumMember enum_member (lldb::TypeEnumMemberImplSP (new TypeEnumMemberImpl(lldb::TypeImplSP(new TypeImpl(integer_type)), name, value)));
- sb_enum_member_list.Append(enum_member);
- return true; // Keep iterating
- });
- }
- }
- return sb_enum_member_list;
+SBType SBType::GetReferenceType() {
+ if (!IsValid())
+ return SBType();
+ return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetReferenceType())));
}
-SBTypeMember
-SBType::GetFieldAtIndex (uint32_t idx)
-{
- SBTypeMember sb_type_member;
- if (IsValid())
- {
- CompilerType this_type (m_opaque_sp->GetCompilerType (false));
- if (this_type.IsValid())
- {
- uint64_t bit_offset = 0;
- uint32_t bitfield_bit_size = 0;
- bool is_bitfield = false;
- std::string name_sstr;
- CompilerType field_type (this_type.GetFieldAtIndex (idx,
- name_sstr,
- &bit_offset,
- &bitfield_bit_size,
- &is_bitfield));
- if (field_type.IsValid())
- {
- ConstString name;
- if (!name_sstr.empty())
- name.SetCString(name_sstr.c_str());
- sb_type_member.reset (new TypeMemberImpl (TypeImplSP (new TypeImpl(field_type)),
- bit_offset,
- name,
- bitfield_bit_size,
- is_bitfield));
- }
- }
- }
- return sb_type_member;
+SBType SBType::GetTypedefedType() {
+ if (!IsValid())
+ return SBType();
+ return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetTypedefedType())));
}
-bool
-SBType::IsTypeComplete()
-{
- if (!IsValid())
- return false;
- return m_opaque_sp->GetCompilerType(false).IsCompleteType();
-}
-
-uint32_t
-SBType::GetTypeFlags ()
-{
- if (!IsValid())
- return 0;
- return m_opaque_sp->GetCompilerType(true).GetTypeInfo();
-}
-
-const char*
-SBType::GetName()
-{
- if (!IsValid())
- return "";
- return m_opaque_sp->GetName().GetCString();
+SBType SBType::GetDereferencedType() {
+ if (!IsValid())
+ return SBType();
+ return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetDereferencedType())));
}
-const char *
-SBType::GetDisplayTypeName ()
-{
- if (!IsValid())
- return "";
- return m_opaque_sp->GetDisplayTypeName().GetCString();
-}
-
-lldb::TypeClass
-SBType::GetTypeClass ()
-{
- if (IsValid())
- return m_opaque_sp->GetCompilerType(true).GetTypeClass();
- return lldb::eTypeClassInvalid;
-}
-
-uint32_t
-SBType::GetNumberOfTemplateArguments ()
-{
- if (IsValid())
- return m_opaque_sp->GetCompilerType(false).GetNumTemplateArguments();
- return 0;
+SBType SBType::GetArrayElementType() {
+ if (!IsValid())
+ return SBType();
+ return SBType(TypeImplSP(
+ new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayElementType())));
}
-lldb::SBType
-SBType::GetTemplateArgumentType (uint32_t idx)
-{
- if (IsValid())
- {
- TemplateArgumentKind kind = eTemplateArgumentKindNull;
- CompilerType template_arg_type = m_opaque_sp->GetCompilerType(false).GetTemplateArgument(idx, kind);
- if (template_arg_type.IsValid())
- return SBType(template_arg_type);
- }
+SBType SBType::GetArrayType(uint64_t size) {
+ if (!IsValid())
return SBType();
+ return SBType(TypeImplSP(
+ new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayType(size))));
}
+SBType SBType::GetVectorElementType() {
+ SBType type_sb;
+ if (IsValid()) {
+ CompilerType vector_element_type;
+ if (m_opaque_sp->GetCompilerType(true).IsVectorType(&vector_element_type,
+ nullptr))
+ type_sb.SetSP(TypeImplSP(new TypeImpl(vector_element_type)));
+ }
+ return type_sb;
+}
-lldb::TemplateArgumentKind
-SBType::GetTemplateArgumentKind (uint32_t idx)
-{
- TemplateArgumentKind kind = eTemplateArgumentKindNull;
- if (IsValid())
- m_opaque_sp->GetCompilerType(false).GetTemplateArgument(idx, kind);
- return kind;
+bool SBType::IsFunctionType() {
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetCompilerType(true).IsFunctionType();
}
+bool SBType::IsPolymorphicClass() {
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetCompilerType(true).IsPolymorphicClass();
+}
-SBTypeList::SBTypeList() :
- m_opaque_ap(new TypeListImpl())
-{
+bool SBType::IsTypedefType() {
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetCompilerType(true).IsTypedefType();
}
-SBTypeList::SBTypeList(const SBTypeList& rhs) :
- m_opaque_ap(new TypeListImpl())
-{
- for (uint32_t i = 0, rhs_size = const_cast<SBTypeList&>(rhs).GetSize(); i < rhs_size; i++)
- Append(const_cast<SBTypeList&>(rhs).GetTypeAtIndex(i));
+bool SBType::IsAnonymousType() {
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetCompilerType(true).IsAnonymousType();
}
-bool
-SBTypeList::IsValid ()
-{
- return (m_opaque_ap.get() != NULL);
+lldb::SBType SBType::GetFunctionReturnType() {
+ if (IsValid()) {
+ CompilerType return_type(
+ m_opaque_sp->GetCompilerType(true).GetFunctionReturnType());
+ if (return_type.IsValid())
+ return SBType(return_type);
+ }
+ return lldb::SBType();
}
-SBTypeList&
-SBTypeList::operator = (const SBTypeList& rhs)
-{
- if (this != &rhs)
- {
- m_opaque_ap.reset (new TypeListImpl());
- for (uint32_t i = 0, rhs_size = const_cast<SBTypeList&>(rhs).GetSize(); i < rhs_size; i++)
- Append(const_cast<SBTypeList&>(rhs).GetTypeAtIndex(i));
+lldb::SBTypeList SBType::GetFunctionArgumentTypes() {
+ SBTypeList sb_type_list;
+ if (IsValid()) {
+ CompilerType func_type(m_opaque_sp->GetCompilerType(true));
+ size_t count = func_type.GetNumberOfFunctionArguments();
+ for (size_t i = 0; i < count; i++) {
+ sb_type_list.Append(SBType(func_type.GetFunctionArgumentAtIndex(i)));
}
- return *this;
+ }
+ return sb_type_list;
}
-void
-SBTypeList::Append (SBType type)
-{
- if (type.IsValid())
- m_opaque_ap->Append (type.m_opaque_sp);
+uint32_t SBType::GetNumberOfMemberFunctions() {
+ if (IsValid()) {
+ return m_opaque_sp->GetCompilerType(true).GetNumMemberFunctions();
+ }
+ return 0;
}
-SBType
-SBTypeList::GetTypeAtIndex(uint32_t index)
-{
- if (m_opaque_ap.get())
- return SBType(m_opaque_ap->GetTypeAtIndex(index));
- return SBType();
+lldb::SBTypeMemberFunction SBType::GetMemberFunctionAtIndex(uint32_t idx) {
+ SBTypeMemberFunction sb_func_type;
+ if (IsValid())
+ sb_func_type.reset(new TypeMemberFunctionImpl(
+ m_opaque_sp->GetCompilerType(true).GetMemberFunctionAtIndex(idx)));
+ return sb_func_type;
}
-uint32_t
-SBTypeList::GetSize()
-{
- return m_opaque_ap->GetSize();
+lldb::SBType SBType::GetUnqualifiedType() {
+ if (!IsValid())
+ return SBType();
+ return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetUnqualifiedType())));
}
-SBTypeList::~SBTypeList()
-{
+lldb::SBType SBType::GetCanonicalType() {
+ if (IsValid())
+ return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetCanonicalType())));
+ return SBType();
+}
+
+lldb::BasicType SBType::GetBasicType() {
+ if (IsValid())
+ return m_opaque_sp->GetCompilerType(false).GetBasicTypeEnumeration();
+ return eBasicTypeInvalid;
+}
+
+SBType SBType::GetBasicType(lldb::BasicType basic_type) {
+ if (IsValid() && m_opaque_sp->IsValid())
+ return SBType(
+ m_opaque_sp->GetTypeSystem(false)->GetBasicTypeFromAST(basic_type));
+ return SBType();
+}
+
+uint32_t SBType::GetNumberOfDirectBaseClasses() {
+ if (IsValid())
+ return m_opaque_sp->GetCompilerType(true).GetNumDirectBaseClasses();
+ return 0;
+}
+
+uint32_t SBType::GetNumberOfVirtualBaseClasses() {
+ if (IsValid())
+ return m_opaque_sp->GetCompilerType(true).GetNumVirtualBaseClasses();
+ return 0;
+}
+
+uint32_t SBType::GetNumberOfFields() {
+ if (IsValid())
+ return m_opaque_sp->GetCompilerType(true).GetNumFields();
+ return 0;
+}
+
+bool SBType::GetDescription(SBStream &description,
+ lldb::DescriptionLevel description_level) {
+ Stream &strm = description.ref();
+
+ if (m_opaque_sp) {
+ m_opaque_sp->GetDescription(strm, description_level);
+ } else
+ strm.PutCString("No value");
+
+ return true;
+}
+
+SBTypeMember SBType::GetDirectBaseClassAtIndex(uint32_t idx) {
+ SBTypeMember sb_type_member;
+ if (IsValid()) {
+ uint32_t bit_offset = 0;
+ CompilerType base_class_type =
+ m_opaque_sp->GetCompilerType(true).GetDirectBaseClassAtIndex(
+ idx, &bit_offset);
+ if (base_class_type.IsValid())
+ sb_type_member.reset(new TypeMemberImpl(
+ TypeImplSP(new TypeImpl(base_class_type)), bit_offset));
+ }
+ return sb_type_member;
+}
+
+SBTypeMember SBType::GetVirtualBaseClassAtIndex(uint32_t idx) {
+ SBTypeMember sb_type_member;
+ if (IsValid()) {
+ uint32_t bit_offset = 0;
+ CompilerType base_class_type =
+ m_opaque_sp->GetCompilerType(true).GetVirtualBaseClassAtIndex(
+ idx, &bit_offset);
+ if (base_class_type.IsValid())
+ sb_type_member.reset(new TypeMemberImpl(
+ TypeImplSP(new TypeImpl(base_class_type)), bit_offset));
+ }
+ return sb_type_member;
+}
+
+SBTypeEnumMemberList SBType::GetEnumMembers() {
+ SBTypeEnumMemberList sb_enum_member_list;
+ if (IsValid()) {
+ CompilerType this_type(m_opaque_sp->GetCompilerType(true));
+ if (this_type.IsValid()) {
+ this_type.ForEachEnumerator([&sb_enum_member_list](
+ const CompilerType &integer_type,
+ const ConstString &name,
+ const llvm::APSInt &value) -> bool {
+ SBTypeEnumMember enum_member(
+ lldb::TypeEnumMemberImplSP(new TypeEnumMemberImpl(
+ lldb::TypeImplSP(new TypeImpl(integer_type)), name, value)));
+ sb_enum_member_list.Append(enum_member);
+ return true; // Keep iterating
+ });
+ }
+ }
+ return sb_enum_member_list;
+}
+
+SBTypeMember SBType::GetFieldAtIndex(uint32_t idx) {
+ SBTypeMember sb_type_member;
+ if (IsValid()) {
+ CompilerType this_type(m_opaque_sp->GetCompilerType(false));
+ if (this_type.IsValid()) {
+ uint64_t bit_offset = 0;
+ uint32_t bitfield_bit_size = 0;
+ bool is_bitfield = false;
+ std::string name_sstr;
+ CompilerType field_type(this_type.GetFieldAtIndex(
+ idx, name_sstr, &bit_offset, &bitfield_bit_size, &is_bitfield));
+ if (field_type.IsValid()) {
+ ConstString name;
+ if (!name_sstr.empty())
+ name.SetCString(name_sstr.c_str());
+ sb_type_member.reset(
+ new TypeMemberImpl(TypeImplSP(new TypeImpl(field_type)), bit_offset,
+ name, bitfield_bit_size, is_bitfield));
+ }
+ }
+ }
+ return sb_type_member;
}
-SBTypeMember::SBTypeMember() :
- m_opaque_ap()
-{
+bool SBType::IsTypeComplete() {
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetCompilerType(false).IsCompleteType();
}
-SBTypeMember::~SBTypeMember()
-{
+uint32_t SBType::GetTypeFlags() {
+ if (!IsValid())
+ return 0;
+ return m_opaque_sp->GetCompilerType(true).GetTypeInfo();
}
-SBTypeMember::SBTypeMember (const SBTypeMember& rhs) :
- m_opaque_ap()
-{
- if (this != &rhs)
- {
- if (rhs.IsValid())
- m_opaque_ap.reset(new TypeMemberImpl(rhs.ref()));
- }
+const char *SBType::GetName() {
+ if (!IsValid())
+ return "";
+ return m_opaque_sp->GetName().GetCString();
}
-lldb::SBTypeMember&
-SBTypeMember::operator = (const lldb::SBTypeMember& rhs)
-{
- if (this != &rhs)
- {
- if (rhs.IsValid())
- m_opaque_ap.reset(new TypeMemberImpl(rhs.ref()));
- }
- return *this;
+const char *SBType::GetDisplayTypeName() {
+ if (!IsValid())
+ return "";
+ return m_opaque_sp->GetDisplayTypeName().GetCString();
}
-bool
-SBTypeMember::IsValid() const
-{
- return m_opaque_ap.get();
-}
-
-const char *
-SBTypeMember::GetName ()
-{
- if (m_opaque_ap.get())
- return m_opaque_ap->GetName().GetCString();
- return NULL;
-}
-
-SBType
-SBTypeMember::GetType ()
-{
- SBType sb_type;
- if (m_opaque_ap.get())
- {
- sb_type.SetSP (m_opaque_ap->GetTypeImpl());
- }
- return sb_type;
-
+lldb::TypeClass SBType::GetTypeClass() {
+ if (IsValid())
+ return m_opaque_sp->GetCompilerType(true).GetTypeClass();
+ return lldb::eTypeClassInvalid;
}
-uint64_t
-SBTypeMember::GetOffsetInBytes()
-{
- if (m_opaque_ap.get())
- return m_opaque_ap->GetBitOffset() / 8u;
- return 0;
+uint32_t SBType::GetNumberOfTemplateArguments() {
+ if (IsValid())
+ return m_opaque_sp->GetCompilerType(false).GetNumTemplateArguments();
+ return 0;
}
-uint64_t
-SBTypeMember::GetOffsetInBits()
-{
- if (m_opaque_ap.get())
- return m_opaque_ap->GetBitOffset();
- return 0;
+lldb::SBType SBType::GetTemplateArgumentType(uint32_t idx) {
+ if (IsValid()) {
+ TemplateArgumentKind kind = eTemplateArgumentKindNull;
+ CompilerType template_arg_type =
+ m_opaque_sp->GetCompilerType(false).GetTemplateArgument(idx, kind);
+ if (template_arg_type.IsValid())
+ return SBType(template_arg_type);
+ }
+ return SBType();
}
-bool
-SBTypeMember::IsBitfield()
-{
- if (m_opaque_ap.get())
- return m_opaque_ap->GetIsBitfield();
- return false;
+lldb::TemplateArgumentKind SBType::GetTemplateArgumentKind(uint32_t idx) {
+ TemplateArgumentKind kind = eTemplateArgumentKindNull;
+ if (IsValid())
+ m_opaque_sp->GetCompilerType(false).GetTemplateArgument(idx, kind);
+ return kind;
}
-uint32_t
-SBTypeMember::GetBitfieldSizeInBits()
-{
- if (m_opaque_ap.get())
- return m_opaque_ap->GetBitfieldBitSize();
- return 0;
+SBTypeList::SBTypeList() : m_opaque_ap(new TypeListImpl()) {}
+
+SBTypeList::SBTypeList(const SBTypeList &rhs)
+ : m_opaque_ap(new TypeListImpl()) {
+ for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize();
+ i < rhs_size; i++)
+ Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i));
}
+bool SBTypeList::IsValid() { return (m_opaque_ap.get() != NULL); }
-bool
-SBTypeMember::GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level)
-{
- Stream &strm = description.ref();
-
- if (m_opaque_ap.get())
- {
- const uint32_t bit_offset = m_opaque_ap->GetBitOffset();
- const uint32_t byte_offset = bit_offset / 8u;
- const uint32_t byte_bit_offset = bit_offset % 8u;
- const char *name = m_opaque_ap->GetName().GetCString();
- if (byte_bit_offset)
- strm.Printf ("+%u + %u bits: (", byte_offset, byte_bit_offset);
- else
- strm.Printf ("+%u: (", byte_offset);
-
- TypeImplSP type_impl_sp (m_opaque_ap->GetTypeImpl());
- if (type_impl_sp)
- type_impl_sp->GetDescription(strm, description_level);
-
- strm.Printf (") %s", name);
- if (m_opaque_ap->GetIsBitfield())
- {
- const uint32_t bitfield_bit_size = m_opaque_ap->GetBitfieldBitSize();
- strm.Printf (" : %u", bitfield_bit_size);
- }
- }
- else
- {
- strm.PutCString ("No value");
- }
- return true;
+SBTypeList &SBTypeList::operator=(const SBTypeList &rhs) {
+ if (this != &rhs) {
+ m_opaque_ap.reset(new TypeListImpl());
+ for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize();
+ i < rhs_size; i++)
+ Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i));
+ }
+ return *this;
}
+void SBTypeList::Append(SBType type) {
+ if (type.IsValid())
+ m_opaque_ap->Append(type.m_opaque_sp);
+}
-void
-SBTypeMember::reset(TypeMemberImpl *type_member_impl)
-{
- m_opaque_ap.reset(type_member_impl);
+SBType SBTypeList::GetTypeAtIndex(uint32_t index) {
+ if (m_opaque_ap.get())
+ return SBType(m_opaque_ap->GetTypeAtIndex(index));
+ return SBType();
}
-TypeMemberImpl &
-SBTypeMember::ref ()
-{
- if (m_opaque_ap.get() == NULL)
- m_opaque_ap.reset (new TypeMemberImpl());
- return *m_opaque_ap.get();
+uint32_t SBTypeList::GetSize() { return m_opaque_ap->GetSize(); }
+
+SBTypeList::~SBTypeList() {}
+
+SBTypeMember::SBTypeMember() : m_opaque_ap() {}
+
+SBTypeMember::~SBTypeMember() {}
+
+SBTypeMember::SBTypeMember(const SBTypeMember &rhs) : m_opaque_ap() {
+ if (this != &rhs) {
+ if (rhs.IsValid())
+ m_opaque_ap.reset(new TypeMemberImpl(rhs.ref()));
+ }
}
-const TypeMemberImpl &
-SBTypeMember::ref () const
-{
- return *m_opaque_ap.get();
+lldb::SBTypeMember &SBTypeMember::operator=(const lldb::SBTypeMember &rhs) {
+ if (this != &rhs) {
+ if (rhs.IsValid())
+ m_opaque_ap.reset(new TypeMemberImpl(rhs.ref()));
+ }
+ return *this;
}
-SBTypeMemberFunction::SBTypeMemberFunction() :
-m_opaque_sp()
-{
+bool SBTypeMember::IsValid() const { return m_opaque_ap.get(); }
+
+const char *SBTypeMember::GetName() {
+ if (m_opaque_ap.get())
+ return m_opaque_ap->GetName().GetCString();
+ return NULL;
}
-SBTypeMemberFunction::~SBTypeMemberFunction()
-{
+SBType SBTypeMember::GetType() {
+ SBType sb_type;
+ if (m_opaque_ap.get()) {
+ sb_type.SetSP(m_opaque_ap->GetTypeImpl());
+ }
+ return sb_type;
}
-SBTypeMemberFunction::SBTypeMemberFunction (const SBTypeMemberFunction& rhs) :
- m_opaque_sp(rhs.m_opaque_sp)
-{
+uint64_t SBTypeMember::GetOffsetInBytes() {
+ if (m_opaque_ap.get())
+ return m_opaque_ap->GetBitOffset() / 8u;
+ return 0;
}
-lldb::SBTypeMemberFunction&
-SBTypeMemberFunction::operator = (const lldb::SBTypeMemberFunction& rhs)
-{
- if (this != &rhs)
- m_opaque_sp = rhs.m_opaque_sp;
- return *this;
+uint64_t SBTypeMember::GetOffsetInBits() {
+ if (m_opaque_ap.get())
+ return m_opaque_ap->GetBitOffset();
+ return 0;
}
-bool
-SBTypeMemberFunction::IsValid() const
-{
- return m_opaque_sp.get();
+bool SBTypeMember::IsBitfield() {
+ if (m_opaque_ap.get())
+ return m_opaque_ap->GetIsBitfield();
+ return false;
}
-const char *
-SBTypeMemberFunction::GetName ()
-{
- if (m_opaque_sp)
- return m_opaque_sp->GetName().GetCString();
- return NULL;
+uint32_t SBTypeMember::GetBitfieldSizeInBits() {
+ if (m_opaque_ap.get())
+ return m_opaque_ap->GetBitfieldBitSize();
+ return 0;
}
-const char *
-SBTypeMemberFunction::GetDemangledName ()
-{
- if (m_opaque_sp)
- {
- ConstString mangled_str = m_opaque_sp->GetMangledName();
- if (mangled_str)
- {
- Mangled mangled(mangled_str, true);
- return mangled.GetDemangledName(mangled.GuessLanguage()).GetCString();
- }
+bool SBTypeMember::GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level) {
+ Stream &strm = description.ref();
+
+ if (m_opaque_ap.get()) {
+ const uint32_t bit_offset = m_opaque_ap->GetBitOffset();
+ const uint32_t byte_offset = bit_offset / 8u;
+ const uint32_t byte_bit_offset = bit_offset % 8u;
+ const char *name = m_opaque_ap->GetName().GetCString();
+ if (byte_bit_offset)
+ strm.Printf("+%u + %u bits: (", byte_offset, byte_bit_offset);
+ else
+ strm.Printf("+%u: (", byte_offset);
+
+ TypeImplSP type_impl_sp(m_opaque_ap->GetTypeImpl());
+ if (type_impl_sp)
+ type_impl_sp->GetDescription(strm, description_level);
+
+ strm.Printf(") %s", name);
+ if (m_opaque_ap->GetIsBitfield()) {
+ const uint32_t bitfield_bit_size = m_opaque_ap->GetBitfieldBitSize();
+ strm.Printf(" : %u", bitfield_bit_size);
}
- return NULL;
+ } else {
+ strm.PutCString("No value");
+ }
+ return true;
+}
+
+void SBTypeMember::reset(TypeMemberImpl *type_member_impl) {
+ m_opaque_ap.reset(type_member_impl);
}
-const char *
-SBTypeMemberFunction::GetMangledName()
-{
- if (m_opaque_sp)
- return m_opaque_sp->GetMangledName().GetCString();
- return NULL;
+TypeMemberImpl &SBTypeMember::ref() {
+ if (m_opaque_ap.get() == NULL)
+ m_opaque_ap.reset(new TypeMemberImpl());
+ return *m_opaque_ap.get();
}
+const TypeMemberImpl &SBTypeMember::ref() const { return *m_opaque_ap.get(); }
-SBType
-SBTypeMemberFunction::GetType ()
-{
- SBType sb_type;
- if (m_opaque_sp)
- {
- sb_type.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetType())));
- }
- return sb_type;
+SBTypeMemberFunction::SBTypeMemberFunction() : m_opaque_sp() {}
+
+SBTypeMemberFunction::~SBTypeMemberFunction() {}
+
+SBTypeMemberFunction::SBTypeMemberFunction(const SBTypeMemberFunction &rhs)
+ : m_opaque_sp(rhs.m_opaque_sp) {}
+
+lldb::SBTypeMemberFunction &SBTypeMemberFunction::
+operator=(const lldb::SBTypeMemberFunction &rhs) {
+ if (this != &rhs)
+ m_opaque_sp = rhs.m_opaque_sp;
+ return *this;
}
-lldb::SBType
-SBTypeMemberFunction::GetReturnType ()
-{
- SBType sb_type;
- if (m_opaque_sp)
- {
- sb_type.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetReturnType())));
+bool SBTypeMemberFunction::IsValid() const { return m_opaque_sp.get(); }
+
+const char *SBTypeMemberFunction::GetName() {
+ if (m_opaque_sp)
+ return m_opaque_sp->GetName().GetCString();
+ return NULL;
+}
+
+const char *SBTypeMemberFunction::GetDemangledName() {
+ if (m_opaque_sp) {
+ ConstString mangled_str = m_opaque_sp->GetMangledName();
+ if (mangled_str) {
+ Mangled mangled(mangled_str, true);
+ return mangled.GetDemangledName(mangled.GuessLanguage()).GetCString();
}
- return sb_type;
+ }
+ return NULL;
}
-uint32_t
-SBTypeMemberFunction::GetNumberOfArguments ()
-{
- if (m_opaque_sp)
- return m_opaque_sp->GetNumArguments();
- return 0;
+const char *SBTypeMemberFunction::GetMangledName() {
+ if (m_opaque_sp)
+ return m_opaque_sp->GetMangledName().GetCString();
+ return NULL;
}
-lldb::SBType
-SBTypeMemberFunction::GetArgumentTypeAtIndex (uint32_t i)
-{
- SBType sb_type;
- if (m_opaque_sp)
- {
- sb_type.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetArgumentAtIndex(i))));
- }
- return sb_type;
+SBType SBTypeMemberFunction::GetType() {
+ SBType sb_type;
+ if (m_opaque_sp) {
+ sb_type.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetType())));
+ }
+ return sb_type;
}
-lldb::MemberFunctionKind
-SBTypeMemberFunction::GetKind ()
-{
- if (m_opaque_sp)
- return m_opaque_sp->GetKind();
- return lldb::eMemberFunctionKindUnknown;
-
+lldb::SBType SBTypeMemberFunction::GetReturnType() {
+ SBType sb_type;
+ if (m_opaque_sp) {
+ sb_type.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetReturnType())));
+ }
+ return sb_type;
}
-bool
-SBTypeMemberFunction::GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level)
-{
- Stream &strm = description.ref();
-
- if (m_opaque_sp)
- return m_opaque_sp->GetDescription(strm);
-
- return false;
+uint32_t SBTypeMemberFunction::GetNumberOfArguments() {
+ if (m_opaque_sp)
+ return m_opaque_sp->GetNumArguments();
+ return 0;
+}
+
+lldb::SBType SBTypeMemberFunction::GetArgumentTypeAtIndex(uint32_t i) {
+ SBType sb_type;
+ if (m_opaque_sp) {
+ sb_type.SetSP(
+ lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetArgumentAtIndex(i))));
+ }
+ return sb_type;
+}
+
+lldb::MemberFunctionKind SBTypeMemberFunction::GetKind() {
+ if (m_opaque_sp)
+ return m_opaque_sp->GetKind();
+ return lldb::eMemberFunctionKindUnknown;
+}
+
+bool SBTypeMemberFunction::GetDescription(
+ lldb::SBStream &description, lldb::DescriptionLevel description_level) {
+ Stream &strm = description.ref();
+
+ if (m_opaque_sp)
+ return m_opaque_sp->GetDescription(strm);
+
+ return false;
}
-void
-SBTypeMemberFunction::reset(TypeMemberFunctionImpl *type_member_impl)
-{
- m_opaque_sp.reset(type_member_impl);
+void SBTypeMemberFunction::reset(TypeMemberFunctionImpl *type_member_impl) {
+ m_opaque_sp.reset(type_member_impl);
}
-TypeMemberFunctionImpl &
-SBTypeMemberFunction::ref ()
-{
- if (!m_opaque_sp)
- m_opaque_sp.reset (new TypeMemberFunctionImpl());
- return *m_opaque_sp.get();
+TypeMemberFunctionImpl &SBTypeMemberFunction::ref() {
+ if (!m_opaque_sp)
+ m_opaque_sp.reset(new TypeMemberFunctionImpl());
+ return *m_opaque_sp.get();
}
-const TypeMemberFunctionImpl &
-SBTypeMemberFunction::ref () const
-{
- return *m_opaque_sp.get();
+const TypeMemberFunctionImpl &SBTypeMemberFunction::ref() const {
+ return *m_opaque_sp.get();
}
Modified: lldb/trunk/source/API/SBTypeCategory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeCategory.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeCategory.cpp (original)
+++ lldb/trunk/source/API/SBTypeCategory.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- SBTypeCategory.cpp ----------------------------------------*- C++ -*-===//
+//===-- SBTypeCategory.cpp ----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -9,12 +10,12 @@
#include "lldb/API/SBTypeCategory.h"
+#include "lldb/API/SBStream.h"
#include "lldb/API/SBTypeFilter.h"
#include "lldb/API/SBTypeFormat.h"
+#include "lldb/API/SBTypeNameSpecifier.h"
#include "lldb/API/SBTypeSummary.h"
#include "lldb/API/SBTypeSynthetic.h"
-#include "lldb/API/SBTypeNameSpecifier.h"
-#include "lldb/API/SBStream.h"
#include "lldb/Core/Debugger.h"
#include "lldb/DataFormatters/DataVisualization.h"
@@ -24,581 +25,537 @@
using namespace lldb;
using namespace lldb_private;
-typedef std::pair<lldb::TypeCategoryImplSP,user_id_t> ImplType;
+typedef std::pair<lldb::TypeCategoryImplSP, user_id_t> ImplType;
-SBTypeCategory::SBTypeCategory() :
-m_opaque_sp()
-{
-}
+SBTypeCategory::SBTypeCategory() : m_opaque_sp() {}
-SBTypeCategory::SBTypeCategory (const char* name) :
-m_opaque_sp()
-{
- DataVisualization::Categories::GetCategory(ConstString(name), m_opaque_sp);
+SBTypeCategory::SBTypeCategory(const char *name) : m_opaque_sp() {
+ DataVisualization::Categories::GetCategory(ConstString(name), m_opaque_sp);
}
-SBTypeCategory::SBTypeCategory (const lldb::SBTypeCategory &rhs) :
-m_opaque_sp(rhs.m_opaque_sp)
-{
+SBTypeCategory::SBTypeCategory(const lldb::SBTypeCategory &rhs)
+ : m_opaque_sp(rhs.m_opaque_sp) {}
+
+SBTypeCategory::~SBTypeCategory() {}
+
+bool SBTypeCategory::IsValid() const { return (m_opaque_sp.get() != NULL); }
+
+bool SBTypeCategory::GetEnabled() {
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->IsEnabled();
}
-SBTypeCategory::~SBTypeCategory ()
-{
+void SBTypeCategory::SetEnabled(bool enabled) {
+ if (!IsValid())
+ return;
+ if (enabled)
+ DataVisualization::Categories::Enable(m_opaque_sp);
+ else
+ DataVisualization::Categories::Disable(m_opaque_sp);
}
-bool
-SBTypeCategory::IsValid() const
-{
- return (m_opaque_sp.get() != NULL);
+const char *SBTypeCategory::GetName() {
+ if (!IsValid())
+ return NULL;
+ return m_opaque_sp->GetName();
}
-bool
-SBTypeCategory::GetEnabled ()
-{
- if (!IsValid())
- return false;
- return m_opaque_sp->IsEnabled();
+lldb::LanguageType SBTypeCategory::GetLanguageAtIndex(uint32_t idx) {
+ if (IsValid())
+ return m_opaque_sp->GetLanguageAtIndex(idx);
+ return lldb::eLanguageTypeUnknown;
}
-void
-SBTypeCategory::SetEnabled (bool enabled)
-{
- if (!IsValid())
- return;
- if (enabled)
- DataVisualization::Categories::Enable(m_opaque_sp);
- else
- DataVisualization::Categories::Disable(m_opaque_sp);
+uint32_t SBTypeCategory::GetNumLanguages() {
+ if (IsValid())
+ return m_opaque_sp->GetNumLanguages();
+ return 0;
}
-const char*
-SBTypeCategory::GetName()
-{
- if (!IsValid())
- return NULL;
- return m_opaque_sp->GetName();
+void SBTypeCategory::AddLanguage(lldb::LanguageType language) {
+ if (IsValid())
+ m_opaque_sp->AddLanguage(language);
}
-lldb::LanguageType
-SBTypeCategory::GetLanguageAtIndex (uint32_t idx)
-{
- if (IsValid())
- return m_opaque_sp->GetLanguageAtIndex(idx);
- return lldb::eLanguageTypeUnknown;
+uint32_t SBTypeCategory::GetNumFormats() {
+ if (!IsValid())
+ return 0;
+
+ return m_opaque_sp->GetTypeFormatsContainer()->GetCount() +
+ m_opaque_sp->GetRegexTypeFormatsContainer()->GetCount();
}
-uint32_t
-SBTypeCategory::GetNumLanguages ()
-{
- if (IsValid())
- return m_opaque_sp->GetNumLanguages();
+uint32_t SBTypeCategory::GetNumSummaries() {
+ if (!IsValid())
return 0;
+ return m_opaque_sp->GetTypeSummariesContainer()->GetCount() +
+ m_opaque_sp->GetRegexTypeSummariesContainer()->GetCount();
}
-void
-SBTypeCategory::AddLanguage (lldb::LanguageType language)
-{
- if (IsValid())
- m_opaque_sp->AddLanguage(language);
-}
-
-uint32_t
-SBTypeCategory::GetNumFormats ()
-{
- if (!IsValid())
- return 0;
-
- return m_opaque_sp->GetTypeFormatsContainer()->GetCount() + m_opaque_sp->GetRegexTypeFormatsContainer()->GetCount();
-}
-
-uint32_t
-SBTypeCategory::GetNumSummaries ()
-{
- if (!IsValid())
- return 0;
- return m_opaque_sp->GetTypeSummariesContainer()->GetCount() + m_opaque_sp->GetRegexTypeSummariesContainer()->GetCount();
-}
-
-uint32_t
-SBTypeCategory::GetNumFilters ()
-{
- if (!IsValid())
- return 0;
- return m_opaque_sp->GetTypeFiltersContainer()->GetCount() + m_opaque_sp->GetRegexTypeFiltersContainer()->GetCount();
+uint32_t SBTypeCategory::GetNumFilters() {
+ if (!IsValid())
+ return 0;
+ return m_opaque_sp->GetTypeFiltersContainer()->GetCount() +
+ m_opaque_sp->GetRegexTypeFiltersContainer()->GetCount();
}
#ifndef LLDB_DISABLE_PYTHON
-uint32_t
-SBTypeCategory::GetNumSynthetics ()
-{
- if (!IsValid())
- return 0;
- return m_opaque_sp->GetTypeSyntheticsContainer()->GetCount() + m_opaque_sp->GetRegexTypeSyntheticsContainer()->GetCount();
+uint32_t SBTypeCategory::GetNumSynthetics() {
+ if (!IsValid())
+ return 0;
+ return m_opaque_sp->GetTypeSyntheticsContainer()->GetCount() +
+ m_opaque_sp->GetRegexTypeSyntheticsContainer()->GetCount();
}
#endif
lldb::SBTypeNameSpecifier
-SBTypeCategory::GetTypeNameSpecifierForFilterAtIndex (uint32_t index)
-{
- if (!IsValid())
- return SBTypeNameSpecifier();
- return SBTypeNameSpecifier(m_opaque_sp->GetTypeNameSpecifierForFilterAtIndex(index));
+SBTypeCategory::GetTypeNameSpecifierForFilterAtIndex(uint32_t index) {
+ if (!IsValid())
+ return SBTypeNameSpecifier();
+ return SBTypeNameSpecifier(
+ m_opaque_sp->GetTypeNameSpecifierForFilterAtIndex(index));
}
lldb::SBTypeNameSpecifier
-SBTypeCategory::GetTypeNameSpecifierForFormatAtIndex (uint32_t index)
-{
- if (!IsValid())
- return SBTypeNameSpecifier();
- return SBTypeNameSpecifier(m_opaque_sp->GetTypeNameSpecifierForFormatAtIndex(index));
+SBTypeCategory::GetTypeNameSpecifierForFormatAtIndex(uint32_t index) {
+ if (!IsValid())
+ return SBTypeNameSpecifier();
+ return SBTypeNameSpecifier(
+ m_opaque_sp->GetTypeNameSpecifierForFormatAtIndex(index));
}
lldb::SBTypeNameSpecifier
-SBTypeCategory::GetTypeNameSpecifierForSummaryAtIndex (uint32_t index)
-{
- if (!IsValid())
- return SBTypeNameSpecifier();
- return SBTypeNameSpecifier(m_opaque_sp->GetTypeNameSpecifierForSummaryAtIndex(index));
+SBTypeCategory::GetTypeNameSpecifierForSummaryAtIndex(uint32_t index) {
+ if (!IsValid())
+ return SBTypeNameSpecifier();
+ return SBTypeNameSpecifier(
+ m_opaque_sp->GetTypeNameSpecifierForSummaryAtIndex(index));
}
#ifndef LLDB_DISABLE_PYTHON
lldb::SBTypeNameSpecifier
-SBTypeCategory::GetTypeNameSpecifierForSyntheticAtIndex (uint32_t index)
-{
- if (!IsValid())
- return SBTypeNameSpecifier();
- return SBTypeNameSpecifier(m_opaque_sp->GetTypeNameSpecifierForSyntheticAtIndex(index));
+SBTypeCategory::GetTypeNameSpecifierForSyntheticAtIndex(uint32_t index) {
+ if (!IsValid())
+ return SBTypeNameSpecifier();
+ return SBTypeNameSpecifier(
+ m_opaque_sp->GetTypeNameSpecifierForSyntheticAtIndex(index));
}
#endif
-SBTypeFilter
-SBTypeCategory::GetFilterForType (SBTypeNameSpecifier spec)
-{
- if (!IsValid())
- return SBTypeFilter();
-
- if (!spec.IsValid())
- return SBTypeFilter();
-
- lldb::TypeFilterImplSP children_sp;
-
- if (spec.IsRegex())
- m_opaque_sp->GetRegexTypeFiltersContainer()->GetExact(ConstString(spec.GetName()), children_sp);
- else
- m_opaque_sp->GetTypeFiltersContainer()->GetExact(ConstString(spec.GetName()), children_sp);
-
- if (!children_sp)
- return lldb::SBTypeFilter();
-
- TypeFilterImplSP filter_sp = std::static_pointer_cast<TypeFilterImpl>(children_sp);
-
- return lldb::SBTypeFilter(filter_sp);
-
-}
-SBTypeFormat
-SBTypeCategory::GetFormatForType (SBTypeNameSpecifier spec)
-{
- if (!IsValid())
- return SBTypeFormat();
-
- if (!spec.IsValid())
- return SBTypeFormat();
-
- lldb::TypeFormatImplSP format_sp;
-
- if (spec.IsRegex())
- m_opaque_sp->GetRegexTypeFormatsContainer()->GetExact(ConstString(spec.GetName()), format_sp);
- else
- m_opaque_sp->GetTypeFormatsContainer()->GetExact(ConstString(spec.GetName()), format_sp);
-
- if (!format_sp)
- return lldb::SBTypeFormat();
-
- return lldb::SBTypeFormat(format_sp);
+SBTypeFilter SBTypeCategory::GetFilterForType(SBTypeNameSpecifier spec) {
+ if (!IsValid())
+ return SBTypeFilter();
+
+ if (!spec.IsValid())
+ return SBTypeFilter();
+
+ lldb::TypeFilterImplSP children_sp;
+
+ if (spec.IsRegex())
+ m_opaque_sp->GetRegexTypeFiltersContainer()->GetExact(
+ ConstString(spec.GetName()), children_sp);
+ else
+ m_opaque_sp->GetTypeFiltersContainer()->GetExact(
+ ConstString(spec.GetName()), children_sp);
+
+ if (!children_sp)
+ return lldb::SBTypeFilter();
+
+ TypeFilterImplSP filter_sp =
+ std::static_pointer_cast<TypeFilterImpl>(children_sp);
+
+ return lldb::SBTypeFilter(filter_sp);
+}
+SBTypeFormat SBTypeCategory::GetFormatForType(SBTypeNameSpecifier spec) {
+ if (!IsValid())
+ return SBTypeFormat();
+
+ if (!spec.IsValid())
+ return SBTypeFormat();
+
+ lldb::TypeFormatImplSP format_sp;
+
+ if (spec.IsRegex())
+ m_opaque_sp->GetRegexTypeFormatsContainer()->GetExact(
+ ConstString(spec.GetName()), format_sp);
+ else
+ m_opaque_sp->GetTypeFormatsContainer()->GetExact(
+ ConstString(spec.GetName()), format_sp);
+
+ if (!format_sp)
+ return lldb::SBTypeFormat();
+
+ return lldb::SBTypeFormat(format_sp);
}
#ifndef LLDB_DISABLE_PYTHON
-SBTypeSummary
-SBTypeCategory::GetSummaryForType (SBTypeNameSpecifier spec)
-{
- if (!IsValid())
- return SBTypeSummary();
-
- if (!spec.IsValid())
- return SBTypeSummary();
-
- lldb::TypeSummaryImplSP summary_sp;
-
- if (spec.IsRegex())
- m_opaque_sp->GetRegexTypeSummariesContainer()->GetExact(ConstString(spec.GetName()), summary_sp);
- else
- m_opaque_sp->GetTypeSummariesContainer()->GetExact(ConstString(spec.GetName()), summary_sp);
-
- if (!summary_sp)
- return lldb::SBTypeSummary();
-
- return lldb::SBTypeSummary(summary_sp);
+SBTypeSummary SBTypeCategory::GetSummaryForType(SBTypeNameSpecifier spec) {
+ if (!IsValid())
+ return SBTypeSummary();
+
+ if (!spec.IsValid())
+ return SBTypeSummary();
+
+ lldb::TypeSummaryImplSP summary_sp;
+
+ if (spec.IsRegex())
+ m_opaque_sp->GetRegexTypeSummariesContainer()->GetExact(
+ ConstString(spec.GetName()), summary_sp);
+ else
+ m_opaque_sp->GetTypeSummariesContainer()->GetExact(
+ ConstString(spec.GetName()), summary_sp);
+
+ if (!summary_sp)
+ return lldb::SBTypeSummary();
+
+ return lldb::SBTypeSummary(summary_sp);
}
#endif // LLDB_DISABLE_PYTHON
#ifndef LLDB_DISABLE_PYTHON
-SBTypeSynthetic
-SBTypeCategory::GetSyntheticForType (SBTypeNameSpecifier spec)
-{
- if (!IsValid())
- return SBTypeSynthetic();
-
- if (!spec.IsValid())
- return SBTypeSynthetic();
-
- lldb::SyntheticChildrenSP children_sp;
-
- if (spec.IsRegex())
- m_opaque_sp->GetRegexTypeSyntheticsContainer()->GetExact(ConstString(spec.GetName()), children_sp);
- else
- m_opaque_sp->GetTypeSyntheticsContainer()->GetExact(ConstString(spec.GetName()), children_sp);
-
- if (!children_sp)
- return lldb::SBTypeSynthetic();
-
- ScriptedSyntheticChildrenSP synth_sp = std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
-
- return lldb::SBTypeSynthetic(synth_sp);
+SBTypeSynthetic SBTypeCategory::GetSyntheticForType(SBTypeNameSpecifier spec) {
+ if (!IsValid())
+ return SBTypeSynthetic();
+
+ if (!spec.IsValid())
+ return SBTypeSynthetic();
+
+ lldb::SyntheticChildrenSP children_sp;
+
+ if (spec.IsRegex())
+ m_opaque_sp->GetRegexTypeSyntheticsContainer()->GetExact(
+ ConstString(spec.GetName()), children_sp);
+ else
+ m_opaque_sp->GetTypeSyntheticsContainer()->GetExact(
+ ConstString(spec.GetName()), children_sp);
+
+ if (!children_sp)
+ return lldb::SBTypeSynthetic();
+
+ ScriptedSyntheticChildrenSP synth_sp =
+ std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
+
+ return lldb::SBTypeSynthetic(synth_sp);
}
#endif
#ifndef LLDB_DISABLE_PYTHON
-SBTypeFilter
-SBTypeCategory::GetFilterAtIndex (uint32_t index)
-{
- if (!IsValid())
- return SBTypeFilter();
- lldb::SyntheticChildrenSP children_sp = m_opaque_sp->GetSyntheticAtIndex((index));
-
- if (!children_sp.get())
- return lldb::SBTypeFilter();
-
- TypeFilterImplSP filter_sp = std::static_pointer_cast<TypeFilterImpl>(children_sp);
-
- return lldb::SBTypeFilter(filter_sp);
+SBTypeFilter SBTypeCategory::GetFilterAtIndex(uint32_t index) {
+ if (!IsValid())
+ return SBTypeFilter();
+ lldb::SyntheticChildrenSP children_sp =
+ m_opaque_sp->GetSyntheticAtIndex((index));
+
+ if (!children_sp.get())
+ return lldb::SBTypeFilter();
+
+ TypeFilterImplSP filter_sp =
+ std::static_pointer_cast<TypeFilterImpl>(children_sp);
+
+ return lldb::SBTypeFilter(filter_sp);
}
#endif
-SBTypeFormat
-SBTypeCategory::GetFormatAtIndex (uint32_t index)
-{
- if (!IsValid())
- return SBTypeFormat();
- return SBTypeFormat(m_opaque_sp->GetFormatAtIndex((index)));
+SBTypeFormat SBTypeCategory::GetFormatAtIndex(uint32_t index) {
+ if (!IsValid())
+ return SBTypeFormat();
+ return SBTypeFormat(m_opaque_sp->GetFormatAtIndex((index)));
}
#ifndef LLDB_DISABLE_PYTHON
-SBTypeSummary
-SBTypeCategory::GetSummaryAtIndex (uint32_t index)
-{
- if (!IsValid())
- return SBTypeSummary();
- return SBTypeSummary(m_opaque_sp->GetSummaryAtIndex((index)));
+SBTypeSummary SBTypeCategory::GetSummaryAtIndex(uint32_t index) {
+ if (!IsValid())
+ return SBTypeSummary();
+ return SBTypeSummary(m_opaque_sp->GetSummaryAtIndex((index)));
}
#endif
#ifndef LLDB_DISABLE_PYTHON
-SBTypeSynthetic
-SBTypeCategory::GetSyntheticAtIndex (uint32_t index)
-{
- if (!IsValid())
- return SBTypeSynthetic();
- lldb::SyntheticChildrenSP children_sp = m_opaque_sp->GetSyntheticAtIndex((index));
-
- if (!children_sp.get())
- return lldb::SBTypeSynthetic();
-
- ScriptedSyntheticChildrenSP synth_sp = std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
-
- return lldb::SBTypeSynthetic(synth_sp);
+SBTypeSynthetic SBTypeCategory::GetSyntheticAtIndex(uint32_t index) {
+ if (!IsValid())
+ return SBTypeSynthetic();
+ lldb::SyntheticChildrenSP children_sp =
+ m_opaque_sp->GetSyntheticAtIndex((index));
+
+ if (!children_sp.get())
+ return lldb::SBTypeSynthetic();
+
+ ScriptedSyntheticChildrenSP synth_sp =
+ std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
+
+ return lldb::SBTypeSynthetic(synth_sp);
}
#endif
-bool
-SBTypeCategory::AddTypeFormat (SBTypeNameSpecifier type_name,
- SBTypeFormat format)
-{
- if (!IsValid())
- return false;
-
- if (!type_name.IsValid())
- return false;
-
- if (!format.IsValid())
- return false;
-
- if (type_name.IsRegex())
- m_opaque_sp->GetRegexTypeFormatsContainer()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), format.GetSP());
- else
- m_opaque_sp->GetTypeFormatsContainer()->Add(ConstString(type_name.GetName()), format.GetSP());
-
- return true;
-}
-
-bool
-SBTypeCategory::DeleteTypeFormat (SBTypeNameSpecifier type_name)
-{
- if (!IsValid())
- return false;
-
- if (!type_name.IsValid())
- return false;
-
- if (type_name.IsRegex())
- return m_opaque_sp->GetRegexTypeFormatsContainer()->Delete(ConstString(type_name.GetName()));
- else
- return m_opaque_sp->GetTypeFormatsContainer()->Delete(ConstString(type_name.GetName()));
+bool SBTypeCategory::AddTypeFormat(SBTypeNameSpecifier type_name,
+ SBTypeFormat format) {
+ if (!IsValid())
+ return false;
+
+ if (!type_name.IsValid())
+ return false;
+
+ if (!format.IsValid())
+ return false;
+
+ if (type_name.IsRegex())
+ m_opaque_sp->GetRegexTypeFormatsContainer()->Add(
+ lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())),
+ format.GetSP());
+ else
+ m_opaque_sp->GetTypeFormatsContainer()->Add(
+ ConstString(type_name.GetName()), format.GetSP());
+
+ return true;
+}
+
+bool SBTypeCategory::DeleteTypeFormat(SBTypeNameSpecifier type_name) {
+ if (!IsValid())
+ return false;
+
+ if (!type_name.IsValid())
+ return false;
+
+ if (type_name.IsRegex())
+ return m_opaque_sp->GetRegexTypeFormatsContainer()->Delete(
+ ConstString(type_name.GetName()));
+ else
+ return m_opaque_sp->GetTypeFormatsContainer()->Delete(
+ ConstString(type_name.GetName()));
}
#ifndef LLDB_DISABLE_PYTHON
-bool
-SBTypeCategory::AddTypeSummary (SBTypeNameSpecifier type_name,
- SBTypeSummary summary)
-{
- if (!IsValid())
- return false;
-
- if (!type_name.IsValid())
- return false;
-
- if (!summary.IsValid())
- return false;
-
- // FIXME: we need to iterate over all the Debugger objects and have each of them contain a copy of the function
- // since we currently have formatters live in a global space, while Python code lives in a specific Debugger-related environment
- // this should eventually be fixed by deciding a final location in the LLDB object space for formatters
- if (summary.IsFunctionCode())
- {
- const void *name_token = (const void*)ConstString(type_name.GetName()).GetCString();
- const char* script = summary.GetData();
- StringList input; input.SplitIntoLines(script, strlen(script));
- uint32_t num_debuggers = lldb_private::Debugger::GetNumDebuggers();
- bool need_set = true;
- for (uint32_t j = 0;
- j < num_debuggers;
- j++)
- {
- DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j);
- if (debugger_sp)
- {
- ScriptInterpreter* interpreter_ptr = debugger_sp->GetCommandInterpreter().GetScriptInterpreter();
- if (interpreter_ptr)
- {
- std::string output;
- if (interpreter_ptr->GenerateTypeScriptFunction(input, output, name_token) && !output.empty())
- {
- if (need_set)
- {
- need_set = false;
- summary.SetFunctionName(output.c_str());
- }
- }
- }
+bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name,
+ SBTypeSummary summary) {
+ if (!IsValid())
+ return false;
+
+ if (!type_name.IsValid())
+ return false;
+
+ if (!summary.IsValid())
+ return false;
+
+ // FIXME: we need to iterate over all the Debugger objects and have each of
+ // them contain a copy of the function
+ // since we currently have formatters live in a global space, while Python
+ // code lives in a specific Debugger-related environment
+ // this should eventually be fixed by deciding a final location in the LLDB
+ // object space for formatters
+ if (summary.IsFunctionCode()) {
+ const void *name_token =
+ (const void *)ConstString(type_name.GetName()).GetCString();
+ const char *script = summary.GetData();
+ StringList input;
+ input.SplitIntoLines(script, strlen(script));
+ uint32_t num_debuggers = lldb_private::Debugger::GetNumDebuggers();
+ bool need_set = true;
+ for (uint32_t j = 0; j < num_debuggers; j++) {
+ DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j);
+ if (debugger_sp) {
+ ScriptInterpreter *interpreter_ptr =
+ debugger_sp->GetCommandInterpreter().GetScriptInterpreter();
+ if (interpreter_ptr) {
+ std::string output;
+ if (interpreter_ptr->GenerateTypeScriptFunction(input, output,
+ name_token) &&
+ !output.empty()) {
+ if (need_set) {
+ need_set = false;
+ summary.SetFunctionName(output.c_str());
}
+ }
}
+ }
}
-
- if (type_name.IsRegex())
- m_opaque_sp->GetRegexTypeSummariesContainer()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), summary.GetSP());
- else
- m_opaque_sp->GetTypeSummariesContainer()->Add(ConstString(type_name.GetName()), summary.GetSP());
-
- return true;
+ }
+
+ if (type_name.IsRegex())
+ m_opaque_sp->GetRegexTypeSummariesContainer()->Add(
+ lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())),
+ summary.GetSP());
+ else
+ m_opaque_sp->GetTypeSummariesContainer()->Add(
+ ConstString(type_name.GetName()), summary.GetSP());
+
+ return true;
}
#endif
-bool
-SBTypeCategory::DeleteTypeSummary (SBTypeNameSpecifier type_name)
-{
- if (!IsValid())
- return false;
-
- if (!type_name.IsValid())
- return false;
-
- if (type_name.IsRegex())
- return m_opaque_sp->GetRegexTypeSummariesContainer()->Delete(ConstString(type_name.GetName()));
- else
- return m_opaque_sp->GetTypeSummariesContainer()->Delete(ConstString(type_name.GetName()));
-}
-
-bool
-SBTypeCategory::AddTypeFilter (SBTypeNameSpecifier type_name,
- SBTypeFilter filter)
-{
- if (!IsValid())
- return false;
-
- if (!type_name.IsValid())
- return false;
-
- if (!filter.IsValid())
- return false;
-
- if (type_name.IsRegex())
- m_opaque_sp->GetRegexTypeFiltersContainer()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), filter.GetSP());
- else
- m_opaque_sp->GetTypeFiltersContainer()->Add(ConstString(type_name.GetName()), filter.GetSP());
-
- return true;
-}
-
-bool
-SBTypeCategory::DeleteTypeFilter (SBTypeNameSpecifier type_name)
-{
- if (!IsValid())
- return false;
-
- if (!type_name.IsValid())
- return false;
-
- if (type_name.IsRegex())
- return m_opaque_sp->GetRegexTypeFiltersContainer()->Delete(ConstString(type_name.GetName()));
- else
- return m_opaque_sp->GetTypeFiltersContainer()->Delete(ConstString(type_name.GetName()));
+bool SBTypeCategory::DeleteTypeSummary(SBTypeNameSpecifier type_name) {
+ if (!IsValid())
+ return false;
+
+ if (!type_name.IsValid())
+ return false;
+
+ if (type_name.IsRegex())
+ return m_opaque_sp->GetRegexTypeSummariesContainer()->Delete(
+ ConstString(type_name.GetName()));
+ else
+ return m_opaque_sp->GetTypeSummariesContainer()->Delete(
+ ConstString(type_name.GetName()));
+}
+
+bool SBTypeCategory::AddTypeFilter(SBTypeNameSpecifier type_name,
+ SBTypeFilter filter) {
+ if (!IsValid())
+ return false;
+
+ if (!type_name.IsValid())
+ return false;
+
+ if (!filter.IsValid())
+ return false;
+
+ if (type_name.IsRegex())
+ m_opaque_sp->GetRegexTypeFiltersContainer()->Add(
+ lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())),
+ filter.GetSP());
+ else
+ m_opaque_sp->GetTypeFiltersContainer()->Add(
+ ConstString(type_name.GetName()), filter.GetSP());
+
+ return true;
+}
+
+bool SBTypeCategory::DeleteTypeFilter(SBTypeNameSpecifier type_name) {
+ if (!IsValid())
+ return false;
+
+ if (!type_name.IsValid())
+ return false;
+
+ if (type_name.IsRegex())
+ return m_opaque_sp->GetRegexTypeFiltersContainer()->Delete(
+ ConstString(type_name.GetName()));
+ else
+ return m_opaque_sp->GetTypeFiltersContainer()->Delete(
+ ConstString(type_name.GetName()));
}
#ifndef LLDB_DISABLE_PYTHON
-bool
-SBTypeCategory::AddTypeSynthetic (SBTypeNameSpecifier type_name,
- SBTypeSynthetic synth)
-{
- if (!IsValid())
- return false;
-
- if (!type_name.IsValid())
- return false;
-
- if (!synth.IsValid())
- return false;
-
- // FIXME: we need to iterate over all the Debugger objects and have each of them contain a copy of the function
- // since we currently have formatters live in a global space, while Python code lives in a specific Debugger-related environment
- // this should eventually be fixed by deciding a final location in the LLDB object space for formatters
- if (synth.IsClassCode())
- {
- const void *name_token = (const void*)ConstString(type_name.GetName()).GetCString();
- const char* script = synth.GetData();
- StringList input; input.SplitIntoLines(script, strlen(script));
- uint32_t num_debuggers = lldb_private::Debugger::GetNumDebuggers();
- bool need_set = true;
- for (uint32_t j = 0;
- j < num_debuggers;
- j++)
- {
- DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j);
- if (debugger_sp)
- {
- ScriptInterpreter* interpreter_ptr = debugger_sp->GetCommandInterpreter().GetScriptInterpreter();
- if (interpreter_ptr)
- {
- std::string output;
- if (interpreter_ptr->GenerateTypeSynthClass(input, output, name_token) && !output.empty())
- {
- if (need_set)
- {
- need_set = false;
- synth.SetClassName(output.c_str());
- }
- }
- }
+bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name,
+ SBTypeSynthetic synth) {
+ if (!IsValid())
+ return false;
+
+ if (!type_name.IsValid())
+ return false;
+
+ if (!synth.IsValid())
+ return false;
+
+ // FIXME: we need to iterate over all the Debugger objects and have each of
+ // them contain a copy of the function
+ // since we currently have formatters live in a global space, while Python
+ // code lives in a specific Debugger-related environment
+ // this should eventually be fixed by deciding a final location in the LLDB
+ // object space for formatters
+ if (synth.IsClassCode()) {
+ const void *name_token =
+ (const void *)ConstString(type_name.GetName()).GetCString();
+ const char *script = synth.GetData();
+ StringList input;
+ input.SplitIntoLines(script, strlen(script));
+ uint32_t num_debuggers = lldb_private::Debugger::GetNumDebuggers();
+ bool need_set = true;
+ for (uint32_t j = 0; j < num_debuggers; j++) {
+ DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j);
+ if (debugger_sp) {
+ ScriptInterpreter *interpreter_ptr =
+ debugger_sp->GetCommandInterpreter().GetScriptInterpreter();
+ if (interpreter_ptr) {
+ std::string output;
+ if (interpreter_ptr->GenerateTypeSynthClass(input, output,
+ name_token) &&
+ !output.empty()) {
+ if (need_set) {
+ need_set = false;
+ synth.SetClassName(output.c_str());
}
+ }
}
+ }
}
-
- if (type_name.IsRegex())
- m_opaque_sp->GetRegexTypeSyntheticsContainer()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), synth.GetSP());
- else
- m_opaque_sp->GetTypeSyntheticsContainer()->Add(ConstString(type_name.GetName()), synth.GetSP());
-
- return true;
-}
-
-bool
-SBTypeCategory::DeleteTypeSynthetic (SBTypeNameSpecifier type_name)
-{
- if (!IsValid())
- return false;
-
- if (!type_name.IsValid())
- return false;
-
- if (type_name.IsRegex())
- return m_opaque_sp->GetRegexTypeSyntheticsContainer()->Delete(ConstString(type_name.GetName()));
- else
- return m_opaque_sp->GetTypeSyntheticsContainer()->Delete(ConstString(type_name.GetName()));
+ }
+
+ if (type_name.IsRegex())
+ m_opaque_sp->GetRegexTypeSyntheticsContainer()->Add(
+ lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())),
+ synth.GetSP());
+ else
+ m_opaque_sp->GetTypeSyntheticsContainer()->Add(
+ ConstString(type_name.GetName()), synth.GetSP());
+
+ return true;
+}
+
+bool SBTypeCategory::DeleteTypeSynthetic(SBTypeNameSpecifier type_name) {
+ if (!IsValid())
+ return false;
+
+ if (!type_name.IsValid())
+ return false;
+
+ if (type_name.IsRegex())
+ return m_opaque_sp->GetRegexTypeSyntheticsContainer()->Delete(
+ ConstString(type_name.GetName()));
+ else
+ return m_opaque_sp->GetTypeSyntheticsContainer()->Delete(
+ ConstString(type_name.GetName()));
}
#endif // LLDB_DISABLE_PYTHON
-bool
-SBTypeCategory::GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level)
-{
- if (!IsValid())
- return false;
- description.Printf("Category name: %s\n",GetName());
- return true;
-}
-
-lldb::SBTypeCategory &
-SBTypeCategory::operator = (const lldb::SBTypeCategory &rhs)
-{
- if (this != &rhs)
- {
- m_opaque_sp = rhs.m_opaque_sp;
- }
- return *this;
+bool SBTypeCategory::GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level) {
+ if (!IsValid())
+ return false;
+ description.Printf("Category name: %s\n", GetName());
+ return true;
}
-bool
-SBTypeCategory::operator == (lldb::SBTypeCategory &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
-
- return m_opaque_sp.get() == rhs.m_opaque_sp.get();
-
-}
-
-bool
-SBTypeCategory::operator != (lldb::SBTypeCategory &rhs)
-{
- if (IsValid() == false)
- return rhs.IsValid();
-
- return m_opaque_sp.get() != rhs.m_opaque_sp.get();
-}
-
-lldb::TypeCategoryImplSP
-SBTypeCategory::GetSP ()
-{
- if (!IsValid())
- return lldb::TypeCategoryImplSP();
- return m_opaque_sp;
-}
-
-void
-SBTypeCategory::SetSP (const lldb::TypeCategoryImplSP &typecategory_impl_sp)
-{
- m_opaque_sp = typecategory_impl_sp;
-}
-
-SBTypeCategory::SBTypeCategory (const lldb::TypeCategoryImplSP &typecategory_impl_sp) :
-m_opaque_sp(typecategory_impl_sp)
-{
-}
-
-bool
-SBTypeCategory::IsDefaultCategory()
-{
- if (!IsValid())
- return false;
-
- return (strcmp(m_opaque_sp->GetName(),"default") == 0);
+lldb::SBTypeCategory &SBTypeCategory::
+operator=(const lldb::SBTypeCategory &rhs) {
+ if (this != &rhs) {
+ m_opaque_sp = rhs.m_opaque_sp;
+ }
+ return *this;
}
+bool SBTypeCategory::operator==(lldb::SBTypeCategory &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+
+ return m_opaque_sp.get() == rhs.m_opaque_sp.get();
+}
+
+bool SBTypeCategory::operator!=(lldb::SBTypeCategory &rhs) {
+ if (IsValid() == false)
+ return rhs.IsValid();
+
+ return m_opaque_sp.get() != rhs.m_opaque_sp.get();
+}
+
+lldb::TypeCategoryImplSP SBTypeCategory::GetSP() {
+ if (!IsValid())
+ return lldb::TypeCategoryImplSP();
+ return m_opaque_sp;
+}
+
+void SBTypeCategory::SetSP(
+ const lldb::TypeCategoryImplSP &typecategory_impl_sp) {
+ m_opaque_sp = typecategory_impl_sp;
+}
+
+SBTypeCategory::SBTypeCategory(
+ const lldb::TypeCategoryImplSP &typecategory_impl_sp)
+ : m_opaque_sp(typecategory_impl_sp) {}
+
+bool SBTypeCategory::IsDefaultCategory() {
+ if (!IsValid())
+ return false;
+
+ return (strcmp(m_opaque_sp->GetName(), "default") == 0);
+}
Modified: lldb/trunk/source/API/SBTypeEnumMember.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeEnumMember.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeEnumMember.cpp (original)
+++ lldb/trunk/source/API/SBTypeEnumMember.cpp Tue Sep 6 15:57:50 2016
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBType.h"
-#include "lldb/API/SBTypeEnumMember.h"
+#include "lldb/API/SBDefines.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBTypeEnumMember.h"
#include "lldb/Core/Stream.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Type.h"
@@ -18,174 +18,124 @@
using namespace lldb;
using namespace lldb_private;
-SBTypeEnumMember::SBTypeEnumMember() :
- m_opaque_sp()
-{
-}
-
-SBTypeEnumMember::~SBTypeEnumMember()
-{
-}
-SBTypeEnumMember::SBTypeEnumMember (const lldb::TypeEnumMemberImplSP &enum_member_sp) :
- m_opaque_sp(enum_member_sp)
-{
-}
-
-SBTypeEnumMember::SBTypeEnumMember (const SBTypeEnumMember& rhs) :
- m_opaque_sp()
-{
- if (this != &rhs)
- {
- if (rhs.IsValid())
- m_opaque_sp.reset(new TypeEnumMemberImpl(rhs.ref()));
- }
+SBTypeEnumMember::SBTypeEnumMember() : m_opaque_sp() {}
+
+SBTypeEnumMember::~SBTypeEnumMember() {}
+SBTypeEnumMember::SBTypeEnumMember(
+ const lldb::TypeEnumMemberImplSP &enum_member_sp)
+ : m_opaque_sp(enum_member_sp) {}
+
+SBTypeEnumMember::SBTypeEnumMember(const SBTypeEnumMember &rhs)
+ : m_opaque_sp() {
+ if (this != &rhs) {
+ if (rhs.IsValid())
+ m_opaque_sp.reset(new TypeEnumMemberImpl(rhs.ref()));
+ }
}
-SBTypeEnumMember&
-SBTypeEnumMember::operator = (const SBTypeEnumMember& rhs)
-{
- if (this != &rhs)
- {
- if (rhs.IsValid())
- m_opaque_sp.reset(new TypeEnumMemberImpl(rhs.ref()));
- }
- return *this;
+SBTypeEnumMember &SBTypeEnumMember::operator=(const SBTypeEnumMember &rhs) {
+ if (this != &rhs) {
+ if (rhs.IsValid())
+ m_opaque_sp.reset(new TypeEnumMemberImpl(rhs.ref()));
+ }
+ return *this;
}
-bool
-SBTypeEnumMember::IsValid() const
-{
- return m_opaque_sp.get();
-}
-
-const char *
-SBTypeEnumMember::GetName ()
-{
- if (m_opaque_sp.get())
- return m_opaque_sp->GetName().GetCString();
- return NULL;
-}
-
-int64_t
-SBTypeEnumMember::GetValueAsSigned()
-{
- if (m_opaque_sp.get())
- return m_opaque_sp->GetValueAsSigned();
- return 0;
-}
-
-uint64_t
-SBTypeEnumMember::GetValueAsUnsigned()
-{
- if (m_opaque_sp.get())
- return m_opaque_sp->GetValueAsUnsigned();
- return 0;
-}
-
-SBType
-SBTypeEnumMember::GetType ()
-{
- SBType sb_type;
- if (m_opaque_sp.get())
- {
- sb_type.SetSP(m_opaque_sp->GetIntegerType());
- }
- return sb_type;
+bool SBTypeEnumMember::IsValid() const { return m_opaque_sp.get(); }
+const char *SBTypeEnumMember::GetName() {
+ if (m_opaque_sp.get())
+ return m_opaque_sp->GetName().GetCString();
+ return NULL;
}
-void
-SBTypeEnumMember::reset(TypeEnumMemberImpl *type_member_impl)
-{
- m_opaque_sp.reset(type_member_impl);
+int64_t SBTypeEnumMember::GetValueAsSigned() {
+ if (m_opaque_sp.get())
+ return m_opaque_sp->GetValueAsSigned();
+ return 0;
}
-TypeEnumMemberImpl &
-SBTypeEnumMember::ref ()
-{
- if (m_opaque_sp.get() == NULL)
- m_opaque_sp.reset (new TypeEnumMemberImpl());
- return *m_opaque_sp.get();
+uint64_t SBTypeEnumMember::GetValueAsUnsigned() {
+ if (m_opaque_sp.get())
+ return m_opaque_sp->GetValueAsUnsigned();
+ return 0;
}
-const TypeEnumMemberImpl &
-SBTypeEnumMember::ref () const
-{
- return *m_opaque_sp.get();
+SBType SBTypeEnumMember::GetType() {
+ SBType sb_type;
+ if (m_opaque_sp.get()) {
+ sb_type.SetSP(m_opaque_sp->GetIntegerType());
+ }
+ return sb_type;
}
+void SBTypeEnumMember::reset(TypeEnumMemberImpl *type_member_impl) {
+ m_opaque_sp.reset(type_member_impl);
+}
-SBTypeEnumMemberList::SBTypeEnumMemberList() :
- m_opaque_ap(new TypeEnumMemberListImpl())
-{
+TypeEnumMemberImpl &SBTypeEnumMember::ref() {
+ if (m_opaque_sp.get() == NULL)
+ m_opaque_sp.reset(new TypeEnumMemberImpl());
+ return *m_opaque_sp.get();
}
-SBTypeEnumMemberList::SBTypeEnumMemberList(const SBTypeEnumMemberList& rhs) :
- m_opaque_ap(new TypeEnumMemberListImpl())
-{
- for (uint32_t i = 0, rhs_size = const_cast<SBTypeEnumMemberList&>(rhs).GetSize(); i < rhs_size; i++)
- Append(const_cast<SBTypeEnumMemberList&>(rhs).GetTypeEnumMemberAtIndex(i));
+const TypeEnumMemberImpl &SBTypeEnumMember::ref() const {
+ return *m_opaque_sp.get();
}
-bool
-SBTypeEnumMemberList::IsValid ()
-{
- return (m_opaque_ap.get() != NULL);
+SBTypeEnumMemberList::SBTypeEnumMemberList()
+ : m_opaque_ap(new TypeEnumMemberListImpl()) {}
+
+SBTypeEnumMemberList::SBTypeEnumMemberList(const SBTypeEnumMemberList &rhs)
+ : m_opaque_ap(new TypeEnumMemberListImpl()) {
+ for (uint32_t i = 0,
+ rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize();
+ i < rhs_size; i++)
+ Append(const_cast<SBTypeEnumMemberList &>(rhs).GetTypeEnumMemberAtIndex(i));
}
-SBTypeEnumMemberList&
-SBTypeEnumMemberList::operator = (const SBTypeEnumMemberList& rhs)
-{
- if (this != &rhs)
- {
- m_opaque_ap.reset (new TypeEnumMemberListImpl());
- for (uint32_t i = 0, rhs_size = const_cast<SBTypeEnumMemberList&>(rhs).GetSize(); i < rhs_size; i++)
- Append(const_cast<SBTypeEnumMemberList&>(rhs).GetTypeEnumMemberAtIndex(i));
- }
- return *this;
+bool SBTypeEnumMemberList::IsValid() { return (m_opaque_ap.get() != NULL); }
+
+SBTypeEnumMemberList &SBTypeEnumMemberList::
+operator=(const SBTypeEnumMemberList &rhs) {
+ if (this != &rhs) {
+ m_opaque_ap.reset(new TypeEnumMemberListImpl());
+ for (uint32_t i = 0,
+ rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize();
+ i < rhs_size; i++)
+ Append(
+ const_cast<SBTypeEnumMemberList &>(rhs).GetTypeEnumMemberAtIndex(i));
+ }
+ return *this;
}
-void
-SBTypeEnumMemberList::Append (SBTypeEnumMember enum_member)
-{
- if (enum_member.IsValid())
- m_opaque_ap->Append (enum_member.m_opaque_sp);
+void SBTypeEnumMemberList::Append(SBTypeEnumMember enum_member) {
+ if (enum_member.IsValid())
+ m_opaque_ap->Append(enum_member.m_opaque_sp);
}
SBTypeEnumMember
-SBTypeEnumMemberList::GetTypeEnumMemberAtIndex(uint32_t index)
-{
- if (m_opaque_ap.get())
- return SBTypeEnumMember(m_opaque_ap->GetTypeEnumMemberAtIndex(index));
- return SBTypeEnumMember();
-}
-
-uint32_t
-SBTypeEnumMemberList::GetSize()
-{
- return m_opaque_ap->GetSize();
-}
-
-SBTypeEnumMemberList::~SBTypeEnumMemberList()
-{
-}
-
-bool
-SBTypeEnumMember::GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level)
-{
- Stream &strm = description.ref();
-
- if (m_opaque_sp.get())
- {
- if( m_opaque_sp->GetIntegerType()->GetDescription(strm, description_level) )
- {
- strm.Printf(" %s", m_opaque_sp->GetName().GetCString());
- }
- }
- else
- {
- strm.PutCString ("No value");
+SBTypeEnumMemberList::GetTypeEnumMemberAtIndex(uint32_t index) {
+ if (m_opaque_ap.get())
+ return SBTypeEnumMember(m_opaque_ap->GetTypeEnumMemberAtIndex(index));
+ return SBTypeEnumMember();
+}
+
+uint32_t SBTypeEnumMemberList::GetSize() { return m_opaque_ap->GetSize(); }
+
+SBTypeEnumMemberList::~SBTypeEnumMemberList() {}
+
+bool SBTypeEnumMember::GetDescription(
+ lldb::SBStream &description, lldb::DescriptionLevel description_level) {
+ Stream &strm = description.ref();
+
+ if (m_opaque_sp.get()) {
+ if (m_opaque_sp->GetIntegerType()->GetDescription(strm,
+ description_level)) {
+ strm.Printf(" %s", m_opaque_sp->GetName().GetCString());
}
- return true;
+ } else {
+ strm.PutCString("No value");
+ }
+ return true;
}
Modified: lldb/trunk/source/API/SBTypeFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeFilter.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeFilter.cpp (original)
+++ lldb/trunk/source/API/SBTypeFilter.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- SBTypeFilter.cpp ------------------------------------------*- C++ -*-===//
+//===-- SBTypeFilter.cpp ------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,182 +17,129 @@
using namespace lldb;
using namespace lldb_private;
-SBTypeFilter::SBTypeFilter() :
-m_opaque_sp()
-{
-}
-
-SBTypeFilter::SBTypeFilter (uint32_t options)
-: m_opaque_sp(TypeFilterImplSP(new TypeFilterImpl(options)))
-{
-}
-
-SBTypeFilter::SBTypeFilter (const lldb::SBTypeFilter &rhs) :
-m_opaque_sp(rhs.m_opaque_sp)
-{
-}
-
-SBTypeFilter::~SBTypeFilter ()
-{
-}
-
-bool
-SBTypeFilter::IsValid() const
-{
- return m_opaque_sp.get() != NULL;
-}
-
-uint32_t
-SBTypeFilter::GetOptions()
-{
- if (IsValid())
- return m_opaque_sp->GetOptions();
- return 0;
-}
-
-void
-SBTypeFilter::SetOptions (uint32_t value)
-{
- if (CopyOnWrite_Impl())
- m_opaque_sp->SetOptions(value);
-}
-
-bool
-SBTypeFilter::GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level)
-{
- if (!IsValid())
- return false;
- else {
- description.Printf("%s\n",
- m_opaque_sp->GetDescription().c_str());
- return true;
- }
-}
-
-void
-SBTypeFilter::Clear()
-{
- if (CopyOnWrite_Impl())
- m_opaque_sp->Clear();
-}
-
-uint32_t
-SBTypeFilter::GetNumberOfExpressionPaths()
-{
- if (IsValid())
- return m_opaque_sp->GetCount();
- return 0;
-}
-
-const char*
-SBTypeFilter::GetExpressionPathAtIndex (uint32_t i)
-{
- if (IsValid())
- {
- const char* item = m_opaque_sp->GetExpressionPathAtIndex(i);
- if (item && *item == '.')
- item++;
- return item;
- }
- return NULL;
-}
-
-bool
-SBTypeFilter::ReplaceExpressionPathAtIndex (uint32_t i, const char* item)
-{
- if (CopyOnWrite_Impl())
- return m_opaque_sp->SetExpressionPathAtIndex(i, item);
- else
- return false;
-}
-
-void
-SBTypeFilter::AppendExpressionPath (const char* item)
-{
- if (CopyOnWrite_Impl())
- m_opaque_sp->AddExpressionPath(item);
-}
-
-lldb::SBTypeFilter &
-SBTypeFilter::operator = (const lldb::SBTypeFilter &rhs)
-{
- if (this != &rhs)
- {
- m_opaque_sp = rhs.m_opaque_sp;
- }
- return *this;
-}
-
-bool
-SBTypeFilter::operator == (lldb::SBTypeFilter &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
-
- return m_opaque_sp == rhs.m_opaque_sp;
-}
-
-bool
-SBTypeFilter::IsEqualTo (lldb::SBTypeFilter &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
-
- if (GetNumberOfExpressionPaths() != rhs.GetNumberOfExpressionPaths())
- return false;
-
- for (uint32_t j = 0;
- j < GetNumberOfExpressionPaths();
- j++)
- if ( strcmp(GetExpressionPathAtIndex(j),rhs.GetExpressionPathAtIndex(j)) != 0)
- return false;
-
- return GetOptions() == rhs.GetOptions();
-}
-
-bool
-SBTypeFilter::operator != (lldb::SBTypeFilter &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
-
- return m_opaque_sp != rhs.m_opaque_sp;
-}
-
-lldb::TypeFilterImplSP
-SBTypeFilter::GetSP ()
-{
- return m_opaque_sp;
-}
-
-void
-SBTypeFilter::SetSP (const lldb::TypeFilterImplSP &typefilter_impl_sp)
-{
- m_opaque_sp = typefilter_impl_sp;
-}
-
-SBTypeFilter::SBTypeFilter (const lldb::TypeFilterImplSP &typefilter_impl_sp) :
-m_opaque_sp(typefilter_impl_sp)
-{
-}
-
-bool
-SBTypeFilter::CopyOnWrite_Impl()
-{
- if (!IsValid())
- return false;
- if (m_opaque_sp.unique())
- return true;
-
- TypeFilterImplSP new_sp(new TypeFilterImpl(GetOptions()));
-
- for (uint32_t j = 0;
- j < GetNumberOfExpressionPaths();
- j++)
- new_sp->AddExpressionPath(GetExpressionPathAtIndex(j));
-
- SetSP(new_sp);
-
+SBTypeFilter::SBTypeFilter() : m_opaque_sp() {}
+
+SBTypeFilter::SBTypeFilter(uint32_t options)
+ : m_opaque_sp(TypeFilterImplSP(new TypeFilterImpl(options))) {}
+
+SBTypeFilter::SBTypeFilter(const lldb::SBTypeFilter &rhs)
+ : m_opaque_sp(rhs.m_opaque_sp) {}
+
+SBTypeFilter::~SBTypeFilter() {}
+
+bool SBTypeFilter::IsValid() const { return m_opaque_sp.get() != NULL; }
+
+uint32_t SBTypeFilter::GetOptions() {
+ if (IsValid())
+ return m_opaque_sp->GetOptions();
+ return 0;
+}
+
+void SBTypeFilter::SetOptions(uint32_t value) {
+ if (CopyOnWrite_Impl())
+ m_opaque_sp->SetOptions(value);
+}
+
+bool SBTypeFilter::GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level) {
+ if (!IsValid())
+ return false;
+ else {
+ description.Printf("%s\n", m_opaque_sp->GetDescription().c_str());
return true;
+ }
+}
+
+void SBTypeFilter::Clear() {
+ if (CopyOnWrite_Impl())
+ m_opaque_sp->Clear();
+}
+
+uint32_t SBTypeFilter::GetNumberOfExpressionPaths() {
+ if (IsValid())
+ return m_opaque_sp->GetCount();
+ return 0;
+}
+
+const char *SBTypeFilter::GetExpressionPathAtIndex(uint32_t i) {
+ if (IsValid()) {
+ const char *item = m_opaque_sp->GetExpressionPathAtIndex(i);
+ if (item && *item == '.')
+ item++;
+ return item;
+ }
+ return NULL;
+}
+
+bool SBTypeFilter::ReplaceExpressionPathAtIndex(uint32_t i, const char *item) {
+ if (CopyOnWrite_Impl())
+ return m_opaque_sp->SetExpressionPathAtIndex(i, item);
+ else
+ return false;
+}
+
+void SBTypeFilter::AppendExpressionPath(const char *item) {
+ if (CopyOnWrite_Impl())
+ m_opaque_sp->AddExpressionPath(item);
+}
+
+lldb::SBTypeFilter &SBTypeFilter::operator=(const lldb::SBTypeFilter &rhs) {
+ if (this != &rhs) {
+ m_opaque_sp = rhs.m_opaque_sp;
+ }
+ return *this;
+}
+
+bool SBTypeFilter::operator==(lldb::SBTypeFilter &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+
+ return m_opaque_sp == rhs.m_opaque_sp;
+}
+
+bool SBTypeFilter::IsEqualTo(lldb::SBTypeFilter &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+
+ if (GetNumberOfExpressionPaths() != rhs.GetNumberOfExpressionPaths())
+ return false;
+
+ for (uint32_t j = 0; j < GetNumberOfExpressionPaths(); j++)
+ if (strcmp(GetExpressionPathAtIndex(j), rhs.GetExpressionPathAtIndex(j)) !=
+ 0)
+ return false;
+
+ return GetOptions() == rhs.GetOptions();
+}
+
+bool SBTypeFilter::operator!=(lldb::SBTypeFilter &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+
+ return m_opaque_sp != rhs.m_opaque_sp;
+}
+
+lldb::TypeFilterImplSP SBTypeFilter::GetSP() { return m_opaque_sp; }
+
+void SBTypeFilter::SetSP(const lldb::TypeFilterImplSP &typefilter_impl_sp) {
+ m_opaque_sp = typefilter_impl_sp;
+}
+
+SBTypeFilter::SBTypeFilter(const lldb::TypeFilterImplSP &typefilter_impl_sp)
+ : m_opaque_sp(typefilter_impl_sp) {}
+
+bool SBTypeFilter::CopyOnWrite_Impl() {
+ if (!IsValid())
+ return false;
+ if (m_opaque_sp.unique())
+ return true;
+
+ TypeFilterImplSP new_sp(new TypeFilterImpl(GetOptions()));
+
+ for (uint32_t j = 0; j < GetNumberOfExpressionPaths(); j++)
+ new_sp->AddExpressionPath(GetExpressionPathAtIndex(j));
+
+ SetSP(new_sp);
+
+ return true;
}
Modified: lldb/trunk/source/API/SBTypeFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeFormat.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeFormat.cpp (original)
+++ lldb/trunk/source/API/SBTypeFormat.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- SBTypeFormat.cpp ------------------------------------------*- C++ -*-===//
+//===-- SBTypeFormat.cpp ------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,176 +17,132 @@
using namespace lldb;
using namespace lldb_private;
-SBTypeFormat::SBTypeFormat() :
-m_opaque_sp()
-{
-}
+SBTypeFormat::SBTypeFormat() : m_opaque_sp() {}
-SBTypeFormat::SBTypeFormat (lldb::Format format,
- uint32_t options)
-: m_opaque_sp(TypeFormatImplSP(new TypeFormatImpl_Format(format,options)))
-{
-}
+SBTypeFormat::SBTypeFormat(lldb::Format format, uint32_t options)
+ : m_opaque_sp(
+ TypeFormatImplSP(new TypeFormatImpl_Format(format, options))) {}
-SBTypeFormat::SBTypeFormat (const char* type,
- uint32_t options)
-: m_opaque_sp(TypeFormatImplSP(new TypeFormatImpl_EnumType(ConstString(type ? type : ""),options)))
-{
-}
+SBTypeFormat::SBTypeFormat(const char *type, uint32_t options)
+ : m_opaque_sp(TypeFormatImplSP(new TypeFormatImpl_EnumType(
+ ConstString(type ? type : ""), options))) {}
-SBTypeFormat::SBTypeFormat (const lldb::SBTypeFormat &rhs) :
-m_opaque_sp(rhs.m_opaque_sp)
-{
-}
+SBTypeFormat::SBTypeFormat(const lldb::SBTypeFormat &rhs)
+ : m_opaque_sp(rhs.m_opaque_sp) {}
+
+SBTypeFormat::~SBTypeFormat() {}
-SBTypeFormat::~SBTypeFormat ()
-{
+bool SBTypeFormat::IsValid() const { return m_opaque_sp.get() != NULL; }
+
+lldb::Format SBTypeFormat::GetFormat() {
+ if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat)
+ return ((TypeFormatImpl_Format *)m_opaque_sp.get())->GetFormat();
+ return lldb::eFormatInvalid;
}
-bool
-SBTypeFormat::IsValid() const
-{
- return m_opaque_sp.get() != NULL;
+const char *SBTypeFormat::GetTypeName() {
+ if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeEnum)
+ return ((TypeFormatImpl_EnumType *)m_opaque_sp.get())
+ ->GetTypeName()
+ .AsCString("");
+ return "";
}
-lldb::Format
-SBTypeFormat::GetFormat ()
-{
- if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat)
- return ((TypeFormatImpl_Format*)m_opaque_sp.get())->GetFormat();
- return lldb::eFormatInvalid;
+uint32_t SBTypeFormat::GetOptions() {
+ if (IsValid())
+ return m_opaque_sp->GetOptions();
+ return 0;
}
-const char*
-SBTypeFormat::GetTypeName ()
-{
- if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeEnum)
- return ((TypeFormatImpl_EnumType*)m_opaque_sp.get())->GetTypeName().AsCString("");
- return "";
+void SBTypeFormat::SetFormat(lldb::Format fmt) {
+ if (CopyOnWrite_Impl(Type::eTypeFormat))
+ ((TypeFormatImpl_Format *)m_opaque_sp.get())->SetFormat(fmt);
}
-uint32_t
-SBTypeFormat::GetOptions()
-{
- if (IsValid())
- return m_opaque_sp->GetOptions();
- return 0;
+void SBTypeFormat::SetTypeName(const char *type) {
+ if (CopyOnWrite_Impl(Type::eTypeEnum))
+ ((TypeFormatImpl_EnumType *)m_opaque_sp.get())
+ ->SetTypeName(ConstString(type ? type : ""));
}
-void
-SBTypeFormat::SetFormat (lldb::Format fmt)
-{
- if (CopyOnWrite_Impl(Type::eTypeFormat))
- ((TypeFormatImpl_Format*)m_opaque_sp.get())->SetFormat(fmt);
+void SBTypeFormat::SetOptions(uint32_t value) {
+ if (CopyOnWrite_Impl(Type::eTypeKeepSame))
+ m_opaque_sp->SetOptions(value);
}
-void
-SBTypeFormat::SetTypeName (const char* type)
-{
- if (CopyOnWrite_Impl(Type::eTypeEnum))
- ((TypeFormatImpl_EnumType*)m_opaque_sp.get())->SetTypeName(ConstString(type ? type : ""));
+bool SBTypeFormat::GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level) {
+ if (!IsValid())
+ return false;
+ else {
+ description.Printf("%s\n", m_opaque_sp->GetDescription().c_str());
+ return true;
+ }
}
-void
-SBTypeFormat::SetOptions (uint32_t value)
-{
- if (CopyOnWrite_Impl(Type::eTypeKeepSame))
- m_opaque_sp->SetOptions(value);
+lldb::SBTypeFormat &SBTypeFormat::operator=(const lldb::SBTypeFormat &rhs) {
+ if (this != &rhs) {
+ m_opaque_sp = rhs.m_opaque_sp;
+ }
+ return *this;
}
-bool
-SBTypeFormat::GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level)
-{
- if (!IsValid())
- return false;
- else {
- description.Printf("%s\n",
- m_opaque_sp->GetDescription().c_str());
- return true;
- }
+bool SBTypeFormat::operator==(lldb::SBTypeFormat &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+ return m_opaque_sp == rhs.m_opaque_sp;
}
-lldb::SBTypeFormat &
-SBTypeFormat::operator = (const lldb::SBTypeFormat &rhs)
-{
- if (this != &rhs)
- {
- m_opaque_sp = rhs.m_opaque_sp;
- }
- return *this;
+bool SBTypeFormat::IsEqualTo(lldb::SBTypeFormat &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+
+ if (GetFormat() == rhs.GetFormat())
+ return GetOptions() == rhs.GetOptions();
+ else
+ return false;
}
-bool
-SBTypeFormat::operator == (lldb::SBTypeFormat &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
- return m_opaque_sp == rhs.m_opaque_sp;
+bool SBTypeFormat::operator!=(lldb::SBTypeFormat &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+ return m_opaque_sp != rhs.m_opaque_sp;
}
-bool
-SBTypeFormat::IsEqualTo (lldb::SBTypeFormat &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
-
- if (GetFormat() == rhs.GetFormat())
- return GetOptions() == rhs.GetOptions();
- else
- return false;
+lldb::TypeFormatImplSP SBTypeFormat::GetSP() { return m_opaque_sp; }
+
+void SBTypeFormat::SetSP(const lldb::TypeFormatImplSP &typeformat_impl_sp) {
+ m_opaque_sp = typeformat_impl_sp;
}
-bool
-SBTypeFormat::operator != (lldb::SBTypeFormat &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
- return m_opaque_sp != rhs.m_opaque_sp;
-}
-
-lldb::TypeFormatImplSP
-SBTypeFormat::GetSP ()
-{
- return m_opaque_sp;
-}
-
-void
-SBTypeFormat::SetSP (const lldb::TypeFormatImplSP &typeformat_impl_sp)
-{
- m_opaque_sp = typeformat_impl_sp;
-}
-
-SBTypeFormat::SBTypeFormat (const lldb::TypeFormatImplSP &typeformat_impl_sp) :
- m_opaque_sp(typeformat_impl_sp)
-{
-}
-
-bool
-SBTypeFormat::CopyOnWrite_Impl(Type type)
-{
- if (!IsValid())
- return false;
-
- if (m_opaque_sp.unique() &&
- ((type == Type::eTypeKeepSame) ||
- (type == Type::eTypeFormat && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat) ||
- (type == Type::eTypeEnum && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeEnum))
- )
- return true;
-
- if (type == Type::eTypeKeepSame)
- {
- if (m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat)
- type = Type::eTypeFormat;
- else
- type = Type::eTypeEnum;
- }
-
- if (type == Type::eTypeFormat)
- SetSP(TypeFormatImplSP(new TypeFormatImpl_Format(GetFormat(),GetOptions())));
- else
- SetSP(TypeFormatImplSP(new TypeFormatImpl_EnumType(ConstString(GetTypeName()),GetOptions())));
-
+SBTypeFormat::SBTypeFormat(const lldb::TypeFormatImplSP &typeformat_impl_sp)
+ : m_opaque_sp(typeformat_impl_sp) {}
+
+bool SBTypeFormat::CopyOnWrite_Impl(Type type) {
+ if (!IsValid())
+ return false;
+
+ if (m_opaque_sp.unique() &&
+ ((type == Type::eTypeKeepSame) ||
+ (type == Type::eTypeFormat &&
+ m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat) ||
+ (type == Type::eTypeEnum &&
+ m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeEnum)))
return true;
+
+ if (type == Type::eTypeKeepSame) {
+ if (m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat)
+ type = Type::eTypeFormat;
+ else
+ type = Type::eTypeEnum;
+ }
+
+ if (type == Type::eTypeFormat)
+ SetSP(
+ TypeFormatImplSP(new TypeFormatImpl_Format(GetFormat(), GetOptions())));
+ else
+ SetSP(TypeFormatImplSP(
+ new TypeFormatImpl_EnumType(ConstString(GetTypeName()), GetOptions())));
+
+ return true;
}
Modified: lldb/trunk/source/API/SBTypeNameSpecifier.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeNameSpecifier.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeNameSpecifier.cpp (original)
+++ lldb/trunk/source/API/SBTypeNameSpecifier.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- SBTypeNameSpecifier.cpp ------------------------------------*- C++ -*-===//
+//===-- SBTypeNameSpecifier.cpp ------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,132 +18,100 @@
using namespace lldb;
using namespace lldb_private;
-SBTypeNameSpecifier::SBTypeNameSpecifier() :
-m_opaque_sp()
-{
+SBTypeNameSpecifier::SBTypeNameSpecifier() : m_opaque_sp() {}
+
+SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, bool is_regex)
+ : m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex)) {
+ if (name == NULL || (*name) == 0)
+ m_opaque_sp.reset();
}
-SBTypeNameSpecifier::SBTypeNameSpecifier (const char* name,
- bool is_regex) :
-m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex))
-{
- if (name == NULL || (*name) == 0)
- m_opaque_sp.reset();
+SBTypeNameSpecifier::SBTypeNameSpecifier(SBType type) : m_opaque_sp() {
+ if (type.IsValid())
+ m_opaque_sp = TypeNameSpecifierImplSP(
+ new TypeNameSpecifierImpl(type.m_opaque_sp->GetCompilerType(true)));
}
-SBTypeNameSpecifier::SBTypeNameSpecifier (SBType type) :
-m_opaque_sp()
-{
- if (type.IsValid())
- m_opaque_sp = TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(type.m_opaque_sp->GetCompilerType(true)));
+SBTypeNameSpecifier::SBTypeNameSpecifier(const lldb::SBTypeNameSpecifier &rhs)
+ : m_opaque_sp(rhs.m_opaque_sp) {}
+
+SBTypeNameSpecifier::~SBTypeNameSpecifier() {}
+
+bool SBTypeNameSpecifier::IsValid() const { return m_opaque_sp.get() != NULL; }
+
+const char *SBTypeNameSpecifier::GetName() {
+ if (!IsValid())
+ return NULL;
+
+ return m_opaque_sp->GetName();
}
-SBTypeNameSpecifier::SBTypeNameSpecifier (const lldb::SBTypeNameSpecifier &rhs) :
-m_opaque_sp(rhs.m_opaque_sp)
-{}
+SBType SBTypeNameSpecifier::GetType() {
+ if (!IsValid())
+ return SBType();
+ lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType();
+ if (c_type.IsValid())
+ return SBType(c_type);
+ return SBType();
+}
-SBTypeNameSpecifier::~SBTypeNameSpecifier ()
-{
+bool SBTypeNameSpecifier::IsRegex() {
+ if (!IsValid())
+ return false;
+
+ return m_opaque_sp->IsRegex();
}
-bool
-SBTypeNameSpecifier::IsValid() const
-{
- return m_opaque_sp.get() != NULL;
+bool SBTypeNameSpecifier::GetDescription(
+ lldb::SBStream &description, lldb::DescriptionLevel description_level) {
+ if (!IsValid())
+ return false;
+ description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(),
+ IsRegex() ? "regex" : "plain");
+ return true;
}
-const char*
-SBTypeNameSpecifier::GetName ()
-{
- if (!IsValid())
- return NULL;
-
- return m_opaque_sp->GetName();
+lldb::SBTypeNameSpecifier &SBTypeNameSpecifier::
+operator=(const lldb::SBTypeNameSpecifier &rhs) {
+ if (this != &rhs) {
+ m_opaque_sp = rhs.m_opaque_sp;
+ }
+ return *this;
}
-SBType
-SBTypeNameSpecifier::GetType ()
-{
- if (!IsValid())
- return SBType();
- lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType();
- if (c_type.IsValid())
- return SBType(c_type);
- return SBType();
+bool SBTypeNameSpecifier::operator==(lldb::SBTypeNameSpecifier &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+ return m_opaque_sp == rhs.m_opaque_sp;
}
-bool
-SBTypeNameSpecifier::IsRegex ()
-{
- if (!IsValid())
- return false;
-
- return m_opaque_sp->IsRegex();
-}
-
-bool
-SBTypeNameSpecifier::GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level)
-{
- if (!IsValid())
- return false;
- description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(), IsRegex() ? "regex" : "plain");
- return true;
-}
-
-lldb::SBTypeNameSpecifier &
-SBTypeNameSpecifier::operator = (const lldb::SBTypeNameSpecifier &rhs)
-{
- if (this != &rhs)
- {
- m_opaque_sp = rhs.m_opaque_sp;
- }
- return *this;
-}
-
-bool
-SBTypeNameSpecifier::operator == (lldb::SBTypeNameSpecifier &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
- return m_opaque_sp == rhs.m_opaque_sp;
-}
-
-bool
-SBTypeNameSpecifier::IsEqualTo (lldb::SBTypeNameSpecifier &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
-
- if (IsRegex() != rhs.IsRegex())
- return false;
- if (GetName() == NULL || rhs.GetName() == NULL)
- return false;
-
- return (strcmp(GetName(), rhs.GetName()) == 0);
-}
-
-bool
-SBTypeNameSpecifier::operator != (lldb::SBTypeNameSpecifier &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
- return m_opaque_sp != rhs.m_opaque_sp;
-}
-
-lldb::TypeNameSpecifierImplSP
-SBTypeNameSpecifier::GetSP ()
-{
- return m_opaque_sp;
-}
-
-void
-SBTypeNameSpecifier::SetSP (const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
-{
- m_opaque_sp = type_namespec_sp;
-}
-
-SBTypeNameSpecifier::SBTypeNameSpecifier (const lldb::TypeNameSpecifierImplSP &type_namespec_sp) :
-m_opaque_sp(type_namespec_sp)
-{
+bool SBTypeNameSpecifier::IsEqualTo(lldb::SBTypeNameSpecifier &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+
+ if (IsRegex() != rhs.IsRegex())
+ return false;
+ if (GetName() == NULL || rhs.GetName() == NULL)
+ return false;
+
+ return (strcmp(GetName(), rhs.GetName()) == 0);
}
+
+bool SBTypeNameSpecifier::operator!=(lldb::SBTypeNameSpecifier &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+ return m_opaque_sp != rhs.m_opaque_sp;
+}
+
+lldb::TypeNameSpecifierImplSP SBTypeNameSpecifier::GetSP() {
+ return m_opaque_sp;
+}
+
+void SBTypeNameSpecifier::SetSP(
+ const lldb::TypeNameSpecifierImplSP &type_namespec_sp) {
+ m_opaque_sp = type_namespec_sp;
+}
+
+SBTypeNameSpecifier::SBTypeNameSpecifier(
+ const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
+ : m_opaque_sp(type_namespec_sp) {}
Modified: lldb/trunk/source/API/SBTypeSummary.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeSummary.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeSummary.cpp (original)
+++ lldb/trunk/source/API/SBTypeSummary.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- SBTypeSummary.cpp -----------------------------------------*- C++ -*-===//
+//===-- SBTypeSummary.cpp -----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,441 +18,361 @@
using namespace lldb;
using namespace lldb_private;
-SBTypeSummaryOptions::SBTypeSummaryOptions()
-{
+SBTypeSummaryOptions::SBTypeSummaryOptions() {
+ m_opaque_ap.reset(new TypeSummaryOptions());
+}
+
+SBTypeSummaryOptions::SBTypeSummaryOptions(
+ const lldb::SBTypeSummaryOptions &rhs) {
+ if (rhs.m_opaque_ap)
+ m_opaque_ap.reset(new TypeSummaryOptions(*rhs.m_opaque_ap.get()));
+ else
m_opaque_ap.reset(new TypeSummaryOptions());
}
-SBTypeSummaryOptions::SBTypeSummaryOptions (const lldb::SBTypeSummaryOptions &rhs)
-{
- if (rhs.m_opaque_ap)
- m_opaque_ap.reset(new TypeSummaryOptions(*rhs.m_opaque_ap.get()));
- else
- m_opaque_ap.reset(new TypeSummaryOptions());
+SBTypeSummaryOptions::~SBTypeSummaryOptions() {}
+
+bool SBTypeSummaryOptions::IsValid() { return m_opaque_ap.get(); }
+
+lldb::LanguageType SBTypeSummaryOptions::GetLanguage() {
+ if (IsValid())
+ return m_opaque_ap->GetLanguage();
+ return lldb::eLanguageTypeUnknown;
}
-SBTypeSummaryOptions::~SBTypeSummaryOptions ()
-{
+lldb::TypeSummaryCapping SBTypeSummaryOptions::GetCapping() {
+ if (IsValid())
+ return m_opaque_ap->GetCapping();
+ return eTypeSummaryCapped;
}
-bool
-SBTypeSummaryOptions::IsValid()
-{
- return m_opaque_ap.get();
+void SBTypeSummaryOptions::SetLanguage(lldb::LanguageType l) {
+ if (IsValid())
+ m_opaque_ap->SetLanguage(l);
}
-lldb::LanguageType
-SBTypeSummaryOptions::GetLanguage ()
-{
- if (IsValid())
- return m_opaque_ap->GetLanguage();
- return lldb::eLanguageTypeUnknown;
+void SBTypeSummaryOptions::SetCapping(lldb::TypeSummaryCapping c) {
+ if (IsValid())
+ m_opaque_ap->SetCapping(c);
}
-lldb::TypeSummaryCapping
-SBTypeSummaryOptions::GetCapping ()
-{
- if (IsValid())
- return m_opaque_ap->GetCapping();
- return eTypeSummaryCapped;
+lldb_private::TypeSummaryOptions *SBTypeSummaryOptions::operator->() {
+ return m_opaque_ap.get();
}
-void
-SBTypeSummaryOptions::SetLanguage (lldb::LanguageType l)
-{
- if (IsValid())
- m_opaque_ap->SetLanguage(l);
+const lldb_private::TypeSummaryOptions *SBTypeSummaryOptions::
+operator->() const {
+ return m_opaque_ap.get();
}
-void
-SBTypeSummaryOptions::SetCapping (lldb::TypeSummaryCapping c)
-{
- if (IsValid())
- m_opaque_ap->SetCapping(c);
+lldb_private::TypeSummaryOptions *SBTypeSummaryOptions::get() {
+ return m_opaque_ap.get();
}
-lldb_private::TypeSummaryOptions *
-SBTypeSummaryOptions::operator->()
-{
- return m_opaque_ap.get();
+lldb_private::TypeSummaryOptions &SBTypeSummaryOptions::ref() {
+ return *m_opaque_ap.get();
}
-const lldb_private::TypeSummaryOptions *
-SBTypeSummaryOptions::operator->() const
-{
- return m_opaque_ap.get();
+const lldb_private::TypeSummaryOptions &SBTypeSummaryOptions::ref() const {
+ return *m_opaque_ap.get();
}
-lldb_private::TypeSummaryOptions *
-SBTypeSummaryOptions::get ()
-{
- return m_opaque_ap.get();
+SBTypeSummaryOptions::SBTypeSummaryOptions(
+ const lldb_private::TypeSummaryOptions *lldb_object_ptr) {
+ SetOptions(lldb_object_ptr);
}
-lldb_private::TypeSummaryOptions &
-SBTypeSummaryOptions::ref()
-{
- return *m_opaque_ap.get();
+void SBTypeSummaryOptions::SetOptions(
+ const lldb_private::TypeSummaryOptions *lldb_object_ptr) {
+ if (lldb_object_ptr)
+ m_opaque_ap.reset(new TypeSummaryOptions(*lldb_object_ptr));
+ else
+ m_opaque_ap.reset(new TypeSummaryOptions());
}
-const lldb_private::TypeSummaryOptions &
-SBTypeSummaryOptions::ref() const
-{
- return *m_opaque_ap.get();
+SBTypeSummary::SBTypeSummary() : m_opaque_sp() {}
+
+SBTypeSummary SBTypeSummary::CreateWithSummaryString(const char *data,
+ uint32_t options) {
+ if (!data || data[0] == 0)
+ return SBTypeSummary();
+
+ return SBTypeSummary(
+ TypeSummaryImplSP(new StringSummaryFormat(options, data)));
+}
+
+SBTypeSummary SBTypeSummary::CreateWithFunctionName(const char *data,
+ uint32_t options) {
+ if (!data || data[0] == 0)
+ return SBTypeSummary();
+
+ return SBTypeSummary(
+ TypeSummaryImplSP(new ScriptSummaryFormat(options, data)));
+}
+
+SBTypeSummary SBTypeSummary::CreateWithScriptCode(const char *data,
+ uint32_t options) {
+ if (!data || data[0] == 0)
+ return SBTypeSummary();
+
+ return SBTypeSummary(
+ TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data)));
+}
+
+SBTypeSummary SBTypeSummary::CreateWithCallback(FormatCallback cb,
+ uint32_t options,
+ const char *description) {
+ SBTypeSummary retval;
+ if (cb) {
+ retval.SetSP(TypeSummaryImplSP(new CXXFunctionSummaryFormat(
+ options,
+ [cb](ValueObject &valobj, Stream &stm,
+ const TypeSummaryOptions &opt) -> bool {
+ SBStream stream;
+ SBValue sb_value(valobj.GetSP());
+ SBTypeSummaryOptions options(&opt);
+ if (!cb(sb_value, options, stream))
+ return false;
+ stm.Write(stream.GetData(), stream.GetSize());
+ return true;
+ },
+ description ? description : "callback summary formatter")));
+ }
+
+ return retval;
}
-SBTypeSummaryOptions::SBTypeSummaryOptions (const lldb_private::TypeSummaryOptions *lldb_object_ptr)
-{
- SetOptions(lldb_object_ptr);
+SBTypeSummary::SBTypeSummary(const lldb::SBTypeSummary &rhs)
+ : m_opaque_sp(rhs.m_opaque_sp) {}
+
+SBTypeSummary::~SBTypeSummary() {}
+
+bool SBTypeSummary::IsValid() const { return m_opaque_sp.get() != NULL; }
+
+bool SBTypeSummary::IsFunctionCode() {
+ if (!IsValid())
+ return false;
+ if (ScriptSummaryFormat *script_summary_ptr =
+ llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) {
+ const char *ftext = script_summary_ptr->GetPythonScript();
+ return (ftext && *ftext != 0);
+ }
+ return false;
}
-void
-SBTypeSummaryOptions::SetOptions (const lldb_private::TypeSummaryOptions *lldb_object_ptr)
-{
- if (lldb_object_ptr)
- m_opaque_ap.reset(new TypeSummaryOptions(*lldb_object_ptr));
- else
- m_opaque_ap.reset(new TypeSummaryOptions());
+bool SBTypeSummary::IsFunctionName() {
+ if (!IsValid())
+ return false;
+ if (ScriptSummaryFormat *script_summary_ptr =
+ llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) {
+ const char *ftext = script_summary_ptr->GetPythonScript();
+ return (!ftext || *ftext == 0);
+ }
+ return false;
+}
+
+bool SBTypeSummary::IsSummaryString() {
+ if (!IsValid())
+ return false;
+
+ return m_opaque_sp->GetKind() == TypeSummaryImpl::Kind::eSummaryString;
}
-SBTypeSummary::SBTypeSummary() :
-m_opaque_sp()
-{
-}
-
-SBTypeSummary
-SBTypeSummary::CreateWithSummaryString (const char* data, uint32_t options)
-{
- if (!data || data[0] == 0)
- return SBTypeSummary();
-
- return SBTypeSummary(TypeSummaryImplSP(new StringSummaryFormat(options, data)));
-}
-
-SBTypeSummary
-SBTypeSummary::CreateWithFunctionName (const char* data, uint32_t options)
-{
- if (!data || data[0] == 0)
- return SBTypeSummary();
-
- return SBTypeSummary(TypeSummaryImplSP(new ScriptSummaryFormat(options, data)));
-}
-
-SBTypeSummary
-SBTypeSummary::CreateWithScriptCode (const char* data, uint32_t options)
-{
- if (!data || data[0] == 0)
- return SBTypeSummary();
-
- return SBTypeSummary(TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data)));
-}
-
-SBTypeSummary
-SBTypeSummary::CreateWithCallback (FormatCallback cb, uint32_t options, const char* description)
-{
- SBTypeSummary retval;
- if (cb)
- {
- retval.SetSP(TypeSummaryImplSP(new CXXFunctionSummaryFormat(options,
- [cb] (ValueObject& valobj, Stream& stm, const TypeSummaryOptions& opt) -> bool {
- SBStream stream;
- SBValue sb_value(valobj.GetSP());
- SBTypeSummaryOptions options(&opt);
- if (!cb(sb_value, options, stream))
- return false;
- stm.Write(stream.GetData(), stream.GetSize());
- return true;
- },
- description ? description : "callback summary formatter")));
- }
-
- return retval;
-}
-
-SBTypeSummary::SBTypeSummary (const lldb::SBTypeSummary &rhs) :
-m_opaque_sp(rhs.m_opaque_sp)
-{
-}
-
-SBTypeSummary::~SBTypeSummary ()
-{
-}
-
-bool
-SBTypeSummary::IsValid() const
-{
- return m_opaque_sp.get() != NULL;
-}
-
-bool
-SBTypeSummary::IsFunctionCode()
-{
- if (!IsValid())
- return false;
- if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
- {
- const char* ftext = script_summary_ptr->GetPythonScript();
- return (ftext && *ftext != 0);
- }
+const char *SBTypeSummary::GetData() {
+ if (!IsValid())
+ return NULL;
+ if (ScriptSummaryFormat *script_summary_ptr =
+ llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) {
+ const char *fname = script_summary_ptr->GetFunctionName();
+ const char *ftext = script_summary_ptr->GetPythonScript();
+ if (ftext && *ftext)
+ return ftext;
+ return fname;
+ } else if (StringSummaryFormat *string_summary_ptr =
+ llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get()))
+ return string_summary_ptr->GetSummaryString();
+ return nullptr;
+}
+
+uint32_t SBTypeSummary::GetOptions() {
+ if (!IsValid())
+ return lldb::eTypeOptionNone;
+ return m_opaque_sp->GetOptions();
+}
+
+void SBTypeSummary::SetOptions(uint32_t value) {
+ if (!CopyOnWrite_Impl())
+ return;
+ m_opaque_sp->SetOptions(value);
+}
+
+void SBTypeSummary::SetSummaryString(const char *data) {
+ if (!IsValid())
+ return;
+ if (!llvm::isa<StringSummaryFormat>(m_opaque_sp.get()))
+ ChangeSummaryType(false);
+ if (StringSummaryFormat *string_summary_ptr =
+ llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get()))
+ string_summary_ptr->SetSummaryString(data);
+}
+
+void SBTypeSummary::SetFunctionName(const char *data) {
+ if (!IsValid())
+ return;
+ if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get()))
+ ChangeSummaryType(true);
+ if (ScriptSummaryFormat *script_summary_ptr =
+ llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
+ script_summary_ptr->SetFunctionName(data);
+}
+
+void SBTypeSummary::SetFunctionCode(const char *data) {
+ if (!IsValid())
+ return;
+ if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get()))
+ ChangeSummaryType(true);
+ if (ScriptSummaryFormat *script_summary_ptr =
+ llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
+ script_summary_ptr->SetPythonScript(data);
+}
+
+bool SBTypeSummary::GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level) {
+ if (!CopyOnWrite_Impl())
return false;
+ else {
+ description.Printf("%s\n", m_opaque_sp->GetDescription().c_str());
+ return true;
+ }
}
-bool
-SBTypeSummary::IsFunctionName()
-{
- if (!IsValid())
- return false;
- if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
- {
- const char* ftext = script_summary_ptr->GetPythonScript();
- return (!ftext || *ftext == 0);
- }
+bool SBTypeSummary::DoesPrintValue(lldb::SBValue value) {
+ if (!IsValid())
return false;
+ lldb::ValueObjectSP value_sp = value.GetSP();
+ return m_opaque_sp->DoesPrintValue(value_sp.get());
}
-bool
-SBTypeSummary::IsSummaryString()
-{
- if (!IsValid())
- return false;
-
- return m_opaque_sp->GetKind() == TypeSummaryImpl::Kind::eSummaryString;
-}
-
-const char*
-SBTypeSummary::GetData ()
-{
- if (!IsValid())
- return NULL;
- if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
- {
- const char* fname = script_summary_ptr->GetFunctionName();
- const char* ftext = script_summary_ptr->GetPythonScript();
- if (ftext && *ftext)
- return ftext;
- return fname;
- }
- else if (StringSummaryFormat* string_summary_ptr = llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get()))
- return string_summary_ptr->GetSummaryString();
- return nullptr;
-}
-
-uint32_t
-SBTypeSummary::GetOptions ()
-{
- if (!IsValid())
- return lldb::eTypeOptionNone;
- return m_opaque_sp->GetOptions();
-}
-
-void
-SBTypeSummary::SetOptions (uint32_t value)
-{
- if (!CopyOnWrite_Impl())
- return;
- m_opaque_sp->SetOptions(value);
-}
-
-void
-SBTypeSummary::SetSummaryString (const char* data)
-{
- if (!IsValid())
- return;
- if (!llvm::isa<StringSummaryFormat>(m_opaque_sp.get()))
- ChangeSummaryType(false);
- if (StringSummaryFormat* string_summary_ptr = llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get()))
- string_summary_ptr->SetSummaryString(data);
-}
-
-void
-SBTypeSummary::SetFunctionName (const char* data)
-{
- if (!IsValid())
- return;
- if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get()))
- ChangeSummaryType(true);
- if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
- script_summary_ptr->SetFunctionName(data);
-}
-
-void
-SBTypeSummary::SetFunctionCode (const char* data)
-{
- if (!IsValid())
- return;
- if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get()))
- ChangeSummaryType(true);
- if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
- script_summary_ptr->SetPythonScript(data);
-}
-
-bool
-SBTypeSummary::GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level)
-{
- if (!CopyOnWrite_Impl())
- return false;
- else {
- description.Printf("%s\n",
- m_opaque_sp->GetDescription().c_str());
- return true;
- }
-}
-
-bool
-SBTypeSummary::DoesPrintValue (lldb::SBValue value)
-{
- if (!IsValid())
- return false;
- lldb::ValueObjectSP value_sp = value.GetSP();
- return m_opaque_sp->DoesPrintValue(value_sp.get());
-}
-
-lldb::SBTypeSummary &
-SBTypeSummary::operator = (const lldb::SBTypeSummary &rhs)
-{
- if (this != &rhs)
- {
- m_opaque_sp = rhs.m_opaque_sp;
- }
- return *this;
-}
-
-bool
-SBTypeSummary::operator == (lldb::SBTypeSummary &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
- return m_opaque_sp == rhs.m_opaque_sp;
-}
-
-bool
-SBTypeSummary::IsEqualTo (lldb::SBTypeSummary &rhs)
-{
- if (IsValid())
- {
- // valid and invalid are different
- if (!rhs.IsValid())
- return false;
- }
+lldb::SBTypeSummary &SBTypeSummary::operator=(const lldb::SBTypeSummary &rhs) {
+ if (this != &rhs) {
+ m_opaque_sp = rhs.m_opaque_sp;
+ }
+ return *this;
+}
+
+bool SBTypeSummary::operator==(lldb::SBTypeSummary &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+ return m_opaque_sp == rhs.m_opaque_sp;
+}
+
+bool SBTypeSummary::IsEqualTo(lldb::SBTypeSummary &rhs) {
+ if (IsValid()) {
+ // valid and invalid are different
+ if (!rhs.IsValid())
+ return false;
+ } else {
+ // invalid and valid are different
+ if (rhs.IsValid())
+ return false;
else
- {
- // invalid and valid are different
- if (rhs.IsValid())
- return false;
- else
- // both invalid are the same
- return true;
- }
-
- if (m_opaque_sp->GetKind() != rhs.m_opaque_sp->GetKind())
- return false;
-
- switch (m_opaque_sp->GetKind())
- {
- case TypeSummaryImpl::Kind::eCallback:
- return llvm::dyn_cast<CXXFunctionSummaryFormat>(m_opaque_sp.get()) == llvm::dyn_cast<CXXFunctionSummaryFormat>(rhs.m_opaque_sp.get());
- case TypeSummaryImpl::Kind::eScript:
- if (IsFunctionCode() != rhs.IsFunctionCode())
- return false;
- if (IsFunctionName() != rhs.IsFunctionName())
- return false;
- return GetOptions() == rhs.GetOptions();
- case TypeSummaryImpl::Kind::eSummaryString:
- if (IsSummaryString() != rhs.IsSummaryString())
- return false;
- return GetOptions() == rhs.GetOptions();
- case TypeSummaryImpl::Kind::eInternal:
- return (m_opaque_sp.get() == rhs.m_opaque_sp.get());
- }
-
+ // both invalid are the same
+ return true;
+ }
+
+ if (m_opaque_sp->GetKind() != rhs.m_opaque_sp->GetKind())
return false;
+
+ switch (m_opaque_sp->GetKind()) {
+ case TypeSummaryImpl::Kind::eCallback:
+ return llvm::dyn_cast<CXXFunctionSummaryFormat>(m_opaque_sp.get()) ==
+ llvm::dyn_cast<CXXFunctionSummaryFormat>(rhs.m_opaque_sp.get());
+ case TypeSummaryImpl::Kind::eScript:
+ if (IsFunctionCode() != rhs.IsFunctionCode())
+ return false;
+ if (IsFunctionName() != rhs.IsFunctionName())
+ return false;
+ return GetOptions() == rhs.GetOptions();
+ case TypeSummaryImpl::Kind::eSummaryString:
+ if (IsSummaryString() != rhs.IsSummaryString())
+ return false;
+ return GetOptions() == rhs.GetOptions();
+ case TypeSummaryImpl::Kind::eInternal:
+ return (m_opaque_sp.get() == rhs.m_opaque_sp.get());
+ }
+
+ return false;
+}
+
+bool SBTypeSummary::operator!=(lldb::SBTypeSummary &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+ return m_opaque_sp != rhs.m_opaque_sp;
+}
+
+lldb::TypeSummaryImplSP SBTypeSummary::GetSP() { return m_opaque_sp; }
+
+void SBTypeSummary::SetSP(const lldb::TypeSummaryImplSP &typesummary_impl_sp) {
+ m_opaque_sp = typesummary_impl_sp;
}
-bool
-SBTypeSummary::operator != (lldb::SBTypeSummary &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
- return m_opaque_sp != rhs.m_opaque_sp;
-}
-
-lldb::TypeSummaryImplSP
-SBTypeSummary::GetSP ()
-{
- return m_opaque_sp;
-}
-
-void
-SBTypeSummary::SetSP (const lldb::TypeSummaryImplSP &typesummary_impl_sp)
-{
- m_opaque_sp = typesummary_impl_sp;
-}
-
-SBTypeSummary::SBTypeSummary (const lldb::TypeSummaryImplSP &typesummary_impl_sp) :
-m_opaque_sp(typesummary_impl_sp)
-{
-}
-
-bool
-SBTypeSummary::CopyOnWrite_Impl()
-{
- if (!IsValid())
- return false;
-
- if (m_opaque_sp.unique())
- return true;
-
- TypeSummaryImplSP new_sp;
-
- if (CXXFunctionSummaryFormat* current_summary_ptr = llvm::dyn_cast<CXXFunctionSummaryFormat>(m_opaque_sp.get()))
- {
- new_sp = TypeSummaryImplSP(new CXXFunctionSummaryFormat(GetOptions(),
- current_summary_ptr->m_impl,
- current_summary_ptr->m_description.c_str()));
- }
- else if (ScriptSummaryFormat* current_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
- {
- new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(GetOptions(),
- current_summary_ptr->GetFunctionName(),
- current_summary_ptr->GetPythonScript()));
- }
- else if (StringSummaryFormat* current_summary_ptr = llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get()))
- {
- new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(),
- current_summary_ptr->GetSummaryString()));
- }
-
- SetSP(new_sp);
-
- return nullptr != new_sp.get();
-}
-
-bool
-SBTypeSummary::ChangeSummaryType (bool want_script)
-{
- if (!IsValid())
- return false;
-
- TypeSummaryImplSP new_sp;
-
- if (want_script == (m_opaque_sp->GetKind() == TypeSummaryImpl::Kind::eScript))
- {
- if (m_opaque_sp->GetKind() == lldb_private::TypeSummaryImpl::Kind::eCallback && !want_script)
- new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), ""));
- else
- return CopyOnWrite_Impl();
- }
-
- if (!new_sp)
- {
- if (want_script)
- new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(GetOptions(), "", ""));
- else
- new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), ""));
- }
-
- SetSP(new_sp);
-
+SBTypeSummary::SBTypeSummary(const lldb::TypeSummaryImplSP &typesummary_impl_sp)
+ : m_opaque_sp(typesummary_impl_sp) {}
+
+bool SBTypeSummary::CopyOnWrite_Impl() {
+ if (!IsValid())
+ return false;
+
+ if (m_opaque_sp.unique())
return true;
+
+ TypeSummaryImplSP new_sp;
+
+ if (CXXFunctionSummaryFormat *current_summary_ptr =
+ llvm::dyn_cast<CXXFunctionSummaryFormat>(m_opaque_sp.get())) {
+ new_sp = TypeSummaryImplSP(new CXXFunctionSummaryFormat(
+ GetOptions(), current_summary_ptr->m_impl,
+ current_summary_ptr->m_description.c_str()));
+ } else if (ScriptSummaryFormat *current_summary_ptr =
+ llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) {
+ new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(
+ GetOptions(), current_summary_ptr->GetFunctionName(),
+ current_summary_ptr->GetPythonScript()));
+ } else if (StringSummaryFormat *current_summary_ptr =
+ llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get())) {
+ new_sp = TypeSummaryImplSP(new StringSummaryFormat(
+ GetOptions(), current_summary_ptr->GetSummaryString()));
+ }
+
+ SetSP(new_sp);
+
+ return nullptr != new_sp.get();
+}
+
+bool SBTypeSummary::ChangeSummaryType(bool want_script) {
+ if (!IsValid())
+ return false;
+
+ TypeSummaryImplSP new_sp;
+
+ if (want_script ==
+ (m_opaque_sp->GetKind() == TypeSummaryImpl::Kind::eScript)) {
+ if (m_opaque_sp->GetKind() ==
+ lldb_private::TypeSummaryImpl::Kind::eCallback &&
+ !want_script)
+ new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), ""));
+ else
+ return CopyOnWrite_Impl();
+ }
+
+ if (!new_sp) {
+ if (want_script)
+ new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(GetOptions(), "", ""));
+ else
+ new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), ""));
+ }
+
+ SetSP(new_sp);
+
+ return true;
}
Modified: lldb/trunk/source/API/SBTypeSynthetic.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeSynthetic.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeSynthetic.cpp (original)
+++ lldb/trunk/source/API/SBTypeSynthetic.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- SBTypeSynthetic.cpp -----------------------------------------*- C++ -*-===//
+//===-- SBTypeSynthetic.cpp -----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,190 +19,146 @@ using namespace lldb_private;
#ifndef LLDB_DISABLE_PYTHON
-SBTypeSynthetic::SBTypeSynthetic() :
-m_opaque_sp()
-{
-}
-
-SBTypeSynthetic
-SBTypeSynthetic::CreateWithClassName (const char* data, uint32_t options)
-{
- if (!data || data[0] == 0)
- return SBTypeSynthetic();
- return SBTypeSynthetic(ScriptedSyntheticChildrenSP(new ScriptedSyntheticChildren(options, data, "")));
-}
-
-SBTypeSynthetic
-SBTypeSynthetic::CreateWithScriptCode (const char* data, uint32_t options)
-{
- if (!data || data[0] == 0)
- return SBTypeSynthetic();
- return SBTypeSynthetic(ScriptedSyntheticChildrenSP(new ScriptedSyntheticChildren(options, "", data)));
-}
-
-SBTypeSynthetic::SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs) :
-m_opaque_sp(rhs.m_opaque_sp)
-{
-}
-
-SBTypeSynthetic::~SBTypeSynthetic ()
-{
-}
-
-bool
-SBTypeSynthetic::IsValid() const
-{
- return m_opaque_sp.get() != NULL;
-}
-
-bool
-SBTypeSynthetic::IsClassCode()
-{
- if (!IsValid())
- return false;
- const char* code = m_opaque_sp->GetPythonCode();
- return (code && *code);
-}
-
-bool
-SBTypeSynthetic::IsClassName()
-{
- if (!IsValid())
- return false;
- return !IsClassCode();
-}
-
-const char*
-SBTypeSynthetic::GetData ()
-{
- if (!IsValid())
- return NULL;
- if (IsClassCode())
- return m_opaque_sp->GetPythonCode();
- else
- return m_opaque_sp->GetPythonClassName();
-}
-
-void
-SBTypeSynthetic::SetClassName (const char* data)
-{
- if (IsValid() && data && *data)
- m_opaque_sp->SetPythonClassName(data);
-}
-
-void
-SBTypeSynthetic::SetClassCode (const char* data)
-{
- if (IsValid() && data && *data)
- m_opaque_sp->SetPythonCode(data);
-}
-
-uint32_t
-SBTypeSynthetic::GetOptions ()
-{
- if (!IsValid())
- return lldb::eTypeOptionNone;
- return m_opaque_sp->GetOptions();
-}
-
-void
-SBTypeSynthetic::SetOptions (uint32_t value)
-{
- if (!CopyOnWrite_Impl())
- return;
- m_opaque_sp->SetOptions(value);
-}
-
-bool
-SBTypeSynthetic::GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level)
-{
- if (m_opaque_sp)
- {
- description.Printf("%s\n",
- m_opaque_sp->GetDescription().c_str());
- return true;
- }
- return false;
-}
-
-lldb::SBTypeSynthetic &
-SBTypeSynthetic::operator = (const lldb::SBTypeSynthetic &rhs)
-{
- if (this != &rhs)
- {
- m_opaque_sp = rhs.m_opaque_sp;
- }
- return *this;
-}
-
-bool
-SBTypeSynthetic::operator == (lldb::SBTypeSynthetic &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
- return m_opaque_sp == rhs.m_opaque_sp;
-}
-
-bool
-SBTypeSynthetic::IsEqualTo (lldb::SBTypeSynthetic &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
-
- if (m_opaque_sp->IsScripted() != rhs.m_opaque_sp->IsScripted())
- return false;
-
- if (IsClassCode() != rhs.IsClassCode())
- return false;
-
- if ( strcmp(GetData(), rhs.GetData()) )
- return false;
-
- return GetOptions() == rhs.GetOptions();
-
-}
-
-bool
-SBTypeSynthetic::operator != (lldb::SBTypeSynthetic &rhs)
-{
- if (IsValid() == false)
- return !rhs.IsValid();
- return m_opaque_sp != rhs.m_opaque_sp;
-}
-
-lldb::ScriptedSyntheticChildrenSP
-SBTypeSynthetic::GetSP ()
-{
- return m_opaque_sp;
-}
-
-void
-SBTypeSynthetic::SetSP (const lldb::ScriptedSyntheticChildrenSP &TypeSynthetic_impl_sp)
-{
- m_opaque_sp = TypeSynthetic_impl_sp;
-}
-
-SBTypeSynthetic::SBTypeSynthetic (const lldb::ScriptedSyntheticChildrenSP &TypeSynthetic_impl_sp) :
-m_opaque_sp(TypeSynthetic_impl_sp)
-{
-}
-
-bool
-SBTypeSynthetic::CopyOnWrite_Impl()
-{
- if (!IsValid())
- return false;
- if (m_opaque_sp.unique())
- return true;
-
- ScriptedSyntheticChildrenSP new_sp(new ScriptedSyntheticChildren(m_opaque_sp->GetOptions(),
- m_opaque_sp->GetPythonClassName(),
- m_opaque_sp->GetPythonCode()));
-
- SetSP(new_sp);
-
+SBTypeSynthetic::SBTypeSynthetic() : m_opaque_sp() {}
+
+SBTypeSynthetic SBTypeSynthetic::CreateWithClassName(const char *data,
+ uint32_t options) {
+ if (!data || data[0] == 0)
+ return SBTypeSynthetic();
+ return SBTypeSynthetic(ScriptedSyntheticChildrenSP(
+ new ScriptedSyntheticChildren(options, data, "")));
+}
+
+SBTypeSynthetic SBTypeSynthetic::CreateWithScriptCode(const char *data,
+ uint32_t options) {
+ if (!data || data[0] == 0)
+ return SBTypeSynthetic();
+ return SBTypeSynthetic(ScriptedSyntheticChildrenSP(
+ new ScriptedSyntheticChildren(options, "", data)));
+}
+
+SBTypeSynthetic::SBTypeSynthetic(const lldb::SBTypeSynthetic &rhs)
+ : m_opaque_sp(rhs.m_opaque_sp) {}
+
+SBTypeSynthetic::~SBTypeSynthetic() {}
+
+bool SBTypeSynthetic::IsValid() const { return m_opaque_sp.get() != NULL; }
+
+bool SBTypeSynthetic::IsClassCode() {
+ if (!IsValid())
+ return false;
+ const char *code = m_opaque_sp->GetPythonCode();
+ return (code && *code);
+}
+
+bool SBTypeSynthetic::IsClassName() {
+ if (!IsValid())
+ return false;
+ return !IsClassCode();
+}
+
+const char *SBTypeSynthetic::GetData() {
+ if (!IsValid())
+ return NULL;
+ if (IsClassCode())
+ return m_opaque_sp->GetPythonCode();
+ else
+ return m_opaque_sp->GetPythonClassName();
+}
+
+void SBTypeSynthetic::SetClassName(const char *data) {
+ if (IsValid() && data && *data)
+ m_opaque_sp->SetPythonClassName(data);
+}
+
+void SBTypeSynthetic::SetClassCode(const char *data) {
+ if (IsValid() && data && *data)
+ m_opaque_sp->SetPythonCode(data);
+}
+
+uint32_t SBTypeSynthetic::GetOptions() {
+ if (!IsValid())
+ return lldb::eTypeOptionNone;
+ return m_opaque_sp->GetOptions();
+}
+
+void SBTypeSynthetic::SetOptions(uint32_t value) {
+ if (!CopyOnWrite_Impl())
+ return;
+ m_opaque_sp->SetOptions(value);
+}
+
+bool SBTypeSynthetic::GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level) {
+ if (m_opaque_sp) {
+ description.Printf("%s\n", m_opaque_sp->GetDescription().c_str());
return true;
+ }
+ return false;
+}
+
+lldb::SBTypeSynthetic &SBTypeSynthetic::
+operator=(const lldb::SBTypeSynthetic &rhs) {
+ if (this != &rhs) {
+ m_opaque_sp = rhs.m_opaque_sp;
+ }
+ return *this;
+}
+
+bool SBTypeSynthetic::operator==(lldb::SBTypeSynthetic &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+ return m_opaque_sp == rhs.m_opaque_sp;
+}
+
+bool SBTypeSynthetic::IsEqualTo(lldb::SBTypeSynthetic &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+
+ if (m_opaque_sp->IsScripted() != rhs.m_opaque_sp->IsScripted())
+ return false;
+
+ if (IsClassCode() != rhs.IsClassCode())
+ return false;
+
+ if (strcmp(GetData(), rhs.GetData()))
+ return false;
+
+ return GetOptions() == rhs.GetOptions();
+}
+
+bool SBTypeSynthetic::operator!=(lldb::SBTypeSynthetic &rhs) {
+ if (IsValid() == false)
+ return !rhs.IsValid();
+ return m_opaque_sp != rhs.m_opaque_sp;
+}
+
+lldb::ScriptedSyntheticChildrenSP SBTypeSynthetic::GetSP() {
+ return m_opaque_sp;
+}
+
+void SBTypeSynthetic::SetSP(
+ const lldb::ScriptedSyntheticChildrenSP &TypeSynthetic_impl_sp) {
+ m_opaque_sp = TypeSynthetic_impl_sp;
+}
+
+SBTypeSynthetic::SBTypeSynthetic(
+ const lldb::ScriptedSyntheticChildrenSP &TypeSynthetic_impl_sp)
+ : m_opaque_sp(TypeSynthetic_impl_sp) {}
+
+bool SBTypeSynthetic::CopyOnWrite_Impl() {
+ if (!IsValid())
+ return false;
+ if (m_opaque_sp.unique())
+ return true;
+
+ ScriptedSyntheticChildrenSP new_sp(new ScriptedSyntheticChildren(
+ m_opaque_sp->GetOptions(), m_opaque_sp->GetPythonClassName(),
+ m_opaque_sp->GetPythonCode()));
+
+ SetSP(new_sp);
+
+ return true;
}
#endif // LLDB_DISABLE_PYTHON
Modified: lldb/trunk/source/API/SBUnixSignals.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBUnixSignals.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBUnixSignals.cpp (original)
+++ lldb/trunk/source/API/SBUnixSignals.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- SBUnixSignals.cpp -------------------------------------------*- C++ -*-===//
+//===-- SBUnixSignals.cpp -------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,190 +8,136 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-defines.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Core/Log.h"
#include "lldb/Target/Platform.h"
+#include "lldb/Target/Process.h"
#include "lldb/Target/UnixSignals.h"
-#include "lldb/Core/Log.h"
+#include "lldb/lldb-defines.h"
#include "lldb/API/SBUnixSignals.h"
using namespace lldb;
using namespace lldb_private;
-SBUnixSignals::SBUnixSignals ()
-{}
+SBUnixSignals::SBUnixSignals() {}
-SBUnixSignals::SBUnixSignals (const SBUnixSignals &rhs) :
- m_opaque_wp(rhs.m_opaque_wp)
-{
-}
+SBUnixSignals::SBUnixSignals(const SBUnixSignals &rhs)
+ : m_opaque_wp(rhs.m_opaque_wp) {}
-SBUnixSignals::SBUnixSignals(ProcessSP &process_sp) :
- m_opaque_wp(process_sp ? process_sp->GetUnixSignals() : nullptr)
-{
-}
+SBUnixSignals::SBUnixSignals(ProcessSP &process_sp)
+ : m_opaque_wp(process_sp ? process_sp->GetUnixSignals() : nullptr) {}
-SBUnixSignals::SBUnixSignals(PlatformSP &platform_sp) :
- m_opaque_wp(platform_sp ? platform_sp->GetUnixSignals() : nullptr)
-{
-}
+SBUnixSignals::SBUnixSignals(PlatformSP &platform_sp)
+ : m_opaque_wp(platform_sp ? platform_sp->GetUnixSignals() : nullptr) {}
-const SBUnixSignals&
-SBUnixSignals::operator = (const SBUnixSignals& rhs)
-{
- if (this != &rhs)
- m_opaque_wp = rhs.m_opaque_wp;
- return *this;
+const SBUnixSignals &SBUnixSignals::operator=(const SBUnixSignals &rhs) {
+ if (this != &rhs)
+ m_opaque_wp = rhs.m_opaque_wp;
+ return *this;
}
-SBUnixSignals::~SBUnixSignals()
-{
-}
+SBUnixSignals::~SBUnixSignals() {}
-UnixSignalsSP
-SBUnixSignals::GetSP() const
-{
- return m_opaque_wp.lock();
-}
+UnixSignalsSP SBUnixSignals::GetSP() const { return m_opaque_wp.lock(); }
-void
-SBUnixSignals::SetSP(const UnixSignalsSP &signals_sp)
-{
- m_opaque_wp = signals_sp;
+void SBUnixSignals::SetSP(const UnixSignalsSP &signals_sp) {
+ m_opaque_wp = signals_sp;
}
-void
-SBUnixSignals::Clear ()
-{
- m_opaque_wp.reset();
-}
+void SBUnixSignals::Clear() { m_opaque_wp.reset(); }
-bool
-SBUnixSignals::IsValid() const
-{
- return static_cast<bool>(GetSP());
-}
+bool SBUnixSignals::IsValid() const { return static_cast<bool>(GetSP()); }
-const char *
-SBUnixSignals::GetSignalAsCString (int32_t signo) const
-{
- if (auto signals_sp = GetSP())
- return signals_sp->GetSignalAsCString(signo);
+const char *SBUnixSignals::GetSignalAsCString(int32_t signo) const {
+ if (auto signals_sp = GetSP())
+ return signals_sp->GetSignalAsCString(signo);
- return nullptr;
+ return nullptr;
}
-int32_t
-SBUnixSignals::GetSignalNumberFromName (const char *name) const
-{
- if (auto signals_sp = GetSP())
- return signals_sp->GetSignalNumberFromName(name);
+int32_t SBUnixSignals::GetSignalNumberFromName(const char *name) const {
+ if (auto signals_sp = GetSP())
+ return signals_sp->GetSignalNumberFromName(name);
- return LLDB_INVALID_SIGNAL_NUMBER;
+ return LLDB_INVALID_SIGNAL_NUMBER;
}
-bool
-SBUnixSignals::GetShouldSuppress (int32_t signo) const
-{
- if (auto signals_sp = GetSP())
- return signals_sp->GetShouldSuppress(signo);
+bool SBUnixSignals::GetShouldSuppress(int32_t signo) const {
+ if (auto signals_sp = GetSP())
+ return signals_sp->GetShouldSuppress(signo);
- return false;
+ return false;
}
-bool
-SBUnixSignals::SetShouldSuppress (int32_t signo, bool value)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- auto signals_sp = GetSP();
+bool SBUnixSignals::SetShouldSuppress(int32_t signo, bool value) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ auto signals_sp = GetSP();
- if (log)
- {
- log->Printf ("SBUnixSignals(%p)::SetShouldSuppress (signo=%d, value=%d)",
- static_cast<void*>(signals_sp.get()),
- signo,
- value);
- }
+ if (log) {
+ log->Printf("SBUnixSignals(%p)::SetShouldSuppress (signo=%d, value=%d)",
+ static_cast<void *>(signals_sp.get()), signo, value);
+ }
- if (signals_sp)
- return signals_sp->SetShouldSuppress(signo, value);
+ if (signals_sp)
+ return signals_sp->SetShouldSuppress(signo, value);
- return false;
+ return false;
}
-bool
-SBUnixSignals::GetShouldStop (int32_t signo) const
-{
- if (auto signals_sp = GetSP())
- return signals_sp->GetShouldStop(signo);
+bool SBUnixSignals::GetShouldStop(int32_t signo) const {
+ if (auto signals_sp = GetSP())
+ return signals_sp->GetShouldStop(signo);
- return false;
+ return false;
}
-bool
-SBUnixSignals::SetShouldStop (int32_t signo, bool value)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- auto signals_sp = GetSP();
+bool SBUnixSignals::SetShouldStop(int32_t signo, bool value) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ auto signals_sp = GetSP();
- if (log)
- {
- log->Printf ("SBUnixSignals(%p)::SetShouldStop (signo=%d, value=%d)",
- static_cast<void*>(signals_sp.get()),
- signo,
- value);
- }
+ if (log) {
+ log->Printf("SBUnixSignals(%p)::SetShouldStop (signo=%d, value=%d)",
+ static_cast<void *>(signals_sp.get()), signo, value);
+ }
- if (signals_sp)
- return signals_sp->SetShouldStop(signo, value);
+ if (signals_sp)
+ return signals_sp->SetShouldStop(signo, value);
- return false;
+ return false;
}
-bool
-SBUnixSignals::GetShouldNotify (int32_t signo) const
-{
- if (auto signals_sp = GetSP())
- return signals_sp->GetShouldNotify(signo);
+bool SBUnixSignals::GetShouldNotify(int32_t signo) const {
+ if (auto signals_sp = GetSP())
+ return signals_sp->GetShouldNotify(signo);
- return false;
+ return false;
}
-bool
-SBUnixSignals::SetShouldNotify (int32_t signo, bool value)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- auto signals_sp = GetSP();
+bool SBUnixSignals::SetShouldNotify(int32_t signo, bool value) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ auto signals_sp = GetSP();
- if (log)
- {
- log->Printf ("SBUnixSignals(%p)::SetShouldNotify (signo=%d, value=%d)",
- static_cast<void*>(signals_sp.get()),
- signo,
- value);
- }
+ if (log) {
+ log->Printf("SBUnixSignals(%p)::SetShouldNotify (signo=%d, value=%d)",
+ static_cast<void *>(signals_sp.get()), signo, value);
+ }
- if (signals_sp)
- return signals_sp->SetShouldNotify(signo, value);
+ if (signals_sp)
+ return signals_sp->SetShouldNotify(signo, value);
- return false;
+ return false;
}
-int32_t
-SBUnixSignals::GetNumSignals () const
-{
- if (auto signals_sp = GetSP())
- return signals_sp->GetNumSignals();
+int32_t SBUnixSignals::GetNumSignals() const {
+ if (auto signals_sp = GetSP())
+ return signals_sp->GetNumSignals();
- return -1;
+ return -1;
}
-int32_t
-SBUnixSignals::GetSignalAtIndex (int32_t index) const
-{
- if (auto signals_sp = GetSP())
- return signals_sp->GetSignalAtIndex(index);
+int32_t SBUnixSignals::GetSignalAtIndex(int32_t index) const {
+ if (auto signals_sp = GetSP())
+ return signals_sp->GetSignalAtIndex(index);
- return LLDB_INVALID_SIGNAL_NUMBER;
+ return LLDB_INVALID_SIGNAL_NUMBER;
}
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Tue Sep 6 15:57:50 2016
@@ -50,1864 +50,1558 @@
using namespace lldb;
using namespace lldb_private;
-class ValueImpl
-{
+class ValueImpl {
public:
- ValueImpl ()
- {
- }
+ ValueImpl() {}
- ValueImpl (lldb::ValueObjectSP in_valobj_sp,
- lldb::DynamicValueType use_dynamic,
- bool use_synthetic,
- const char *name = NULL) :
- m_valobj_sp(),
- m_use_dynamic(use_dynamic),
- m_use_synthetic(use_synthetic),
- m_name (name)
- {
- if (in_valobj_sp)
- {
- if ( (m_valobj_sp = in_valobj_sp->GetQualifiedRepresentationIfAvailable(lldb::eNoDynamicValues, false)) )
- {
- if (!m_name.IsEmpty())
- m_valobj_sp->SetName(m_name);
- }
- }
+ ValueImpl(lldb::ValueObjectSP in_valobj_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ const char *name = NULL)
+ : m_valobj_sp(), m_use_dynamic(use_dynamic),
+ m_use_synthetic(use_synthetic), m_name(name) {
+ if (in_valobj_sp) {
+ if ((m_valobj_sp = in_valobj_sp->GetQualifiedRepresentationIfAvailable(
+ lldb::eNoDynamicValues, false))) {
+ if (!m_name.IsEmpty())
+ m_valobj_sp->SetName(m_name);
+ }
}
+ }
- ValueImpl (const ValueImpl& rhs) :
- m_valobj_sp(rhs.m_valobj_sp),
- m_use_dynamic(rhs.m_use_dynamic),
- m_use_synthetic(rhs.m_use_synthetic),
- m_name (rhs.m_name)
- {
+ ValueImpl(const ValueImpl &rhs)
+ : m_valobj_sp(rhs.m_valobj_sp), m_use_dynamic(rhs.m_use_dynamic),
+ m_use_synthetic(rhs.m_use_synthetic), m_name(rhs.m_name) {}
+
+ ValueImpl &operator=(const ValueImpl &rhs) {
+ if (this != &rhs) {
+ m_valobj_sp = rhs.m_valobj_sp;
+ m_use_dynamic = rhs.m_use_dynamic;
+ m_use_synthetic = rhs.m_use_synthetic;
+ m_name = rhs.m_name;
}
+ return *this;
+ }
- ValueImpl &
- operator = (const ValueImpl &rhs)
- {
- if (this != &rhs)
- {
- m_valobj_sp = rhs.m_valobj_sp;
- m_use_dynamic = rhs.m_use_dynamic;
- m_use_synthetic = rhs.m_use_synthetic;
- m_name = rhs.m_name;
- }
- return *this;
+ bool IsValid() {
+ if (m_valobj_sp.get() == NULL)
+ return false;
+ else {
+ // FIXME: This check is necessary but not sufficient. We for sure don't
+ // want to touch SBValues whose owning
+ // targets have gone away. This check is a little weak in that it
+ // enforces that restriction when you call
+ // IsValid, but since IsValid doesn't lock the target, you have no
+ // guarantee that the SBValue won't go
+ // invalid after you call this...
+ // Also, an SBValue could depend on data from one of the modules in the
+ // target, and those could go away
+ // independently of the target, for instance if a module is unloaded. But
+ // right now, neither SBValues
+ // nor ValueObjects know which modules they depend on. So I have no good
+ // way to make that check without
+ // tracking that in all the ValueObject subclasses.
+ TargetSP target_sp = m_valobj_sp->GetTargetSP();
+ if (target_sp && target_sp->IsValid())
+ return true;
+ else
+ return false;
}
+ }
- bool
- IsValid ()
- {
- if (m_valobj_sp.get() == NULL)
- return false;
- else
- {
- // FIXME: This check is necessary but not sufficient. We for sure don't want to touch SBValues whose owning
- // targets have gone away. This check is a little weak in that it enforces that restriction when you call
- // IsValid, but since IsValid doesn't lock the target, you have no guarantee that the SBValue won't go
- // invalid after you call this...
- // Also, an SBValue could depend on data from one of the modules in the target, and those could go away
- // independently of the target, for instance if a module is unloaded. But right now, neither SBValues
- // nor ValueObjects know which modules they depend on. So I have no good way to make that check without
- // tracking that in all the ValueObject subclasses.
- TargetSP target_sp = m_valobj_sp->GetTargetSP();
- if (target_sp && target_sp->IsValid())
- return true;
- else
- return false;
- }
- }
+ lldb::ValueObjectSP GetRootSP() { return m_valobj_sp; }
- lldb::ValueObjectSP
- GetRootSP ()
- {
- return m_valobj_sp;
+ lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker,
+ std::unique_lock<std::recursive_mutex> &lock,
+ Error &error) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (!m_valobj_sp) {
+ error.SetErrorString("invalid value object");
+ return m_valobj_sp;
}
- lldb::ValueObjectSP
- GetSP(Process::StopLocker &stop_locker, std::unique_lock<std::recursive_mutex> &lock, Error &error)
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (!m_valobj_sp)
- {
- error.SetErrorString("invalid value object");
- return m_valobj_sp;
- }
+ lldb::ValueObjectSP value_sp = m_valobj_sp;
- lldb::ValueObjectSP value_sp = m_valobj_sp;
+ Target *target = value_sp->GetTargetSP().get();
+ if (!target)
+ return ValueObjectSP();
- Target *target = value_sp->GetTargetSP().get();
- if (!target)
- return ValueObjectSP();
-
- lock = std::unique_lock<std::recursive_mutex>(target->GetAPIMutex());
-
- ProcessSP process_sp(value_sp->GetProcessSP());
- if (process_sp && !stop_locker.TryLock (&process_sp->GetRunLock()))
- {
- // We don't allow people to play around with ValueObject if the process is running.
- // If you want to look at values, pause the process, then look.
- if (log)
- log->Printf ("SBValue(%p)::GetSP() => error: process is running",
- static_cast<void*>(value_sp.get()));
- error.SetErrorString ("process must be stopped.");
- return ValueObjectSP();
- }
-
- if (m_use_dynamic != eNoDynamicValues)
- {
- ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(m_use_dynamic);
- if (dynamic_sp)
- value_sp = dynamic_sp;
- }
-
- if (m_use_synthetic)
- {
- ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue(m_use_synthetic);
- if (synthetic_sp)
- value_sp = synthetic_sp;
- }
+ lock = std::unique_lock<std::recursive_mutex>(target->GetAPIMutex());
- if (!value_sp)
- error.SetErrorString("invalid value object");
- if (!m_name.IsEmpty())
- value_sp->SetName(m_name);
-
- return value_sp;
+ ProcessSP process_sp(value_sp->GetProcessSP());
+ if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock())) {
+ // We don't allow people to play around with ValueObject if the process is
+ // running.
+ // If you want to look at values, pause the process, then look.
+ if (log)
+ log->Printf("SBValue(%p)::GetSP() => error: process is running",
+ static_cast<void *>(value_sp.get()));
+ error.SetErrorString("process must be stopped.");
+ return ValueObjectSP();
}
- void
- SetUseDynamic (lldb::DynamicValueType use_dynamic)
- {
- m_use_dynamic = use_dynamic;
+ if (m_use_dynamic != eNoDynamicValues) {
+ ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(m_use_dynamic);
+ if (dynamic_sp)
+ value_sp = dynamic_sp;
}
- void
- SetUseSynthetic (bool use_synthetic)
- {
- m_use_synthetic = use_synthetic;
+ if (m_use_synthetic) {
+ ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue(m_use_synthetic);
+ if (synthetic_sp)
+ value_sp = synthetic_sp;
}
- lldb::DynamicValueType
- GetUseDynamic ()
- {
- return m_use_dynamic;
- }
+ if (!value_sp)
+ error.SetErrorString("invalid value object");
+ if (!m_name.IsEmpty())
+ value_sp->SetName(m_name);
- bool
- GetUseSynthetic ()
- {
- return m_use_synthetic;
- }
+ return value_sp;
+ }
- // All the derived values that we would make from the m_valobj_sp will share
- // the ExecutionContext with m_valobj_sp, so we don't need to do the calculations
- // in GetSP to return the Target, Process, Thread or Frame. It is convenient to
- // provide simple accessors for these, which I do here.
- TargetSP
- GetTargetSP ()
- {
- if (m_valobj_sp)
- return m_valobj_sp->GetTargetSP();
- else
- return TargetSP();
- }
+ void SetUseDynamic(lldb::DynamicValueType use_dynamic) {
+ m_use_dynamic = use_dynamic;
+ }
- ProcessSP
- GetProcessSP ()
- {
- if (m_valobj_sp)
- return m_valobj_sp->GetProcessSP();
- else
- return ProcessSP();
- }
+ void SetUseSynthetic(bool use_synthetic) { m_use_synthetic = use_synthetic; }
- ThreadSP
- GetThreadSP ()
- {
- if (m_valobj_sp)
- return m_valobj_sp->GetThreadSP();
- else
- return ThreadSP();
- }
+ lldb::DynamicValueType GetUseDynamic() { return m_use_dynamic; }
- StackFrameSP
- GetFrameSP ()
- {
- if (m_valobj_sp)
- return m_valobj_sp->GetFrameSP();
- else
- return StackFrameSP();
- }
+ bool GetUseSynthetic() { return m_use_synthetic; }
-private:
- lldb::ValueObjectSP m_valobj_sp;
- lldb::DynamicValueType m_use_dynamic;
- bool m_use_synthetic;
- ConstString m_name;
-};
+ // All the derived values that we would make from the m_valobj_sp will share
+ // the ExecutionContext with m_valobj_sp, so we don't need to do the
+ // calculations
+ // in GetSP to return the Target, Process, Thread or Frame. It is convenient
+ // to
+ // provide simple accessors for these, which I do here.
+ TargetSP GetTargetSP() {
+ if (m_valobj_sp)
+ return m_valobj_sp->GetTargetSP();
+ else
+ return TargetSP();
+ }
-class ValueLocker
-{
-public:
- ValueLocker ()
- {
- }
+ ProcessSP GetProcessSP() {
+ if (m_valobj_sp)
+ return m_valobj_sp->GetProcessSP();
+ else
+ return ProcessSP();
+ }
- ValueObjectSP
- GetLockedSP(ValueImpl &in_value)
- {
- return in_value.GetSP(m_stop_locker, m_lock, m_lock_error);
- }
+ ThreadSP GetThreadSP() {
+ if (m_valobj_sp)
+ return m_valobj_sp->GetThreadSP();
+ else
+ return ThreadSP();
+ }
+
+ StackFrameSP GetFrameSP() {
+ if (m_valobj_sp)
+ return m_valobj_sp->GetFrameSP();
+ else
+ return StackFrameSP();
+ }
- Error &
- GetError()
- {
- return m_lock_error;
- }
-
private:
- Process::StopLocker m_stop_locker;
- std::unique_lock<std::recursive_mutex> m_lock;
- Error m_lock_error;
+ lldb::ValueObjectSP m_valobj_sp;
+ lldb::DynamicValueType m_use_dynamic;
+ bool m_use_synthetic;
+ ConstString m_name;
};
-SBValue::SBValue () :
-m_opaque_sp ()
-{
-}
+class ValueLocker {
+public:
+ ValueLocker() {}
-SBValue::SBValue (const lldb::ValueObjectSP &value_sp)
-{
- SetSP(value_sp);
-}
+ ValueObjectSP GetLockedSP(ValueImpl &in_value) {
+ return in_value.GetSP(m_stop_locker, m_lock, m_lock_error);
+ }
-SBValue::SBValue(const SBValue &rhs)
-{
- SetSP(rhs.m_opaque_sp);
-}
+ Error &GetError() { return m_lock_error; }
-SBValue &
-SBValue::operator = (const SBValue &rhs)
-{
- if (this != &rhs)
- {
- SetSP(rhs.m_opaque_sp);
- }
- return *this;
-}
+private:
+ Process::StopLocker m_stop_locker;
+ std::unique_lock<std::recursive_mutex> m_lock;
+ Error m_lock_error;
+};
-SBValue::~SBValue()
-{
-}
+SBValue::SBValue() : m_opaque_sp() {}
-bool
-SBValue::IsValid ()
-{
- // If this function ever changes to anything that does more than just
- // check if the opaque shared pointer is non NULL, then we need to update
- // all "if (m_opaque_sp)" code in this file.
- return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid() && m_opaque_sp->GetRootSP().get() != NULL;
-}
-
-void
-SBValue::Clear()
-{
- m_opaque_sp.reset();
-}
-
-SBError
-SBValue::GetError()
-{
- SBError sb_error;
-
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- sb_error.SetError(value_sp->GetError());
- else
- sb_error.SetErrorStringWithFormat ("error: %s", locker.GetError().AsCString());
-
- return sb_error;
-}
-
-user_id_t
-SBValue::GetID()
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- return value_sp->GetID();
- return LLDB_INVALID_UID;
-}
-
-const char *
-SBValue::GetName()
-{
- const char *name = NULL;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- name = value_sp->GetName().GetCString();
+SBValue::SBValue(const lldb::ValueObjectSP &value_sp) { SetSP(value_sp); }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- if (name)
- log->Printf ("SBValue(%p)::GetName () => \"%s\"",
- static_cast<void*>(value_sp.get()), name);
- else
- log->Printf ("SBValue(%p)::GetName () => NULL",
- static_cast<void*>(value_sp.get()));
- }
+SBValue::SBValue(const SBValue &rhs) { SetSP(rhs.m_opaque_sp); }
- return name;
+SBValue &SBValue::operator=(const SBValue &rhs) {
+ if (this != &rhs) {
+ SetSP(rhs.m_opaque_sp);
+ }
+ return *this;
}
-const char *
-SBValue::GetTypeName ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- const char *name = NULL;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- name = value_sp->GetQualifiedTypeName().GetCString();
- }
+SBValue::~SBValue() {}
- if (log)
- {
- if (name)
- log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"",
- static_cast<void*>(value_sp.get()), name);
- else
- log->Printf ("SBValue(%p)::GetTypeName () => NULL",
- static_cast<void*>(value_sp.get()));
- }
-
- return name;
-}
-
-const char *
-SBValue::GetDisplayTypeName ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- const char *name = NULL;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- name = value_sp->GetDisplayTypeName().GetCString();
- }
-
- if (log)
- {
- if (name)
- log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"",
- static_cast<void*>(value_sp.get()), name);
- else
- log->Printf ("SBValue(%p)::GetTypeName () => NULL",
- static_cast<void*>(value_sp.get()));
- }
-
- return name;
+bool SBValue::IsValid() {
+ // If this function ever changes to anything that does more than just
+ // check if the opaque shared pointer is non NULL, then we need to update
+ // all "if (m_opaque_sp)" code in this file.
+ return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid() &&
+ m_opaque_sp->GetRootSP().get() != NULL;
}
-size_t
-SBValue::GetByteSize ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- size_t result = 0;
-
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- result = value_sp->GetByteSize();
- }
+void SBValue::Clear() { m_opaque_sp.reset(); }
- if (log)
- log->Printf ("SBValue(%p)::GetByteSize () => %" PRIu64,
- static_cast<void*>(value_sp.get()),
- static_cast<uint64_t>(result));
-
- return result;
-}
-
-bool
-SBValue::IsInScope ()
-{
- bool result = false;
-
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- result = value_sp->IsInScope ();
- }
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBValue(%p)::IsInScope () => %i",
- static_cast<void*>(value_sp.get()), result);
-
- return result;
-}
+SBError SBValue::GetError() {
+ SBError sb_error;
-const char *
-SBValue::GetValue ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- const char *cstr = NULL;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- cstr = value_sp->GetValueAsCString ();
- }
- if (log)
- {
- if (cstr)
- log->Printf ("SBValue(%p)::GetValue() => \"%s\"",
- static_cast<void*>(value_sp.get()), cstr);
- else
- log->Printf ("SBValue(%p)::GetValue() => NULL",
- static_cast<void*>(value_sp.get()));
- }
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ sb_error.SetError(value_sp->GetError());
+ else
+ sb_error.SetErrorStringWithFormat("error: %s",
+ locker.GetError().AsCString());
- return cstr;
+ return sb_error;
}
-ValueType
-SBValue::GetValueType ()
-{
- ValueType result = eValueTypeInvalid;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- result = value_sp->GetValueType();
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- switch (result)
- {
- case eValueTypeInvalid:
- log->Printf ("SBValue(%p)::GetValueType () => eValueTypeInvalid",
- static_cast<void*>(value_sp.get()));
- break;
- case eValueTypeVariableGlobal:
- log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal",
- static_cast<void*>(value_sp.get()));
- break;
- case eValueTypeVariableStatic:
- log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableStatic",
- static_cast<void*>(value_sp.get()));
- break;
- case eValueTypeVariableArgument:
- log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableArgument",
- static_cast<void*>(value_sp.get()));
- break;
- case eValueTypeVariableLocal:
- log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableLocal",
- static_cast<void*>(value_sp.get()));
- break;
- case eValueTypeRegister:
- log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegister",
- static_cast<void*>(value_sp.get()));
- break;
- case eValueTypeRegisterSet:
- log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegisterSet",
- static_cast<void*>(value_sp.get()));
- break;
- case eValueTypeConstResult:
- log->Printf ("SBValue(%p)::GetValueType () => eValueTypeConstResult",
- static_cast<void*>(value_sp.get()));
- break;
- case eValueTypeVariableThreadLocal:
- log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableThreadLocal",
- static_cast<void *>(value_sp.get()));
- break;
- }
- }
- return result;
+user_id_t SBValue::GetID() {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ return value_sp->GetID();
+ return LLDB_INVALID_UID;
}
-const char *
-SBValue::GetObjectDescription ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- const char *cstr = NULL;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- cstr = value_sp->GetObjectDescription ();
- }
- if (log)
- {
- if (cstr)
- log->Printf ("SBValue(%p)::GetObjectDescription() => \"%s\"",
- static_cast<void*>(value_sp.get()), cstr);
- else
- log->Printf ("SBValue(%p)::GetObjectDescription() => NULL",
- static_cast<void*>(value_sp.get()));
- }
- return cstr;
-}
+const char *SBValue::GetName() {
+ const char *name = NULL;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ name = value_sp->GetName().GetCString();
-const char *
-SBValue::GetTypeValidatorResult ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- const char *cstr = NULL;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- const auto& validation(value_sp->GetValidationStatus());
- if (TypeValidatorResult::Failure == validation.first)
- {
- if (validation.second.empty())
- cstr = "unknown error";
- else
- cstr = validation.second.c_str();
- }
- }
- if (log)
- {
- if (cstr)
- log->Printf ("SBValue(%p)::GetTypeValidatorResult() => \"%s\"",
- static_cast<void*>(value_sp.get()), cstr);
- else
- log->Printf ("SBValue(%p)::GetTypeValidatorResult() => NULL",
- static_cast<void*>(value_sp.get()));
- }
- return cstr;
-}
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ if (name)
+ log->Printf("SBValue(%p)::GetName () => \"%s\"",
+ static_cast<void *>(value_sp.get()), name);
+ else
+ log->Printf("SBValue(%p)::GetName () => NULL",
+ static_cast<void *>(value_sp.get()));
+ }
+
+ return name;
+}
+
+const char *SBValue::GetTypeName() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ const char *name = NULL;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ name = value_sp->GetQualifiedTypeName().GetCString();
+ }
+
+ if (log) {
+ if (name)
+ log->Printf("SBValue(%p)::GetTypeName () => \"%s\"",
+ static_cast<void *>(value_sp.get()), name);
+ else
+ log->Printf("SBValue(%p)::GetTypeName () => NULL",
+ static_cast<void *>(value_sp.get()));
+ }
+
+ return name;
+}
+
+const char *SBValue::GetDisplayTypeName() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ const char *name = NULL;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ name = value_sp->GetDisplayTypeName().GetCString();
+ }
+
+ if (log) {
+ if (name)
+ log->Printf("SBValue(%p)::GetTypeName () => \"%s\"",
+ static_cast<void *>(value_sp.get()), name);
+ else
+ log->Printf("SBValue(%p)::GetTypeName () => NULL",
+ static_cast<void *>(value_sp.get()));
+ }
-SBType
-SBValue::GetType()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- SBType sb_type;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- TypeImplSP type_sp;
- if (value_sp)
- {
- type_sp.reset (new TypeImpl(value_sp->GetTypeImpl()));
- sb_type.SetSP(type_sp);
- }
- if (log)
- {
- if (type_sp)
- log->Printf ("SBValue(%p)::GetType => SBType(%p)",
- static_cast<void*>(value_sp.get()),
- static_cast<void*>(type_sp.get()));
- else
- log->Printf ("SBValue(%p)::GetType => NULL",
- static_cast<void*>(value_sp.get()));
- }
- return sb_type;
+ return name;
}
-bool
-SBValue::GetValueDidChange ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- bool result = false;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- if (value_sp->UpdateValueIfNeeded(false))
- result = value_sp->GetValueDidChange ();
- }
- if (log)
- log->Printf ("SBValue(%p)::GetValueDidChange() => %i",
- static_cast<void*>(value_sp.get()), result);
+size_t SBValue::GetByteSize() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ size_t result = 0;
- return result;
-}
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ result = value_sp->GetByteSize();
+ }
-const char *
-SBValue::GetSummary ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- const char *cstr = NULL;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- cstr = value_sp->GetSummaryAsCString();
- }
- if (log)
- {
- if (cstr)
- log->Printf ("SBValue(%p)::GetSummary() => \"%s\"",
- static_cast<void*>(value_sp.get()), cstr);
- else
- log->Printf ("SBValue(%p)::GetSummary() => NULL",
- static_cast<void*>(value_sp.get()));
- }
- return cstr;
-}
+ if (log)
+ log->Printf("SBValue(%p)::GetByteSize () => %" PRIu64,
+ static_cast<void *>(value_sp.get()),
+ static_cast<uint64_t>(result));
-const char *
-SBValue::GetSummary (lldb::SBStream& stream,
- lldb::SBTypeSummaryOptions& options)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- std::string buffer;
- if (value_sp->GetSummaryAsCString(buffer,options.ref()) && !buffer.empty())
- stream.Printf("%s",buffer.c_str());
- }
- const char* cstr = stream.GetData();
- if (log)
- {
- if (cstr)
- log->Printf ("SBValue(%p)::GetSummary() => \"%s\"",
- static_cast<void*>(value_sp.get()), cstr);
- else
- log->Printf ("SBValue(%p)::GetSummary() => NULL",
- static_cast<void*>(value_sp.get()));
- }
- return cstr;
+ return result;
}
-const char *
-SBValue::GetLocation ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- const char *cstr = NULL;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- cstr = value_sp->GetLocationAsCString();
- }
- if (log)
- {
- if (cstr)
- log->Printf ("SBValue(%p)::GetLocation() => \"%s\"",
- static_cast<void*>(value_sp.get()), cstr);
- else
- log->Printf ("SBValue(%p)::GetLocation() => NULL",
- static_cast<void*>(value_sp.get()));
- }
- return cstr;
-}
+bool SBValue::IsInScope() {
+ bool result = false;
-// Deprecated - use the one that takes an lldb::SBError
-bool
-SBValue::SetValueFromCString (const char *value_str)
-{
- lldb::SBError dummy;
- return SetValueFromCString(value_str,dummy);
-}
-
-bool
-SBValue::SetValueFromCString (const char *value_str, lldb::SBError& error)
-{
- bool success = false;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (value_sp)
- {
- success = value_sp->SetValueFromCString (value_str,error.ref());
- }
- else
- error.SetErrorStringWithFormat ("Could not get value: %s", locker.GetError().AsCString());
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ result = value_sp->IsInScope();
+ }
- if (log)
- log->Printf ("SBValue(%p)::SetValueFromCString(\"%s\") => %i",
- static_cast<void*>(value_sp.get()), value_str, success);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBValue(%p)::IsInScope () => %i",
+ static_cast<void *>(value_sp.get()), result);
- return success;
+ return result;
}
-lldb::SBTypeFormat
-SBValue::GetTypeFormat ()
-{
- lldb::SBTypeFormat format;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- if (value_sp->UpdateValueIfNeeded(true))
- {
- lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
- if (format_sp)
- format.SetSP(format_sp);
- }
- }
- return format;
-}
+const char *SBValue::GetValue() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-lldb::SBTypeSummary
-SBValue::GetTypeSummary ()
-{
- lldb::SBTypeSummary summary;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- if (value_sp->UpdateValueIfNeeded(true))
- {
- lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat();
- if (summary_sp)
- summary.SetSP(summary_sp);
- }
- }
- return summary;
+ const char *cstr = NULL;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ cstr = value_sp->GetValueAsCString();
+ }
+ if (log) {
+ if (cstr)
+ log->Printf("SBValue(%p)::GetValue() => \"%s\"",
+ static_cast<void *>(value_sp.get()), cstr);
+ else
+ log->Printf("SBValue(%p)::GetValue() => NULL",
+ static_cast<void *>(value_sp.get()));
+ }
+
+ return cstr;
+}
+
+ValueType SBValue::GetValueType() {
+ ValueType result = eValueTypeInvalid;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ result = value_sp->GetValueType();
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ switch (result) {
+ case eValueTypeInvalid:
+ log->Printf("SBValue(%p)::GetValueType () => eValueTypeInvalid",
+ static_cast<void *>(value_sp.get()));
+ break;
+ case eValueTypeVariableGlobal:
+ log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal",
+ static_cast<void *>(value_sp.get()));
+ break;
+ case eValueTypeVariableStatic:
+ log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableStatic",
+ static_cast<void *>(value_sp.get()));
+ break;
+ case eValueTypeVariableArgument:
+ log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableArgument",
+ static_cast<void *>(value_sp.get()));
+ break;
+ case eValueTypeVariableLocal:
+ log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableLocal",
+ static_cast<void *>(value_sp.get()));
+ break;
+ case eValueTypeRegister:
+ log->Printf("SBValue(%p)::GetValueType () => eValueTypeRegister",
+ static_cast<void *>(value_sp.get()));
+ break;
+ case eValueTypeRegisterSet:
+ log->Printf("SBValue(%p)::GetValueType () => eValueTypeRegisterSet",
+ static_cast<void *>(value_sp.get()));
+ break;
+ case eValueTypeConstResult:
+ log->Printf("SBValue(%p)::GetValueType () => eValueTypeConstResult",
+ static_cast<void *>(value_sp.get()));
+ break;
+ case eValueTypeVariableThreadLocal:
+ log->Printf(
+ "SBValue(%p)::GetValueType () => eValueTypeVariableThreadLocal",
+ static_cast<void *>(value_sp.get()));
+ break;
+ }
+ }
+ return result;
+}
+
+const char *SBValue::GetObjectDescription() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ const char *cstr = NULL;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ cstr = value_sp->GetObjectDescription();
+ }
+ if (log) {
+ if (cstr)
+ log->Printf("SBValue(%p)::GetObjectDescription() => \"%s\"",
+ static_cast<void *>(value_sp.get()), cstr);
+ else
+ log->Printf("SBValue(%p)::GetObjectDescription() => NULL",
+ static_cast<void *>(value_sp.get()));
+ }
+ return cstr;
+}
+
+const char *SBValue::GetTypeValidatorResult() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ const char *cstr = NULL;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ const auto &validation(value_sp->GetValidationStatus());
+ if (TypeValidatorResult::Failure == validation.first) {
+ if (validation.second.empty())
+ cstr = "unknown error";
+ else
+ cstr = validation.second.c_str();
+ }
+ }
+ if (log) {
+ if (cstr)
+ log->Printf("SBValue(%p)::GetTypeValidatorResult() => \"%s\"",
+ static_cast<void *>(value_sp.get()), cstr);
+ else
+ log->Printf("SBValue(%p)::GetTypeValidatorResult() => NULL",
+ static_cast<void *>(value_sp.get()));
+ }
+ return cstr;
+}
+
+SBType SBValue::GetType() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ SBType sb_type;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ TypeImplSP type_sp;
+ if (value_sp) {
+ type_sp.reset(new TypeImpl(value_sp->GetTypeImpl()));
+ sb_type.SetSP(type_sp);
+ }
+ if (log) {
+ if (type_sp)
+ log->Printf("SBValue(%p)::GetType => SBType(%p)",
+ static_cast<void *>(value_sp.get()),
+ static_cast<void *>(type_sp.get()));
+ else
+ log->Printf("SBValue(%p)::GetType => NULL",
+ static_cast<void *>(value_sp.get()));
+ }
+ return sb_type;
+}
+
+bool SBValue::GetValueDidChange() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ bool result = false;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ if (value_sp->UpdateValueIfNeeded(false))
+ result = value_sp->GetValueDidChange();
+ }
+ if (log)
+ log->Printf("SBValue(%p)::GetValueDidChange() => %i",
+ static_cast<void *>(value_sp.get()), result);
+
+ return result;
+}
+
+const char *SBValue::GetSummary() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ const char *cstr = NULL;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ cstr = value_sp->GetSummaryAsCString();
+ }
+ if (log) {
+ if (cstr)
+ log->Printf("SBValue(%p)::GetSummary() => \"%s\"",
+ static_cast<void *>(value_sp.get()), cstr);
+ else
+ log->Printf("SBValue(%p)::GetSummary() => NULL",
+ static_cast<void *>(value_sp.get()));
+ }
+ return cstr;
+}
+
+const char *SBValue::GetSummary(lldb::SBStream &stream,
+ lldb::SBTypeSummaryOptions &options) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ std::string buffer;
+ if (value_sp->GetSummaryAsCString(buffer, options.ref()) && !buffer.empty())
+ stream.Printf("%s", buffer.c_str());
+ }
+ const char *cstr = stream.GetData();
+ if (log) {
+ if (cstr)
+ log->Printf("SBValue(%p)::GetSummary() => \"%s\"",
+ static_cast<void *>(value_sp.get()), cstr);
+ else
+ log->Printf("SBValue(%p)::GetSummary() => NULL",
+ static_cast<void *>(value_sp.get()));
+ }
+ return cstr;
+}
+
+const char *SBValue::GetLocation() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ const char *cstr = NULL;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ cstr = value_sp->GetLocationAsCString();
+ }
+ if (log) {
+ if (cstr)
+ log->Printf("SBValue(%p)::GetLocation() => \"%s\"",
+ static_cast<void *>(value_sp.get()), cstr);
+ else
+ log->Printf("SBValue(%p)::GetLocation() => NULL",
+ static_cast<void *>(value_sp.get()));
+ }
+ return cstr;
}
-lldb::SBTypeFilter
-SBValue::GetTypeFilter ()
-{
- lldb::SBTypeFilter filter;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- if (value_sp->UpdateValueIfNeeded(true))
- {
- lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren();
-
- if (synthetic_sp && !synthetic_sp->IsScripted())
- {
- TypeFilterImplSP filter_sp = std::static_pointer_cast<TypeFilterImpl>(synthetic_sp);
- filter.SetSP(filter_sp);
- }
- }
+// Deprecated - use the one that takes an lldb::SBError
+bool SBValue::SetValueFromCString(const char *value_str) {
+ lldb::SBError dummy;
+ return SetValueFromCString(value_str, dummy);
+}
+
+bool SBValue::SetValueFromCString(const char *value_str, lldb::SBError &error) {
+ bool success = false;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (value_sp) {
+ success = value_sp->SetValueFromCString(value_str, error.ref());
+ } else
+ error.SetErrorStringWithFormat("Could not get value: %s",
+ locker.GetError().AsCString());
+
+ if (log)
+ log->Printf("SBValue(%p)::SetValueFromCString(\"%s\") => %i",
+ static_cast<void *>(value_sp.get()), value_str, success);
+
+ return success;
+}
+
+lldb::SBTypeFormat SBValue::GetTypeFormat() {
+ lldb::SBTypeFormat format;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ if (value_sp->UpdateValueIfNeeded(true)) {
+ lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
+ if (format_sp)
+ format.SetSP(format_sp);
+ }
+ }
+ return format;
+}
+
+lldb::SBTypeSummary SBValue::GetTypeSummary() {
+ lldb::SBTypeSummary summary;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ if (value_sp->UpdateValueIfNeeded(true)) {
+ lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat();
+ if (summary_sp)
+ summary.SetSP(summary_sp);
+ }
+ }
+ return summary;
+}
+
+lldb::SBTypeFilter SBValue::GetTypeFilter() {
+ lldb::SBTypeFilter filter;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ if (value_sp->UpdateValueIfNeeded(true)) {
+ lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren();
+
+ if (synthetic_sp && !synthetic_sp->IsScripted()) {
+ TypeFilterImplSP filter_sp =
+ std::static_pointer_cast<TypeFilterImpl>(synthetic_sp);
+ filter.SetSP(filter_sp);
+ }
}
- return filter;
+ }
+ return filter;
}
#ifndef LLDB_DISABLE_PYTHON
-lldb::SBTypeSynthetic
-SBValue::GetTypeSynthetic ()
-{
- lldb::SBTypeSynthetic synthetic;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- if (value_sp->UpdateValueIfNeeded(true))
- {
- lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren();
-
- if (children_sp && children_sp->IsScripted())
- {
- ScriptedSyntheticChildrenSP synth_sp = std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
- synthetic.SetSP(synth_sp);
- }
- }
+lldb::SBTypeSynthetic SBValue::GetTypeSynthetic() {
+ lldb::SBTypeSynthetic synthetic;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ if (value_sp->UpdateValueIfNeeded(true)) {
+ lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren();
+
+ if (children_sp && children_sp->IsScripted()) {
+ ScriptedSyntheticChildrenSP synth_sp =
+ std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
+ synthetic.SetSP(synth_sp);
+ }
}
- return synthetic;
+ }
+ return synthetic;
}
#endif
-lldb::SBValue
-SBValue::CreateChildAtOffset (const char *name, uint32_t offset, SBType type)
-{
- lldb::SBValue sb_value;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- lldb::ValueObjectSP new_value_sp;
- if (value_sp)
- {
- TypeImplSP type_sp (type.GetSP());
- if (type.IsValid())
- {
- sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(offset, type_sp->GetCompilerType(false), true),GetPreferDynamicValue(),GetPreferSyntheticValue(), name);
- }
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- if (new_value_sp)
- log->Printf ("SBValue(%p)::CreateChildAtOffset => \"%s\"",
- static_cast<void*>(value_sp.get()),
- new_value_sp->GetName().AsCString());
- else
- log->Printf ("SBValue(%p)::CreateChildAtOffset => NULL",
- static_cast<void*>(value_sp.get()));
- }
- return sb_value;
-}
-
-lldb::SBValue
-SBValue::Cast (SBType type)
-{
- lldb::SBValue sb_value;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- TypeImplSP type_sp (type.GetSP());
- if (value_sp && type_sp)
- sb_value.SetSP(value_sp->Cast(type_sp->GetCompilerType(false)),GetPreferDynamicValue(),GetPreferSyntheticValue());
- return sb_value;
-}
-
-lldb::SBValue
-SBValue::CreateValueFromExpression (const char *name, const char* expression)
-{
- SBExpressionOptions options;
- options.ref().SetKeepInMemory(true);
- return CreateValueFromExpression (name, expression, options);
-}
-
-lldb::SBValue
-SBValue::CreateValueFromExpression (const char *name, const char *expression, SBExpressionOptions &options)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- lldb::SBValue sb_value;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- lldb::ValueObjectSP new_value_sp;
- if (value_sp)
- {
- ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
- new_value_sp = ValueObject::CreateValueObjectFromExpression(name, expression, exe_ctx, options.ref());
- if (new_value_sp)
- new_value_sp->SetName(ConstString(name));
- }
- sb_value.SetSP(new_value_sp);
- if (log)
- {
- if (new_value_sp)
- log->Printf ("SBValue(%p)::CreateValueFromExpression(name=\"%s\", expression=\"%s\") => SBValue (%p)",
- static_cast<void*>(value_sp.get()), name, expression,
- static_cast<void*>(new_value_sp.get()));
- else
- log->Printf ("SBValue(%p)::CreateValueFromExpression(name=\"%s\", expression=\"%s\") => NULL",
- static_cast<void*>(value_sp.get()), name, expression);
- }
- return sb_value;
-}
-
-lldb::SBValue
-SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType sb_type)
-{
- lldb::SBValue sb_value;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- lldb::ValueObjectSP new_value_sp;
- lldb::TypeImplSP type_impl_sp (sb_type.GetSP());
- if (value_sp && type_impl_sp)
- {
- CompilerType ast_type(type_impl_sp->GetCompilerType(true));
- ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
- new_value_sp = ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, ast_type);
- }
- sb_value.SetSP(new_value_sp);
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- if (new_value_sp)
- log->Printf ("SBValue(%p)::CreateValueFromAddress => \"%s\"",
- static_cast<void*>(value_sp.get()),
- new_value_sp->GetName().AsCString());
- else
- log->Printf ("SBValue(%p)::CreateValueFromAddress => NULL",
- static_cast<void*>(value_sp.get()));
- }
- return sb_value;
-}
-
-lldb::SBValue
-SBValue::CreateValueFromData (const char* name, SBData data, SBType sb_type)
-{
- lldb::SBValue sb_value;
- lldb::ValueObjectSP new_value_sp;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- lldb::TypeImplSP type_impl_sp (sb_type.GetSP());
- if (value_sp && type_impl_sp)
- {
- ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
- new_value_sp = ValueObject::CreateValueObjectFromData(name, **data, exe_ctx, type_impl_sp->GetCompilerType(true));
- new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
- }
- sb_value.SetSP(new_value_sp);
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- if (new_value_sp)
- log->Printf ("SBValue(%p)::CreateValueFromData => \"%s\"",
- static_cast<void*>(value_sp.get()),
- new_value_sp->GetName().AsCString());
- else
- log->Printf ("SBValue(%p)::CreateValueFromData => NULL",
- static_cast<void*>(value_sp.get()));
- }
- return sb_value;
-}
-
-SBValue
-SBValue::GetChildAtIndex (uint32_t idx)
-{
- const bool can_create_synthetic = false;
- lldb::DynamicValueType use_dynamic = eNoDynamicValues;
- TargetSP target_sp;
- if (m_opaque_sp)
- target_sp = m_opaque_sp->GetTargetSP();
-
- if (target_sp)
- use_dynamic = target_sp->GetPreferDynamicValue();
-
- return GetChildAtIndex (idx, use_dynamic, can_create_synthetic);
-}
-
-SBValue
-SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic)
-{
- lldb::ValueObjectSP child_sp;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- const bool can_create = true;
- child_sp = value_sp->GetChildAtIndex (idx, can_create);
- if (can_create_synthetic && !child_sp)
- {
- child_sp = value_sp->GetSyntheticArrayMember(idx, can_create);
- }
- }
-
- SBValue sb_value;
- sb_value.SetSP (child_sp, use_dynamic, GetPreferSyntheticValue());
- if (log)
- log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)",
- static_cast<void*>(value_sp.get()), idx,
- static_cast<void*>(value_sp.get()));
-
- return sb_value;
-}
-
-uint32_t
-SBValue::GetIndexOfChildWithName (const char *name)
-{
- uint32_t idx = UINT32_MAX;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- idx = value_sp->GetIndexOfChildWithName (ConstString(name));
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- if (idx == UINT32_MAX)
- log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND",
- static_cast<void*>(value_sp.get()), name);
- else
- log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u",
- static_cast<void*>(value_sp.get()), name, idx);
- }
- return idx;
-}
-
-SBValue
-SBValue::GetChildMemberWithName (const char *name)
-{
- lldb::DynamicValueType use_dynamic_value = eNoDynamicValues;
- TargetSP target_sp;
- if (m_opaque_sp)
- target_sp = m_opaque_sp->GetTargetSP();
-
- if (target_sp)
- use_dynamic_value = target_sp->GetPreferDynamicValue();
- return GetChildMemberWithName (name, use_dynamic_value);
-}
-
-SBValue
-SBValue::GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic_value)
-{
- lldb::ValueObjectSP child_sp;
- const ConstString str_name (name);
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- child_sp = value_sp->GetChildMemberWithName (str_name, true);
- }
-
- SBValue sb_value;
- sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue());
-
- if (log)
- log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)",
- static_cast<void*>(value_sp.get()), name,
- static_cast<void*>(value_sp.get()));
-
- return sb_value;
-}
-
-lldb::SBValue
-SBValue::GetDynamicValue (lldb::DynamicValueType use_dynamic)
-{
- SBValue value_sb;
- if (IsValid())
- {
- ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),use_dynamic,m_opaque_sp->GetUseSynthetic()));
- value_sb.SetSP(proxy_sp);
- }
- return value_sb;
-}
-
-lldb::SBValue
-SBValue::GetStaticValue ()
-{
- SBValue value_sb;
- if (IsValid())
- {
- ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),eNoDynamicValues,m_opaque_sp->GetUseSynthetic()));
- value_sb.SetSP(proxy_sp);
- }
- return value_sb;
-}
-
-lldb::SBValue
-SBValue::GetNonSyntheticValue ()
-{
- SBValue value_sb;
- if (IsValid())
- {
- ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),m_opaque_sp->GetUseDynamic(),false));
- value_sb.SetSP(proxy_sp);
- }
- return value_sb;
-}
-
-lldb::DynamicValueType
-SBValue::GetPreferDynamicValue ()
-{
- if (!IsValid())
- return eNoDynamicValues;
- return m_opaque_sp->GetUseDynamic();
-}
-
-void
-SBValue::SetPreferDynamicValue (lldb::DynamicValueType use_dynamic)
-{
- if (IsValid())
- return m_opaque_sp->SetUseDynamic (use_dynamic);
-}
-
-bool
-SBValue::GetPreferSyntheticValue ()
-{
- if (!IsValid())
- return false;
- return m_opaque_sp->GetUseSynthetic();
-}
-
-void
-SBValue::SetPreferSyntheticValue (bool use_synthetic)
-{
- if (IsValid())
- return m_opaque_sp->SetUseSynthetic (use_synthetic);
-}
-
-bool
-SBValue::IsDynamic()
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- return value_sp->IsDynamic();
- return false;
-}
-
-bool
-SBValue::IsSynthetic ()
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- return value_sp->IsSynthetic();
- return false;
-}
-
-bool
-SBValue::IsSyntheticChildrenGenerated ()
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- return value_sp->IsSyntheticChildrenGenerated();
- return false;
-}
-
-void
-SBValue::SetSyntheticChildrenGenerated (bool is)
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- return value_sp->SetSyntheticChildrenGenerated(is);
-}
-
-lldb::SBValue
-SBValue::GetValueForExpressionPath(const char* expr_path)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- lldb::ValueObjectSP child_sp;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- // using default values for all the fancy options, just do it if you can
- child_sp = value_sp->GetValueForExpressionPath(expr_path);
- }
-
- SBValue sb_value;
- sb_value.SetSP(child_sp,GetPreferDynamicValue(),GetPreferSyntheticValue());
-
- if (log)
- log->Printf ("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => SBValue(%p)",
- static_cast<void*>(value_sp.get()), expr_path,
- static_cast<void*>(value_sp.get()));
-
- return sb_value;
-}
-
-int64_t
-SBValue::GetValueAsSigned(SBError& error, int64_t fail_value)
-{
- error.Clear();
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- bool success = true;
- uint64_t ret_val = fail_value;
- ret_val = value_sp->GetValueAsSigned(fail_value, &success);
- if (!success)
- error.SetErrorString("could not resolve value");
- return ret_val;
- }
+lldb::SBValue SBValue::CreateChildAtOffset(const char *name, uint32_t offset,
+ SBType type) {
+ lldb::SBValue sb_value;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ lldb::ValueObjectSP new_value_sp;
+ if (value_sp) {
+ TypeImplSP type_sp(type.GetSP());
+ if (type.IsValid()) {
+ sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(
+ offset, type_sp->GetCompilerType(false), true),
+ GetPreferDynamicValue(), GetPreferSyntheticValue(), name);
+ }
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ if (new_value_sp)
+ log->Printf("SBValue(%p)::CreateChildAtOffset => \"%s\"",
+ static_cast<void *>(value_sp.get()),
+ new_value_sp->GetName().AsCString());
else
- error.SetErrorStringWithFormat ("could not get SBValue: %s", locker.GetError().AsCString());
-
- return fail_value;
-}
-
-uint64_t
-SBValue::GetValueAsUnsigned(SBError& error, uint64_t fail_value)
-{
- error.Clear();
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- bool success = true;
- uint64_t ret_val = fail_value;
- ret_val = value_sp->GetValueAsUnsigned(fail_value, &success);
- if (!success)
- error.SetErrorString("could not resolve value");
- return ret_val;
- }
+ log->Printf("SBValue(%p)::CreateChildAtOffset => NULL",
+ static_cast<void *>(value_sp.get()));
+ }
+ return sb_value;
+}
+
+lldb::SBValue SBValue::Cast(SBType type) {
+ lldb::SBValue sb_value;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ TypeImplSP type_sp(type.GetSP());
+ if (value_sp && type_sp)
+ sb_value.SetSP(value_sp->Cast(type_sp->GetCompilerType(false)),
+ GetPreferDynamicValue(), GetPreferSyntheticValue());
+ return sb_value;
+}
+
+lldb::SBValue SBValue::CreateValueFromExpression(const char *name,
+ const char *expression) {
+ SBExpressionOptions options;
+ options.ref().SetKeepInMemory(true);
+ return CreateValueFromExpression(name, expression, options);
+}
+
+lldb::SBValue SBValue::CreateValueFromExpression(const char *name,
+ const char *expression,
+ SBExpressionOptions &options) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ lldb::SBValue sb_value;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ lldb::ValueObjectSP new_value_sp;
+ if (value_sp) {
+ ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
+ new_value_sp = ValueObject::CreateValueObjectFromExpression(
+ name, expression, exe_ctx, options.ref());
+ if (new_value_sp)
+ new_value_sp->SetName(ConstString(name));
+ }
+ sb_value.SetSP(new_value_sp);
+ if (log) {
+ if (new_value_sp)
+ log->Printf("SBValue(%p)::CreateValueFromExpression(name=\"%s\", "
+ "expression=\"%s\") => SBValue (%p)",
+ static_cast<void *>(value_sp.get()), name, expression,
+ static_cast<void *>(new_value_sp.get()));
else
- error.SetErrorStringWithFormat ("could not get SBValue: %s", locker.GetError().AsCString());
-
- return fail_value;
-}
-
-int64_t
-SBValue::GetValueAsSigned(int64_t fail_value)
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- return value_sp->GetValueAsSigned(fail_value);
- }
- return fail_value;
-}
-
-uint64_t
-SBValue::GetValueAsUnsigned(uint64_t fail_value)
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- return value_sp->GetValueAsUnsigned(fail_value);
- }
- return fail_value;
-}
-
-bool
-SBValue::MightHaveChildren ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- bool has_children = false;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- has_children = value_sp->MightHaveChildren();
-
- if (log)
- log->Printf ("SBValue(%p)::MightHaveChildren() => %i",
- static_cast<void*>(value_sp.get()), has_children);
- return has_children;
+ log->Printf("SBValue(%p)::CreateValueFromExpression(name=\"%s\", "
+ "expression=\"%s\") => NULL",
+ static_cast<void *>(value_sp.get()), name, expression);
+ }
+ return sb_value;
+}
+
+lldb::SBValue SBValue::CreateValueFromAddress(const char *name,
+ lldb::addr_t address,
+ SBType sb_type) {
+ lldb::SBValue sb_value;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ lldb::ValueObjectSP new_value_sp;
+ lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
+ if (value_sp && type_impl_sp) {
+ CompilerType ast_type(type_impl_sp->GetCompilerType(true));
+ ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
+ new_value_sp = ValueObject::CreateValueObjectFromAddress(name, address,
+ exe_ctx, ast_type);
+ }
+ sb_value.SetSP(new_value_sp);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ if (new_value_sp)
+ log->Printf("SBValue(%p)::CreateValueFromAddress => \"%s\"",
+ static_cast<void *>(value_sp.get()),
+ new_value_sp->GetName().AsCString());
+ else
+ log->Printf("SBValue(%p)::CreateValueFromAddress => NULL",
+ static_cast<void *>(value_sp.get()));
+ }
+ return sb_value;
+}
+
+lldb::SBValue SBValue::CreateValueFromData(const char *name, SBData data,
+ SBType sb_type) {
+ lldb::SBValue sb_value;
+ lldb::ValueObjectSP new_value_sp;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
+ if (value_sp && type_impl_sp) {
+ ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
+ new_value_sp = ValueObject::CreateValueObjectFromData(
+ name, **data, exe_ctx, type_impl_sp->GetCompilerType(true));
+ new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
+ }
+ sb_value.SetSP(new_value_sp);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ if (new_value_sp)
+ log->Printf("SBValue(%p)::CreateValueFromData => \"%s\"",
+ static_cast<void *>(value_sp.get()),
+ new_value_sp->GetName().AsCString());
+ else
+ log->Printf("SBValue(%p)::CreateValueFromData => NULL",
+ static_cast<void *>(value_sp.get()));
+ }
+ return sb_value;
+}
+
+SBValue SBValue::GetChildAtIndex(uint32_t idx) {
+ const bool can_create_synthetic = false;
+ lldb::DynamicValueType use_dynamic = eNoDynamicValues;
+ TargetSP target_sp;
+ if (m_opaque_sp)
+ target_sp = m_opaque_sp->GetTargetSP();
+
+ if (target_sp)
+ use_dynamic = target_sp->GetPreferDynamicValue();
+
+ return GetChildAtIndex(idx, use_dynamic, can_create_synthetic);
+}
+
+SBValue SBValue::GetChildAtIndex(uint32_t idx,
+ lldb::DynamicValueType use_dynamic,
+ bool can_create_synthetic) {
+ lldb::ValueObjectSP child_sp;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ const bool can_create = true;
+ child_sp = value_sp->GetChildAtIndex(idx, can_create);
+ if (can_create_synthetic && !child_sp) {
+ child_sp = value_sp->GetSyntheticArrayMember(idx, can_create);
+ }
+ }
+
+ SBValue sb_value;
+ sb_value.SetSP(child_sp, use_dynamic, GetPreferSyntheticValue());
+ if (log)
+ log->Printf("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)",
+ static_cast<void *>(value_sp.get()), idx,
+ static_cast<void *>(value_sp.get()));
+
+ return sb_value;
+}
+
+uint32_t SBValue::GetIndexOfChildWithName(const char *name) {
+ uint32_t idx = UINT32_MAX;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ idx = value_sp->GetIndexOfChildWithName(ConstString(name));
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ if (idx == UINT32_MAX)
+ log->Printf(
+ "SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND",
+ static_cast<void *>(value_sp.get()), name);
+ else
+ log->Printf("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u",
+ static_cast<void *>(value_sp.get()), name, idx);
+ }
+ return idx;
}
-bool
-SBValue::IsRuntimeSupportValue ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- bool is_support = false;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- is_support = value_sp->IsRuntimeSupportValue();
-
- if (log)
- log->Printf ("SBValue(%p)::IsRuntimeSupportValue() => %i",
- static_cast<void*>(value_sp.get()), is_support);
- return is_support;
-}
-
-uint32_t
-SBValue::GetNumChildren ()
-{
- return GetNumChildren (UINT32_MAX);
-}
-
-uint32_t
-SBValue::GetNumChildren (uint32_t max)
-{
- uint32_t num_children = 0;
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- num_children = value_sp->GetNumChildren(max);
-
- if (log)
- log->Printf ("SBValue(%p)::GetNumChildren (%u) => %u",
- static_cast<void*>(value_sp.get()), max, num_children);
-
- return num_children;
+SBValue SBValue::GetChildMemberWithName(const char *name) {
+ lldb::DynamicValueType use_dynamic_value = eNoDynamicValues;
+ TargetSP target_sp;
+ if (m_opaque_sp)
+ target_sp = m_opaque_sp->GetTargetSP();
+
+ if (target_sp)
+ use_dynamic_value = target_sp->GetPreferDynamicValue();
+ return GetChildMemberWithName(name, use_dynamic_value);
}
SBValue
-SBValue::Dereference ()
-{
- SBValue sb_value;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- Error error;
- sb_value = value_sp->Dereference (error);
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)",
- static_cast<void*>(value_sp.get()),
- static_cast<void*>(value_sp.get()));
-
- return sb_value;
-}
-
-// Deprecated - please use GetType().IsPointerType() instead.
-bool
-SBValue::TypeIsPointerType ()
-{
- return GetType().IsPointerType();
-}
-
-void *
-SBValue::GetOpaqueType()
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- return value_sp->GetCompilerType().GetOpaqueQualType();
- return NULL;
-}
-
-lldb::SBTarget
-SBValue::GetTarget()
-{
- SBTarget sb_target;
- TargetSP target_sp;
- if (m_opaque_sp)
- {
- target_sp = m_opaque_sp->GetTargetSP();
- sb_target.SetSP (target_sp);
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- if (target_sp.get() == NULL)
- log->Printf ("SBValue(%p)::GetTarget () => NULL",
- static_cast<void*>(m_opaque_sp.get()));
- else
- log->Printf ("SBValue(%p)::GetTarget () => %p",
- static_cast<void*>(m_opaque_sp.get()),
- static_cast<void*>(target_sp.get()));
- }
- return sb_target;
+SBValue::GetChildMemberWithName(const char *name,
+ lldb::DynamicValueType use_dynamic_value) {
+ lldb::ValueObjectSP child_sp;
+ const ConstString str_name(name);
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ child_sp = value_sp->GetChildMemberWithName(str_name, true);
+ }
+
+ SBValue sb_value;
+ sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue());
+
+ if (log)
+ log->Printf(
+ "SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)",
+ static_cast<void *>(value_sp.get()), name,
+ static_cast<void *>(value_sp.get()));
+
+ return sb_value;
+}
+
+lldb::SBValue SBValue::GetDynamicValue(lldb::DynamicValueType use_dynamic) {
+ SBValue value_sb;
+ if (IsValid()) {
+ ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), use_dynamic,
+ m_opaque_sp->GetUseSynthetic()));
+ value_sb.SetSP(proxy_sp);
+ }
+ return value_sb;
+}
+
+lldb::SBValue SBValue::GetStaticValue() {
+ SBValue value_sb;
+ if (IsValid()) {
+ ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
+ eNoDynamicValues,
+ m_opaque_sp->GetUseSynthetic()));
+ value_sb.SetSP(proxy_sp);
+ }
+ return value_sb;
+}
+
+lldb::SBValue SBValue::GetNonSyntheticValue() {
+ SBValue value_sb;
+ if (IsValid()) {
+ ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
+ m_opaque_sp->GetUseDynamic(), false));
+ value_sb.SetSP(proxy_sp);
+ }
+ return value_sb;
+}
+
+lldb::DynamicValueType SBValue::GetPreferDynamicValue() {
+ if (!IsValid())
+ return eNoDynamicValues;
+ return m_opaque_sp->GetUseDynamic();
+}
+
+void SBValue::SetPreferDynamicValue(lldb::DynamicValueType use_dynamic) {
+ if (IsValid())
+ return m_opaque_sp->SetUseDynamic(use_dynamic);
}
-lldb::SBProcess
-SBValue::GetProcess()
-{
- SBProcess sb_process;
- ProcessSP process_sp;
- if (m_opaque_sp)
- {
- process_sp = m_opaque_sp->GetProcessSP();
- sb_process.SetSP (process_sp);
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- if (process_sp.get() == NULL)
- log->Printf ("SBValue(%p)::GetProcess () => NULL",
- static_cast<void*>(m_opaque_sp.get()));
- else
- log->Printf ("SBValue(%p)::GetProcess () => %p",
- static_cast<void*>(m_opaque_sp.get()),
- static_cast<void*>(process_sp.get()));
- }
- return sb_process;
+bool SBValue::GetPreferSyntheticValue() {
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetUseSynthetic();
}
-lldb::SBThread
-SBValue::GetThread()
-{
- SBThread sb_thread;
- ThreadSP thread_sp;
- if (m_opaque_sp)
- {
- thread_sp = m_opaque_sp->GetThreadSP();
- sb_thread.SetThread(thread_sp);
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- if (thread_sp.get() == NULL)
- log->Printf ("SBValue(%p)::GetThread () => NULL",
- static_cast<void*>(m_opaque_sp.get()));
- else
- log->Printf ("SBValue(%p)::GetThread () => %p",
- static_cast<void*>(m_opaque_sp.get()),
- static_cast<void*>(thread_sp.get()));
- }
- return sb_thread;
-}
+void SBValue::SetPreferSyntheticValue(bool use_synthetic) {
+ if (IsValid())
+ return m_opaque_sp->SetUseSynthetic(use_synthetic);
+}
+
+bool SBValue::IsDynamic() {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ return value_sp->IsDynamic();
+ return false;
+}
+
+bool SBValue::IsSynthetic() {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ return value_sp->IsSynthetic();
+ return false;
+}
+
+bool SBValue::IsSyntheticChildrenGenerated() {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ return value_sp->IsSyntheticChildrenGenerated();
+ return false;
+}
+
+void SBValue::SetSyntheticChildrenGenerated(bool is) {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ return value_sp->SetSyntheticChildrenGenerated(is);
+}
+
+lldb::SBValue SBValue::GetValueForExpressionPath(const char *expr_path) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ lldb::ValueObjectSP child_sp;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ // using default values for all the fancy options, just do it if you can
+ child_sp = value_sp->GetValueForExpressionPath(expr_path);
+ }
+
+ SBValue sb_value;
+ sb_value.SetSP(child_sp, GetPreferDynamicValue(), GetPreferSyntheticValue());
+
+ if (log)
+ log->Printf("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => "
+ "SBValue(%p)",
+ static_cast<void *>(value_sp.get()), expr_path,
+ static_cast<void *>(value_sp.get()));
+
+ return sb_value;
+}
+
+int64_t SBValue::GetValueAsSigned(SBError &error, int64_t fail_value) {
+ error.Clear();
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ bool success = true;
+ uint64_t ret_val = fail_value;
+ ret_val = value_sp->GetValueAsSigned(fail_value, &success);
+ if (!success)
+ error.SetErrorString("could not resolve value");
+ return ret_val;
+ } else
+ error.SetErrorStringWithFormat("could not get SBValue: %s",
+ locker.GetError().AsCString());
+
+ return fail_value;
+}
+
+uint64_t SBValue::GetValueAsUnsigned(SBError &error, uint64_t fail_value) {
+ error.Clear();
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ bool success = true;
+ uint64_t ret_val = fail_value;
+ ret_val = value_sp->GetValueAsUnsigned(fail_value, &success);
+ if (!success)
+ error.SetErrorString("could not resolve value");
+ return ret_val;
+ } else
+ error.SetErrorStringWithFormat("could not get SBValue: %s",
+ locker.GetError().AsCString());
+
+ return fail_value;
+}
+
+int64_t SBValue::GetValueAsSigned(int64_t fail_value) {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ return value_sp->GetValueAsSigned(fail_value);
+ }
+ return fail_value;
+}
+
+uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ return value_sp->GetValueAsUnsigned(fail_value);
+ }
+ return fail_value;
+}
+
+bool SBValue::MightHaveChildren() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ bool has_children = false;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ has_children = value_sp->MightHaveChildren();
+
+ if (log)
+ log->Printf("SBValue(%p)::MightHaveChildren() => %i",
+ static_cast<void *>(value_sp.get()), has_children);
+ return has_children;
+}
+
+bool SBValue::IsRuntimeSupportValue() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ bool is_support = false;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ is_support = value_sp->IsRuntimeSupportValue();
+
+ if (log)
+ log->Printf("SBValue(%p)::IsRuntimeSupportValue() => %i",
+ static_cast<void *>(value_sp.get()), is_support);
+ return is_support;
+}
+
+uint32_t SBValue::GetNumChildren() { return GetNumChildren(UINT32_MAX); }
+
+uint32_t SBValue::GetNumChildren(uint32_t max) {
+ uint32_t num_children = 0;
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ num_children = value_sp->GetNumChildren(max);
+
+ if (log)
+ log->Printf("SBValue(%p)::GetNumChildren (%u) => %u",
+ static_cast<void *>(value_sp.get()), max, num_children);
+
+ return num_children;
+}
+
+SBValue SBValue::Dereference() {
+ SBValue sb_value;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ Error error;
+ sb_value = value_sp->Dereference(error);
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBValue(%p)::Dereference () => SBValue(%p)",
+ static_cast<void *>(value_sp.get()),
+ static_cast<void *>(value_sp.get()));
-lldb::SBFrame
-SBValue::GetFrame()
-{
- SBFrame sb_frame;
- StackFrameSP frame_sp;
- if (m_opaque_sp)
- {
- frame_sp = m_opaque_sp->GetFrameSP();
- sb_frame.SetFrameSP (frame_sp);
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- if (frame_sp.get() == NULL)
- log->Printf ("SBValue(%p)::GetFrame () => NULL",
- static_cast<void*>(m_opaque_sp.get()));
- else
- log->Printf ("SBValue(%p)::GetFrame () => %p",
- static_cast<void*>(m_opaque_sp.get()),
- static_cast<void*>(frame_sp.get()));
- }
- return sb_frame;
+ return sb_value;
}
+// Deprecated - please use GetType().IsPointerType() instead.
+bool SBValue::TypeIsPointerType() { return GetType().IsPointerType(); }
-lldb::ValueObjectSP
-SBValue::GetSP (ValueLocker &locker) const
-{
- if (!m_opaque_sp || !m_opaque_sp->IsValid())
- {
- locker.GetError().SetErrorString("No value");
- return ValueObjectSP();
- }
- return locker.GetLockedSP(*m_opaque_sp.get());
-}
-
-lldb::ValueObjectSP
-SBValue::GetSP () const
-{
- ValueLocker locker;
- return GetSP(locker);
-}
-
-void
-SBValue::SetSP (ValueImplSP impl_sp)
-{
- m_opaque_sp = impl_sp;
-}
-
-void
-SBValue::SetSP (const lldb::ValueObjectSP &sp)
-{
- if (sp)
- {
- lldb::TargetSP target_sp(sp->GetTargetSP());
- if (target_sp)
- {
- lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
- bool use_synthetic = target_sp->TargetProperties::GetEnableSyntheticValue();
- m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
- }
- else
- m_opaque_sp = ValueImplSP(new ValueImpl(sp,eNoDynamicValues,true));
- }
+void *SBValue::GetOpaqueType() {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ return value_sp->GetCompilerType().GetOpaqueQualType();
+ return NULL;
+}
+
+lldb::SBTarget SBValue::GetTarget() {
+ SBTarget sb_target;
+ TargetSP target_sp;
+ if (m_opaque_sp) {
+ target_sp = m_opaque_sp->GetTargetSP();
+ sb_target.SetSP(target_sp);
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ if (target_sp.get() == NULL)
+ log->Printf("SBValue(%p)::GetTarget () => NULL",
+ static_cast<void *>(m_opaque_sp.get()));
else
- m_opaque_sp = ValueImplSP(new ValueImpl(sp,eNoDynamicValues,false));
-}
-
-void
-SBValue::SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic)
-{
- if (sp)
- {
- lldb::TargetSP target_sp(sp->GetTargetSP());
- if (target_sp)
- {
- bool use_synthetic = target_sp->TargetProperties::GetEnableSyntheticValue();
- SetSP (sp, use_dynamic, use_synthetic);
- }
- else
- SetSP (sp, use_dynamic, true);
- }
+ log->Printf("SBValue(%p)::GetTarget () => %p",
+ static_cast<void *>(m_opaque_sp.get()),
+ static_cast<void *>(target_sp.get()));
+ }
+ return sb_target;
+}
+
+lldb::SBProcess SBValue::GetProcess() {
+ SBProcess sb_process;
+ ProcessSP process_sp;
+ if (m_opaque_sp) {
+ process_sp = m_opaque_sp->GetProcessSP();
+ sb_process.SetSP(process_sp);
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ if (process_sp.get() == NULL)
+ log->Printf("SBValue(%p)::GetProcess () => NULL",
+ static_cast<void *>(m_opaque_sp.get()));
else
- SetSP (sp, use_dynamic, false);
-}
-
-void
-SBValue::SetSP (const lldb::ValueObjectSP &sp, bool use_synthetic)
-{
- if (sp)
- {
- lldb::TargetSP target_sp(sp->GetTargetSP());
- if (target_sp)
- {
- lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
- SetSP (sp, use_dynamic, use_synthetic);
- }
- else
- SetSP (sp, eNoDynamicValues, use_synthetic);
- }
+ log->Printf("SBValue(%p)::GetProcess () => %p",
+ static_cast<void *>(m_opaque_sp.get()),
+ static_cast<void *>(process_sp.get()));
+ }
+ return sb_process;
+}
+
+lldb::SBThread SBValue::GetThread() {
+ SBThread sb_thread;
+ ThreadSP thread_sp;
+ if (m_opaque_sp) {
+ thread_sp = m_opaque_sp->GetThreadSP();
+ sb_thread.SetThread(thread_sp);
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ if (thread_sp.get() == NULL)
+ log->Printf("SBValue(%p)::GetThread () => NULL",
+ static_cast<void *>(m_opaque_sp.get()));
else
- SetSP (sp, eNoDynamicValues, use_synthetic);
-}
-
-void
-SBValue::SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic, bool use_synthetic)
-{
- m_opaque_sp = ValueImplSP(new ValueImpl(sp,use_dynamic,use_synthetic));
-}
-
-void
-SBValue::SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, const char *name)
-{
- m_opaque_sp = ValueImplSP(new ValueImpl(sp,use_dynamic,use_synthetic, name));
-}
-
-bool
-SBValue::GetExpressionPath (SBStream &description)
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- value_sp->GetExpressionPath (description.ref(), false);
- return true;
- }
- return false;
-}
-
-bool
-SBValue::GetExpressionPath (SBStream &description, bool qualify_cxx_base_classes)
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- value_sp->GetExpressionPath (description.ref(), qualify_cxx_base_classes);
- return true;
- }
- return false;
-}
-
-bool
-SBValue::GetDescription (SBStream &description)
-{
- Stream &strm = description.ref();
-
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- value_sp->Dump(strm);
+ log->Printf("SBValue(%p)::GetThread () => %p",
+ static_cast<void *>(m_opaque_sp.get()),
+ static_cast<void *>(thread_sp.get()));
+ }
+ return sb_thread;
+}
+
+lldb::SBFrame SBValue::GetFrame() {
+ SBFrame sb_frame;
+ StackFrameSP frame_sp;
+ if (m_opaque_sp) {
+ frame_sp = m_opaque_sp->GetFrameSP();
+ sb_frame.SetFrameSP(frame_sp);
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log) {
+ if (frame_sp.get() == NULL)
+ log->Printf("SBValue(%p)::GetFrame () => NULL",
+ static_cast<void *>(m_opaque_sp.get()));
else
- strm.PutCString ("No value");
-
+ log->Printf("SBValue(%p)::GetFrame () => %p",
+ static_cast<void *>(m_opaque_sp.get()),
+ static_cast<void *>(frame_sp.get()));
+ }
+ return sb_frame;
+}
+
+lldb::ValueObjectSP SBValue::GetSP(ValueLocker &locker) const {
+ if (!m_opaque_sp || !m_opaque_sp->IsValid()) {
+ locker.GetError().SetErrorString("No value");
+ return ValueObjectSP();
+ }
+ return locker.GetLockedSP(*m_opaque_sp.get());
+}
+
+lldb::ValueObjectSP SBValue::GetSP() const {
+ ValueLocker locker;
+ return GetSP(locker);
+}
+
+void SBValue::SetSP(ValueImplSP impl_sp) { m_opaque_sp = impl_sp; }
+
+void SBValue::SetSP(const lldb::ValueObjectSP &sp) {
+ if (sp) {
+ lldb::TargetSP target_sp(sp->GetTargetSP());
+ if (target_sp) {
+ lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
+ bool use_synthetic =
+ target_sp->TargetProperties::GetEnableSyntheticValue();
+ m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
+ } else
+ m_opaque_sp = ValueImplSP(new ValueImpl(sp, eNoDynamicValues, true));
+ } else
+ m_opaque_sp = ValueImplSP(new ValueImpl(sp, eNoDynamicValues, false));
+}
+
+void SBValue::SetSP(const lldb::ValueObjectSP &sp,
+ lldb::DynamicValueType use_dynamic) {
+ if (sp) {
+ lldb::TargetSP target_sp(sp->GetTargetSP());
+ if (target_sp) {
+ bool use_synthetic =
+ target_sp->TargetProperties::GetEnableSyntheticValue();
+ SetSP(sp, use_dynamic, use_synthetic);
+ } else
+ SetSP(sp, use_dynamic, true);
+ } else
+ SetSP(sp, use_dynamic, false);
+}
+
+void SBValue::SetSP(const lldb::ValueObjectSP &sp, bool use_synthetic) {
+ if (sp) {
+ lldb::TargetSP target_sp(sp->GetTargetSP());
+ if (target_sp) {
+ lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
+ SetSP(sp, use_dynamic, use_synthetic);
+ } else
+ SetSP(sp, eNoDynamicValues, use_synthetic);
+ } else
+ SetSP(sp, eNoDynamicValues, use_synthetic);
+}
+
+void SBValue::SetSP(const lldb::ValueObjectSP &sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic) {
+ m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
+}
+
+void SBValue::SetSP(const lldb::ValueObjectSP &sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ const char *name) {
+ m_opaque_sp =
+ ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic, name));
+}
+
+bool SBValue::GetExpressionPath(SBStream &description) {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ value_sp->GetExpressionPath(description.ref(), false);
return true;
+ }
+ return false;
}
-lldb::Format
-SBValue::GetFormat ()
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- return value_sp->GetFormat();
- return eFormatDefault;
-}
-
-void
-SBValue::SetFormat (lldb::Format format)
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- value_sp->SetFormat(format);
-}
-
-lldb::SBValue
-SBValue::AddressOf()
-{
- SBValue sb_value;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- Error error;
- sb_value.SetSP(value_sp->AddressOf (error),GetPreferDynamicValue(), GetPreferSyntheticValue());
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBValue(%p)::AddressOf () => SBValue(%p)",
- static_cast<void*>(value_sp.get()),
- static_cast<void*>(value_sp.get()));
-
- return sb_value;
-}
-
-lldb::addr_t
-SBValue::GetLoadAddress()
-{
- lldb::addr_t value = LLDB_INVALID_ADDRESS;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- TargetSP target_sp (value_sp->GetTargetSP());
- if (target_sp)
- {
- const bool scalar_is_load_address = true;
- AddressType addr_type;
- value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
- if (addr_type == eAddressTypeFile)
- {
- ModuleSP module_sp (value_sp->GetModule());
- if (!module_sp)
- value = LLDB_INVALID_ADDRESS;
- else
- {
- Address addr;
- module_sp->ResolveFileAddress(value, addr);
- value = addr.GetLoadAddress(target_sp.get());
- }
- }
- else if (addr_type == eAddressTypeHost || addr_type == eAddressTypeInvalid)
- value = LLDB_INVALID_ADDRESS;
- }
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBValue(%p)::GetLoadAddress () => (%" PRIu64 ")",
- static_cast<void*>(value_sp.get()), value);
-
- return value;
+bool SBValue::GetExpressionPath(SBStream &description,
+ bool qualify_cxx_base_classes) {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ value_sp->GetExpressionPath(description.ref(), qualify_cxx_base_classes);
+ return true;
+ }
+ return false;
}
-lldb::SBAddress
-SBValue::GetAddress()
-{
- Address addr;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- TargetSP target_sp (value_sp->GetTargetSP());
- if (target_sp)
- {
- lldb::addr_t value = LLDB_INVALID_ADDRESS;
- const bool scalar_is_load_address = true;
- AddressType addr_type;
- value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
- if (addr_type == eAddressTypeFile)
- {
- ModuleSP module_sp (value_sp->GetModule());
- if (module_sp)
- module_sp->ResolveFileAddress(value, addr);
- }
- else if (addr_type == eAddressTypeLoad)
- {
- // no need to check the return value on this.. if it can actually do the resolve
- // addr will be in the form (section,offset), otherwise it will simply be returned
- // as (NULL, value)
- addr.SetLoadAddress(value, target_sp.get());
- }
- }
- }
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBValue(%p)::GetAddress () => (%s,%" PRIu64 ")",
- static_cast<void*>(value_sp.get()),
- (addr.GetSection()
- ? addr.GetSection()->GetName().GetCString()
- : "NULL"),
- addr.GetOffset());
- return SBAddress(new Address(addr));
-}
-
-lldb::SBData
-SBValue::GetPointeeData (uint32_t item_idx,
- uint32_t item_count)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- lldb::SBData sb_data;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- TargetSP target_sp (value_sp->GetTargetSP());
- if (target_sp)
- {
- DataExtractorSP data_sp(new DataExtractor());
- value_sp->GetPointeeData(*data_sp, item_idx, item_count);
- if (data_sp->GetByteSize() > 0)
- *sb_data = data_sp;
- }
- }
- if (log)
- log->Printf ("SBValue(%p)::GetPointeeData (%d, %d) => SBData(%p)",
- static_cast<void*>(value_sp.get()), item_idx, item_count,
- static_cast<void*>(sb_data.get()));
-
- return sb_data;
-}
-
-lldb::SBData
-SBValue::GetData ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- lldb::SBData sb_data;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- {
- DataExtractorSP data_sp(new DataExtractor());
- Error error;
- value_sp->GetData(*data_sp, error);
- if (error.Success())
- *sb_data = data_sp;
- }
- if (log)
- log->Printf ("SBValue(%p)::GetData () => SBData(%p)",
- static_cast<void*>(value_sp.get()),
- static_cast<void*>(sb_data.get()));
-
- return sb_data;
-}
-
-bool
-SBValue::SetData (lldb::SBData &data, SBError &error)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- bool ret = true;
-
- if (value_sp)
- {
- DataExtractor *data_extractor = data.get();
-
- if (!data_extractor)
- {
- if (log)
- log->Printf ("SBValue(%p)::SetData() => error: no data to set",
- static_cast<void*>(value_sp.get()));
+bool SBValue::GetDescription(SBStream &description) {
+ Stream &strm = description.ref();
- error.SetErrorString("No data to set");
- ret = false;
- }
- else
- {
- Error set_error;
-
- value_sp->SetData(*data_extractor, set_error);
-
- if (!set_error.Success())
- {
- error.SetErrorStringWithFormat("Couldn't set data: %s", set_error.AsCString());
- ret = false;
- }
- }
- }
- else
- {
- error.SetErrorStringWithFormat ("Couldn't set data: could not get SBValue: %s", locker.GetError().AsCString());
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ value_sp->Dump(strm);
+ else
+ strm.PutCString("No value");
+
+ return true;
+}
+
+lldb::Format SBValue::GetFormat() {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ return value_sp->GetFormat();
+ return eFormatDefault;
+}
+
+void SBValue::SetFormat(lldb::Format format) {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ value_sp->SetFormat(format);
+}
+
+lldb::SBValue SBValue::AddressOf() {
+ SBValue sb_value;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ Error error;
+ sb_value.SetSP(value_sp->AddressOf(error), GetPreferDynamicValue(),
+ GetPreferSyntheticValue());
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBValue(%p)::AddressOf () => SBValue(%p)",
+ static_cast<void *>(value_sp.get()),
+ static_cast<void *>(value_sp.get()));
+
+ return sb_value;
+}
+
+lldb::addr_t SBValue::GetLoadAddress() {
+ lldb::addr_t value = LLDB_INVALID_ADDRESS;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ TargetSP target_sp(value_sp->GetTargetSP());
+ if (target_sp) {
+ const bool scalar_is_load_address = true;
+ AddressType addr_type;
+ value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
+ if (addr_type == eAddressTypeFile) {
+ ModuleSP module_sp(value_sp->GetModule());
+ if (!module_sp)
+ value = LLDB_INVALID_ADDRESS;
+ else {
+ Address addr;
+ module_sp->ResolveFileAddress(value, addr);
+ value = addr.GetLoadAddress(target_sp.get());
+ }
+ } else if (addr_type == eAddressTypeHost ||
+ addr_type == eAddressTypeInvalid)
+ value = LLDB_INVALID_ADDRESS;
+ }
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBValue(%p)::GetLoadAddress () => (%" PRIu64 ")",
+ static_cast<void *>(value_sp.get()), value);
+
+ return value;
+}
+
+lldb::SBAddress SBValue::GetAddress() {
+ Address addr;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ TargetSP target_sp(value_sp->GetTargetSP());
+ if (target_sp) {
+ lldb::addr_t value = LLDB_INVALID_ADDRESS;
+ const bool scalar_is_load_address = true;
+ AddressType addr_type;
+ value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
+ if (addr_type == eAddressTypeFile) {
+ ModuleSP module_sp(value_sp->GetModule());
+ if (module_sp)
+ module_sp->ResolveFileAddress(value, addr);
+ } else if (addr_type == eAddressTypeLoad) {
+ // no need to check the return value on this.. if it can actually do the
+ // resolve
+ // addr will be in the form (section,offset), otherwise it will simply
+ // be returned
+ // as (NULL, value)
+ addr.SetLoadAddress(value, target_sp.get());
+ }
+ }
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBValue(%p)::GetAddress () => (%s,%" PRIu64 ")",
+ static_cast<void *>(value_sp.get()),
+ (addr.GetSection() ? addr.GetSection()->GetName().GetCString()
+ : "NULL"),
+ addr.GetOffset());
+ return SBAddress(new Address(addr));
+}
+
+lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ lldb::SBData sb_data;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ TargetSP target_sp(value_sp->GetTargetSP());
+ if (target_sp) {
+ DataExtractorSP data_sp(new DataExtractor());
+ value_sp->GetPointeeData(*data_sp, item_idx, item_count);
+ if (data_sp->GetByteSize() > 0)
+ *sb_data = data_sp;
+ }
+ }
+ if (log)
+ log->Printf("SBValue(%p)::GetPointeeData (%d, %d) => SBData(%p)",
+ static_cast<void *>(value_sp.get()), item_idx, item_count,
+ static_cast<void *>(sb_data.get()));
+
+ return sb_data;
+}
+
+lldb::SBData SBValue::GetData() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ lldb::SBData sb_data;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp) {
+ DataExtractorSP data_sp(new DataExtractor());
+ Error error;
+ value_sp->GetData(*data_sp, error);
+ if (error.Success())
+ *sb_data = data_sp;
+ }
+ if (log)
+ log->Printf("SBValue(%p)::GetData () => SBData(%p)",
+ static_cast<void *>(value_sp.get()),
+ static_cast<void *>(sb_data.get()));
+
+ return sb_data;
+}
+
+bool SBValue::SetData(lldb::SBData &data, SBError &error) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ bool ret = true;
+
+ if (value_sp) {
+ DataExtractor *data_extractor = data.get();
+
+ if (!data_extractor) {
+ if (log)
+ log->Printf("SBValue(%p)::SetData() => error: no data to set",
+ static_cast<void *>(value_sp.get()));
+
+ error.SetErrorString("No data to set");
+ ret = false;
+ } else {
+ Error set_error;
+
+ value_sp->SetData(*data_extractor, set_error);
+
+ if (!set_error.Success()) {
+ error.SetErrorStringWithFormat("Couldn't set data: %s",
+ set_error.AsCString());
ret = false;
+ }
}
+ } else {
+ error.SetErrorStringWithFormat(
+ "Couldn't set data: could not get SBValue: %s",
+ locker.GetError().AsCString());
+ ret = false;
+ }
+
+ if (log)
+ log->Printf("SBValue(%p)::SetData (%p) => %s",
+ static_cast<void *>(value_sp.get()),
+ static_cast<void *>(data.get()), ret ? "true" : "false");
+ return ret;
+}
+
+lldb::SBDeclaration SBValue::GetDeclaration() {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ SBDeclaration decl_sb;
+ if (value_sp) {
+ Declaration decl;
+ if (value_sp->GetDeclaration(decl))
+ decl_sb.SetDeclaration(decl);
+ }
+ return decl_sb;
+}
+
+lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
+ SBError &error) {
+ SBWatchpoint sb_watchpoint;
+
+ // If the SBValue is not valid, there's no point in even trying to watch it.
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ TargetSP target_sp(GetTarget().GetSP());
+ if (value_sp && target_sp) {
+ // Read and Write cannot both be false.
+ if (!read && !write)
+ return sb_watchpoint;
+
+ // If the value is not in scope, don't try and watch and invalid value
+ if (!IsInScope())
+ return sb_watchpoint;
+
+ addr_t addr = GetLoadAddress();
+ if (addr == LLDB_INVALID_ADDRESS)
+ return sb_watchpoint;
+ size_t byte_size = GetByteSize();
+ if (byte_size == 0)
+ return sb_watchpoint;
+
+ uint32_t watch_type = 0;
+ if (read)
+ watch_type |= LLDB_WATCH_TYPE_READ;
+ if (write)
+ watch_type |= LLDB_WATCH_TYPE_WRITE;
+
+ Error rc;
+ CompilerType type(value_sp->GetCompilerType());
+ WatchpointSP watchpoint_sp =
+ target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc);
+ error.SetError(rc);
+
+ if (watchpoint_sp) {
+ sb_watchpoint.SetSP(watchpoint_sp);
+ Declaration decl;
+ if (value_sp->GetDeclaration(decl)) {
+ if (decl.GetFile()) {
+ StreamString ss;
+ // True to show fullpath for declaration file.
+ decl.DumpStopContext(&ss, true);
+ watchpoint_sp->SetDeclInfo(ss.GetString());
+ }
+ }
+ }
+ } else if (target_sp) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBValue(%p)::Watch() => error getting SBValue: %s",
+ static_cast<void *>(value_sp.get()),
+ locker.GetError().AsCString());
+
+ error.SetErrorStringWithFormat("could not get SBValue: %s",
+ locker.GetError().AsCString());
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBValue(%p)::Watch() => error getting SBValue: no target",
+ static_cast<void *>(value_sp.get()));
+ error.SetErrorString("could not set watchpoint, a target is required");
+ }
- if (log)
- log->Printf ("SBValue(%p)::SetData (%p) => %s",
- static_cast<void*>(value_sp.get()),
- static_cast<void*>(data.get()), ret ? "true" : "false");
- return ret;
-}
-
-lldb::SBDeclaration
-SBValue::GetDeclaration ()
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- SBDeclaration decl_sb;
- if (value_sp)
- {
- Declaration decl;
- if (value_sp->GetDeclaration(decl))
- decl_sb.SetDeclaration(decl);
- }
- return decl_sb;
-}
-
-lldb::SBWatchpoint
-SBValue::Watch (bool resolve_location, bool read, bool write, SBError &error)
-{
- SBWatchpoint sb_watchpoint;
-
- // If the SBValue is not valid, there's no point in even trying to watch it.
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- TargetSP target_sp (GetTarget().GetSP());
- if (value_sp && target_sp)
- {
- // Read and Write cannot both be false.
- if (!read && !write)
- return sb_watchpoint;
-
- // If the value is not in scope, don't try and watch and invalid value
- if (!IsInScope())
- return sb_watchpoint;
-
- addr_t addr = GetLoadAddress();
- if (addr == LLDB_INVALID_ADDRESS)
- return sb_watchpoint;
- size_t byte_size = GetByteSize();
- if (byte_size == 0)
- return sb_watchpoint;
-
- uint32_t watch_type = 0;
- if (read)
- watch_type |= LLDB_WATCH_TYPE_READ;
- if (write)
- watch_type |= LLDB_WATCH_TYPE_WRITE;
-
- Error rc;
- CompilerType type (value_sp->GetCompilerType());
- WatchpointSP watchpoint_sp = target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc);
- error.SetError(rc);
-
- if (watchpoint_sp)
- {
- sb_watchpoint.SetSP (watchpoint_sp);
- Declaration decl;
- if (value_sp->GetDeclaration (decl))
- {
- if (decl.GetFile())
- {
- StreamString ss;
- // True to show fullpath for declaration file.
- decl.DumpStopContext(&ss, true);
- watchpoint_sp->SetDeclInfo(ss.GetString());
- }
- }
- }
- }
- else if (target_sp)
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBValue(%p)::Watch() => error getting SBValue: %s",
- static_cast<void*>(value_sp.get()),
- locker.GetError().AsCString());
-
- error.SetErrorStringWithFormat("could not get SBValue: %s", locker.GetError().AsCString());
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBValue(%p)::Watch() => error getting SBValue: no target",
- static_cast<void*>(value_sp.get()));
- error.SetErrorString("could not set watchpoint, a target is required");
- }
-
- return sb_watchpoint;
+ return sb_watchpoint;
}
-// FIXME: Remove this method impl (as well as the decl in .h) once it is no longer needed.
+// FIXME: Remove this method impl (as well as the decl in .h) once it is no
+// longer needed.
// Backward compatibility fix in the interim.
-lldb::SBWatchpoint
-SBValue::Watch (bool resolve_location, bool read, bool write)
-{
- SBError error;
- return Watch(resolve_location, read, write, error);
-}
-
-lldb::SBWatchpoint
-SBValue::WatchPointee (bool resolve_location, bool read, bool write, SBError &error)
-{
- SBWatchpoint sb_watchpoint;
- if (IsInScope() && GetType().IsPointerType())
- sb_watchpoint = Dereference().Watch (resolve_location, read, write, error);
- return sb_watchpoint;
-}
-
-lldb::SBValue
-SBValue::Persist ()
-{
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- SBValue persisted_sb;
- if (value_sp)
- {
- persisted_sb.SetSP(value_sp->Persist());
- }
- return persisted_sb;
+lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read,
+ bool write) {
+ SBError error;
+ return Watch(resolve_location, read, write, error);
+}
+
+lldb::SBWatchpoint SBValue::WatchPointee(bool resolve_location, bool read,
+ bool write, SBError &error) {
+ SBWatchpoint sb_watchpoint;
+ if (IsInScope() && GetType().IsPointerType())
+ sb_watchpoint = Dereference().Watch(resolve_location, read, write, error);
+ return sb_watchpoint;
+}
+
+lldb::SBValue SBValue::Persist() {
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ SBValue persisted_sb;
+ if (value_sp) {
+ persisted_sb.SetSP(value_sp->Persist());
+ }
+ return persisted_sb;
}
Modified: lldb/trunk/source/API/SBValueList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValueList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValueList.cpp (original)
+++ lldb/trunk/source/API/SBValueList.cpp Tue Sep 6 15:57:50 2016
@@ -7,10 +7,9 @@
//
//===----------------------------------------------------------------------===//
-
#include "lldb/API/SBValueList.h"
-#include "lldb/API/SBValue.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBValue.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/ValueObjectList.h"
@@ -19,281 +18,192 @@
using namespace lldb;
using namespace lldb_private;
-class ValueListImpl
-{
+class ValueListImpl {
public:
- ValueListImpl () :
- m_values()
- {
- }
-
- ValueListImpl (const ValueListImpl& rhs) :
- m_values(rhs.m_values)
- {
- }
-
- ValueListImpl&
- operator = (const ValueListImpl& rhs)
- {
- if (this == &rhs)
- return *this;
- m_values = rhs.m_values;
- return *this;
- }
-
- uint32_t
- GetSize ()
- {
- return m_values.size();
- }
-
- void
- Append (const lldb::SBValue& sb_value)
- {
- m_values.push_back(sb_value);
- }
-
- void
- Append (const ValueListImpl& list)
- {
- for (auto val : list.m_values)
- Append (val);
- }
-
- lldb::SBValue
- GetValueAtIndex (uint32_t index)
- {
- if (index >= GetSize())
- return lldb::SBValue();
- return m_values[index];
- }
-
- lldb::SBValue
- FindValueByUID (lldb::user_id_t uid)
- {
- for (auto val : m_values)
- {
- if (val.IsValid() && val.GetID() == uid)
- return val;
- }
- return lldb::SBValue();
- }
-
- lldb::SBValue
- GetFirstValueByName (const char* name) const
- {
- if (name)
- {
- for (auto val : m_values)
- {
- if (val.IsValid() && val.GetName() &&
- strcmp(name,val.GetName()) == 0)
- return val;
- }
- }
- return lldb::SBValue();
+ ValueListImpl() : m_values() {}
+
+ ValueListImpl(const ValueListImpl &rhs) : m_values(rhs.m_values) {}
+
+ ValueListImpl &operator=(const ValueListImpl &rhs) {
+ if (this == &rhs)
+ return *this;
+ m_values = rhs.m_values;
+ return *this;
+ }
+
+ uint32_t GetSize() { return m_values.size(); }
+
+ void Append(const lldb::SBValue &sb_value) { m_values.push_back(sb_value); }
+
+ void Append(const ValueListImpl &list) {
+ for (auto val : list.m_values)
+ Append(val);
+ }
+
+ lldb::SBValue GetValueAtIndex(uint32_t index) {
+ if (index >= GetSize())
+ return lldb::SBValue();
+ return m_values[index];
+ }
+
+ lldb::SBValue FindValueByUID(lldb::user_id_t uid) {
+ for (auto val : m_values) {
+ if (val.IsValid() && val.GetID() == uid)
+ return val;
+ }
+ return lldb::SBValue();
+ }
+
+ lldb::SBValue GetFirstValueByName(const char *name) const {
+ if (name) {
+ for (auto val : m_values) {
+ if (val.IsValid() && val.GetName() && strcmp(name, val.GetName()) == 0)
+ return val;
+ }
}
+ return lldb::SBValue();
+ }
private:
- std::vector<lldb::SBValue> m_values;
+ std::vector<lldb::SBValue> m_values;
};
-SBValueList::SBValueList () :
- m_opaque_ap ()
-{
-}
+SBValueList::SBValueList() : m_opaque_ap() {}
-SBValueList::SBValueList (const SBValueList &rhs) :
- m_opaque_ap ()
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+SBValueList::SBValueList(const SBValueList &rhs) : m_opaque_ap() {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (rhs.IsValid())
- m_opaque_ap.reset (new ValueListImpl (*rhs));
+ if (rhs.IsValid())
+ m_opaque_ap.reset(new ValueListImpl(*rhs));
- if (log)
- {
- log->Printf ("SBValueList::SBValueList (rhs.ap=%p) => this.ap = %p",
- static_cast<void*>(rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL),
- static_cast<void*>(m_opaque_ap.get()));
- }
+ if (log) {
+ log->Printf(
+ "SBValueList::SBValueList (rhs.ap=%p) => this.ap = %p",
+ static_cast<void *>(rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL),
+ static_cast<void *>(m_opaque_ap.get()));
+ }
}
-SBValueList::SBValueList (const ValueListImpl *lldb_object_ptr) :
- m_opaque_ap ()
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- if (lldb_object_ptr)
- m_opaque_ap.reset (new ValueListImpl (*lldb_object_ptr));
-
- if (log)
- {
- log->Printf ("SBValueList::SBValueList (lldb_object_ptr=%p) => this.ap = %p",
- static_cast<const void*>(lldb_object_ptr),
- static_cast<void*>(m_opaque_ap.get()));
- }
-}
+SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) : m_opaque_ap() {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-SBValueList::~SBValueList ()
-{
-}
+ if (lldb_object_ptr)
+ m_opaque_ap.reset(new ValueListImpl(*lldb_object_ptr));
-bool
-SBValueList::IsValid () const
-{
- return (m_opaque_ap.get() != NULL);
-}
-
-void
-SBValueList::Clear()
-{
- m_opaque_ap.reset();
-}
-
-const SBValueList &
-SBValueList::operator = (const SBValueList &rhs)
-{
- if (this != &rhs)
- {
- if (rhs.IsValid())
- m_opaque_ap.reset (new ValueListImpl (*rhs));
- else
- m_opaque_ap.reset ();
- }
- return *this;
+ if (log) {
+ log->Printf("SBValueList::SBValueList (lldb_object_ptr=%p) => this.ap = %p",
+ static_cast<const void *>(lldb_object_ptr),
+ static_cast<void *>(m_opaque_ap.get()));
+ }
}
-ValueListImpl *
-SBValueList::operator->()
-{
- return m_opaque_ap.get();
-}
+SBValueList::~SBValueList() {}
-ValueListImpl &
-SBValueList::operator*()
-{
- return *m_opaque_ap;
-}
+bool SBValueList::IsValid() const { return (m_opaque_ap.get() != NULL); }
-const ValueListImpl *
-SBValueList::operator->() const
-{
- return m_opaque_ap.get();
+void SBValueList::Clear() { m_opaque_ap.reset(); }
+
+const SBValueList &SBValueList::operator=(const SBValueList &rhs) {
+ if (this != &rhs) {
+ if (rhs.IsValid())
+ m_opaque_ap.reset(new ValueListImpl(*rhs));
+ else
+ m_opaque_ap.reset();
+ }
+ return *this;
}
-const ValueListImpl &
-SBValueList::operator*() const
-{
- return *m_opaque_ap;
+ValueListImpl *SBValueList::operator->() { return m_opaque_ap.get(); }
+
+ValueListImpl &SBValueList::operator*() { return *m_opaque_ap; }
+
+const ValueListImpl *SBValueList::operator->() const {
+ return m_opaque_ap.get();
}
-void
-SBValueList::Append (const SBValue &val_obj)
-{
- CreateIfNeeded ();
- m_opaque_ap->Append (val_obj);
+const ValueListImpl &SBValueList::operator*() const { return *m_opaque_ap; }
+
+void SBValueList::Append(const SBValue &val_obj) {
+ CreateIfNeeded();
+ m_opaque_ap->Append(val_obj);
}
-void
-SBValueList::Append (lldb::ValueObjectSP& val_obj_sp)
-{
- if (val_obj_sp)
- {
- CreateIfNeeded ();
- m_opaque_ap->Append (SBValue(val_obj_sp));
- }
+void SBValueList::Append(lldb::ValueObjectSP &val_obj_sp) {
+ if (val_obj_sp) {
+ CreateIfNeeded();
+ m_opaque_ap->Append(SBValue(val_obj_sp));
+ }
}
-void
-SBValueList::Append (const lldb::SBValueList& value_list)
-{
- if (value_list.IsValid())
- {
- CreateIfNeeded ();
- m_opaque_ap->Append (*value_list);
- }
+void SBValueList::Append(const lldb::SBValueList &value_list) {
+ if (value_list.IsValid()) {
+ CreateIfNeeded();
+ m_opaque_ap->Append(*value_list);
+ }
}
+SBValue SBValueList::GetValueAtIndex(uint32_t idx) const {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-SBValue
-SBValueList::GetValueAtIndex (uint32_t idx) const
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- //if (log)
- // log->Printf ("SBValueList::GetValueAtIndex (uint32_t idx) idx = %d", idx);
-
- SBValue sb_value;
- if (m_opaque_ap.get())
- sb_value = m_opaque_ap->GetValueAtIndex (idx);
-
- if (log)
- {
- SBStream sstr;
- sb_value.GetDescription (sstr);
- log->Printf ("SBValueList::GetValueAtIndex (this.ap=%p, idx=%d) => SBValue (this.sp = %p, '%s')",
- static_cast<void*>(m_opaque_ap.get()), idx,
- static_cast<void*>(sb_value.GetSP().get()), sstr.GetData());
- }
+ // if (log)
+ // log->Printf ("SBValueList::GetValueAtIndex (uint32_t idx) idx = %d",
+ // idx);
- return sb_value;
+ SBValue sb_value;
+ if (m_opaque_ap.get())
+ sb_value = m_opaque_ap->GetValueAtIndex(idx);
+
+ if (log) {
+ SBStream sstr;
+ sb_value.GetDescription(sstr);
+ log->Printf("SBValueList::GetValueAtIndex (this.ap=%p, idx=%d) => SBValue "
+ "(this.sp = %p, '%s')",
+ static_cast<void *>(m_opaque_ap.get()), idx,
+ static_cast<void *>(sb_value.GetSP().get()), sstr.GetData());
+ }
+
+ return sb_value;
}
-uint32_t
-SBValueList::GetSize () const
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+uint32_t SBValueList::GetSize() const {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- //if (log)
- // log->Printf ("SBValueList::GetSize ()");
+ // if (log)
+ // log->Printf ("SBValueList::GetSize ()");
- uint32_t size = 0;
- if (m_opaque_ap.get())
- size = m_opaque_ap->GetSize();
+ uint32_t size = 0;
+ if (m_opaque_ap.get())
+ size = m_opaque_ap->GetSize();
- if (log)
- log->Printf ("SBValueList::GetSize (this.ap=%p) => %d",
- static_cast<void*>(m_opaque_ap.get()), size);
+ if (log)
+ log->Printf("SBValueList::GetSize (this.ap=%p) => %d",
+ static_cast<void *>(m_opaque_ap.get()), size);
- return size;
+ return size;
}
-void
-SBValueList::CreateIfNeeded ()
-{
- if (m_opaque_ap.get() == NULL)
- m_opaque_ap.reset (new ValueListImpl());
+void SBValueList::CreateIfNeeded() {
+ if (m_opaque_ap.get() == NULL)
+ m_opaque_ap.reset(new ValueListImpl());
}
-
-SBValue
-SBValueList::FindValueObjectByUID (lldb::user_id_t uid)
-{
- SBValue sb_value;
- if (m_opaque_ap.get())
- sb_value = m_opaque_ap->FindValueByUID(uid);
- return sb_value;
+SBValue SBValueList::FindValueObjectByUID(lldb::user_id_t uid) {
+ SBValue sb_value;
+ if (m_opaque_ap.get())
+ sb_value = m_opaque_ap->FindValueByUID(uid);
+ return sb_value;
}
-SBValue
-SBValueList::GetFirstValueByName (const char* name) const
-{
- SBValue sb_value;
- if (m_opaque_ap.get())
- sb_value = m_opaque_ap->GetFirstValueByName(name);
- return sb_value;
+SBValue SBValueList::GetFirstValueByName(const char *name) const {
+ SBValue sb_value;
+ if (m_opaque_ap.get())
+ sb_value = m_opaque_ap->GetFirstValueByName(name);
+ return sb_value;
}
-void *
-SBValueList::opaque_ptr ()
-{
- return m_opaque_ap.get();
-}
+void *SBValueList::opaque_ptr() { return m_opaque_ap.get(); }
-ValueListImpl &
-SBValueList::ref ()
-{
- CreateIfNeeded();
- return *m_opaque_ap.get();
+ValueListImpl &SBValueList::ref() {
+ CreateIfNeeded();
+ return *m_opaque_ap.get();
}
Modified: lldb/trunk/source/API/SBVariablesOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBVariablesOptions.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBVariablesOptions.cpp (original)
+++ lldb/trunk/source/API/SBVariablesOptions.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- SBVariablesOptions.cpp --------------------------------------*- C++ -*-===//
+//===-- SBVariablesOptions.cpp --------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,248 +8,148 @@
//
//===----------------------------------------------------------------------===//
-
#include "lldb/API/SBVariablesOptions.h"
using namespace lldb;
using namespace lldb_private;
-class VariablesOptionsImpl
-{
+class VariablesOptionsImpl {
public:
- VariablesOptionsImpl () :
- m_include_arguments(false),
- m_include_locals(false),
- m_include_statics(false),
- m_in_scope_only(false),
- m_include_runtime_support_values(false),
- m_use_dynamic(lldb::eNoDynamicValues)
- {}
-
- VariablesOptionsImpl (const VariablesOptionsImpl&) = default;
-
- ~VariablesOptionsImpl () = default;
-
- VariablesOptionsImpl&
- operator = (const VariablesOptionsImpl&) = default;
-
- bool
- GetIncludeArguments () const
- {
- return m_include_arguments;
- }
-
- void
- SetIncludeArguments (bool b)
- {
- m_include_arguments = b;
- }
-
- bool
- GetIncludeLocals () const
- {
- return m_include_locals;
- }
-
- void
- SetIncludeLocals (bool b)
- {
- m_include_locals = b;
- }
-
- bool
- GetIncludeStatics () const
- {
- return m_include_statics;
- }
-
- void
- SetIncludeStatics (bool b)
- {
- m_include_statics = b;
- }
-
- bool
- GetInScopeOnly () const
- {
- return m_in_scope_only;
- }
-
- void
- SetInScopeOnly (bool b)
- {
- m_in_scope_only = b;
- }
-
- bool
- GetIncludeRuntimeSupportValues () const
- {
- return m_include_runtime_support_values;
- }
-
- void
- SetIncludeRuntimeSupportValues (bool b)
- {
- m_include_runtime_support_values = b;
- }
-
- lldb::DynamicValueType
- GetUseDynamic () const
- {
- return m_use_dynamic;
- }
-
- void
- SetUseDynamic (lldb::DynamicValueType d)
- {
- m_use_dynamic = d;
- }
+ VariablesOptionsImpl()
+ : m_include_arguments(false), m_include_locals(false),
+ m_include_statics(false), m_in_scope_only(false),
+ m_include_runtime_support_values(false),
+ m_use_dynamic(lldb::eNoDynamicValues) {}
+
+ VariablesOptionsImpl(const VariablesOptionsImpl &) = default;
+
+ ~VariablesOptionsImpl() = default;
+
+ VariablesOptionsImpl &operator=(const VariablesOptionsImpl &) = default;
+
+ bool GetIncludeArguments() const { return m_include_arguments; }
+
+ void SetIncludeArguments(bool b) { m_include_arguments = b; }
+
+ bool GetIncludeLocals() const { return m_include_locals; }
+
+ void SetIncludeLocals(bool b) { m_include_locals = b; }
+
+ bool GetIncludeStatics() const { return m_include_statics; }
+
+ void SetIncludeStatics(bool b) { m_include_statics = b; }
+
+ bool GetInScopeOnly() const { return m_in_scope_only; }
+
+ void SetInScopeOnly(bool b) { m_in_scope_only = b; }
+
+ bool GetIncludeRuntimeSupportValues() const {
+ return m_include_runtime_support_values;
+ }
+
+ void SetIncludeRuntimeSupportValues(bool b) {
+ m_include_runtime_support_values = b;
+ }
+
+ lldb::DynamicValueType GetUseDynamic() const { return m_use_dynamic; }
+
+ void SetUseDynamic(lldb::DynamicValueType d) { m_use_dynamic = d; }
-
private:
- bool m_include_arguments : 1;
- bool m_include_locals : 1;
- bool m_include_statics : 1;
- bool m_in_scope_only : 1;
- bool m_include_runtime_support_values : 1;
- lldb::DynamicValueType m_use_dynamic;
+ bool m_include_arguments : 1;
+ bool m_include_locals : 1;
+ bool m_include_statics : 1;
+ bool m_in_scope_only : 1;
+ bool m_include_runtime_support_values : 1;
+ lldb::DynamicValueType m_use_dynamic;
};
-SBVariablesOptions::SBVariablesOptions () :
-m_opaque_ap(new VariablesOptionsImpl())
-{
-}
+SBVariablesOptions::SBVariablesOptions()
+ : m_opaque_ap(new VariablesOptionsImpl()) {}
-SBVariablesOptions::SBVariablesOptions (const SBVariablesOptions& options) :
-m_opaque_ap(new VariablesOptionsImpl(options.ref()))
-{
-}
+SBVariablesOptions::SBVariablesOptions(const SBVariablesOptions &options)
+ : m_opaque_ap(new VariablesOptionsImpl(options.ref())) {}
-SBVariablesOptions&
-SBVariablesOptions::operator = (const SBVariablesOptions& options)
-{
- m_opaque_ap.reset(new VariablesOptionsImpl(options.ref()));
- return *this;
+SBVariablesOptions &SBVariablesOptions::
+operator=(const SBVariablesOptions &options) {
+ m_opaque_ap.reset(new VariablesOptionsImpl(options.ref()));
+ return *this;
}
-SBVariablesOptions::~SBVariablesOptions () = default;
+SBVariablesOptions::~SBVariablesOptions() = default;
-bool
-SBVariablesOptions::IsValid () const
-{
- return m_opaque_ap.get() != nullptr;
+bool SBVariablesOptions::IsValid() const {
+ return m_opaque_ap.get() != nullptr;
}
-bool
-SBVariablesOptions::GetIncludeArguments () const
-{
- return m_opaque_ap->GetIncludeArguments();
+bool SBVariablesOptions::GetIncludeArguments() const {
+ return m_opaque_ap->GetIncludeArguments();
}
-void
-SBVariablesOptions::SetIncludeArguments (bool arguments)
-{
- m_opaque_ap->SetIncludeArguments(arguments);
+void SBVariablesOptions::SetIncludeArguments(bool arguments) {
+ m_opaque_ap->SetIncludeArguments(arguments);
}
-bool
-SBVariablesOptions::GetIncludeLocals () const
-{
- return m_opaque_ap->GetIncludeLocals();
+bool SBVariablesOptions::GetIncludeLocals() const {
+ return m_opaque_ap->GetIncludeLocals();
}
-void
-SBVariablesOptions::SetIncludeLocals (bool locals)
-{
- m_opaque_ap->SetIncludeLocals(locals);
+void SBVariablesOptions::SetIncludeLocals(bool locals) {
+ m_opaque_ap->SetIncludeLocals(locals);
}
-bool
-SBVariablesOptions::GetIncludeStatics () const
-{
- return m_opaque_ap->GetIncludeStatics();
+bool SBVariablesOptions::GetIncludeStatics() const {
+ return m_opaque_ap->GetIncludeStatics();
}
-void
-SBVariablesOptions::SetIncludeStatics (bool statics)
-{
- m_opaque_ap->SetIncludeStatics(statics);
+void SBVariablesOptions::SetIncludeStatics(bool statics) {
+ m_opaque_ap->SetIncludeStatics(statics);
}
-bool
-SBVariablesOptions::GetInScopeOnly () const
-{
- return m_opaque_ap->GetInScopeOnly();
+bool SBVariablesOptions::GetInScopeOnly() const {
+ return m_opaque_ap->GetInScopeOnly();
}
-void
-SBVariablesOptions::SetInScopeOnly (bool in_scope_only)
-{
- m_opaque_ap->SetInScopeOnly(in_scope_only);
+void SBVariablesOptions::SetInScopeOnly(bool in_scope_only) {
+ m_opaque_ap->SetInScopeOnly(in_scope_only);
}
-bool
-SBVariablesOptions::GetIncludeRuntimeSupportValues () const
-{
- return m_opaque_ap->GetIncludeRuntimeSupportValues();
+bool SBVariablesOptions::GetIncludeRuntimeSupportValues() const {
+ return m_opaque_ap->GetIncludeRuntimeSupportValues();
}
-void
-SBVariablesOptions::SetIncludeRuntimeSupportValues (bool runtime_support_values)
-{
- m_opaque_ap->SetIncludeRuntimeSupportValues(runtime_support_values);
+void SBVariablesOptions::SetIncludeRuntimeSupportValues(
+ bool runtime_support_values) {
+ m_opaque_ap->SetIncludeRuntimeSupportValues(runtime_support_values);
}
-lldb::DynamicValueType
-SBVariablesOptions::GetUseDynamic () const
-{
- return m_opaque_ap->GetUseDynamic();
+lldb::DynamicValueType SBVariablesOptions::GetUseDynamic() const {
+ return m_opaque_ap->GetUseDynamic();
}
-void
-SBVariablesOptions::SetUseDynamic (lldb::DynamicValueType dynamic)
-{
- m_opaque_ap->SetUseDynamic(dynamic);
+void SBVariablesOptions::SetUseDynamic(lldb::DynamicValueType dynamic) {
+ m_opaque_ap->SetUseDynamic(dynamic);
}
-VariablesOptionsImpl *
-SBVariablesOptions::operator->()
-{
- return m_opaque_ap.operator->();
+VariablesOptionsImpl *SBVariablesOptions::operator->() {
+ return m_opaque_ap.operator->();
}
-const VariablesOptionsImpl *
-SBVariablesOptions::operator->() const
-{
- return m_opaque_ap.operator->();
+const VariablesOptionsImpl *SBVariablesOptions::operator->() const {
+ return m_opaque_ap.operator->();
}
-VariablesOptionsImpl *
-SBVariablesOptions::get ()
-{
- return m_opaque_ap.get();
-}
+VariablesOptionsImpl *SBVariablesOptions::get() { return m_opaque_ap.get(); }
-VariablesOptionsImpl &
-SBVariablesOptions::ref()
-{
- return *m_opaque_ap;
-}
+VariablesOptionsImpl &SBVariablesOptions::ref() { return *m_opaque_ap; }
-const VariablesOptionsImpl &
-SBVariablesOptions::ref() const
-{
- return *m_opaque_ap;
+const VariablesOptionsImpl &SBVariablesOptions::ref() const {
+ return *m_opaque_ap;
}
-SBVariablesOptions::SBVariablesOptions (VariablesOptionsImpl *lldb_object_ptr) :
-m_opaque_ap(std::move(lldb_object_ptr))
-{
-}
+SBVariablesOptions::SBVariablesOptions(VariablesOptionsImpl *lldb_object_ptr)
+ : m_opaque_ap(std::move(lldb_object_ptr)) {}
-void
-SBVariablesOptions::SetOptions (VariablesOptionsImpl *lldb_object_ptr)
-{
- m_opaque_ap.reset(std::move(lldb_object_ptr));
+void SBVariablesOptions::SetOptions(VariablesOptionsImpl *lldb_object_ptr) {
+ m_opaque_ap.reset(std::move(lldb_object_ptr));
}
-
Modified: lldb/trunk/source/API/SBWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBWatchpoint.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SBWatchpoint.cpp (original)
+++ lldb/trunk/source/API/SBWatchpoint.cpp Tue Sep 6 15:57:50 2016
@@ -8,296 +8,234 @@
//===----------------------------------------------------------------------===//
#include "lldb/API/SBWatchpoint.h"
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBDefines.h"
#include "lldb/API/SBEvent.h"
#include "lldb/API/SBStream.h"
-#include "lldb/lldb-types.h"
-#include "lldb/lldb-defines.h"
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Breakpoint/WatchpointList.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Target/Target.h"
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-types.h"
using namespace lldb;
using namespace lldb_private;
+SBWatchpoint::SBWatchpoint() : m_opaque_sp() {}
-SBWatchpoint::SBWatchpoint () :
- m_opaque_sp ()
-{
-}
-
-SBWatchpoint::SBWatchpoint (const lldb::WatchpointSP &wp_sp) :
- m_opaque_sp (wp_sp)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- if (log)
- {
- SBStream sstr;
- GetDescription (sstr, lldb::eDescriptionLevelBrief);
- log->Printf ("SBWatchpoint::SBWatchpoint (const lldb::WatchpointSP &wp_sp"
- "=%p) => this.sp = %p (%s)",
- static_cast<void*>(wp_sp.get()),
- static_cast<void*>(m_opaque_sp.get()), sstr.GetData());
- }
-}
-
-SBWatchpoint::SBWatchpoint(const SBWatchpoint &rhs) :
- m_opaque_sp (rhs.m_opaque_sp)
-{
-}
-
-const SBWatchpoint &
-SBWatchpoint::operator = (const SBWatchpoint &rhs)
-{
- if (this != &rhs)
- m_opaque_sp = rhs.m_opaque_sp;
- return *this;
-}
-
-
-SBWatchpoint::~SBWatchpoint ()
-{
-}
-
-watch_id_t
-SBWatchpoint::GetID ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- watch_id_t watch_id = LLDB_INVALID_WATCH_ID;
- lldb::WatchpointSP watchpoint_sp(GetSP());
- if (watchpoint_sp)
- watch_id = watchpoint_sp->GetID();
-
- if (log)
- {
- if (watch_id == LLDB_INVALID_WATCH_ID)
- log->Printf ("SBWatchpoint(%p)::GetID () => LLDB_INVALID_WATCH_ID",
- static_cast<void*>(watchpoint_sp.get()));
- else
- log->Printf ("SBWatchpoint(%p)::GetID () => %u",
- static_cast<void*>(watchpoint_sp.get()), watch_id);
- }
-
- return watch_id;
-}
-
-bool
-SBWatchpoint::IsValid() const
-{
- return (bool) m_opaque_sp;
-}
-
-SBError
-SBWatchpoint::GetError ()
-{
- SBError sb_error;
- lldb::WatchpointSP watchpoint_sp(GetSP());
- if (watchpoint_sp)
- {
- sb_error.SetError(watchpoint_sp->GetError());
- }
- return sb_error;
-}
-
-int32_t
-SBWatchpoint::GetHardwareIndex ()
-{
- int32_t hw_index = -1;
-
- lldb::WatchpointSP watchpoint_sp(GetSP());
- if (watchpoint_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
- hw_index = watchpoint_sp->GetHardwareIndex();
- }
-
- return hw_index;
-}
-
-addr_t
-SBWatchpoint::GetWatchAddress ()
-{
- addr_t ret_addr = LLDB_INVALID_ADDRESS;
-
- lldb::WatchpointSP watchpoint_sp(GetSP());
- if (watchpoint_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
- ret_addr = watchpoint_sp->GetLoadAddress();
- }
-
- return ret_addr;
-}
-
-size_t
-SBWatchpoint::GetWatchSize ()
-{
- size_t watch_size = 0;
-
- lldb::WatchpointSP watchpoint_sp(GetSP());
- if (watchpoint_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
- watch_size = watchpoint_sp->GetByteSize();
- }
-
- return watch_size;
-}
-
-void
-SBWatchpoint::SetEnabled (bool enabled)
-{
- lldb::WatchpointSP watchpoint_sp(GetSP());
- if (watchpoint_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
- watchpoint_sp->SetEnabled(enabled);
- }
-}
-
-bool
-SBWatchpoint::IsEnabled ()
-{
- lldb::WatchpointSP watchpoint_sp(GetSP());
- if (watchpoint_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
- return watchpoint_sp->IsEnabled();
- }
- else
- return false;
+SBWatchpoint::SBWatchpoint(const lldb::WatchpointSP &wp_sp)
+ : m_opaque_sp(wp_sp) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ if (log) {
+ SBStream sstr;
+ GetDescription(sstr, lldb::eDescriptionLevelBrief);
+ log->Printf("SBWatchpoint::SBWatchpoint (const lldb::WatchpointSP &wp_sp"
+ "=%p) => this.sp = %p (%s)",
+ static_cast<void *>(wp_sp.get()),
+ static_cast<void *>(m_opaque_sp.get()), sstr.GetData());
+ }
}
-uint32_t
-SBWatchpoint::GetHitCount ()
-{
- uint32_t count = 0;
- lldb::WatchpointSP watchpoint_sp(GetSP());
- if (watchpoint_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
- count = watchpoint_sp->GetHitCount();
- }
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBWatchpoint(%p)::GetHitCount () => %u",
- static_cast<void*>(watchpoint_sp.get()), count);
-
- return count;
-}
-
-uint32_t
-SBWatchpoint::GetIgnoreCount ()
-{
- lldb::WatchpointSP watchpoint_sp(GetSP());
- if (watchpoint_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
- return watchpoint_sp->GetIgnoreCount();
- }
- else
- return 0;
+SBWatchpoint::SBWatchpoint(const SBWatchpoint &rhs)
+ : m_opaque_sp(rhs.m_opaque_sp) {}
+
+const SBWatchpoint &SBWatchpoint::operator=(const SBWatchpoint &rhs) {
+ if (this != &rhs)
+ m_opaque_sp = rhs.m_opaque_sp;
+ return *this;
}
-void
-SBWatchpoint::SetIgnoreCount (uint32_t n)
-{
- lldb::WatchpointSP watchpoint_sp(GetSP());
- if (watchpoint_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
- watchpoint_sp->SetIgnoreCount (n);
- }
-}
-
-const char *
-SBWatchpoint::GetCondition ()
-{
- lldb::WatchpointSP watchpoint_sp(GetSP());
- if (watchpoint_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
- return watchpoint_sp->GetConditionText ();
- }
- return NULL;
-}
-
-void
-SBWatchpoint::SetCondition (const char *condition)
-{
- lldb::WatchpointSP watchpoint_sp(GetSP());
- if (watchpoint_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
- watchpoint_sp->SetCondition (condition);
- }
-}
-
-bool
-SBWatchpoint::GetDescription (SBStream &description, DescriptionLevel level)
-{
- Stream &strm = description.ref();
-
- lldb::WatchpointSP watchpoint_sp(GetSP());
- if (watchpoint_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
- watchpoint_sp->GetDescription (&strm, level);
- strm.EOL();
- }
+SBWatchpoint::~SBWatchpoint() {}
+
+watch_id_t SBWatchpoint::GetID() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ watch_id_t watch_id = LLDB_INVALID_WATCH_ID;
+ lldb::WatchpointSP watchpoint_sp(GetSP());
+ if (watchpoint_sp)
+ watch_id = watchpoint_sp->GetID();
+
+ if (log) {
+ if (watch_id == LLDB_INVALID_WATCH_ID)
+ log->Printf("SBWatchpoint(%p)::GetID () => LLDB_INVALID_WATCH_ID",
+ static_cast<void *>(watchpoint_sp.get()));
else
- strm.PutCString ("No value");
+ log->Printf("SBWatchpoint(%p)::GetID () => %u",
+ static_cast<void *>(watchpoint_sp.get()), watch_id);
+ }
+
+ return watch_id;
+}
+
+bool SBWatchpoint::IsValid() const { return (bool)m_opaque_sp; }
+
+SBError SBWatchpoint::GetError() {
+ SBError sb_error;
+ lldb::WatchpointSP watchpoint_sp(GetSP());
+ if (watchpoint_sp) {
+ sb_error.SetError(watchpoint_sp->GetError());
+ }
+ return sb_error;
+}
+
+int32_t SBWatchpoint::GetHardwareIndex() {
+ int32_t hw_index = -1;
+
+ lldb::WatchpointSP watchpoint_sp(GetSP());
+ if (watchpoint_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ watchpoint_sp->GetTarget().GetAPIMutex());
+ hw_index = watchpoint_sp->GetHardwareIndex();
+ }
+
+ return hw_index;
+}
- return true;
+addr_t SBWatchpoint::GetWatchAddress() {
+ addr_t ret_addr = LLDB_INVALID_ADDRESS;
+
+ lldb::WatchpointSP watchpoint_sp(GetSP());
+ if (watchpoint_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ watchpoint_sp->GetTarget().GetAPIMutex());
+ ret_addr = watchpoint_sp->GetLoadAddress();
+ }
+
+ return ret_addr;
+}
+
+size_t SBWatchpoint::GetWatchSize() {
+ size_t watch_size = 0;
+
+ lldb::WatchpointSP watchpoint_sp(GetSP());
+ if (watchpoint_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ watchpoint_sp->GetTarget().GetAPIMutex());
+ watch_size = watchpoint_sp->GetByteSize();
+ }
+
+ return watch_size;
+}
+
+void SBWatchpoint::SetEnabled(bool enabled) {
+ lldb::WatchpointSP watchpoint_sp(GetSP());
+ if (watchpoint_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ watchpoint_sp->GetTarget().GetAPIMutex());
+ watchpoint_sp->SetEnabled(enabled);
+ }
+}
+
+bool SBWatchpoint::IsEnabled() {
+ lldb::WatchpointSP watchpoint_sp(GetSP());
+ if (watchpoint_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ watchpoint_sp->GetTarget().GetAPIMutex());
+ return watchpoint_sp->IsEnabled();
+ } else
+ return false;
+}
+
+uint32_t SBWatchpoint::GetHitCount() {
+ uint32_t count = 0;
+ lldb::WatchpointSP watchpoint_sp(GetSP());
+ if (watchpoint_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ watchpoint_sp->GetTarget().GetAPIMutex());
+ count = watchpoint_sp->GetHitCount();
+ }
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ if (log)
+ log->Printf("SBWatchpoint(%p)::GetHitCount () => %u",
+ static_cast<void *>(watchpoint_sp.get()), count);
+
+ return count;
}
-void
-SBWatchpoint::Clear ()
-{
- m_opaque_sp.reset();
+uint32_t SBWatchpoint::GetIgnoreCount() {
+ lldb::WatchpointSP watchpoint_sp(GetSP());
+ if (watchpoint_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ watchpoint_sp->GetTarget().GetAPIMutex());
+ return watchpoint_sp->GetIgnoreCount();
+ } else
+ return 0;
}
-lldb::WatchpointSP
-SBWatchpoint::GetSP () const
-{
- return m_opaque_sp;
+void SBWatchpoint::SetIgnoreCount(uint32_t n) {
+ lldb::WatchpointSP watchpoint_sp(GetSP());
+ if (watchpoint_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ watchpoint_sp->GetTarget().GetAPIMutex());
+ watchpoint_sp->SetIgnoreCount(n);
+ }
}
-void
-SBWatchpoint::SetSP (const lldb::WatchpointSP &sp)
-{
- m_opaque_sp = sp;
+const char *SBWatchpoint::GetCondition() {
+ lldb::WatchpointSP watchpoint_sp(GetSP());
+ if (watchpoint_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ watchpoint_sp->GetTarget().GetAPIMutex());
+ return watchpoint_sp->GetConditionText();
+ }
+ return NULL;
}
-bool
-SBWatchpoint::EventIsWatchpointEvent (const lldb::SBEvent &event)
-{
- return Watchpoint::WatchpointEventData::GetEventDataFromEvent(event.get()) != NULL;
+void SBWatchpoint::SetCondition(const char *condition) {
+ lldb::WatchpointSP watchpoint_sp(GetSP());
+ if (watchpoint_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ watchpoint_sp->GetTarget().GetAPIMutex());
+ watchpoint_sp->SetCondition(condition);
+ }
+}
+
+bool SBWatchpoint::GetDescription(SBStream &description,
+ DescriptionLevel level) {
+ Stream &strm = description.ref();
+
+ lldb::WatchpointSP watchpoint_sp(GetSP());
+ if (watchpoint_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ watchpoint_sp->GetTarget().GetAPIMutex());
+ watchpoint_sp->GetDescription(&strm, level);
+ strm.EOL();
+ } else
+ strm.PutCString("No value");
+
+ return true;
+}
+
+void SBWatchpoint::Clear() { m_opaque_sp.reset(); }
+
+lldb::WatchpointSP SBWatchpoint::GetSP() const { return m_opaque_sp; }
+
+void SBWatchpoint::SetSP(const lldb::WatchpointSP &sp) { m_opaque_sp = sp; }
+bool SBWatchpoint::EventIsWatchpointEvent(const lldb::SBEvent &event) {
+ return Watchpoint::WatchpointEventData::GetEventDataFromEvent(event.get()) !=
+ NULL;
}
WatchpointEventType
-SBWatchpoint::GetWatchpointEventTypeFromEvent (const SBEvent& event)
-{
- if (event.IsValid())
- return Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent (event.GetSP());
- return eWatchpointEventTypeInvalidType;
+SBWatchpoint::GetWatchpointEventTypeFromEvent(const SBEvent &event) {
+ if (event.IsValid())
+ return Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent(
+ event.GetSP());
+ return eWatchpointEventTypeInvalidType;
}
-SBWatchpoint
-SBWatchpoint::GetWatchpointFromEvent (const lldb::SBEvent& event)
-{
- SBWatchpoint sb_watchpoint;
- if (event.IsValid())
- sb_watchpoint.m_opaque_sp = Watchpoint::WatchpointEventData::GetWatchpointFromEvent (event.GetSP());
- return sb_watchpoint;
+SBWatchpoint SBWatchpoint::GetWatchpointFromEvent(const lldb::SBEvent &event) {
+ SBWatchpoint sb_watchpoint;
+ if (event.IsValid())
+ sb_watchpoint.m_opaque_sp =
+ Watchpoint::WatchpointEventData::GetWatchpointFromEvent(event.GetSP());
+ return sb_watchpoint;
}
Modified: lldb/trunk/source/API/SystemInitializerFull.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SystemInitializerFull.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/API/SystemInitializerFull.cpp (original)
+++ lldb/trunk/source/API/SystemInitializerFull.cpp Tue Sep 6 15:57:50 2016
@@ -43,8 +43,8 @@
#include "Plugins/ABI/SysV-s390x/ABISysV_s390x.h"
#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
-#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h"
+#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
@@ -55,9 +55,9 @@
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
#include "Plugins/Language/Go/GoLanguage.h"
#include "Plugins/Language/Java/JavaLanguage.h"
+#include "Plugins/Language/OCaml/OCamlLanguage.h"
#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h"
-#include "Plugins/Language/OCaml/OCamlLanguage.h"
#include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
#include "Plugins/LanguageRuntime/Go/GoLanguageRuntime.h"
#include "Plugins/LanguageRuntime/Java/JavaLanguageRuntime.h"
@@ -107,9 +107,9 @@
#endif
#if defined(_MSC_VER)
-#include "lldb/Host/windows/windows.h"
#include "Plugins/Process/Windows/Live/ProcessWindowsLive.h"
#include "Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h"
+#include "lldb/Host/windows/windows.h"
#endif
#include "llvm/Support/TargetSelect.h"
@@ -122,14 +122,12 @@ using namespace lldb_private;
// Defined in the SWIG source file
#if PY_MAJOR_VERSION >= 3
-extern "C" PyObject*
-PyInit__lldb(void);
+extern "C" PyObject *PyInit__lldb(void);
#define LLDBSwigPyInit PyInit__lldb
#else
-extern "C" void
-init_lldb(void);
+extern "C" void init_lldb(void);
#define LLDBSwigPyInit init_lldb
#endif
@@ -139,412 +137,370 @@ init_lldb(void);
// we still need to use function pointers to them instead of relying
// on linkage-time resolution because the SWIG stuff and this file
// get built at different times
-extern "C" bool
-LLDBSwigPythonBreakpointCallbackFunction (const char *python_function_name,
- const char *session_dictionary_name,
- const lldb::StackFrameSP& sb_frame,
- const lldb::BreakpointLocationSP& sb_bp_loc);
-
-extern "C" bool
-LLDBSwigPythonWatchpointCallbackFunction (const char *python_function_name,
- const char *session_dictionary_name,
- const lldb::StackFrameSP& sb_frame,
- const lldb::WatchpointSP& sb_wp);
-
-extern "C" bool
-LLDBSwigPythonCallTypeScript (const char *python_function_name,
- void *session_dictionary,
- const lldb::ValueObjectSP& valobj_sp,
- void** pyfunct_wrapper,
- const lldb::TypeSummaryOptionsSP& options_sp,
- std::string& retval);
-
-extern "C" void*
-LLDBSwigPythonCreateSyntheticProvider (const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::ValueObjectSP& valobj_sp);
-
-extern "C" void*
-LLDBSwigPythonCreateCommandObject (const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::DebuggerSP debugger_sp);
-
-extern "C" void*
-LLDBSwigPythonCreateScriptedThreadPlan (const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::ThreadPlanSP& thread_plan_sp);
-
-extern "C" bool
-LLDBSWIGPythonCallThreadPlan (void *implementor,
- const char *method_name,
- Event *event_sp,
- bool &got_error);
-
-extern "C" size_t
-LLDBSwigPython_CalculateNumChildren (void *implementor, uint32_t max);
+extern "C" bool LLDBSwigPythonBreakpointCallbackFunction(
+ const char *python_function_name, const char *session_dictionary_name,
+ const lldb::StackFrameSP &sb_frame,
+ const lldb::BreakpointLocationSP &sb_bp_loc);
+
+extern "C" bool LLDBSwigPythonWatchpointCallbackFunction(
+ const char *python_function_name, const char *session_dictionary_name,
+ const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp);
+
+extern "C" bool LLDBSwigPythonCallTypeScript(
+ const char *python_function_name, void *session_dictionary,
+ const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper,
+ const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval);
extern "C" void *
-LLDBSwigPython_GetChildAtIndex (void *implementor, uint32_t idx);
-
-extern "C" int
-LLDBSwigPython_GetIndexOfChildWithName (void *implementor, const char* child_name);
+LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::ValueObjectSP &valobj_sp);
extern "C" void *
-LLDBSWIGPython_CastPyObjectToSBValue (void* data);
+LLDBSwigPythonCreateCommandObject(const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::DebuggerSP debugger_sp);
-extern lldb::ValueObjectSP
-LLDBSWIGPython_GetValueObjectSPFromSBValue (void* data);
+extern "C" void *LLDBSwigPythonCreateScriptedThreadPlan(
+ const char *python_class_name, const char *session_dictionary_name,
+ const lldb::ThreadPlanSP &thread_plan_sp);
-extern "C" bool
-LLDBSwigPython_UpdateSynthProviderInstance (void* implementor);
+extern "C" bool LLDBSWIGPythonCallThreadPlan(void *implementor,
+ const char *method_name,
+ Event *event_sp, bool &got_error);
-extern "C" bool
-LLDBSwigPython_MightHaveChildrenSynthProviderInstance (void* implementor);
+extern "C" size_t LLDBSwigPython_CalculateNumChildren(void *implementor,
+ uint32_t max);
-extern "C" void *
-LLDBSwigPython_GetValueSynthProviderInstance (void* implementor);
+extern "C" void *LLDBSwigPython_GetChildAtIndex(void *implementor,
+ uint32_t idx);
-extern "C" bool
-LLDBSwigPythonCallCommand (const char *python_function_name,
- const char *session_dictionary_name,
- lldb::DebuggerSP& debugger,
- const char* args,
- lldb_private::CommandReturnObject &cmd_retobj,
- lldb::ExecutionContextRefSP exe_ctx_ref_sp);
+extern "C" int LLDBSwigPython_GetIndexOfChildWithName(void *implementor,
+ const char *child_name);
-extern "C" bool
-LLDBSwigPythonCallCommandObject (void *implementor,
- lldb::DebuggerSP& debugger,
- const char* args,
- lldb_private::CommandReturnObject& cmd_retobj,
- lldb::ExecutionContextRefSP exe_ctx_ref_sp);
+extern "C" void *LLDBSWIGPython_CastPyObjectToSBValue(void *data);
-extern "C" bool
-LLDBSwigPythonCallModuleInit (const char *python_module_name,
- const char *session_dictionary_name,
- lldb::DebuggerSP& debugger);
-
-extern "C" void*
-LLDBSWIGPythonCreateOSPlugin (const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::ProcessSP& process_sp);
+extern lldb::ValueObjectSP
+LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data);
-extern "C" bool
-LLDBSWIGPythonRunScriptKeywordProcess (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::ProcessSP& process,
- std::string& output);
+extern "C" bool LLDBSwigPython_UpdateSynthProviderInstance(void *implementor);
extern "C" bool
-LLDBSWIGPythonRunScriptKeywordThread (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::ThreadSP& thread,
- std::string& output);
+LLDBSwigPython_MightHaveChildrenSynthProviderInstance(void *implementor);
+
+extern "C" void *
+LLDBSwigPython_GetValueSynthProviderInstance(void *implementor);
extern "C" bool
-LLDBSWIGPythonRunScriptKeywordTarget (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::TargetSP& target,
- std::string& output);
+LLDBSwigPythonCallCommand(const char *python_function_name,
+ const char *session_dictionary_name,
+ lldb::DebuggerSP &debugger, const char *args,
+ lldb_private::CommandReturnObject &cmd_retobj,
+ lldb::ExecutionContextRefSP exe_ctx_ref_sp);
extern "C" bool
-LLDBSWIGPythonRunScriptKeywordFrame (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::StackFrameSP& frame,
- std::string& output);
+LLDBSwigPythonCallCommandObject(void *implementor, lldb::DebuggerSP &debugger,
+ const char *args,
+ lldb_private::CommandReturnObject &cmd_retobj,
+ lldb::ExecutionContextRefSP exe_ctx_ref_sp);
extern "C" bool
-LLDBSWIGPythonRunScriptKeywordValue (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::ValueObjectSP& value,
- std::string& output);
+LLDBSwigPythonCallModuleInit(const char *python_module_name,
+ const char *session_dictionary_name,
+ lldb::DebuggerSP &debugger);
-extern "C" void*
-LLDBSWIGPython_GetDynamicSetting (void* module,
- const char* setting,
- const lldb::TargetSP& target_sp);
+extern "C" void *
+LLDBSWIGPythonCreateOSPlugin(const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::ProcessSP &process_sp);
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordProcess(
+ const char *python_function_name, const char *session_dictionary_name,
+ lldb::ProcessSP &process, std::string &output);
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordThread(
+ const char *python_function_name, const char *session_dictionary_name,
+ lldb::ThreadSP &thread, std::string &output);
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordTarget(
+ const char *python_function_name, const char *session_dictionary_name,
+ lldb::TargetSP &target, std::string &output);
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordFrame(
+ const char *python_function_name, const char *session_dictionary_name,
+ lldb::StackFrameSP &frame, std::string &output);
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordValue(
+ const char *python_function_name, const char *session_dictionary_name,
+ lldb::ValueObjectSP &value, std::string &output);
+extern "C" void *
+LLDBSWIGPython_GetDynamicSetting(void *module, const char *setting,
+ const lldb::TargetSP &target_sp);
#endif
-SystemInitializerFull::SystemInitializerFull()
-{
-}
+SystemInitializerFull::SystemInitializerFull() {}
-SystemInitializerFull::~SystemInitializerFull()
-{
-}
+SystemInitializerFull::~SystemInitializerFull() {}
-void
-SystemInitializerFull::Initialize()
-{
- SystemInitializerCommon::Initialize();
- ScriptInterpreterNone::Initialize();
+void SystemInitializerFull::Initialize() {
+ SystemInitializerCommon::Initialize();
+ ScriptInterpreterNone::Initialize();
#ifndef LLDB_DISABLE_PYTHON
- OperatingSystemPython::Initialize();
+ OperatingSystemPython::Initialize();
#endif
- OperatingSystemGo::Initialize();
+ OperatingSystemGo::Initialize();
#if !defined(LLDB_DISABLE_PYTHON)
- InitializeSWIG();
+ InitializeSWIG();
- // ScriptInterpreterPython::Initialize() depends on things like HostInfo being initialized
- // so it can compute the python directory etc, so we need to do this after
- // SystemInitializerCommon::Initialize().
- ScriptInterpreterPython::Initialize();
-#endif
-
- platform_freebsd::PlatformFreeBSD::Initialize();
- platform_linux::PlatformLinux::Initialize();
- platform_netbsd::PlatformNetBSD::Initialize();
- PlatformWindows::Initialize();
- PlatformKalimba::Initialize();
- platform_android::PlatformAndroid::Initialize();
- PlatformRemoteiOS::Initialize();
- PlatformMacOSX::Initialize();
+ // ScriptInterpreterPython::Initialize() depends on things like HostInfo being
+ // initialized
+ // so it can compute the python directory etc, so we need to do this after
+ // SystemInitializerCommon::Initialize().
+ ScriptInterpreterPython::Initialize();
+#endif
+
+ platform_freebsd::PlatformFreeBSD::Initialize();
+ platform_linux::PlatformLinux::Initialize();
+ platform_netbsd::PlatformNetBSD::Initialize();
+ PlatformWindows::Initialize();
+ PlatformKalimba::Initialize();
+ platform_android::PlatformAndroid::Initialize();
+ PlatformRemoteiOS::Initialize();
+ PlatformMacOSX::Initialize();
#if defined(__APPLE__)
- PlatformiOSSimulator::Initialize();
- PlatformDarwinKernel::Initialize();
+ PlatformiOSSimulator::Initialize();
+ PlatformDarwinKernel::Initialize();
#endif
- // Initialize LLVM and Clang
- llvm::InitializeAllTargets();
- llvm::InitializeAllAsmPrinters();
- llvm::InitializeAllTargetMCs();
- llvm::InitializeAllDisassemblers();
-
- ClangASTContext::Initialize();
- GoASTContext::Initialize();
- JavaASTContext::Initialize();
- OCamlASTContext::Initialize();
-
- ABIMacOSX_i386::Initialize();
- ABIMacOSX_arm::Initialize();
- ABIMacOSX_arm64::Initialize();
- ABISysV_arm::Initialize();
- ABISysV_arm64::Initialize();
- ABISysV_hexagon::Initialize();
- ABISysV_i386::Initialize();
- ABISysV_x86_64::Initialize();
- ABISysV_ppc::Initialize();
- ABISysV_ppc64::Initialize();
- ABISysV_mips::Initialize();
- ABISysV_mips64::Initialize();
- ABISysV_s390x::Initialize();
- DisassemblerLLVMC::Initialize();
+ // Initialize LLVM and Clang
+ llvm::InitializeAllTargets();
+ llvm::InitializeAllAsmPrinters();
+ llvm::InitializeAllTargetMCs();
+ llvm::InitializeAllDisassemblers();
+
+ ClangASTContext::Initialize();
+ GoASTContext::Initialize();
+ JavaASTContext::Initialize();
+ OCamlASTContext::Initialize();
+
+ ABIMacOSX_i386::Initialize();
+ ABIMacOSX_arm::Initialize();
+ ABIMacOSX_arm64::Initialize();
+ ABISysV_arm::Initialize();
+ ABISysV_arm64::Initialize();
+ ABISysV_hexagon::Initialize();
+ ABISysV_i386::Initialize();
+ ABISysV_x86_64::Initialize();
+ ABISysV_ppc::Initialize();
+ ABISysV_ppc64::Initialize();
+ ABISysV_mips::Initialize();
+ ABISysV_mips64::Initialize();
+ ABISysV_s390x::Initialize();
+ DisassemblerLLVMC::Initialize();
- JITLoaderGDB::Initialize();
- ProcessElfCore::Initialize();
+ JITLoaderGDB::Initialize();
+ ProcessElfCore::Initialize();
#if defined(_MSC_VER)
- ProcessWinMiniDump::Initialize();
+ ProcessWinMiniDump::Initialize();
#endif
- MemoryHistoryASan::Initialize();
- AddressSanitizerRuntime::Initialize();
- ThreadSanitizerRuntime::Initialize();
-
- SymbolVendorELF::Initialize();
- SymbolFileDWARF::Initialize();
- SymbolFilePDB::Initialize();
- SymbolFileSymtab::Initialize();
- UnwindAssemblyInstEmulation::Initialize();
- UnwindAssembly_x86::Initialize();
- EmulateInstructionARM64::Initialize();
- SymbolFileDWARFDebugMap::Initialize();
- ItaniumABILanguageRuntime::Initialize();
- AppleObjCRuntimeV2::Initialize();
- AppleObjCRuntimeV1::Initialize();
- SystemRuntimeMacOSX::Initialize();
- RenderScriptRuntime::Initialize();
- GoLanguageRuntime::Initialize();
- JavaLanguageRuntime::Initialize();
-
- CPlusPlusLanguage::Initialize();
- GoLanguage::Initialize();
- JavaLanguage::Initialize();
- ObjCLanguage::Initialize();
- ObjCPlusPlusLanguage::Initialize();
- OCamlLanguage::Initialize();
+ MemoryHistoryASan::Initialize();
+ AddressSanitizerRuntime::Initialize();
+ ThreadSanitizerRuntime::Initialize();
+
+ SymbolVendorELF::Initialize();
+ SymbolFileDWARF::Initialize();
+ SymbolFilePDB::Initialize();
+ SymbolFileSymtab::Initialize();
+ UnwindAssemblyInstEmulation::Initialize();
+ UnwindAssembly_x86::Initialize();
+ EmulateInstructionARM64::Initialize();
+ SymbolFileDWARFDebugMap::Initialize();
+ ItaniumABILanguageRuntime::Initialize();
+ AppleObjCRuntimeV2::Initialize();
+ AppleObjCRuntimeV1::Initialize();
+ SystemRuntimeMacOSX::Initialize();
+ RenderScriptRuntime::Initialize();
+ GoLanguageRuntime::Initialize();
+ JavaLanguageRuntime::Initialize();
+
+ CPlusPlusLanguage::Initialize();
+ GoLanguage::Initialize();
+ JavaLanguage::Initialize();
+ ObjCLanguage::Initialize();
+ ObjCPlusPlusLanguage::Initialize();
+ OCamlLanguage::Initialize();
#if defined(_MSC_VER)
- ProcessWindowsLive::Initialize();
+ ProcessWindowsLive::Initialize();
#endif
#if defined(__FreeBSD__)
- ProcessFreeBSD::Initialize();
+ ProcessFreeBSD::Initialize();
#endif
#if defined(__APPLE__)
- SymbolVendorMacOSX::Initialize();
- ProcessKDP::Initialize();
- ProcessMachCore::Initialize();
- PlatformAppleTVSimulator::Initialize();
- PlatformAppleWatchSimulator::Initialize();
- PlatformRemoteAppleTV::Initialize();
- PlatformRemoteAppleWatch::Initialize();
- DynamicLoaderDarwinKernel::Initialize();
-#endif
-
- // This plugin is valid on any host that talks to a Darwin remote.
- // It shouldn't be limited to __APPLE__.
- StructuredDataDarwinLog::Initialize();
-
- //----------------------------------------------------------------------
- // Platform agnostic plugins
- //----------------------------------------------------------------------
- platform_gdb_server::PlatformRemoteGDBServer::Initialize();
-
- process_gdb_remote::ProcessGDBRemote::Initialize();
- DynamicLoaderMacOSXDYLD::Initialize();
- DynamicLoaderMacOS::Initialize();
- DynamicLoaderPOSIXDYLD::Initialize();
- DynamicLoaderStatic::Initialize();
- DynamicLoaderWindowsDYLD::Initialize();
-
- // Scan for any system or user LLDB plug-ins
- PluginManager::Initialize();
+ SymbolVendorMacOSX::Initialize();
+ ProcessKDP::Initialize();
+ ProcessMachCore::Initialize();
+ PlatformAppleTVSimulator::Initialize();
+ PlatformAppleWatchSimulator::Initialize();
+ PlatformRemoteAppleTV::Initialize();
+ PlatformRemoteAppleWatch::Initialize();
+ DynamicLoaderDarwinKernel::Initialize();
+#endif
+
+ // This plugin is valid on any host that talks to a Darwin remote.
+ // It shouldn't be limited to __APPLE__.
+ StructuredDataDarwinLog::Initialize();
+
+ //----------------------------------------------------------------------
+ // Platform agnostic plugins
+ //----------------------------------------------------------------------
+ platform_gdb_server::PlatformRemoteGDBServer::Initialize();
+
+ process_gdb_remote::ProcessGDBRemote::Initialize();
+ DynamicLoaderMacOSXDYLD::Initialize();
+ DynamicLoaderMacOS::Initialize();
+ DynamicLoaderPOSIXDYLD::Initialize();
+ DynamicLoaderStatic::Initialize();
+ DynamicLoaderWindowsDYLD::Initialize();
+
+ // Scan for any system or user LLDB plug-ins
+ PluginManager::Initialize();
+
+ // The process settings need to know about installed plug-ins, so the Settings
+ // must be initialized
+ // AFTER PluginManager::Initialize is called.
- // The process settings need to know about installed plug-ins, so the Settings must be initialized
- // AFTER PluginManager::Initialize is called.
-
- Debugger::SettingsInitialize();
+ Debugger::SettingsInitialize();
}
-void SystemInitializerFull::InitializeSWIG()
-{
+void SystemInitializerFull::InitializeSWIG() {
#if !defined(LLDB_DISABLE_PYTHON)
- ScriptInterpreterPython::InitializeInterpreter(
- LLDBSwigPyInit,
- LLDBSwigPythonBreakpointCallbackFunction,
- LLDBSwigPythonWatchpointCallbackFunction,
- LLDBSwigPythonCallTypeScript,
- LLDBSwigPythonCreateSyntheticProvider,
- LLDBSwigPythonCreateCommandObject,
- LLDBSwigPython_CalculateNumChildren,
- LLDBSwigPython_GetChildAtIndex,
- LLDBSwigPython_GetIndexOfChildWithName,
- LLDBSWIGPython_CastPyObjectToSBValue,
- LLDBSWIGPython_GetValueObjectSPFromSBValue,
- LLDBSwigPython_UpdateSynthProviderInstance,
- LLDBSwigPython_MightHaveChildrenSynthProviderInstance,
- LLDBSwigPython_GetValueSynthProviderInstance,
- LLDBSwigPythonCallCommand,
- LLDBSwigPythonCallCommandObject,
- LLDBSwigPythonCallModuleInit,
- LLDBSWIGPythonCreateOSPlugin,
- LLDBSWIGPythonRunScriptKeywordProcess,
- LLDBSWIGPythonRunScriptKeywordThread,
- LLDBSWIGPythonRunScriptKeywordTarget,
- LLDBSWIGPythonRunScriptKeywordFrame,
- LLDBSWIGPythonRunScriptKeywordValue,
- LLDBSWIGPython_GetDynamicSetting,
- LLDBSwigPythonCreateScriptedThreadPlan,
- LLDBSWIGPythonCallThreadPlan);
+ ScriptInterpreterPython::InitializeInterpreter(
+ LLDBSwigPyInit, LLDBSwigPythonBreakpointCallbackFunction,
+ LLDBSwigPythonWatchpointCallbackFunction, LLDBSwigPythonCallTypeScript,
+ LLDBSwigPythonCreateSyntheticProvider, LLDBSwigPythonCreateCommandObject,
+ LLDBSwigPython_CalculateNumChildren, LLDBSwigPython_GetChildAtIndex,
+ LLDBSwigPython_GetIndexOfChildWithName,
+ LLDBSWIGPython_CastPyObjectToSBValue,
+ LLDBSWIGPython_GetValueObjectSPFromSBValue,
+ LLDBSwigPython_UpdateSynthProviderInstance,
+ LLDBSwigPython_MightHaveChildrenSynthProviderInstance,
+ LLDBSwigPython_GetValueSynthProviderInstance, LLDBSwigPythonCallCommand,
+ LLDBSwigPythonCallCommandObject, LLDBSwigPythonCallModuleInit,
+ LLDBSWIGPythonCreateOSPlugin, LLDBSWIGPythonRunScriptKeywordProcess,
+ LLDBSWIGPythonRunScriptKeywordThread,
+ LLDBSWIGPythonRunScriptKeywordTarget, LLDBSWIGPythonRunScriptKeywordFrame,
+ LLDBSWIGPythonRunScriptKeywordValue, LLDBSWIGPython_GetDynamicSetting,
+ LLDBSwigPythonCreateScriptedThreadPlan, LLDBSWIGPythonCallThreadPlan);
#endif
}
-void
-SystemInitializerFull::Terminate()
-{
- Timer scoped_timer(LLVM_PRETTY_FUNCTION, LLVM_PRETTY_FUNCTION);
-
- Debugger::SettingsTerminate();
-
- // Terminate and unload and loaded system or user LLDB plug-ins
- PluginManager::Terminate();
-
- ClangASTContext::Terminate();
- GoASTContext::Terminate();
- JavaASTContext::Terminate();
- OCamlASTContext::Terminate();
-
- ABIMacOSX_i386::Terminate();
- ABIMacOSX_arm::Terminate();
- ABIMacOSX_arm64::Terminate();
- ABISysV_arm::Terminate();
- ABISysV_arm64::Terminate();
- ABISysV_hexagon::Terminate();
- ABISysV_i386::Terminate();
- ABISysV_x86_64::Terminate();
- ABISysV_ppc::Terminate();
- ABISysV_ppc64::Terminate();
- ABISysV_mips::Terminate();
- ABISysV_mips64::Terminate();
- ABISysV_s390x::Terminate();
- DisassemblerLLVMC::Terminate();
+void SystemInitializerFull::Terminate() {
+ Timer scoped_timer(LLVM_PRETTY_FUNCTION, LLVM_PRETTY_FUNCTION);
+
+ Debugger::SettingsTerminate();
+
+ // Terminate and unload and loaded system or user LLDB plug-ins
+ PluginManager::Terminate();
+
+ ClangASTContext::Terminate();
+ GoASTContext::Terminate();
+ JavaASTContext::Terminate();
+ OCamlASTContext::Terminate();
+
+ ABIMacOSX_i386::Terminate();
+ ABIMacOSX_arm::Terminate();
+ ABIMacOSX_arm64::Terminate();
+ ABISysV_arm::Terminate();
+ ABISysV_arm64::Terminate();
+ ABISysV_hexagon::Terminate();
+ ABISysV_i386::Terminate();
+ ABISysV_x86_64::Terminate();
+ ABISysV_ppc::Terminate();
+ ABISysV_ppc64::Terminate();
+ ABISysV_mips::Terminate();
+ ABISysV_mips64::Terminate();
+ ABISysV_s390x::Terminate();
+ DisassemblerLLVMC::Terminate();
- JITLoaderGDB::Terminate();
- ProcessElfCore::Terminate();
+ JITLoaderGDB::Terminate();
+ ProcessElfCore::Terminate();
#if defined(_MSC_VER)
- ProcessWinMiniDump::Terminate();
+ ProcessWinMiniDump::Terminate();
#endif
- MemoryHistoryASan::Terminate();
- AddressSanitizerRuntime::Terminate();
- ThreadSanitizerRuntime::Terminate();
- SymbolVendorELF::Terminate();
- SymbolFileDWARF::Terminate();
- SymbolFilePDB::Terminate();
- SymbolFileSymtab::Terminate();
- UnwindAssembly_x86::Terminate();
- UnwindAssemblyInstEmulation::Terminate();
- EmulateInstructionARM64::Terminate();
- SymbolFileDWARFDebugMap::Terminate();
- ItaniumABILanguageRuntime::Terminate();
- AppleObjCRuntimeV2::Terminate();
- AppleObjCRuntimeV1::Terminate();
- SystemRuntimeMacOSX::Terminate();
- RenderScriptRuntime::Terminate();
- JavaLanguageRuntime::Terminate();
-
- CPlusPlusLanguage::Terminate();
- GoLanguage::Terminate();
- JavaLanguage::Terminate();
- ObjCLanguage::Terminate();
- ObjCPlusPlusLanguage::Terminate();
- OCamlLanguage::Terminate();
+ MemoryHistoryASan::Terminate();
+ AddressSanitizerRuntime::Terminate();
+ ThreadSanitizerRuntime::Terminate();
+ SymbolVendorELF::Terminate();
+ SymbolFileDWARF::Terminate();
+ SymbolFilePDB::Terminate();
+ SymbolFileSymtab::Terminate();
+ UnwindAssembly_x86::Terminate();
+ UnwindAssemblyInstEmulation::Terminate();
+ EmulateInstructionARM64::Terminate();
+ SymbolFileDWARFDebugMap::Terminate();
+ ItaniumABILanguageRuntime::Terminate();
+ AppleObjCRuntimeV2::Terminate();
+ AppleObjCRuntimeV1::Terminate();
+ SystemRuntimeMacOSX::Terminate();
+ RenderScriptRuntime::Terminate();
+ JavaLanguageRuntime::Terminate();
+
+ CPlusPlusLanguage::Terminate();
+ GoLanguage::Terminate();
+ JavaLanguage::Terminate();
+ ObjCLanguage::Terminate();
+ ObjCPlusPlusLanguage::Terminate();
+ OCamlLanguage::Terminate();
#if defined(__APPLE__)
- DynamicLoaderDarwinKernel::Terminate();
- ProcessMachCore::Terminate();
- ProcessKDP::Terminate();
- SymbolVendorMacOSX::Terminate();
- PlatformAppleTVSimulator::Terminate();
- PlatformAppleWatchSimulator::Terminate();
- PlatformRemoteAppleTV::Terminate();
- PlatformRemoteAppleWatch::Terminate();
+ DynamicLoaderDarwinKernel::Terminate();
+ ProcessMachCore::Terminate();
+ ProcessKDP::Terminate();
+ SymbolVendorMacOSX::Terminate();
+ PlatformAppleTVSimulator::Terminate();
+ PlatformAppleWatchSimulator::Terminate();
+ PlatformRemoteAppleTV::Terminate();
+ PlatformRemoteAppleWatch::Terminate();
#endif
#if defined(__FreeBSD__)
- ProcessFreeBSD::Terminate();
+ ProcessFreeBSD::Terminate();
#endif
- Debugger::SettingsTerminate();
+ Debugger::SettingsTerminate();
- platform_gdb_server::PlatformRemoteGDBServer::Terminate();
- process_gdb_remote::ProcessGDBRemote::Terminate();
- StructuredDataDarwinLog::Terminate();
-
- DynamicLoaderMacOSXDYLD::Terminate();
- DynamicLoaderMacOS::Terminate();
- DynamicLoaderPOSIXDYLD::Terminate();
- DynamicLoaderStatic::Terminate();
- DynamicLoaderWindowsDYLD::Terminate();
+ platform_gdb_server::PlatformRemoteGDBServer::Terminate();
+ process_gdb_remote::ProcessGDBRemote::Terminate();
+ StructuredDataDarwinLog::Terminate();
+
+ DynamicLoaderMacOSXDYLD::Terminate();
+ DynamicLoaderMacOS::Terminate();
+ DynamicLoaderPOSIXDYLD::Terminate();
+ DynamicLoaderStatic::Terminate();
+ DynamicLoaderWindowsDYLD::Terminate();
#ifndef LLDB_DISABLE_PYTHON
- OperatingSystemPython::Terminate();
+ OperatingSystemPython::Terminate();
#endif
- OperatingSystemGo::Terminate();
+ OperatingSystemGo::Terminate();
- platform_freebsd::PlatformFreeBSD::Terminate();
- platform_linux::PlatformLinux::Terminate();
- platform_netbsd::PlatformNetBSD::Terminate();
- PlatformWindows::Terminate();
- PlatformKalimba::Terminate();
- platform_android::PlatformAndroid::Terminate();
- PlatformMacOSX::Terminate();
- PlatformRemoteiOS::Terminate();
+ platform_freebsd::PlatformFreeBSD::Terminate();
+ platform_linux::PlatformLinux::Terminate();
+ platform_netbsd::PlatformNetBSD::Terminate();
+ PlatformWindows::Terminate();
+ PlatformKalimba::Terminate();
+ platform_android::PlatformAndroid::Terminate();
+ PlatformMacOSX::Terminate();
+ PlatformRemoteiOS::Terminate();
#if defined(__APPLE__)
- PlatformiOSSimulator::Terminate();
- PlatformDarwinKernel::Terminate();
+ PlatformiOSSimulator::Terminate();
+ PlatformDarwinKernel::Terminate();
#endif
- // Now shutdown the common parts, in reverse order.
- SystemInitializerCommon::Terminate();
+ // Now shutdown the common parts, in reverse order.
+ SystemInitializerCommon::Terminate();
}
Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Tue Sep 6 15:57:50 2016
@@ -13,12 +13,12 @@
#include "llvm/Support/Casting.h"
// Project includes
-#include "lldb/Core/Address.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Breakpoint/BreakpointResolverFileLine.h"
+#include "lldb/Core/Address.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
@@ -36,47 +36,33 @@ using namespace lldb;
using namespace lldb_private;
using namespace llvm;
-const ConstString &
-Breakpoint::GetEventIdentifier ()
-{
- static ConstString g_identifier("event-identifier.breakpoint.changed");
- return g_identifier;
+const ConstString &Breakpoint::GetEventIdentifier() {
+ static ConstString g_identifier("event-identifier.breakpoint.changed");
+ return g_identifier;
}
//----------------------------------------------------------------------
// Breakpoint constructor
//----------------------------------------------------------------------
-Breakpoint::Breakpoint(Target &target,
- SearchFilterSP &filter_sp,
- BreakpointResolverSP &resolver_sp,
- bool hardware,
- bool resolve_indirect_symbols) :
- m_being_created(true),
- m_hardware(hardware),
- m_target (target),
- m_filter_sp (filter_sp),
- m_resolver_sp (resolver_sp),
- m_options (),
- m_locations (*this),
- m_resolve_indirect_symbols(resolve_indirect_symbols),
- m_hit_count(0)
-{
- m_being_created = false;
-}
-
-Breakpoint::Breakpoint (Target &new_target, Breakpoint &source_bp) :
- m_being_created(true),
- m_hardware(source_bp.m_hardware),
- m_target(new_target),
- m_name_list (source_bp.m_name_list),
- m_options (source_bp.m_options),
- m_locations(*this),
- m_resolve_indirect_symbols(source_bp.m_resolve_indirect_symbols),
- m_hit_count(0)
-{
- // Now go through and copy the filter & resolver:
- m_resolver_sp = source_bp.m_resolver_sp->CopyForBreakpoint(*this);
- m_filter_sp = source_bp.m_filter_sp->CopyForBreakpoint(*this);
+Breakpoint::Breakpoint(Target &target, SearchFilterSP &filter_sp,
+ BreakpointResolverSP &resolver_sp, bool hardware,
+ bool resolve_indirect_symbols)
+ : m_being_created(true), m_hardware(hardware), m_target(target),
+ m_filter_sp(filter_sp), m_resolver_sp(resolver_sp), m_options(),
+ m_locations(*this), m_resolve_indirect_symbols(resolve_indirect_symbols),
+ m_hit_count(0) {
+ m_being_created = false;
+}
+
+Breakpoint::Breakpoint(Target &new_target, Breakpoint &source_bp)
+ : m_being_created(true), m_hardware(source_bp.m_hardware),
+ m_target(new_target), m_name_list(source_bp.m_name_list),
+ m_options(source_bp.m_options), m_locations(*this),
+ m_resolve_indirect_symbols(source_bp.m_resolve_indirect_symbols),
+ m_hit_count(0) {
+ // Now go through and copy the filter & resolver:
+ m_resolver_sp = source_bp.m_resolver_sp->CopyForBreakpoint(*this);
+ m_filter_sp = source_bp.m_filter_sp->CopyForBreakpoint(*this);
}
//----------------------------------------------------------------------
@@ -84,52 +70,36 @@ Breakpoint::Breakpoint (Target &new_targ
//----------------------------------------------------------------------
Breakpoint::~Breakpoint() = default;
-const lldb::TargetSP
-Breakpoint::GetTargetSP ()
-{
- return m_target.shared_from_this();
+const lldb::TargetSP Breakpoint::GetTargetSP() {
+ return m_target.shared_from_this();
}
-bool
-Breakpoint::IsInternal () const
-{
- return LLDB_BREAK_ID_IS_INTERNAL(m_bid);
-}
+bool Breakpoint::IsInternal() const { return LLDB_BREAK_ID_IS_INTERNAL(m_bid); }
-BreakpointLocationSP
-Breakpoint::AddLocation (const Address &addr, bool *new_location)
-{
- return m_locations.AddLocation (addr, m_resolve_indirect_symbols, new_location);
+BreakpointLocationSP Breakpoint::AddLocation(const Address &addr,
+ bool *new_location) {
+ return m_locations.AddLocation(addr, m_resolve_indirect_symbols,
+ new_location);
}
-BreakpointLocationSP
-Breakpoint::FindLocationByAddress (const Address &addr)
-{
- return m_locations.FindByAddress(addr);
+BreakpointLocationSP Breakpoint::FindLocationByAddress(const Address &addr) {
+ return m_locations.FindByAddress(addr);
}
-break_id_t
-Breakpoint::FindLocationIDByAddress (const Address &addr)
-{
- return m_locations.FindIDByAddress(addr);
+break_id_t Breakpoint::FindLocationIDByAddress(const Address &addr) {
+ return m_locations.FindIDByAddress(addr);
}
-BreakpointLocationSP
-Breakpoint::FindLocationByID (break_id_t bp_loc_id)
-{
- return m_locations.FindByID(bp_loc_id);
+BreakpointLocationSP Breakpoint::FindLocationByID(break_id_t bp_loc_id) {
+ return m_locations.FindByID(bp_loc_id);
}
-BreakpointLocationSP
-Breakpoint::GetLocationAtIndex (size_t index)
-{
- return m_locations.GetByIndex(index);
+BreakpointLocationSP Breakpoint::GetLocationAtIndex(size_t index) {
+ return m_locations.GetByIndex(index);
}
-void
-Breakpoint::RemoveInvalidLocations (const ArchSpec &arch)
-{
- m_locations.RemoveInvalidLocations(arch);
+void Breakpoint::RemoveInvalidLocations(const ArchSpec &arch) {
+ m_locations.RemoveInvalidLocations(arch);
}
// For each of the overall options we need to decide how they propagate to
@@ -140,962 +110,815 @@ Breakpoint::RemoveInvalidLocations (cons
// That way you can conveniently turn off a whole breakpoint without messing
// up the individual settings.
-void
-Breakpoint::SetEnabled (bool enable)
-{
- if (enable == m_options.IsEnabled())
- return;
-
- m_options.SetEnabled(enable);
- if (enable)
- m_locations.ResolveAllBreakpointSites();
- else
- m_locations.ClearAllBreakpointSites();
-
- SendBreakpointChangedEvent (enable ? eBreakpointEventTypeEnabled : eBreakpointEventTypeDisabled);
+void Breakpoint::SetEnabled(bool enable) {
+ if (enable == m_options.IsEnabled())
+ return;
+
+ m_options.SetEnabled(enable);
+ if (enable)
+ m_locations.ResolveAllBreakpointSites();
+ else
+ m_locations.ClearAllBreakpointSites();
+ SendBreakpointChangedEvent(enable ? eBreakpointEventTypeEnabled
+ : eBreakpointEventTypeDisabled);
}
-bool
-Breakpoint::IsEnabled ()
-{
- return m_options.IsEnabled();
-}
-
-void
-Breakpoint::SetIgnoreCount (uint32_t n)
-{
- if (m_options.GetIgnoreCount() == n)
- return;
-
- m_options.SetIgnoreCount(n);
- SendBreakpointChangedEvent (eBreakpointEventTypeIgnoreChanged);
-}
-
-void
-Breakpoint::DecrementIgnoreCount ()
-{
- uint32_t ignore = m_options.GetIgnoreCount();
- if (ignore != 0)
- m_options.SetIgnoreCount(ignore - 1);
-}
-
-uint32_t
-Breakpoint::GetIgnoreCount () const
-{
- return m_options.GetIgnoreCount();
-}
-
-bool
-Breakpoint::IgnoreCountShouldStop ()
-{
- uint32_t ignore = GetIgnoreCount();
- if (ignore != 0)
- {
- // When we get here we know the location that caused the stop doesn't have an ignore count,
- // since by contract we call it first... So we don't have to find & decrement it, we only have
- // to decrement our own ignore count.
- DecrementIgnoreCount();
- return false;
- }
- else
- return true;
+bool Breakpoint::IsEnabled() { return m_options.IsEnabled(); }
+
+void Breakpoint::SetIgnoreCount(uint32_t n) {
+ if (m_options.GetIgnoreCount() == n)
+ return;
+
+ m_options.SetIgnoreCount(n);
+ SendBreakpointChangedEvent(eBreakpointEventTypeIgnoreChanged);
}
-uint32_t
-Breakpoint::GetHitCount () const
-{
- return m_hit_count;
+void Breakpoint::DecrementIgnoreCount() {
+ uint32_t ignore = m_options.GetIgnoreCount();
+ if (ignore != 0)
+ m_options.SetIgnoreCount(ignore - 1);
}
-bool
-Breakpoint::IsOneShot () const
-{
- return m_options.IsOneShot();
+uint32_t Breakpoint::GetIgnoreCount() const {
+ return m_options.GetIgnoreCount();
}
-void
-Breakpoint::SetOneShot (bool one_shot)
-{
- m_options.SetOneShot (one_shot);
+bool Breakpoint::IgnoreCountShouldStop() {
+ uint32_t ignore = GetIgnoreCount();
+ if (ignore != 0) {
+ // When we get here we know the location that caused the stop doesn't have
+ // an ignore count,
+ // since by contract we call it first... So we don't have to find &
+ // decrement it, we only have
+ // to decrement our own ignore count.
+ DecrementIgnoreCount();
+ return false;
+ } else
+ return true;
}
-void
-Breakpoint::SetThreadID (lldb::tid_t thread_id)
-{
- if (m_options.GetThreadSpec()->GetTID() == thread_id)
- return;
-
- m_options.GetThreadSpec()->SetTID(thread_id);
- SendBreakpointChangedEvent (eBreakpointEventTypeThreadChanged);
+uint32_t Breakpoint::GetHitCount() const { return m_hit_count; }
+
+bool Breakpoint::IsOneShot() const { return m_options.IsOneShot(); }
+
+void Breakpoint::SetOneShot(bool one_shot) { m_options.SetOneShot(one_shot); }
+
+void Breakpoint::SetThreadID(lldb::tid_t thread_id) {
+ if (m_options.GetThreadSpec()->GetTID() == thread_id)
+ return;
+
+ m_options.GetThreadSpec()->SetTID(thread_id);
+ SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
}
-lldb::tid_t
-Breakpoint::GetThreadID () const
-{
- if (m_options.GetThreadSpecNoCreate() == nullptr)
- return LLDB_INVALID_THREAD_ID;
- else
- return m_options.GetThreadSpecNoCreate()->GetTID();
+lldb::tid_t Breakpoint::GetThreadID() const {
+ if (m_options.GetThreadSpecNoCreate() == nullptr)
+ return LLDB_INVALID_THREAD_ID;
+ else
+ return m_options.GetThreadSpecNoCreate()->GetTID();
}
-void
-Breakpoint::SetThreadIndex (uint32_t index)
-{
- if (m_options.GetThreadSpec()->GetIndex() == index)
- return;
-
- m_options.GetThreadSpec()->SetIndex(index);
- SendBreakpointChangedEvent (eBreakpointEventTypeThreadChanged);
-}
-
-uint32_t
-Breakpoint::GetThreadIndex() const
-{
- if (m_options.GetThreadSpecNoCreate() == nullptr)
- return 0;
- else
- return m_options.GetThreadSpecNoCreate()->GetIndex();
+void Breakpoint::SetThreadIndex(uint32_t index) {
+ if (m_options.GetThreadSpec()->GetIndex() == index)
+ return;
+
+ m_options.GetThreadSpec()->SetIndex(index);
+ SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
}
-void
-Breakpoint::SetThreadName (const char *thread_name)
-{
- if (m_options.GetThreadSpec()->GetName() != nullptr
- && ::strcmp (m_options.GetThreadSpec()->GetName(), thread_name) == 0)
- return;
-
- m_options.GetThreadSpec()->SetName (thread_name);
- SendBreakpointChangedEvent (eBreakpointEventTypeThreadChanged);
-}
-
-const char *
-Breakpoint::GetThreadName () const
-{
- if (m_options.GetThreadSpecNoCreate() == nullptr)
- return nullptr;
- else
- return m_options.GetThreadSpecNoCreate()->GetName();
+uint32_t Breakpoint::GetThreadIndex() const {
+ if (m_options.GetThreadSpecNoCreate() == nullptr)
+ return 0;
+ else
+ return m_options.GetThreadSpecNoCreate()->GetIndex();
}
-void
-Breakpoint::SetQueueName (const char *queue_name)
-{
- if (m_options.GetThreadSpec()->GetQueueName() != nullptr
- && ::strcmp (m_options.GetThreadSpec()->GetQueueName(), queue_name) == 0)
- return;
-
- m_options.GetThreadSpec()->SetQueueName (queue_name);
- SendBreakpointChangedEvent (eBreakpointEventTypeThreadChanged);
-}
-
-const char *
-Breakpoint::GetQueueName () const
-{
- if (m_options.GetThreadSpecNoCreate() == nullptr)
- return nullptr;
- else
- return m_options.GetThreadSpecNoCreate()->GetQueueName();
+void Breakpoint::SetThreadName(const char *thread_name) {
+ if (m_options.GetThreadSpec()->GetName() != nullptr &&
+ ::strcmp(m_options.GetThreadSpec()->GetName(), thread_name) == 0)
+ return;
+
+ m_options.GetThreadSpec()->SetName(thread_name);
+ SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
+}
+
+const char *Breakpoint::GetThreadName() const {
+ if (m_options.GetThreadSpecNoCreate() == nullptr)
+ return nullptr;
+ else
+ return m_options.GetThreadSpecNoCreate()->GetName();
+}
+
+void Breakpoint::SetQueueName(const char *queue_name) {
+ if (m_options.GetThreadSpec()->GetQueueName() != nullptr &&
+ ::strcmp(m_options.GetThreadSpec()->GetQueueName(), queue_name) == 0)
+ return;
+
+ m_options.GetThreadSpec()->SetQueueName(queue_name);
+ SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
+}
+
+const char *Breakpoint::GetQueueName() const {
+ if (m_options.GetThreadSpecNoCreate() == nullptr)
+ return nullptr;
+ else
+ return m_options.GetThreadSpecNoCreate()->GetQueueName();
}
-void
-Breakpoint::SetCondition (const char *condition)
-{
- m_options.SetCondition (condition);
- SendBreakpointChangedEvent (eBreakpointEventTypeConditionChanged);
+void Breakpoint::SetCondition(const char *condition) {
+ m_options.SetCondition(condition);
+ SendBreakpointChangedEvent(eBreakpointEventTypeConditionChanged);
}
-const char *
-Breakpoint::GetConditionText () const
-{
- return m_options.GetConditionText();
+const char *Breakpoint::GetConditionText() const {
+ return m_options.GetConditionText();
}
// This function is used when "baton" doesn't need to be freed
-void
-Breakpoint::SetCallback (BreakpointHitCallback callback, void *baton, bool is_synchronous)
-{
- // The default "Baton" class will keep a copy of "baton" and won't free
- // or delete it when it goes goes out of scope.
- m_options.SetCallback(callback, BatonSP (new Baton(baton)), is_synchronous);
-
- SendBreakpointChangedEvent (eBreakpointEventTypeCommandChanged);
+void Breakpoint::SetCallback(BreakpointHitCallback callback, void *baton,
+ bool is_synchronous) {
+ // The default "Baton" class will keep a copy of "baton" and won't free
+ // or delete it when it goes goes out of scope.
+ m_options.SetCallback(callback, BatonSP(new Baton(baton)), is_synchronous);
+
+ SendBreakpointChangedEvent(eBreakpointEventTypeCommandChanged);
}
-// This function is used when a baton needs to be freed and therefore is
+// This function is used when a baton needs to be freed and therefore is
// contained in a "Baton" subclass.
-void
-Breakpoint::SetCallback (BreakpointHitCallback callback, const BatonSP &callback_baton_sp, bool is_synchronous)
-{
- m_options.SetCallback(callback, callback_baton_sp, is_synchronous);
-}
-
-void
-Breakpoint::ClearCallback ()
-{
- m_options.ClearCallback ();
-}
-
-bool
-Breakpoint::InvokeCallback (StoppointCallbackContext *context, break_id_t bp_loc_id)
-{
- return m_options.InvokeCallback (context, GetID(), bp_loc_id);
-}
-
-BreakpointOptions *
-Breakpoint::GetOptions ()
-{
- return &m_options;
-}
-
-void
-Breakpoint::ResolveBreakpoint ()
-{
- if (m_resolver_sp)
- m_resolver_sp->ResolveBreakpoint(*m_filter_sp);
-}
-
-void
-Breakpoint::ResolveBreakpointInModules (ModuleList &module_list, BreakpointLocationCollection &new_locations)
-{
- m_locations.StartRecordingNewLocations(new_locations);
-
- m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
-
- m_locations.StopRecordingNewLocations();
-}
-
-void
-Breakpoint::ResolveBreakpointInModules (ModuleList &module_list, bool send_event)
-{
- if (m_resolver_sp)
- {
- // If this is not an internal breakpoint, set up to record the new locations, then dispatch
- // an event with the new locations.
- if (!IsInternal() && send_event)
- {
- BreakpointEventData *new_locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsAdded,
- shared_from_this());
-
- ResolveBreakpointInModules (module_list, new_locations_event->GetBreakpointLocationCollection());
-
- if (new_locations_event->GetBreakpointLocationCollection().GetSize() != 0)
- {
- SendBreakpointChangedEvent (new_locations_event);
- }
- else
- delete new_locations_event;
- }
- else
- {
- m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
- }
+void Breakpoint::SetCallback(BreakpointHitCallback callback,
+ const BatonSP &callback_baton_sp,
+ bool is_synchronous) {
+ m_options.SetCallback(callback, callback_baton_sp, is_synchronous);
+}
+
+void Breakpoint::ClearCallback() { m_options.ClearCallback(); }
+
+bool Breakpoint::InvokeCallback(StoppointCallbackContext *context,
+ break_id_t bp_loc_id) {
+ return m_options.InvokeCallback(context, GetID(), bp_loc_id);
+}
+
+BreakpointOptions *Breakpoint::GetOptions() { return &m_options; }
+
+void Breakpoint::ResolveBreakpoint() {
+ if (m_resolver_sp)
+ m_resolver_sp->ResolveBreakpoint(*m_filter_sp);
+}
+
+void Breakpoint::ResolveBreakpointInModules(
+ ModuleList &module_list, BreakpointLocationCollection &new_locations) {
+ m_locations.StartRecordingNewLocations(new_locations);
+
+ m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
+
+ m_locations.StopRecordingNewLocations();
+}
+
+void Breakpoint::ResolveBreakpointInModules(ModuleList &module_list,
+ bool send_event) {
+ if (m_resolver_sp) {
+ // If this is not an internal breakpoint, set up to record the new
+ // locations, then dispatch
+ // an event with the new locations.
+ if (!IsInternal() && send_event) {
+ BreakpointEventData *new_locations_event = new BreakpointEventData(
+ eBreakpointEventTypeLocationsAdded, shared_from_this());
+
+ ResolveBreakpointInModules(
+ module_list, new_locations_event->GetBreakpointLocationCollection());
+
+ if (new_locations_event->GetBreakpointLocationCollection().GetSize() !=
+ 0) {
+ SendBreakpointChangedEvent(new_locations_event);
+ } else
+ delete new_locations_event;
+ } else {
+ m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
}
+ }
}
-void
-Breakpoint::ClearAllBreakpointSites ()
-{
- m_locations.ClearAllBreakpointSites();
+void Breakpoint::ClearAllBreakpointSites() {
+ m_locations.ClearAllBreakpointSites();
}
//----------------------------------------------------------------------
// ModulesChanged: Pass in a list of new modules, and
//----------------------------------------------------------------------
-void
-Breakpoint::ModulesChanged (ModuleList &module_list, bool load, bool delete_locations)
-{
- Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf ("Breakpoint::ModulesChanged: num_modules: %zu load: %i delete_locations: %i\n",
- module_list.GetSize(), load, delete_locations);
-
- std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
- if (load)
- {
- // The logic for handling new modules is:
- // 1) If the filter rejects this module, then skip it.
- // 2) Run through the current location list and if there are any locations
- // for that module, we mark the module as "seen" and we don't try to re-resolve
- // breakpoint locations for that module.
- // However, we do add breakpoint sites to these locations if needed.
- // 3) If we don't see this module in our breakpoint location list, call ResolveInModules.
-
- ModuleList new_modules; // We'll stuff the "unseen" modules in this list, and then resolve
- // them after the locations pass. Have to do it this way because
- // resolving breakpoints will add new locations potentially.
-
- for (ModuleSP module_sp : module_list.ModulesNoLocking())
- {
- bool seen = false;
- if (!m_filter_sp->ModulePasses (module_sp))
- continue;
-
- for (BreakpointLocationSP break_loc_sp : m_locations.BreakpointLocations())
- {
- if (!break_loc_sp->IsEnabled())
- continue;
- SectionSP section_sp (break_loc_sp->GetAddress().GetSection());
- if (!section_sp || section_sp->GetModule() == module_sp)
- {
- if (!seen)
- seen = true;
-
- if (!break_loc_sp->ResolveBreakpointSite())
- {
- if (log)
- log->Printf ("Warning: could not set breakpoint site for breakpoint location %d of breakpoint %d.\n",
- break_loc_sp->GetID(), GetID());
- }
- }
- }
-
- if (!seen)
- new_modules.AppendIfNeeded (module_sp);
- }
-
- if (new_modules.GetSize() > 0)
- {
- ResolveBreakpointInModules(new_modules);
- }
- }
- else
- {
- // Go through the currently set locations and if any have breakpoints in
- // the module list, then remove their breakpoint sites, and their locations if asked to.
-
- BreakpointEventData *removed_locations_event;
- if (!IsInternal())
- removed_locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsRemoved,
- shared_from_this());
- else
- removed_locations_event = nullptr;
-
- size_t num_modules = module_list.GetSize();
- for (size_t i = 0; i < num_modules; i++)
- {
- ModuleSP module_sp (module_list.GetModuleAtIndexUnlocked (i));
- if (m_filter_sp->ModulePasses (module_sp))
- {
- size_t loc_idx = 0;
- size_t num_locations = m_locations.GetSize();
- BreakpointLocationCollection locations_to_remove;
- for (loc_idx = 0; loc_idx < num_locations; loc_idx++)
- {
- BreakpointLocationSP break_loc_sp (m_locations.GetByIndex(loc_idx));
- SectionSP section_sp (break_loc_sp->GetAddress().GetSection());
- if (section_sp && section_sp->GetModule() == module_sp)
- {
- // Remove this breakpoint since the shared library is
- // unloaded, but keep the breakpoint location around
- // so we always get complete hit count and breakpoint
- // lifetime info
- break_loc_sp->ClearBreakpointSite();
- if (removed_locations_event)
- {
- removed_locations_event->GetBreakpointLocationCollection().Add(break_loc_sp);
- }
- if (delete_locations)
- locations_to_remove.Add (break_loc_sp);
- }
- }
-
- if (delete_locations)
- {
- size_t num_locations_to_remove = locations_to_remove.GetSize();
- for (loc_idx = 0; loc_idx < num_locations_to_remove; loc_idx++)
- m_locations.RemoveLocation (locations_to_remove.GetByIndex(loc_idx));
- }
+void Breakpoint::ModulesChanged(ModuleList &module_list, bool load,
+ bool delete_locations) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+ if (log)
+ log->Printf("Breakpoint::ModulesChanged: num_modules: %zu load: %i "
+ "delete_locations: %i\n",
+ module_list.GetSize(), load, delete_locations);
+
+ std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
+ if (load) {
+ // The logic for handling new modules is:
+ // 1) If the filter rejects this module, then skip it.
+ // 2) Run through the current location list and if there are any locations
+ // for that module, we mark the module as "seen" and we don't try to
+ // re-resolve
+ // breakpoint locations for that module.
+ // However, we do add breakpoint sites to these locations if needed.
+ // 3) If we don't see this module in our breakpoint location list, call
+ // ResolveInModules.
+
+ ModuleList new_modules; // We'll stuff the "unseen" modules in this list,
+ // and then resolve
+ // them after the locations pass. Have to do it this way because
+ // resolving breakpoints will add new locations potentially.
+
+ for (ModuleSP module_sp : module_list.ModulesNoLocking()) {
+ bool seen = false;
+ if (!m_filter_sp->ModulePasses(module_sp))
+ continue;
+
+ for (BreakpointLocationSP break_loc_sp :
+ m_locations.BreakpointLocations()) {
+ if (!break_loc_sp->IsEnabled())
+ continue;
+ SectionSP section_sp(break_loc_sp->GetAddress().GetSection());
+ if (!section_sp || section_sp->GetModule() == module_sp) {
+ if (!seen)
+ seen = true;
+
+ if (!break_loc_sp->ResolveBreakpointSite()) {
+ if (log)
+ log->Printf("Warning: could not set breakpoint site for "
+ "breakpoint location %d of breakpoint %d.\n",
+ break_loc_sp->GetID(), GetID());
+ }
+ }
+ }
+
+ if (!seen)
+ new_modules.AppendIfNeeded(module_sp);
+ }
+
+ if (new_modules.GetSize() > 0) {
+ ResolveBreakpointInModules(new_modules);
+ }
+ } else {
+ // Go through the currently set locations and if any have breakpoints in
+ // the module list, then remove their breakpoint sites, and their locations
+ // if asked to.
+
+ BreakpointEventData *removed_locations_event;
+ if (!IsInternal())
+ removed_locations_event = new BreakpointEventData(
+ eBreakpointEventTypeLocationsRemoved, shared_from_this());
+ else
+ removed_locations_event = nullptr;
+
+ size_t num_modules = module_list.GetSize();
+ for (size_t i = 0; i < num_modules; i++) {
+ ModuleSP module_sp(module_list.GetModuleAtIndexUnlocked(i));
+ if (m_filter_sp->ModulePasses(module_sp)) {
+ size_t loc_idx = 0;
+ size_t num_locations = m_locations.GetSize();
+ BreakpointLocationCollection locations_to_remove;
+ for (loc_idx = 0; loc_idx < num_locations; loc_idx++) {
+ BreakpointLocationSP break_loc_sp(m_locations.GetByIndex(loc_idx));
+ SectionSP section_sp(break_loc_sp->GetAddress().GetSection());
+ if (section_sp && section_sp->GetModule() == module_sp) {
+ // Remove this breakpoint since the shared library is
+ // unloaded, but keep the breakpoint location around
+ // so we always get complete hit count and breakpoint
+ // lifetime info
+ break_loc_sp->ClearBreakpointSite();
+ if (removed_locations_event) {
+ removed_locations_event->GetBreakpointLocationCollection().Add(
+ break_loc_sp);
}
- }
- SendBreakpointChangedEvent (removed_locations_event);
+ if (delete_locations)
+ locations_to_remove.Add(break_loc_sp);
+ }
+ }
+
+ if (delete_locations) {
+ size_t num_locations_to_remove = locations_to_remove.GetSize();
+ for (loc_idx = 0; loc_idx < num_locations_to_remove; loc_idx++)
+ m_locations.RemoveLocation(locations_to_remove.GetByIndex(loc_idx));
+ }
+ }
+ }
+ SendBreakpointChangedEvent(removed_locations_event);
+ }
+}
+
+namespace {
+static bool SymbolContextsMightBeEquivalent(SymbolContext &old_sc,
+ SymbolContext &new_sc) {
+ bool equivalent_scs = false;
+
+ if (old_sc.module_sp.get() == new_sc.module_sp.get()) {
+ // If these come from the same module, we can directly compare the pointers:
+ if (old_sc.comp_unit && new_sc.comp_unit &&
+ (old_sc.comp_unit == new_sc.comp_unit)) {
+ if (old_sc.function && new_sc.function &&
+ (old_sc.function == new_sc.function)) {
+ equivalent_scs = true;
+ }
+ } else if (old_sc.symbol && new_sc.symbol &&
+ (old_sc.symbol == new_sc.symbol)) {
+ equivalent_scs = true;
+ }
+ } else {
+ // Otherwise we will compare by name...
+ if (old_sc.comp_unit && new_sc.comp_unit) {
+ if (FileSpec::Equal(*old_sc.comp_unit, *new_sc.comp_unit, true)) {
+ // Now check the functions:
+ if (old_sc.function && new_sc.function &&
+ (old_sc.function->GetName() == new_sc.function->GetName())) {
+ equivalent_scs = true;
+ }
+ }
+ } else if (old_sc.symbol && new_sc.symbol) {
+ if (Mangled::Compare(old_sc.symbol->GetMangled(),
+ new_sc.symbol->GetMangled()) == 0) {
+ equivalent_scs = true;
+ }
}
+ }
+ return equivalent_scs;
}
+} // anonymous namespace
-namespace
-{
-static bool
-SymbolContextsMightBeEquivalent(SymbolContext &old_sc, SymbolContext &new_sc)
-{
- bool equivalent_scs = false;
-
- if (old_sc.module_sp.get() == new_sc.module_sp.get())
- {
- // If these come from the same module, we can directly compare the pointers:
- if (old_sc.comp_unit && new_sc.comp_unit
- && (old_sc.comp_unit == new_sc.comp_unit))
- {
- if (old_sc.function && new_sc.function
- && (old_sc.function == new_sc.function))
- {
- equivalent_scs = true;
+void Breakpoint::ModuleReplaced(ModuleSP old_module_sp,
+ ModuleSP new_module_sp) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+ if (log)
+ log->Printf("Breakpoint::ModulesReplaced for %s\n",
+ old_module_sp->GetSpecificationDescription().c_str());
+ // First find all the locations that are in the old module
+
+ BreakpointLocationCollection old_break_locs;
+ for (BreakpointLocationSP break_loc_sp : m_locations.BreakpointLocations()) {
+ SectionSP section_sp = break_loc_sp->GetAddress().GetSection();
+ if (section_sp && section_sp->GetModule() == old_module_sp) {
+ old_break_locs.Add(break_loc_sp);
+ }
+ }
+
+ size_t num_old_locations = old_break_locs.GetSize();
+
+ if (num_old_locations == 0) {
+ // There were no locations in the old module, so we just need to check if
+ // there were any in the new module.
+ ModuleList temp_list;
+ temp_list.Append(new_module_sp);
+ ResolveBreakpointInModules(temp_list);
+ } else {
+ // First search the new module for locations.
+ // Then compare this with the old list, copy over locations that "look the
+ // same"
+ // Then delete the old locations.
+ // Finally remember to post the creation event.
+ //
+ // Two locations are the same if they have the same comp unit & function (by
+ // name) and there are the same number
+ // of locations in the old function as in the new one.
+
+ ModuleList temp_list;
+ temp_list.Append(new_module_sp);
+ BreakpointLocationCollection new_break_locs;
+ ResolveBreakpointInModules(temp_list, new_break_locs);
+ BreakpointLocationCollection locations_to_remove;
+ BreakpointLocationCollection locations_to_announce;
+
+ size_t num_new_locations = new_break_locs.GetSize();
+
+ if (num_new_locations > 0) {
+ // Break out the case of one location -> one location since that's the
+ // most common one, and there's no need
+ // to build up the structures needed for the merge in that case.
+ if (num_new_locations == 1 && num_old_locations == 1) {
+ bool equivalent_locations = false;
+ SymbolContext old_sc, new_sc;
+ // The only way the old and new location can be equivalent is if they
+ // have the same amount of information:
+ BreakpointLocationSP old_loc_sp = old_break_locs.GetByIndex(0);
+ BreakpointLocationSP new_loc_sp = new_break_locs.GetByIndex(0);
+
+ if (old_loc_sp->GetAddress().CalculateSymbolContext(&old_sc) ==
+ new_loc_sp->GetAddress().CalculateSymbolContext(&new_sc)) {
+ equivalent_locations =
+ SymbolContextsMightBeEquivalent(old_sc, new_sc);
+ }
+
+ if (equivalent_locations) {
+ m_locations.SwapLocation(old_loc_sp, new_loc_sp);
+ } else {
+ locations_to_remove.Add(old_loc_sp);
+ locations_to_announce.Add(new_loc_sp);
+ }
+ } else {
+ // We don't want to have to keep computing the SymbolContexts for these
+ // addresses over and over,
+ // so lets get them up front:
+
+ typedef std::map<lldb::break_id_t, SymbolContext> IDToSCMap;
+ IDToSCMap old_sc_map;
+ for (size_t idx = 0; idx < num_old_locations; idx++) {
+ SymbolContext sc;
+ BreakpointLocationSP bp_loc_sp = old_break_locs.GetByIndex(idx);
+ lldb::break_id_t loc_id = bp_loc_sp->GetID();
+ bp_loc_sp->GetAddress().CalculateSymbolContext(&old_sc_map[loc_id]);
+ }
+
+ std::map<lldb::break_id_t, SymbolContext> new_sc_map;
+ for (size_t idx = 0; idx < num_new_locations; idx++) {
+ SymbolContext sc;
+ BreakpointLocationSP bp_loc_sp = new_break_locs.GetByIndex(idx);
+ lldb::break_id_t loc_id = bp_loc_sp->GetID();
+ bp_loc_sp->GetAddress().CalculateSymbolContext(&new_sc_map[loc_id]);
+ }
+ // Take an element from the old Symbol Contexts
+ while (old_sc_map.size() > 0) {
+ lldb::break_id_t old_id = old_sc_map.begin()->first;
+ SymbolContext &old_sc = old_sc_map.begin()->second;
+
+ // Count the number of entries equivalent to this SC for the old list:
+ std::vector<lldb::break_id_t> old_id_vec;
+ old_id_vec.push_back(old_id);
+
+ IDToSCMap::iterator tmp_iter;
+ for (tmp_iter = ++old_sc_map.begin(); tmp_iter != old_sc_map.end();
+ tmp_iter++) {
+ if (SymbolContextsMightBeEquivalent(old_sc, tmp_iter->second))
+ old_id_vec.push_back(tmp_iter->first);
+ }
+
+ // Now find all the equivalent locations in the new list.
+ std::vector<lldb::break_id_t> new_id_vec;
+ for (tmp_iter = new_sc_map.begin(); tmp_iter != new_sc_map.end();
+ tmp_iter++) {
+ if (SymbolContextsMightBeEquivalent(old_sc, tmp_iter->second))
+ new_id_vec.push_back(tmp_iter->first);
+ }
+
+ // Alright, if we have the same number of potentially equivalent
+ // locations in the old
+ // and new modules, we'll just map them one to one in ascending ID
+ // order (assuming the
+ // resolver's order would match the equivalent ones.
+ // Otherwise, we'll dump all the old ones, and just take the new ones,
+ // erasing the elements
+ // from both maps as we go.
+
+ if (old_id_vec.size() == new_id_vec.size()) {
+ sort(old_id_vec.begin(), old_id_vec.end());
+ sort(new_id_vec.begin(), new_id_vec.end());
+ size_t num_elements = old_id_vec.size();
+ for (size_t idx = 0; idx < num_elements; idx++) {
+ BreakpointLocationSP old_loc_sp =
+ old_break_locs.FindByIDPair(GetID(), old_id_vec[idx]);
+ BreakpointLocationSP new_loc_sp =
+ new_break_locs.FindByIDPair(GetID(), new_id_vec[idx]);
+ m_locations.SwapLocation(old_loc_sp, new_loc_sp);
+ old_sc_map.erase(old_id_vec[idx]);
+ new_sc_map.erase(new_id_vec[idx]);
}
- }
- else if (old_sc.symbol && new_sc.symbol
- && (old_sc.symbol == new_sc.symbol))
- {
- equivalent_scs = true;
- }
- }
- else
- {
- // Otherwise we will compare by name...
- if (old_sc.comp_unit && new_sc.comp_unit)
- {
- if (FileSpec::Equal(*old_sc.comp_unit, *new_sc.comp_unit, true))
- {
- // Now check the functions:
- if (old_sc.function && new_sc.function
- && (old_sc.function->GetName() == new_sc.function->GetName()))
- {
- equivalent_scs = true;
- }
+ } else {
+ for (lldb::break_id_t old_id : old_id_vec) {
+ locations_to_remove.Add(
+ old_break_locs.FindByIDPair(GetID(), old_id));
+ old_sc_map.erase(old_id);
}
- }
- else if (old_sc.symbol && new_sc.symbol)
- {
- if (Mangled::Compare(old_sc.symbol->GetMangled(), new_sc.symbol->GetMangled()) == 0)
- {
- equivalent_scs = true;
+ for (lldb::break_id_t new_id : new_id_vec) {
+ locations_to_announce.Add(
+ new_break_locs.FindByIDPair(GetID(), new_id));
+ new_sc_map.erase(new_id);
}
+ }
}
+ }
}
- return equivalent_scs;
-}
-} // anonymous namespace
-void
-Breakpoint::ModuleReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp)
-{
- Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf ("Breakpoint::ModulesReplaced for %s\n",
- old_module_sp->GetSpecificationDescription().c_str());
- // First find all the locations that are in the old module
-
- BreakpointLocationCollection old_break_locs;
- for (BreakpointLocationSP break_loc_sp : m_locations.BreakpointLocations())
- {
- SectionSP section_sp = break_loc_sp->GetAddress().GetSection();
- if (section_sp && section_sp->GetModule() == old_module_sp)
- {
- old_break_locs.Add(break_loc_sp);
- }
- }
-
- size_t num_old_locations = old_break_locs.GetSize();
-
- if (num_old_locations == 0)
- {
- // There were no locations in the old module, so we just need to check if there were any in the new module.
- ModuleList temp_list;
- temp_list.Append (new_module_sp);
- ResolveBreakpointInModules(temp_list);
- }
+ // Now remove the remaining old locations, and cons up a removed locations
+ // event.
+ // Note, we don't put the new locations that were swapped with an old
+ // location on the locations_to_remove
+ // list, so we don't need to worry about telling the world about removing a
+ // location we didn't tell them
+ // about adding.
+
+ BreakpointEventData *locations_event;
+ if (!IsInternal())
+ locations_event = new BreakpointEventData(
+ eBreakpointEventTypeLocationsRemoved, shared_from_this());
else
- {
- // First search the new module for locations.
- // Then compare this with the old list, copy over locations that "look the same"
- // Then delete the old locations.
- // Finally remember to post the creation event.
- //
- // Two locations are the same if they have the same comp unit & function (by name) and there are the same number
- // of locations in the old function as in the new one.
-
- ModuleList temp_list;
- temp_list.Append (new_module_sp);
- BreakpointLocationCollection new_break_locs;
- ResolveBreakpointInModules(temp_list, new_break_locs);
- BreakpointLocationCollection locations_to_remove;
- BreakpointLocationCollection locations_to_announce;
-
- size_t num_new_locations = new_break_locs.GetSize();
-
- if (num_new_locations > 0)
- {
- // Break out the case of one location -> one location since that's the most common one, and there's no need
- // to build up the structures needed for the merge in that case.
- if (num_new_locations == 1 && num_old_locations == 1)
- {
- bool equivalent_locations = false;
- SymbolContext old_sc, new_sc;
- // The only way the old and new location can be equivalent is if they have the same amount of information:
- BreakpointLocationSP old_loc_sp = old_break_locs.GetByIndex(0);
- BreakpointLocationSP new_loc_sp = new_break_locs.GetByIndex(0);
-
- if (old_loc_sp->GetAddress().CalculateSymbolContext(&old_sc)
- == new_loc_sp->GetAddress().CalculateSymbolContext(&new_sc))
- {
- equivalent_locations = SymbolContextsMightBeEquivalent(old_sc, new_sc);
- }
-
- if (equivalent_locations)
- {
- m_locations.SwapLocation (old_loc_sp, new_loc_sp);
- }
- else
- {
- locations_to_remove.Add(old_loc_sp);
- locations_to_announce.Add(new_loc_sp);
- }
- }
- else
- {
- //We don't want to have to keep computing the SymbolContexts for these addresses over and over,
- // so lets get them up front:
-
- typedef std::map<lldb::break_id_t, SymbolContext> IDToSCMap;
- IDToSCMap old_sc_map;
- for (size_t idx = 0; idx < num_old_locations; idx++)
- {
- SymbolContext sc;
- BreakpointLocationSP bp_loc_sp = old_break_locs.GetByIndex(idx);
- lldb::break_id_t loc_id = bp_loc_sp->GetID();
- bp_loc_sp->GetAddress().CalculateSymbolContext(&old_sc_map[loc_id]);
- }
-
- std::map<lldb::break_id_t, SymbolContext> new_sc_map;
- for (size_t idx = 0; idx < num_new_locations; idx++)
- {
- SymbolContext sc;
- BreakpointLocationSP bp_loc_sp = new_break_locs.GetByIndex(idx);
- lldb::break_id_t loc_id = bp_loc_sp->GetID();
- bp_loc_sp->GetAddress().CalculateSymbolContext(&new_sc_map[loc_id]);
- }
- // Take an element from the old Symbol Contexts
- while (old_sc_map.size() > 0)
- {
- lldb::break_id_t old_id = old_sc_map.begin()->first;
- SymbolContext &old_sc = old_sc_map.begin()->second;
-
- // Count the number of entries equivalent to this SC for the old list:
- std::vector<lldb::break_id_t> old_id_vec;
- old_id_vec.push_back(old_id);
-
- IDToSCMap::iterator tmp_iter;
- for (tmp_iter = ++old_sc_map.begin(); tmp_iter != old_sc_map.end(); tmp_iter++)
- {
- if (SymbolContextsMightBeEquivalent (old_sc, tmp_iter->second))
- old_id_vec.push_back (tmp_iter->first);
- }
-
- // Now find all the equivalent locations in the new list.
- std::vector<lldb::break_id_t> new_id_vec;
- for (tmp_iter = new_sc_map.begin(); tmp_iter != new_sc_map.end(); tmp_iter++)
- {
- if (SymbolContextsMightBeEquivalent (old_sc, tmp_iter->second))
- new_id_vec.push_back(tmp_iter->first);
- }
-
- // Alright, if we have the same number of potentially equivalent locations in the old
- // and new modules, we'll just map them one to one in ascending ID order (assuming the
- // resolver's order would match the equivalent ones.
- // Otherwise, we'll dump all the old ones, and just take the new ones, erasing the elements
- // from both maps as we go.
-
- if (old_id_vec.size() == new_id_vec.size())
- {
- sort(old_id_vec.begin(), old_id_vec.end());
- sort(new_id_vec.begin(), new_id_vec.end());
- size_t num_elements = old_id_vec.size();
- for (size_t idx = 0; idx < num_elements; idx++)
- {
- BreakpointLocationSP old_loc_sp = old_break_locs.FindByIDPair(GetID(), old_id_vec[idx]);
- BreakpointLocationSP new_loc_sp = new_break_locs.FindByIDPair(GetID(), new_id_vec[idx]);
- m_locations.SwapLocation(old_loc_sp, new_loc_sp);
- old_sc_map.erase(old_id_vec[idx]);
- new_sc_map.erase(new_id_vec[idx]);
- }
- }
- else
- {
- for (lldb::break_id_t old_id : old_id_vec)
- {
- locations_to_remove.Add(old_break_locs.FindByIDPair(GetID(), old_id));
- old_sc_map.erase(old_id);
- }
- for (lldb::break_id_t new_id : new_id_vec)
- {
- locations_to_announce.Add(new_break_locs.FindByIDPair(GetID(), new_id));
- new_sc_map.erase(new_id);
- }
- }
- }
- }
- }
-
- // Now remove the remaining old locations, and cons up a removed locations event.
- // Note, we don't put the new locations that were swapped with an old location on the locations_to_remove
- // list, so we don't need to worry about telling the world about removing a location we didn't tell them
- // about adding.
-
- BreakpointEventData *locations_event;
- if (!IsInternal())
- locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsRemoved,
- shared_from_this());
- else
- locations_event = nullptr;
-
- for (BreakpointLocationSP loc_sp : locations_to_remove.BreakpointLocations())
- {
- m_locations.RemoveLocation(loc_sp);
- if (locations_event)
- locations_event->GetBreakpointLocationCollection().Add(loc_sp);
- }
- SendBreakpointChangedEvent (locations_event);
+ locations_event = nullptr;
- // And announce the new ones.
-
- if (!IsInternal())
- {
- locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsAdded,
- shared_from_this());
- for (BreakpointLocationSP loc_sp : locations_to_announce.BreakpointLocations())
- locations_event->GetBreakpointLocationCollection().Add(loc_sp);
+ for (BreakpointLocationSP loc_sp :
+ locations_to_remove.BreakpointLocations()) {
+ m_locations.RemoveLocation(loc_sp);
+ if (locations_event)
+ locations_event->GetBreakpointLocationCollection().Add(loc_sp);
+ }
+ SendBreakpointChangedEvent(locations_event);
- SendBreakpointChangedEvent (locations_event);
- }
- m_locations.Compact();
+ // And announce the new ones.
+
+ if (!IsInternal()) {
+ locations_event = new BreakpointEventData(
+ eBreakpointEventTypeLocationsAdded, shared_from_this());
+ for (BreakpointLocationSP loc_sp :
+ locations_to_announce.BreakpointLocations())
+ locations_event->GetBreakpointLocationCollection().Add(loc_sp);
+
+ SendBreakpointChangedEvent(locations_event);
}
+ m_locations.Compact();
+ }
}
-void
-Breakpoint::Dump (Stream *)
-{
-}
-
-size_t
-Breakpoint::GetNumResolvedLocations() const
-{
- // Return the number of breakpoints that are actually resolved and set
- // down in the inferior process.
- return m_locations.GetNumResolvedLocations();
-}
-
-size_t
-Breakpoint::GetNumLocations() const
-{
- return m_locations.GetSize();
-}
-
-bool
-Breakpoint::AddName (const char *new_name, Error &error)
-{
- if (!new_name)
- return false;
- if (!BreakpointID::StringIsBreakpointName(new_name, error))
- {
- error.SetErrorStringWithFormat("input name \"%s\" not a breakpoint name.", new_name);
- return false;
- }
- if (!error.Success())
- return false;
+void Breakpoint::Dump(Stream *) {}
- m_name_list.insert(new_name);
- return true;
+size_t Breakpoint::GetNumResolvedLocations() const {
+ // Return the number of breakpoints that are actually resolved and set
+ // down in the inferior process.
+ return m_locations.GetNumResolvedLocations();
}
-void
-Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_locations)
-{
- assert (s != nullptr);
-
- if (!m_kind_description.empty())
- {
- if (level == eDescriptionLevelBrief)
- {
- s->PutCString (GetBreakpointKind());
- return;
- }
- else
- s->Printf("Kind: %s\n", GetBreakpointKind ());
- }
-
- const size_t num_locations = GetNumLocations ();
- const size_t num_resolved_locations = GetNumResolvedLocations ();
-
- // They just made the breakpoint, they don't need to be told HOW they made it...
- // Also, we'll print the breakpoint number differently depending on whether there is 1 or more locations.
- if (level != eDescriptionLevelInitial)
- {
- s->Printf("%i: ", GetID());
- GetResolverDescription (s);
- GetFilterDescription (s);
- }
-
- switch (level)
- {
- case lldb::eDescriptionLevelBrief:
- case lldb::eDescriptionLevelFull:
- if (num_locations > 0)
- {
- s->Printf(", locations = %" PRIu64, (uint64_t)num_locations);
- if (num_resolved_locations > 0)
- s->Printf(", resolved = %" PRIu64 ", hit count = %d", (uint64_t)num_resolved_locations, GetHitCount());
- }
- else
- {
- // Don't print the pending notification for exception resolvers since we don't generally
- // know how to set them until the target is run.
- if (m_resolver_sp->getResolverID() != BreakpointResolver::ExceptionResolver)
- s->Printf(", locations = 0 (pending)");
- }
+size_t Breakpoint::GetNumLocations() const { return m_locations.GetSize(); }
- GetOptions()->GetDescription(s, level);
-
- if (m_precondition_sp)
- m_precondition_sp->GetDescription(*s, level);
-
- if (level == lldb::eDescriptionLevelFull)
- {
- if (!m_name_list.empty())
- {
- s->EOL();
- s->Indent();
- s->Printf ("Names:");
- s->EOL();
- s->IndentMore();
- for (std::string name : m_name_list)
- {
- s->Indent();
- s->Printf("%s\n", name.c_str());
- }
- s->IndentLess();
- }
- s->IndentLess();
- s->EOL();
- }
- break;
-
- case lldb::eDescriptionLevelInitial:
- s->Printf ("Breakpoint %i: ", GetID());
- if (num_locations == 0)
- {
- s->Printf ("no locations (pending).");
- }
- else if (num_locations == 1 && !show_locations)
- {
- // There is only one location, so we'll just print that location information.
- GetLocationAtIndex(0)->GetDescription(s, level);
- }
- else
- {
- s->Printf ("%" PRIu64 " locations.", static_cast<uint64_t>(num_locations));
- }
- s->EOL();
- break;
+bool Breakpoint::AddName(const char *new_name, Error &error) {
+ if (!new_name)
+ return false;
+ if (!BreakpointID::StringIsBreakpointName(new_name, error)) {
+ error.SetErrorStringWithFormat("input name \"%s\" not a breakpoint name.",
+ new_name);
+ return false;
+ }
+ if (!error.Success())
+ return false;
- case lldb::eDescriptionLevelVerbose:
- // Verbose mode does a debug dump of the breakpoint
- Dump (s);
- s->EOL ();
- //s->Indent();
- GetOptions()->GetDescription(s, level);
- break;
+ m_name_list.insert(new_name);
+ return true;
+}
- default:
- break;
+void Breakpoint::GetDescription(Stream *s, lldb::DescriptionLevel level,
+ bool show_locations) {
+ assert(s != nullptr);
+
+ if (!m_kind_description.empty()) {
+ if (level == eDescriptionLevelBrief) {
+ s->PutCString(GetBreakpointKind());
+ return;
+ } else
+ s->Printf("Kind: %s\n", GetBreakpointKind());
+ }
+
+ const size_t num_locations = GetNumLocations();
+ const size_t num_resolved_locations = GetNumResolvedLocations();
+
+ // They just made the breakpoint, they don't need to be told HOW they made
+ // it...
+ // Also, we'll print the breakpoint number differently depending on whether
+ // there is 1 or more locations.
+ if (level != eDescriptionLevelInitial) {
+ s->Printf("%i: ", GetID());
+ GetResolverDescription(s);
+ GetFilterDescription(s);
+ }
+
+ switch (level) {
+ case lldb::eDescriptionLevelBrief:
+ case lldb::eDescriptionLevelFull:
+ if (num_locations > 0) {
+ s->Printf(", locations = %" PRIu64, (uint64_t)num_locations);
+ if (num_resolved_locations > 0)
+ s->Printf(", resolved = %" PRIu64 ", hit count = %d",
+ (uint64_t)num_resolved_locations, GetHitCount());
+ } else {
+ // Don't print the pending notification for exception resolvers since we
+ // don't generally
+ // know how to set them until the target is run.
+ if (m_resolver_sp->getResolverID() !=
+ BreakpointResolver::ExceptionResolver)
+ s->Printf(", locations = 0 (pending)");
}
- // The brief description is just the location name (1.2 or whatever). That's pointless to
- // show in the breakpoint's description, so suppress it.
- if (show_locations && level != lldb::eDescriptionLevelBrief)
- {
+ GetOptions()->GetDescription(s, level);
+
+ if (m_precondition_sp)
+ m_precondition_sp->GetDescription(*s, level);
+
+ if (level == lldb::eDescriptionLevelFull) {
+ if (!m_name_list.empty()) {
+ s->EOL();
+ s->Indent();
+ s->Printf("Names:");
+ s->EOL();
s->IndentMore();
- for (size_t i = 0; i < num_locations; ++i)
- {
- BreakpointLocation *loc = GetLocationAtIndex(i).get();
- loc->GetDescription(s, level);
- s->EOL();
+ for (std::string name : m_name_list) {
+ s->Indent();
+ s->Printf("%s\n", name.c_str());
}
s->IndentLess();
- }
+ }
+ s->IndentLess();
+ s->EOL();
+ }
+ break;
+
+ case lldb::eDescriptionLevelInitial:
+ s->Printf("Breakpoint %i: ", GetID());
+ if (num_locations == 0) {
+ s->Printf("no locations (pending).");
+ } else if (num_locations == 1 && !show_locations) {
+ // There is only one location, so we'll just print that location
+ // information.
+ GetLocationAtIndex(0)->GetDescription(s, level);
+ } else {
+ s->Printf("%" PRIu64 " locations.", static_cast<uint64_t>(num_locations));
+ }
+ s->EOL();
+ break;
+
+ case lldb::eDescriptionLevelVerbose:
+ // Verbose mode does a debug dump of the breakpoint
+ Dump(s);
+ s->EOL();
+ // s->Indent();
+ GetOptions()->GetDescription(s, level);
+ break;
+
+ default:
+ break;
+ }
+
+ // The brief description is just the location name (1.2 or whatever). That's
+ // pointless to
+ // show in the breakpoint's description, so suppress it.
+ if (show_locations && level != lldb::eDescriptionLevelBrief) {
+ s->IndentMore();
+ for (size_t i = 0; i < num_locations; ++i) {
+ BreakpointLocation *loc = GetLocationAtIndex(i).get();
+ loc->GetDescription(s, level);
+ s->EOL();
+ }
+ s->IndentLess();
+ }
+}
+
+void Breakpoint::GetResolverDescription(Stream *s) {
+ if (m_resolver_sp)
+ m_resolver_sp->GetDescription(s);
+}
+
+bool Breakpoint::GetMatchingFileLine(const ConstString &filename,
+ uint32_t line_number,
+ BreakpointLocationCollection &loc_coll) {
+ // TODO: To be correct, this method needs to fill the breakpoint location
+ // collection
+ // with the location IDs which match the filename and line_number.
+ //
+
+ if (m_resolver_sp) {
+ BreakpointResolverFileLine *resolverFileLine =
+ dyn_cast<BreakpointResolverFileLine>(m_resolver_sp.get());
+ if (resolverFileLine &&
+ resolverFileLine->m_file_spec.GetFilename() == filename &&
+ resolverFileLine->m_line_number == line_number) {
+ return true;
+ }
+ }
+ return false;
}
-void
-Breakpoint::GetResolverDescription (Stream *s)
-{
- if (m_resolver_sp)
- m_resolver_sp->GetDescription (s);
+void Breakpoint::GetFilterDescription(Stream *s) {
+ m_filter_sp->GetDescription(s);
}
-bool
-Breakpoint::GetMatchingFileLine (const ConstString &filename, uint32_t line_number, BreakpointLocationCollection &loc_coll)
-{
- // TODO: To be correct, this method needs to fill the breakpoint location collection
- // with the location IDs which match the filename and line_number.
- //
+bool Breakpoint::EvaluatePrecondition(StoppointCallbackContext &context) {
+ if (!m_precondition_sp)
+ return true;
- if (m_resolver_sp)
- {
- BreakpointResolverFileLine *resolverFileLine = dyn_cast<BreakpointResolverFileLine>(m_resolver_sp.get());
- if (resolverFileLine &&
- resolverFileLine->m_file_spec.GetFilename() == filename &&
- resolverFileLine->m_line_number == line_number)
- {
- return true;
- }
- }
- return false;
+ return m_precondition_sp->EvaluatePrecondition(context);
}
-void
-Breakpoint::GetFilterDescription (Stream *s)
-{
- m_filter_sp->GetDescription (s);
+bool Breakpoint::BreakpointPrecondition::EvaluatePrecondition(
+ StoppointCallbackContext &context) {
+ return true;
}
-bool
-Breakpoint::EvaluatePrecondition (StoppointCallbackContext &context)
-{
- if (!m_precondition_sp)
- return true;
+void Breakpoint::BreakpointPrecondition::GetDescription(
+ Stream &stream, lldb::DescriptionLevel level) {}
- return m_precondition_sp->EvaluatePrecondition(context);
+Error Breakpoint::BreakpointPrecondition::ConfigurePrecondition(Args &options) {
+ Error error;
+ error.SetErrorString("Base breakpoint precondition has no options.");
+ return error;
}
-bool
-Breakpoint::BreakpointPrecondition::EvaluatePrecondition(StoppointCallbackContext &context)
-{
- return true;
-}
+void Breakpoint::SendBreakpointChangedEvent(
+ lldb::BreakpointEventType eventKind) {
+ if (!m_being_created && !IsInternal() &&
+ GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitBreakpointChanged)) {
+ BreakpointEventData *data =
+ new Breakpoint::BreakpointEventData(eventKind, shared_from_this());
-void
-Breakpoint::BreakpointPrecondition::GetDescription(Stream &stream, lldb::DescriptionLevel level)
-{
-}
-
-Error
-Breakpoint::BreakpointPrecondition::ConfigurePrecondition(Args &options)
-{
- Error error;
- error.SetErrorString("Base breakpoint precondition has no options.");
- return error;
-}
-
-void
-Breakpoint::SendBreakpointChangedEvent (lldb::BreakpointEventType eventKind)
-{
- if (!m_being_created
- && !IsInternal()
- && GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- {
- BreakpointEventData *data = new Breakpoint::BreakpointEventData (eventKind, shared_from_this());
-
- GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, data);
- }
+ GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged, data);
+ }
}
-void
-Breakpoint::SendBreakpointChangedEvent (BreakpointEventData *data)
-{
- if (data == nullptr)
- return;
-
- if (!m_being_created
- && !IsInternal()
- && GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, data);
- else
- delete data;
-}
+void Breakpoint::SendBreakpointChangedEvent(BreakpointEventData *data) {
+ if (data == nullptr)
+ return;
-Breakpoint::BreakpointEventData::BreakpointEventData (BreakpointEventType sub_type,
- const BreakpointSP &new_breakpoint_sp) :
- EventData (),
- m_breakpoint_event (sub_type),
- m_new_breakpoint_sp (new_breakpoint_sp)
-{
+ if (!m_being_created && !IsInternal() &&
+ GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
+ GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged, data);
+ else
+ delete data;
}
+Breakpoint::BreakpointEventData::BreakpointEventData(
+ BreakpointEventType sub_type, const BreakpointSP &new_breakpoint_sp)
+ : EventData(), m_breakpoint_event(sub_type),
+ m_new_breakpoint_sp(new_breakpoint_sp) {}
+
Breakpoint::BreakpointEventData::~BreakpointEventData() = default;
-const ConstString &
-Breakpoint::BreakpointEventData::GetFlavorString ()
-{
- static ConstString g_flavor ("Breakpoint::BreakpointEventData");
- return g_flavor;
-}
-
-const ConstString &
-Breakpoint::BreakpointEventData::GetFlavor () const
-{
- return BreakpointEventData::GetFlavorString ();
-}
-
-BreakpointSP &
-Breakpoint::BreakpointEventData::GetBreakpoint ()
-{
- return m_new_breakpoint_sp;
+const ConstString &Breakpoint::BreakpointEventData::GetFlavorString() {
+ static ConstString g_flavor("Breakpoint::BreakpointEventData");
+ return g_flavor;
}
-BreakpointEventType
-Breakpoint::BreakpointEventData::GetBreakpointEventType () const
-{
- return m_breakpoint_event;
+const ConstString &Breakpoint::BreakpointEventData::GetFlavor() const {
+ return BreakpointEventData::GetFlavorString();
}
-void
-Breakpoint::BreakpointEventData::Dump (Stream *s) const
-{
+BreakpointSP &Breakpoint::BreakpointEventData::GetBreakpoint() {
+ return m_new_breakpoint_sp;
}
+BreakpointEventType
+Breakpoint::BreakpointEventData::GetBreakpointEventType() const {
+ return m_breakpoint_event;
+}
+
+void Breakpoint::BreakpointEventData::Dump(Stream *s) const {}
+
const Breakpoint::BreakpointEventData *
-Breakpoint::BreakpointEventData::GetEventDataFromEvent (const Event *event)
-{
- if (event)
- {
- const EventData *event_data = event->GetData();
- if (event_data && event_data->GetFlavor() == BreakpointEventData::GetFlavorString())
- return static_cast <const BreakpointEventData *> (event->GetData());
- }
- return nullptr;
+Breakpoint::BreakpointEventData::GetEventDataFromEvent(const Event *event) {
+ if (event) {
+ const EventData *event_data = event->GetData();
+ if (event_data &&
+ event_data->GetFlavor() == BreakpointEventData::GetFlavorString())
+ return static_cast<const BreakpointEventData *>(event->GetData());
+ }
+ return nullptr;
}
BreakpointEventType
-Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (const EventSP &event_sp)
-{
- const BreakpointEventData *data = GetEventDataFromEvent (event_sp.get());
+Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent(
+ const EventSP &event_sp) {
+ const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
- if (data == nullptr)
- return eBreakpointEventTypeInvalidType;
- else
- return data->GetBreakpointEventType();
+ if (data == nullptr)
+ return eBreakpointEventTypeInvalidType;
+ else
+ return data->GetBreakpointEventType();
}
-BreakpointSP
-Breakpoint::BreakpointEventData::GetBreakpointFromEvent (const EventSP &event_sp)
-{
- BreakpointSP bp_sp;
+BreakpointSP Breakpoint::BreakpointEventData::GetBreakpointFromEvent(
+ const EventSP &event_sp) {
+ BreakpointSP bp_sp;
- const BreakpointEventData *data = GetEventDataFromEvent (event_sp.get());
- if (data)
- bp_sp = data->m_new_breakpoint_sp;
+ const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
+ if (data)
+ bp_sp = data->m_new_breakpoint_sp;
- return bp_sp;
+ return bp_sp;
}
-size_t
-Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent (const EventSP &event_sp)
-{
- const BreakpointEventData *data = GetEventDataFromEvent (event_sp.get());
- if (data)
- return data->m_locations.GetSize();
+size_t Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent(
+ const EventSP &event_sp) {
+ const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
+ if (data)
+ return data->m_locations.GetSize();
- return 0;
+ return 0;
}
lldb::BreakpointLocationSP
-Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent (const lldb::EventSP &event_sp, uint32_t bp_loc_idx)
-{
- lldb::BreakpointLocationSP bp_loc_sp;
-
- const BreakpointEventData *data = GetEventDataFromEvent (event_sp.get());
- if (data)
- {
- bp_loc_sp = data->m_locations.GetByIndex(bp_loc_idx);
- }
+Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent(
+ const lldb::EventSP &event_sp, uint32_t bp_loc_idx) {
+ lldb::BreakpointLocationSP bp_loc_sp;
+
+ const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
+ if (data) {
+ bp_loc_sp = data->m_locations.GetByIndex(bp_loc_idx);
+ }
- return bp_loc_sp;
+ return bp_loc_sp;
}
Modified: lldb/trunk/source/Breakpoint/BreakpointID.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointID.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointID.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointID.cpp Tue Sep 6 15:57:50 2016
@@ -13,121 +13,108 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Breakpoint/BreakpointID.h"
#include "lldb/Breakpoint/Breakpoint.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Breakpoint/BreakpointID.h"
#include "lldb/Core/Error.h"
+#include "lldb/Core/Stream.h"
using namespace lldb;
using namespace lldb_private;
-BreakpointID::BreakpointID (break_id_t bp_id, break_id_t loc_id) :
- m_break_id (bp_id),
- m_location_id (loc_id)
-{
-}
+BreakpointID::BreakpointID(break_id_t bp_id, break_id_t loc_id)
+ : m_break_id(bp_id), m_location_id(loc_id) {}
BreakpointID::~BreakpointID() = default;
-const char *BreakpointID::g_range_specifiers[] = { "-", "to", "To", "TO", nullptr };
+const char *BreakpointID::g_range_specifiers[] = {"-", "to", "To", "TO",
+ nullptr};
-// Tells whether or not STR is valid to use between two strings representing breakpoint IDs, to
-// indicate a range of breakpoint IDs. This is broken out into a separate function so that we can
+// Tells whether or not STR is valid to use between two strings representing
+// breakpoint IDs, to
+// indicate a range of breakpoint IDs. This is broken out into a separate
+// function so that we can
// easily change or add to the format for specifying ID ranges at a later date.
-bool
-BreakpointID::IsRangeIdentifier (const char *str)
-{
- int specifier_count = 0;
- for (int i = 0; g_range_specifiers[i] != nullptr; ++i)
- ++specifier_count;
-
- for (int i = 0; i < specifier_count; ++i)
- {
- if (strcmp (g_range_specifiers[i], str) == 0)
- return true;
- }
+bool BreakpointID::IsRangeIdentifier(const char *str) {
+ int specifier_count = 0;
+ for (int i = 0; g_range_specifiers[i] != nullptr; ++i)
+ ++specifier_count;
+
+ for (int i = 0; i < specifier_count; ++i) {
+ if (strcmp(g_range_specifiers[i], str) == 0)
+ return true;
+ }
return false;
}
-bool
-BreakpointID::IsValidIDExpression (const char *str)
-{
- break_id_t bp_id;
- break_id_t loc_id;
- BreakpointID::ParseCanonicalReference (str, &bp_id, &loc_id);
-
- return (bp_id != LLDB_INVALID_BREAK_ID);
-}
-
-void
-BreakpointID::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
- if (level == eDescriptionLevelVerbose)
- s->Printf("%p BreakpointID:", static_cast<void*>(this));
-
- if (m_break_id == LLDB_INVALID_BREAK_ID)
- s->PutCString ("<invalid>");
- else if (m_location_id == LLDB_INVALID_BREAK_ID)
- s->Printf("%i", m_break_id);
- else
- s->Printf("%i.%i", m_break_id, m_location_id);
-}
-
-void
-BreakpointID::GetCanonicalReference (Stream *s, break_id_t bp_id, break_id_t loc_id)
-{
- if (bp_id == LLDB_INVALID_BREAK_ID)
- s->PutCString ("<invalid>");
- else if (loc_id == LLDB_INVALID_BREAK_ID)
- s->Printf("%i", bp_id);
- else
- s->Printf("%i.%i", bp_id, loc_id);
-}
-
-bool
-BreakpointID::ParseCanonicalReference (const char *input, break_id_t *break_id_ptr, break_id_t *break_loc_id_ptr)
-{
- *break_id_ptr = LLDB_INVALID_BREAK_ID;
- *break_loc_id_ptr = LLDB_INVALID_BREAK_ID;
-
- if (input == nullptr || *input == '\0')
- return false;
-
- const char *format = "%i%n.%i%n";
- int chars_consumed_1 = 0;
- int chars_consumed_2 = 0;
- int n_items_parsed = ::sscanf (input,
- format,
- break_id_ptr, // %i parse the breakpoint ID
- &chars_consumed_1, // %n gets the number of characters parsed so far
- break_loc_id_ptr, // %i parse the breakpoint location ID
- &chars_consumed_2); // %n gets the number of characters parsed so far
-
- if ((n_items_parsed == 1 && input[chars_consumed_1] == '\0') ||
- (n_items_parsed == 2 && input[chars_consumed_2] == '\0'))
- return true;
-
- // Badly formatted canonical reference.
- *break_id_ptr = LLDB_INVALID_BREAK_ID;
- *break_loc_id_ptr = LLDB_INVALID_BREAK_ID;
+bool BreakpointID::IsValidIDExpression(const char *str) {
+ break_id_t bp_id;
+ break_id_t loc_id;
+ BreakpointID::ParseCanonicalReference(str, &bp_id, &loc_id);
+
+ return (bp_id != LLDB_INVALID_BREAK_ID);
+}
+
+void BreakpointID::GetDescription(Stream *s, lldb::DescriptionLevel level) {
+ if (level == eDescriptionLevelVerbose)
+ s->Printf("%p BreakpointID:", static_cast<void *>(this));
+
+ if (m_break_id == LLDB_INVALID_BREAK_ID)
+ s->PutCString("<invalid>");
+ else if (m_location_id == LLDB_INVALID_BREAK_ID)
+ s->Printf("%i", m_break_id);
+ else
+ s->Printf("%i.%i", m_break_id, m_location_id);
+}
+
+void BreakpointID::GetCanonicalReference(Stream *s, break_id_t bp_id,
+ break_id_t loc_id) {
+ if (bp_id == LLDB_INVALID_BREAK_ID)
+ s->PutCString("<invalid>");
+ else if (loc_id == LLDB_INVALID_BREAK_ID)
+ s->Printf("%i", bp_id);
+ else
+ s->Printf("%i.%i", bp_id, loc_id);
+}
+
+bool BreakpointID::ParseCanonicalReference(const char *input,
+ break_id_t *break_id_ptr,
+ break_id_t *break_loc_id_ptr) {
+ *break_id_ptr = LLDB_INVALID_BREAK_ID;
+ *break_loc_id_ptr = LLDB_INVALID_BREAK_ID;
+
+ if (input == nullptr || *input == '\0')
return false;
+
+ const char *format = "%i%n.%i%n";
+ int chars_consumed_1 = 0;
+ int chars_consumed_2 = 0;
+ int n_items_parsed = ::sscanf(
+ input, format,
+ break_id_ptr, // %i parse the breakpoint ID
+ &chars_consumed_1, // %n gets the number of characters parsed so far
+ break_loc_id_ptr, // %i parse the breakpoint location ID
+ &chars_consumed_2); // %n gets the number of characters parsed so far
+
+ if ((n_items_parsed == 1 && input[chars_consumed_1] == '\0') ||
+ (n_items_parsed == 2 && input[chars_consumed_2] == '\0'))
+ return true;
+
+ // Badly formatted canonical reference.
+ *break_id_ptr = LLDB_INVALID_BREAK_ID;
+ *break_loc_id_ptr = LLDB_INVALID_BREAK_ID;
+ return false;
}
-bool
-BreakpointID::StringIsBreakpointName(const char *name, Error &error)
-{
- error.Clear();
-
- if (name && (name[0] >= 'A' && name[0] <= 'z'))
- {
- if (strcspn(name, ".- ") != strlen(name))
- {
- error.SetErrorStringWithFormat("invalid breakpoint name: \"%s\"", name);
- }
- return true;
+bool BreakpointID::StringIsBreakpointName(const char *name, Error &error) {
+ error.Clear();
+
+ if (name && (name[0] >= 'A' && name[0] <= 'z')) {
+ if (strcspn(name, ".- ") != strlen(name)) {
+ error.SetErrorStringWithFormat("invalid breakpoint name: \"%s\"", name);
}
- else
- return false;
+ return true;
+ } else
+ return false;
}
Modified: lldb/trunk/source/Breakpoint/BreakpointIDList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointIDList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointIDList.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointIDList.cpp Tue Sep 6 15:57:50 2016
@@ -15,8 +15,8 @@
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Target.h"
using namespace lldb;
@@ -26,412 +26,370 @@ using namespace lldb_private;
// class BreakpointIDList
//----------------------------------------------------------------------
-BreakpointIDList::BreakpointIDList () :
-m_invalid_id (LLDB_INVALID_BREAK_ID, LLDB_INVALID_BREAK_ID)
-{
-}
+BreakpointIDList::BreakpointIDList()
+ : m_invalid_id(LLDB_INVALID_BREAK_ID, LLDB_INVALID_BREAK_ID) {}
BreakpointIDList::~BreakpointIDList() = default;
-size_t
-BreakpointIDList::GetSize()
-{
- return m_breakpoint_ids.size();
-}
+size_t BreakpointIDList::GetSize() { return m_breakpoint_ids.size(); }
-BreakpointID &
-BreakpointIDList::GetBreakpointIDAtIndex(size_t index)
-{
- return ((index < m_breakpoint_ids.size()) ? m_breakpoint_ids[index] : m_invalid_id);
+BreakpointID &BreakpointIDList::GetBreakpointIDAtIndex(size_t index) {
+ return ((index < m_breakpoint_ids.size()) ? m_breakpoint_ids[index]
+ : m_invalid_id);
}
-bool
-BreakpointIDList::RemoveBreakpointIDAtIndex (size_t index)
-{
- if (index >= m_breakpoint_ids.size())
- return false;
+bool BreakpointIDList::RemoveBreakpointIDAtIndex(size_t index) {
+ if (index >= m_breakpoint_ids.size())
+ return false;
- m_breakpoint_ids.erase (m_breakpoint_ids.begin() + index);
- return true;
+ m_breakpoint_ids.erase(m_breakpoint_ids.begin() + index);
+ return true;
}
-void
-BreakpointIDList::Clear()
-{
- m_breakpoint_ids.clear ();
-}
+void BreakpointIDList::Clear() { m_breakpoint_ids.clear(); }
-bool
-BreakpointIDList::AddBreakpointID (BreakpointID bp_id)
-{
- m_breakpoint_ids.push_back (bp_id);
+bool BreakpointIDList::AddBreakpointID(BreakpointID bp_id) {
+ m_breakpoint_ids.push_back(bp_id);
- return true; // We don't do any verification in this function, so always return true.
+ return true; // We don't do any verification in this function, so always
+ // return true.
}
-bool
-BreakpointIDList::AddBreakpointID (const char *bp_id_str)
-{
- BreakpointID temp_bp_id;
- break_id_t bp_id;
- break_id_t loc_id;
+bool BreakpointIDList::AddBreakpointID(const char *bp_id_str) {
+ BreakpointID temp_bp_id;
+ break_id_t bp_id;
+ break_id_t loc_id;
- bool success = BreakpointID::ParseCanonicalReference (bp_id_str, &bp_id, &loc_id);
+ bool success =
+ BreakpointID::ParseCanonicalReference(bp_id_str, &bp_id, &loc_id);
- if (success)
- {
- temp_bp_id.SetID (bp_id, loc_id);
- m_breakpoint_ids.push_back (temp_bp_id);
- }
+ if (success) {
+ temp_bp_id.SetID(bp_id, loc_id);
+ m_breakpoint_ids.push_back(temp_bp_id);
+ }
- return success;
+ return success;
}
-bool
-BreakpointIDList::FindBreakpointID (BreakpointID &bp_id, size_t *position)
-{
- for (size_t i = 0; i < m_breakpoint_ids.size(); ++i)
- {
- BreakpointID tmp_id = m_breakpoint_ids[i];
- if (tmp_id.GetBreakpointID() == bp_id.GetBreakpointID()
- && tmp_id.GetLocationID() == bp_id.GetLocationID())
- {
- *position = i;
- return true;
- }
+bool BreakpointIDList::FindBreakpointID(BreakpointID &bp_id, size_t *position) {
+ for (size_t i = 0; i < m_breakpoint_ids.size(); ++i) {
+ BreakpointID tmp_id = m_breakpoint_ids[i];
+ if (tmp_id.GetBreakpointID() == bp_id.GetBreakpointID() &&
+ tmp_id.GetLocationID() == bp_id.GetLocationID()) {
+ *position = i;
+ return true;
}
+ }
- return false;
+ return false;
}
-bool
-BreakpointIDList::FindBreakpointID (const char *bp_id_str, size_t *position)
-{
- BreakpointID temp_bp_id;
- break_id_t bp_id;
- break_id_t loc_id;
+bool BreakpointIDList::FindBreakpointID(const char *bp_id_str,
+ size_t *position) {
+ BreakpointID temp_bp_id;
+ break_id_t bp_id;
+ break_id_t loc_id;
- if (BreakpointID::ParseCanonicalReference (bp_id_str, &bp_id, &loc_id))
- {
- temp_bp_id.SetID (bp_id, loc_id);
- return FindBreakpointID (temp_bp_id, position);
- }
- else
- return false;
+ if (BreakpointID::ParseCanonicalReference(bp_id_str, &bp_id, &loc_id)) {
+ temp_bp_id.SetID(bp_id, loc_id);
+ return FindBreakpointID(temp_bp_id, position);
+ } else
+ return false;
}
-void
-BreakpointIDList::InsertStringArray (const char **string_array, size_t array_size, CommandReturnObject &result)
-{
- if (string_array == nullptr)
- return;
+void BreakpointIDList::InsertStringArray(const char **string_array,
+ size_t array_size,
+ CommandReturnObject &result) {
+ if (string_array == nullptr)
+ return;
- for (uint32_t i = 0; i < array_size; ++i)
- {
- break_id_t bp_id;
- break_id_t loc_id;
+ for (uint32_t i = 0; i < array_size; ++i) {
+ break_id_t bp_id;
+ break_id_t loc_id;
- if (BreakpointID::ParseCanonicalReference (string_array[i], &bp_id, &loc_id))
- {
- if (bp_id != LLDB_INVALID_BREAK_ID)
- {
- BreakpointID temp_bp_id(bp_id, loc_id);
- m_breakpoint_ids.push_back (temp_bp_id);
- }
- else
- {
- result.AppendErrorWithFormat ("'%s' is not a valid breakpoint ID.\n", string_array[i]);
- result.SetStatus (eReturnStatusFailed);
- return;
- }
- }
+ if (BreakpointID::ParseCanonicalReference(string_array[i], &bp_id,
+ &loc_id)) {
+ if (bp_id != LLDB_INVALID_BREAK_ID) {
+ BreakpointID temp_bp_id(bp_id, loc_id);
+ m_breakpoint_ids.push_back(temp_bp_id);
+ } else {
+ result.AppendErrorWithFormat("'%s' is not a valid breakpoint ID.\n",
+ string_array[i]);
+ result.SetStatus(eReturnStatusFailed);
+ return;
+ }
}
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ }
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
+// This function takes OLD_ARGS, which is usually the result of breaking the
+// command string arguments into
+// an array of space-separated strings, and searches through the arguments for
+// any breakpoint ID range specifiers.
+// Any string in the array that is not part of an ID range specifier is copied
+// directly into NEW_ARGS. If any
+// ID range specifiers are found, the range is interpreted and a list of
+// canonical breakpoint IDs corresponding to
+// all the current breakpoints and locations in the range are added to
+// NEW_ARGS. When this function is done,
+// NEW_ARGS should be a copy of OLD_ARGS, with and ID range specifiers replaced
+// by the members of the range.
+
+void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
+ bool allow_locations,
+ CommandReturnObject &result,
+ Args &new_args) {
+ std::string range_start;
+ const char *range_end;
+ const char *current_arg;
+ const size_t num_old_args = old_args.GetArgumentCount();
+ std::set<std::string> names_found;
+
+ for (size_t i = 0; i < num_old_args; ++i) {
+ bool is_range = false;
+
+ current_arg = old_args.GetArgumentAtIndex(i);
+ if (!allow_locations && strchr(current_arg, '.') != nullptr) {
+ result.AppendErrorWithFormat(
+ "Breakpoint locations not allowed, saw location: %s.", current_arg);
+ new_args.Clear();
+ return;
+ }
-// This function takes OLD_ARGS, which is usually the result of breaking the command string arguments into
-// an array of space-separated strings, and searches through the arguments for any breakpoint ID range specifiers.
-// Any string in the array that is not part of an ID range specifier is copied directly into NEW_ARGS. If any
-// ID range specifiers are found, the range is interpreted and a list of canonical breakpoint IDs corresponding to
-// all the current breakpoints and locations in the range are added to NEW_ARGS. When this function is done,
-// NEW_ARGS should be a copy of OLD_ARGS, with and ID range specifiers replaced by the members of the range.
-
-void
-BreakpointIDList::FindAndReplaceIDRanges (Args &old_args,
- Target *target,
- bool allow_locations,
- CommandReturnObject &result,
- Args &new_args)
-{
- std::string range_start;
- const char *range_end;
- const char *current_arg;
- const size_t num_old_args = old_args.GetArgumentCount();
- std::set<std::string> names_found;
-
- for (size_t i = 0; i < num_old_args; ++i)
- {
- bool is_range = false;
-
- current_arg = old_args.GetArgumentAtIndex (i);
- if (!allow_locations && strchr(current_arg, '.') != nullptr)
- {
- result.AppendErrorWithFormat ("Breakpoint locations not allowed, saw location: %s.", current_arg);
+ size_t range_start_len = 0;
+ size_t range_end_pos = 0;
+ Error error;
+
+ if (BreakpointIDList::StringContainsIDRangeExpression(
+ current_arg, &range_start_len, &range_end_pos)) {
+ is_range = true;
+ range_start.assign(current_arg, range_start_len);
+ range_end = current_arg + range_end_pos;
+ } else if (BreakpointID::StringIsBreakpointName(current_arg, error)) {
+ if (!error.Success()) {
+ new_args.Clear();
+ result.AppendError(error.AsCString());
+ result.SetStatus(eReturnStatusFailed);
+ return;
+ } else
+ names_found.insert(current_arg);
+ } else if ((i + 2 < num_old_args) &&
+ BreakpointID::IsRangeIdentifier(
+ old_args.GetArgumentAtIndex(i + 1)) &&
+ BreakpointID::IsValidIDExpression(current_arg) &&
+ BreakpointID::IsValidIDExpression(
+ old_args.GetArgumentAtIndex(i + 2))) {
+ range_start.assign(current_arg);
+ range_end = old_args.GetArgumentAtIndex(i + 2);
+ is_range = true;
+ i = i + 2;
+ } else {
+ // See if user has specified id.*
+ std::string tmp_str = old_args.GetArgumentAtIndex(i);
+ size_t pos = tmp_str.find('.');
+ if (pos != std::string::npos) {
+ std::string bp_id_str = tmp_str.substr(0, pos);
+ if (BreakpointID::IsValidIDExpression(bp_id_str.c_str()) &&
+ tmp_str[pos + 1] == '*' && tmp_str.length() == (pos + 2)) {
+ break_id_t bp_id;
+ break_id_t bp_loc_id;
+
+ BreakpointID::ParseCanonicalReference(bp_id_str.c_str(), &bp_id,
+ &bp_loc_id);
+ BreakpointSP breakpoint_sp = target->GetBreakpointByID(bp_id);
+ if (!breakpoint_sp) {
new_args.Clear();
+ result.AppendErrorWithFormat("'%d' is not a valid breakpoint ID.\n",
+ bp_id);
+ result.SetStatus(eReturnStatusFailed);
return;
+ }
+ const size_t num_locations = breakpoint_sp->GetNumLocations();
+ for (size_t j = 0; j < num_locations; ++j) {
+ BreakpointLocation *bp_loc =
+ breakpoint_sp->GetLocationAtIndex(j).get();
+ StreamString canonical_id_str;
+ BreakpointID::GetCanonicalReference(&canonical_id_str, bp_id,
+ bp_loc->GetID());
+ new_args.AppendArgument(canonical_id_str.GetData());
+ }
}
+ }
+ }
- size_t range_start_len = 0;
- size_t range_end_pos = 0;
- Error error;
-
- if (BreakpointIDList::StringContainsIDRangeExpression (current_arg, &range_start_len, &range_end_pos))
- {
- is_range = true;
- range_start.assign (current_arg, range_start_len);
- range_end = current_arg + range_end_pos;
- }
- else if (BreakpointID::StringIsBreakpointName(current_arg, error))
- {
- if (!error.Success())
- {
- new_args.Clear();
- result.AppendError (error.AsCString());
- result.SetStatus (eReturnStatusFailed);
- return;
- }
- else
- names_found.insert(current_arg);
- }
- else if ((i + 2 < num_old_args)
- && BreakpointID::IsRangeIdentifier (old_args.GetArgumentAtIndex (i+1))
- && BreakpointID::IsValidIDExpression (current_arg)
- && BreakpointID::IsValidIDExpression (old_args.GetArgumentAtIndex (i+2)))
- {
- range_start.assign (current_arg);
- range_end = old_args.GetArgumentAtIndex (i+2);
- is_range = true;
- i = i+2;
- }
- else
- {
- // See if user has specified id.*
- std::string tmp_str = old_args.GetArgumentAtIndex (i);
- size_t pos = tmp_str.find ('.');
- if (pos != std::string::npos)
- {
- std::string bp_id_str = tmp_str.substr (0, pos);
- if (BreakpointID::IsValidIDExpression (bp_id_str.c_str())
- && tmp_str[pos+1] == '*'
- && tmp_str.length() == (pos + 2))
- {
- break_id_t bp_id;
- break_id_t bp_loc_id;
-
- BreakpointID::ParseCanonicalReference (bp_id_str.c_str(), &bp_id, &bp_loc_id);
- BreakpointSP breakpoint_sp = target->GetBreakpointByID (bp_id);
- if (! breakpoint_sp)
- {
- new_args.Clear();
- result.AppendErrorWithFormat ("'%d' is not a valid breakpoint ID.\n", bp_id);
- result.SetStatus (eReturnStatusFailed);
- return;
- }
- const size_t num_locations = breakpoint_sp->GetNumLocations();
- for (size_t j = 0; j < num_locations; ++j)
- {
- BreakpointLocation *bp_loc = breakpoint_sp->GetLocationAtIndex(j).get();
- StreamString canonical_id_str;
- BreakpointID::GetCanonicalReference (&canonical_id_str, bp_id, bp_loc->GetID());
- new_args.AppendArgument (canonical_id_str.GetData());
- }
- }
-
- }
- }
-
- if (is_range)
- {
- break_id_t start_bp_id;
- break_id_t end_bp_id;
- break_id_t start_loc_id;
- break_id_t end_loc_id;
-
- BreakpointID::ParseCanonicalReference (range_start.c_str(), &start_bp_id, &start_loc_id);
- BreakpointID::ParseCanonicalReference (range_end, &end_bp_id, &end_loc_id);
-
- if ((start_bp_id == LLDB_INVALID_BREAK_ID)
- || (! target->GetBreakpointByID (start_bp_id)))
- {
- new_args.Clear();
- result.AppendErrorWithFormat ("'%s' is not a valid breakpoint ID.\n", range_start.c_str());
- result.SetStatus (eReturnStatusFailed);
- return;
- }
-
- if ((end_bp_id == LLDB_INVALID_BREAK_ID)
- || (! target->GetBreakpointByID (end_bp_id)))
- {
- new_args.Clear();
- result.AppendErrorWithFormat ("'%s' is not a valid breakpoint ID.\n", range_end);
- result.SetStatus (eReturnStatusFailed);
- return;
- }
-
+ if (is_range) {
+ break_id_t start_bp_id;
+ break_id_t end_bp_id;
+ break_id_t start_loc_id;
+ break_id_t end_loc_id;
+
+ BreakpointID::ParseCanonicalReference(range_start.c_str(), &start_bp_id,
+ &start_loc_id);
+ BreakpointID::ParseCanonicalReference(range_end, &end_bp_id, &end_loc_id);
+
+ if ((start_bp_id == LLDB_INVALID_BREAK_ID) ||
+ (!target->GetBreakpointByID(start_bp_id))) {
+ new_args.Clear();
+ result.AppendErrorWithFormat("'%s' is not a valid breakpoint ID.\n",
+ range_start.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return;
+ }
- if (((start_loc_id == LLDB_INVALID_BREAK_ID)
- && (end_loc_id != LLDB_INVALID_BREAK_ID))
- || ((start_loc_id != LLDB_INVALID_BREAK_ID)
- && (end_loc_id == LLDB_INVALID_BREAK_ID)))
- {
- new_args.Clear ();
- result.AppendErrorWithFormat ("Invalid breakpoint id range: Either both ends of range must specify"
- " a breakpoint location, or neither can specify a breakpoint location.\n");
- result.SetStatus (eReturnStatusFailed);
- return;
- }
+ if ((end_bp_id == LLDB_INVALID_BREAK_ID) ||
+ (!target->GetBreakpointByID(end_bp_id))) {
+ new_args.Clear();
+ result.AppendErrorWithFormat("'%s' is not a valid breakpoint ID.\n",
+ range_end);
+ result.SetStatus(eReturnStatusFailed);
+ return;
+ }
- // We have valid range starting & ending breakpoint IDs. Go through all the breakpoints in the
- // target and find all the breakpoints that fit into this range, and add them to new_args.
-
- // Next check to see if we have location id's. If so, make sure the start_bp_id and end_bp_id are
- // for the same breakpoint; otherwise we have an illegal range: breakpoint id ranges that specify
- // bp locations are NOT allowed to cross major bp id numbers.
-
- if ((start_loc_id != LLDB_INVALID_BREAK_ID)
- || (end_loc_id != LLDB_INVALID_BREAK_ID))
- {
- if (start_bp_id != end_bp_id)
- {
- new_args.Clear();
- result.AppendErrorWithFormat ("Invalid range: Ranges that specify particular breakpoint locations"
- " must be within the same major breakpoint; you specified two"
- " different major breakpoints, %d and %d.\n",
- start_bp_id, end_bp_id);
- result.SetStatus (eReturnStatusFailed);
- return;
- }
- }
+ if (((start_loc_id == LLDB_INVALID_BREAK_ID) &&
+ (end_loc_id != LLDB_INVALID_BREAK_ID)) ||
+ ((start_loc_id != LLDB_INVALID_BREAK_ID) &&
+ (end_loc_id == LLDB_INVALID_BREAK_ID))) {
+ new_args.Clear();
+ result.AppendErrorWithFormat("Invalid breakpoint id range: Either "
+ "both ends of range must specify"
+ " a breakpoint location, or neither can "
+ "specify a breakpoint location.\n");
+ result.SetStatus(eReturnStatusFailed);
+ return;
+ }
- const BreakpointList& breakpoints = target->GetBreakpointList();
- const size_t num_breakpoints = breakpoints.GetSize();
- for (size_t j = 0; j < num_breakpoints; ++j)
- {
- Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (j).get();
- break_id_t cur_bp_id = breakpoint->GetID();
-
- if ((cur_bp_id < start_bp_id) || (cur_bp_id > end_bp_id))
- continue;
-
- const size_t num_locations = breakpoint->GetNumLocations();
-
- if ((cur_bp_id == start_bp_id) && (start_loc_id != LLDB_INVALID_BREAK_ID))
- {
- for (size_t k = 0; k < num_locations; ++k)
- {
- BreakpointLocation * bp_loc = breakpoint->GetLocationAtIndex(k).get();
- if ((bp_loc->GetID() >= start_loc_id) && (bp_loc->GetID() <= end_loc_id))
- {
- StreamString canonical_id_str;
- BreakpointID::GetCanonicalReference (&canonical_id_str, cur_bp_id, bp_loc->GetID());
- new_args.AppendArgument (canonical_id_str.GetData());
- }
- }
- }
- else if ((cur_bp_id == end_bp_id) && (end_loc_id != LLDB_INVALID_BREAK_ID))
- {
- for (size_t k = 0; k < num_locations; ++k)
- {
- BreakpointLocation * bp_loc = breakpoint->GetLocationAtIndex(k).get();
- if (bp_loc->GetID() <= end_loc_id)
- {
- StreamString canonical_id_str;
- BreakpointID::GetCanonicalReference (&canonical_id_str, cur_bp_id, bp_loc->GetID());
- new_args.AppendArgument (canonical_id_str.GetData());
- }
- }
- }
- else
- {
- StreamString canonical_id_str;
- BreakpointID::GetCanonicalReference (&canonical_id_str, cur_bp_id, LLDB_INVALID_BREAK_ID);
- new_args.AppendArgument (canonical_id_str.GetData());
- }
- }
- }
- else // else is_range was false
- {
- new_args.AppendArgument (current_arg);
+ // We have valid range starting & ending breakpoint IDs. Go through all
+ // the breakpoints in the
+ // target and find all the breakpoints that fit into this range, and add
+ // them to new_args.
+
+ // Next check to see if we have location id's. If so, make sure the
+ // start_bp_id and end_bp_id are
+ // for the same breakpoint; otherwise we have an illegal range: breakpoint
+ // id ranges that specify
+ // bp locations are NOT allowed to cross major bp id numbers.
+
+ if ((start_loc_id != LLDB_INVALID_BREAK_ID) ||
+ (end_loc_id != LLDB_INVALID_BREAK_ID)) {
+ if (start_bp_id != end_bp_id) {
+ new_args.Clear();
+ result.AppendErrorWithFormat(
+ "Invalid range: Ranges that specify particular breakpoint "
+ "locations"
+ " must be within the same major breakpoint; you specified two"
+ " different major breakpoints, %d and %d.\n",
+ start_bp_id, end_bp_id);
+ result.SetStatus(eReturnStatusFailed);
+ return;
+ }
+ }
+
+ const BreakpointList &breakpoints = target->GetBreakpointList();
+ const size_t num_breakpoints = breakpoints.GetSize();
+ for (size_t j = 0; j < num_breakpoints; ++j) {
+ Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex(j).get();
+ break_id_t cur_bp_id = breakpoint->GetID();
+
+ if ((cur_bp_id < start_bp_id) || (cur_bp_id > end_bp_id))
+ continue;
+
+ const size_t num_locations = breakpoint->GetNumLocations();
+
+ if ((cur_bp_id == start_bp_id) &&
+ (start_loc_id != LLDB_INVALID_BREAK_ID)) {
+ for (size_t k = 0; k < num_locations; ++k) {
+ BreakpointLocation *bp_loc =
+ breakpoint->GetLocationAtIndex(k).get();
+ if ((bp_loc->GetID() >= start_loc_id) &&
+ (bp_loc->GetID() <= end_loc_id)) {
+ StreamString canonical_id_str;
+ BreakpointID::GetCanonicalReference(&canonical_id_str, cur_bp_id,
+ bp_loc->GetID());
+ new_args.AppendArgument(canonical_id_str.GetData());
+ }
+ }
+ } else if ((cur_bp_id == end_bp_id) &&
+ (end_loc_id != LLDB_INVALID_BREAK_ID)) {
+ for (size_t k = 0; k < num_locations; ++k) {
+ BreakpointLocation *bp_loc =
+ breakpoint->GetLocationAtIndex(k).get();
+ if (bp_loc->GetID() <= end_loc_id) {
+ StreamString canonical_id_str;
+ BreakpointID::GetCanonicalReference(&canonical_id_str, cur_bp_id,
+ bp_loc->GetID());
+ new_args.AppendArgument(canonical_id_str.GetData());
+ }
+ }
+ } else {
+ StreamString canonical_id_str;
+ BreakpointID::GetCanonicalReference(&canonical_id_str, cur_bp_id,
+ LLDB_INVALID_BREAK_ID);
+ new_args.AppendArgument(canonical_id_str.GetData());
}
+ }
+ } else // else is_range was false
+ {
+ new_args.AppendArgument(current_arg);
}
+ }
- // Okay, now see if we found any names, and if we did, add them:
- if (target && names_found.size())
- {
- for (BreakpointSP bkpt_sp : target->GetBreakpointList().Breakpoints())
- {
- for (std::string name : names_found)
- {
- if (bkpt_sp->MatchesName(name.c_str()))
- {
- StreamString canonical_id_str;
- BreakpointID::GetCanonicalReference (&canonical_id_str, bkpt_sp->GetID(), LLDB_INVALID_BREAK_ID);
- new_args.AppendArgument (canonical_id_str.GetData());
- }
- }
+ // Okay, now see if we found any names, and if we did, add them:
+ if (target && names_found.size()) {
+ for (BreakpointSP bkpt_sp : target->GetBreakpointList().Breakpoints()) {
+ for (std::string name : names_found) {
+ if (bkpt_sp->MatchesName(name.c_str())) {
+ StreamString canonical_id_str;
+ BreakpointID::GetCanonicalReference(
+ &canonical_id_str, bkpt_sp->GetID(), LLDB_INVALID_BREAK_ID);
+ new_args.AppendArgument(canonical_id_str.GetData());
}
+ }
}
+ }
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
-bool
-BreakpointIDList::StringContainsIDRangeExpression (const char *in_string,
- size_t *range_start_len,
- size_t *range_end_pos)
-{
- bool is_range_expression = false;
- std::string arg_str = in_string;
- std::string::size_type idx;
- std::string::size_type start_pos = 0;
-
- *range_start_len = 0;
- *range_end_pos = 0;
-
- int specifiers_size = 0;
- for (int i = 0; BreakpointID::g_range_specifiers[i] != nullptr; ++i)
- ++specifiers_size;
-
- for (int i = 0; i < specifiers_size && !is_range_expression; ++i)
- {
- const char *specifier_str = BreakpointID::g_range_specifiers[i];
- size_t len = strlen (specifier_str);
- idx = arg_str.find (BreakpointID::g_range_specifiers[i]);
- if (idx != std::string::npos)
- {
- *range_start_len = idx - start_pos;
- std::string start_str = arg_str.substr (start_pos, *range_start_len);
- if (idx + len < arg_str.length())
- {
- *range_end_pos = idx + len;
- std::string end_str = arg_str.substr (*range_end_pos);
- if (BreakpointID::IsValidIDExpression (start_str.c_str())
- && BreakpointID::IsValidIDExpression (end_str.c_str()))
- {
- is_range_expression = true;
- //*range_start = start_str;
- //*range_end = end_str;
- }
- }
+bool BreakpointIDList::StringContainsIDRangeExpression(const char *in_string,
+ size_t *range_start_len,
+ size_t *range_end_pos) {
+ bool is_range_expression = false;
+ std::string arg_str = in_string;
+ std::string::size_type idx;
+ std::string::size_type start_pos = 0;
+
+ *range_start_len = 0;
+ *range_end_pos = 0;
+
+ int specifiers_size = 0;
+ for (int i = 0; BreakpointID::g_range_specifiers[i] != nullptr; ++i)
+ ++specifiers_size;
+
+ for (int i = 0; i < specifiers_size && !is_range_expression; ++i) {
+ const char *specifier_str = BreakpointID::g_range_specifiers[i];
+ size_t len = strlen(specifier_str);
+ idx = arg_str.find(BreakpointID::g_range_specifiers[i]);
+ if (idx != std::string::npos) {
+ *range_start_len = idx - start_pos;
+ std::string start_str = arg_str.substr(start_pos, *range_start_len);
+ if (idx + len < arg_str.length()) {
+ *range_end_pos = idx + len;
+ std::string end_str = arg_str.substr(*range_end_pos);
+ if (BreakpointID::IsValidIDExpression(start_str.c_str()) &&
+ BreakpointID::IsValidIDExpression(end_str.c_str())) {
+ is_range_expression = true;
+ //*range_start = start_str;
+ //*range_end = end_str;
}
+ }
}
+ }
- if (!is_range_expression)
- {
- *range_start_len = 0;
- *range_end_pos = 0;
- }
+ if (!is_range_expression) {
+ *range_start_len = 0;
+ *range_end_pos = 0;
+ }
- return is_range_expression;
+ return is_range_expression;
}
Modified: lldb/trunk/source/Breakpoint/BreakpointList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointList.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointList.cpp Tue Sep 6 15:57:50 2016
@@ -19,222 +19,183 @@ using namespace lldb;
using namespace lldb_private;
BreakpointList::BreakpointList(bool is_internal)
- : m_mutex(), m_breakpoints(), m_next_break_id(0), m_is_internal(is_internal)
-{
-}
-
-BreakpointList::~BreakpointList()
-{
-}
+ : m_mutex(), m_breakpoints(), m_next_break_id(0),
+ m_is_internal(is_internal) {}
+BreakpointList::~BreakpointList() {}
-break_id_t
-BreakpointList::Add (BreakpointSP &bp_sp, bool notify)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- // Internal breakpoint IDs are negative, normal ones are positive
- bp_sp->SetID (m_is_internal ? --m_next_break_id : ++m_next_break_id);
-
- m_breakpoints.push_back(bp_sp);
- if (notify)
- {
- if (bp_sp->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- bp_sp->GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged,
- new Breakpoint::BreakpointEventData (eBreakpointEventTypeAdded, bp_sp));
+break_id_t BreakpointList::Add(BreakpointSP &bp_sp, bool notify) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ // Internal breakpoint IDs are negative, normal ones are positive
+ bp_sp->SetID(m_is_internal ? --m_next_break_id : ++m_next_break_id);
+
+ m_breakpoints.push_back(bp_sp);
+ if (notify) {
+ if (bp_sp->GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitBreakpointChanged))
+ bp_sp->GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged,
+ new Breakpoint::BreakpointEventData(
+ eBreakpointEventTypeAdded, bp_sp));
+ }
+ return bp_sp->GetID();
+}
+
+bool BreakpointList::Remove(break_id_t break_id, bool notify) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ bp_collection::iterator pos = GetBreakpointIDIterator(break_id); // Predicate
+ if (pos != m_breakpoints.end()) {
+ BreakpointSP bp_sp(*pos);
+ m_breakpoints.erase(pos);
+ if (notify) {
+ if (bp_sp->GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitBreakpointChanged))
+ bp_sp->GetTarget().BroadcastEvent(
+ Target::eBroadcastBitBreakpointChanged,
+ new Breakpoint::BreakpointEventData(eBreakpointEventTypeRemoved,
+ bp_sp));
+ }
+ return true;
+ }
+ return false;
+}
+
+void BreakpointList::RemoveInvalidLocations(const ArchSpec &arch) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ for (const auto &bp_sp : m_breakpoints)
+ bp_sp->RemoveInvalidLocations(arch);
+}
+
+void BreakpointList::SetEnabledAll(bool enabled) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ for (const auto &bp_sp : m_breakpoints)
+ bp_sp->SetEnabled(enabled);
+}
+
+void BreakpointList::RemoveAll(bool notify) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ ClearAllBreakpointSites();
+
+ if (notify) {
+ bp_collection::iterator pos, end = m_breakpoints.end();
+ for (pos = m_breakpoints.begin(); pos != end; ++pos) {
+ if ((*pos)->GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitBreakpointChanged)) {
+ (*pos)->GetTarget().BroadcastEvent(
+ Target::eBroadcastBitBreakpointChanged,
+ new Breakpoint::BreakpointEventData(eBreakpointEventTypeRemoved,
+ *pos));
+ }
}
- return bp_sp->GetID();
+ }
+ m_breakpoints.erase(m_breakpoints.begin(), m_breakpoints.end());
}
-bool
-BreakpointList::Remove (break_id_t break_id, bool notify)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- bp_collection::iterator pos = GetBreakpointIDIterator(break_id); // Predicate
- if (pos != m_breakpoints.end())
- {
- BreakpointSP bp_sp (*pos);
- m_breakpoints.erase(pos);
- if (notify)
- {
- if (bp_sp->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- bp_sp->GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged,
- new Breakpoint::BreakpointEventData (eBreakpointEventTypeRemoved, bp_sp));
- }
- return true;
- }
- return false;
-}
-
-void
-BreakpointList::RemoveInvalidLocations (const ArchSpec &arch)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- for (const auto &bp_sp : m_breakpoints)
- bp_sp->RemoveInvalidLocations(arch);
-}
-
-
-void
-BreakpointList::SetEnabledAll (bool enabled)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- for (const auto &bp_sp : m_breakpoints)
- bp_sp->SetEnabled (enabled);
-}
-
-
-void
-BreakpointList::RemoveAll (bool notify)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- ClearAllBreakpointSites ();
-
- if (notify)
- {
- bp_collection::iterator pos, end = m_breakpoints.end();
- for (pos = m_breakpoints.begin(); pos != end; ++pos)
- {
- if ((*pos)->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- {
- (*pos)->GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged,
- new Breakpoint::BreakpointEventData (eBreakpointEventTypeRemoved,
- *pos));
- }
- }
- }
- m_breakpoints.erase (m_breakpoints.begin(), m_breakpoints.end());
-}
-
-class BreakpointIDMatches
-{
+class BreakpointIDMatches {
public:
- BreakpointIDMatches (break_id_t break_id) :
- m_break_id(break_id)
- {
- }
+ BreakpointIDMatches(break_id_t break_id) : m_break_id(break_id) {}
- bool operator() (const BreakpointSP &bp) const
- {
- return m_break_id == bp->GetID();
- }
+ bool operator()(const BreakpointSP &bp) const {
+ return m_break_id == bp->GetID();
+ }
private:
- const break_id_t m_break_id;
+ const break_id_t m_break_id;
};
BreakpointList::bp_collection::iterator
-BreakpointList::GetBreakpointIDIterator (break_id_t break_id)
-{
- return std::find_if(m_breakpoints.begin(), m_breakpoints.end(), // Search full range
- BreakpointIDMatches(break_id)); // Predicate
+BreakpointList::GetBreakpointIDIterator(break_id_t break_id) {
+ return std::find_if(m_breakpoints.begin(),
+ m_breakpoints.end(), // Search full range
+ BreakpointIDMatches(break_id)); // Predicate
}
BreakpointList::bp_collection::const_iterator
-BreakpointList::GetBreakpointIDConstIterator (break_id_t break_id) const
-{
- return std::find_if(m_breakpoints.begin(), m_breakpoints.end(), // Search full range
- BreakpointIDMatches(break_id)); // Predicate
-}
-
-BreakpointSP
-BreakpointList::FindBreakpointByID (break_id_t break_id)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointSP stop_sp;
- bp_collection::iterator pos = GetBreakpointIDIterator(break_id);
- if (pos != m_breakpoints.end())
- stop_sp = *pos;
-
- return stop_sp;
+BreakpointList::GetBreakpointIDConstIterator(break_id_t break_id) const {
+ return std::find_if(m_breakpoints.begin(),
+ m_breakpoints.end(), // Search full range
+ BreakpointIDMatches(break_id)); // Predicate
}
-const BreakpointSP
-BreakpointList::FindBreakpointByID (break_id_t break_id) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointSP stop_sp;
- bp_collection::const_iterator pos = GetBreakpointIDConstIterator(break_id);
- if (pos != m_breakpoints.end())
- stop_sp = *pos;
-
- return stop_sp;
-}
-
-void
-BreakpointList::Dump (Stream *s) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- s->Printf("%p: ", static_cast<const void*>(this));
- s->Indent();
- s->Printf("BreakpointList with %u Breakpoints:\n", (uint32_t)m_breakpoints.size());
- s->IndentMore();
- for (const auto &bp_sp : m_breakpoints)
- bp_sp->Dump(s);
- s->IndentLess();
-}
+BreakpointSP BreakpointList::FindBreakpointByID(break_id_t break_id) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointSP stop_sp;
+ bp_collection::iterator pos = GetBreakpointIDIterator(break_id);
+ if (pos != m_breakpoints.end())
+ stop_sp = *pos;
-
-BreakpointSP
-BreakpointList::GetBreakpointAtIndex (size_t i)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointSP stop_sp;
- bp_collection::iterator end = m_breakpoints.end();
- bp_collection::iterator pos;
- size_t curr_i = 0;
- for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i)
- {
- if (curr_i == i)
- stop_sp = *pos;
- }
- return stop_sp;
+ return stop_sp;
}
const BreakpointSP
-BreakpointList::GetBreakpointAtIndex (size_t i) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointSP stop_sp;
- bp_collection::const_iterator end = m_breakpoints.end();
- bp_collection::const_iterator pos;
- size_t curr_i = 0;
- for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i)
- {
- if (curr_i == i)
- stop_sp = *pos;
- }
- return stop_sp;
-}
-
-void
-BreakpointList::UpdateBreakpoints (ModuleList& module_list, bool added, bool delete_locations)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- for (const auto &bp_sp : m_breakpoints)
- bp_sp->ModulesChanged (module_list, added, delete_locations);
-
-}
-
-void
-BreakpointList::UpdateBreakpointsWhenModuleIsReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- for (const auto &bp_sp : m_breakpoints)
- bp_sp->ModuleReplaced (old_module_sp, new_module_sp);
-
-}
-
-void
-BreakpointList::ClearAllBreakpointSites ()
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- for (const auto &bp_sp : m_breakpoints)
- bp_sp->ClearAllBreakpointSites ();
-
-}
-
-void
-BreakpointList::GetListMutex(std::unique_lock<std::recursive_mutex> &lock)
-{
- lock = std::unique_lock<std::recursive_mutex>(m_mutex);
+BreakpointList::FindBreakpointByID(break_id_t break_id) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointSP stop_sp;
+ bp_collection::const_iterator pos = GetBreakpointIDConstIterator(break_id);
+ if (pos != m_breakpoints.end())
+ stop_sp = *pos;
+
+ return stop_sp;
+}
+
+void BreakpointList::Dump(Stream *s) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ s->Printf("%p: ", static_cast<const void *>(this));
+ s->Indent();
+ s->Printf("BreakpointList with %u Breakpoints:\n",
+ (uint32_t)m_breakpoints.size());
+ s->IndentMore();
+ for (const auto &bp_sp : m_breakpoints)
+ bp_sp->Dump(s);
+ s->IndentLess();
+}
+
+BreakpointSP BreakpointList::GetBreakpointAtIndex(size_t i) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointSP stop_sp;
+ bp_collection::iterator end = m_breakpoints.end();
+ bp_collection::iterator pos;
+ size_t curr_i = 0;
+ for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i) {
+ if (curr_i == i)
+ stop_sp = *pos;
+ }
+ return stop_sp;
+}
+
+const BreakpointSP BreakpointList::GetBreakpointAtIndex(size_t i) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointSP stop_sp;
+ bp_collection::const_iterator end = m_breakpoints.end();
+ bp_collection::const_iterator pos;
+ size_t curr_i = 0;
+ for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i) {
+ if (curr_i == i)
+ stop_sp = *pos;
+ }
+ return stop_sp;
+}
+
+void BreakpointList::UpdateBreakpoints(ModuleList &module_list, bool added,
+ bool delete_locations) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ for (const auto &bp_sp : m_breakpoints)
+ bp_sp->ModulesChanged(module_list, added, delete_locations);
+}
+
+void BreakpointList::UpdateBreakpointsWhenModuleIsReplaced(
+ ModuleSP old_module_sp, ModuleSP new_module_sp) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ for (const auto &bp_sp : m_breakpoints)
+ bp_sp->ModuleReplaced(old_module_sp, new_module_sp);
+}
+
+void BreakpointList::ClearAllBreakpointSites() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ for (const auto &bp_sp : m_breakpoints)
+ bp_sp->ClearAllBreakpointSites();
+}
+
+void BreakpointList::GetListMutex(
+ std::unique_lock<std::recursive_mutex> &lock) {
+ lock = std::unique_lock<std::recursive_mutex>(m_mutex);
}
Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Tue Sep 6 15:57:50 2016
@@ -25,421 +25,336 @@
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/TypeSystem.h"
-#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
using namespace lldb;
using namespace lldb_private;
-BreakpointLocation::BreakpointLocation(break_id_t loc_id, Breakpoint &owner, const Address &addr, lldb::tid_t tid,
+BreakpointLocation::BreakpointLocation(break_id_t loc_id, Breakpoint &owner,
+ const Address &addr, lldb::tid_t tid,
bool hardware, bool check_for_resolver)
- : StoppointLocation(loc_id, addr.GetOpcodeLoadAddress(&owner.GetTarget()), hardware),
- m_being_created(true),
- m_should_resolve_indirect_functions(false),
- m_is_reexported(false),
- m_is_indirect(false),
- m_address(addr),
- m_owner(owner),
- m_options_ap(),
- m_bp_site_sp(),
- m_condition_mutex()
-{
- if (check_for_resolver)
- {
- Symbol *symbol = m_address.CalculateSymbolContextSymbol();
- if (symbol && symbol->IsIndirect())
- {
- SetShouldResolveIndirectFunctions(true);
- }
+ : StoppointLocation(loc_id, addr.GetOpcodeLoadAddress(&owner.GetTarget()),
+ hardware),
+ m_being_created(true), m_should_resolve_indirect_functions(false),
+ m_is_reexported(false), m_is_indirect(false), m_address(addr),
+ m_owner(owner), m_options_ap(), m_bp_site_sp(), m_condition_mutex() {
+ if (check_for_resolver) {
+ Symbol *symbol = m_address.CalculateSymbolContextSymbol();
+ if (symbol && symbol->IsIndirect()) {
+ SetShouldResolveIndirectFunctions(true);
}
+ }
- SetThreadID(tid);
- m_being_created = false;
+ SetThreadID(tid);
+ m_being_created = false;
}
-BreakpointLocation::~BreakpointLocation()
-{
- ClearBreakpointSite();
-}
+BreakpointLocation::~BreakpointLocation() { ClearBreakpointSite(); }
-lldb::addr_t
-BreakpointLocation::GetLoadAddress () const
-{
- return m_address.GetOpcodeLoadAddress (&m_owner.GetTarget());
+lldb::addr_t BreakpointLocation::GetLoadAddress() const {
+ return m_address.GetOpcodeLoadAddress(&m_owner.GetTarget());
}
-Address &
-BreakpointLocation::GetAddress ()
-{
- return m_address;
-}
+Address &BreakpointLocation::GetAddress() { return m_address; }
-Breakpoint &
-BreakpointLocation::GetBreakpoint ()
-{
- return m_owner;
-}
+Breakpoint &BreakpointLocation::GetBreakpoint() { return m_owner; }
-Target &
-BreakpointLocation::GetTarget()
-{
- return m_owner.GetTarget();
-}
+Target &BreakpointLocation::GetTarget() { return m_owner.GetTarget(); }
-bool
-BreakpointLocation::IsEnabled () const
-{
- if (!m_owner.IsEnabled())
- return false;
- else if (m_options_ap.get() != nullptr)
- return m_options_ap->IsEnabled();
- else
- return true;
+bool BreakpointLocation::IsEnabled() const {
+ if (!m_owner.IsEnabled())
+ return false;
+ else if (m_options_ap.get() != nullptr)
+ return m_options_ap->IsEnabled();
+ else
+ return true;
}
-void
-BreakpointLocation::SetEnabled (bool enabled)
-{
- GetLocationOptions()->SetEnabled(enabled);
- if (enabled)
- {
- ResolveBreakpointSite();
- }
- else
- {
- ClearBreakpointSite();
- }
- SendBreakpointLocationChangedEvent (enabled ? eBreakpointEventTypeEnabled : eBreakpointEventTypeDisabled);
+void BreakpointLocation::SetEnabled(bool enabled) {
+ GetLocationOptions()->SetEnabled(enabled);
+ if (enabled) {
+ ResolveBreakpointSite();
+ } else {
+ ClearBreakpointSite();
+ }
+ SendBreakpointLocationChangedEvent(enabled ? eBreakpointEventTypeEnabled
+ : eBreakpointEventTypeDisabled);
}
-void
-BreakpointLocation::SetThreadID (lldb::tid_t thread_id)
-{
- if (thread_id != LLDB_INVALID_THREAD_ID)
- GetLocationOptions()->SetThreadID(thread_id);
- else
- {
- // If we're resetting this to an invalid thread id, then
- // don't make an options pointer just to do that.
- if (m_options_ap.get() != nullptr)
- m_options_ap->SetThreadID (thread_id);
- }
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
+void BreakpointLocation::SetThreadID(lldb::tid_t thread_id) {
+ if (thread_id != LLDB_INVALID_THREAD_ID)
+ GetLocationOptions()->SetThreadID(thread_id);
+ else {
+ // If we're resetting this to an invalid thread id, then
+ // don't make an options pointer just to do that.
+ if (m_options_ap.get() != nullptr)
+ m_options_ap->SetThreadID(thread_id);
+ }
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
+}
+
+lldb::tid_t BreakpointLocation::GetThreadID() {
+ if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
+ return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID();
+ else
+ return LLDB_INVALID_THREAD_ID;
+}
+
+void BreakpointLocation::SetThreadIndex(uint32_t index) {
+ if (index != 0)
+ GetLocationOptions()->GetThreadSpec()->SetIndex(index);
+ else {
+ // If we're resetting this to an invalid thread id, then
+ // don't make an options pointer just to do that.
+ if (m_options_ap.get() != nullptr)
+ m_options_ap->GetThreadSpec()->SetIndex(index);
+ }
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
+}
+
+uint32_t BreakpointLocation::GetThreadIndex() const {
+ if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
+ return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetIndex();
+ else
+ return 0;
+}
+
+void BreakpointLocation::SetThreadName(const char *thread_name) {
+ if (thread_name != nullptr)
+ GetLocationOptions()->GetThreadSpec()->SetName(thread_name);
+ else {
+ // If we're resetting this to an invalid thread id, then
+ // don't make an options pointer just to do that.
+ if (m_options_ap.get() != nullptr)
+ m_options_ap->GetThreadSpec()->SetName(thread_name);
+ }
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
+}
+
+const char *BreakpointLocation::GetThreadName() const {
+ if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
+ return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetName();
+ else
+ return nullptr;
+}
+
+void BreakpointLocation::SetQueueName(const char *queue_name) {
+ if (queue_name != nullptr)
+ GetLocationOptions()->GetThreadSpec()->SetQueueName(queue_name);
+ else {
+ // If we're resetting this to an invalid thread id, then
+ // don't make an options pointer just to do that.
+ if (m_options_ap.get() != nullptr)
+ m_options_ap->GetThreadSpec()->SetQueueName(queue_name);
+ }
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
}
-lldb::tid_t
-BreakpointLocation::GetThreadID ()
-{
- if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
- return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID();
- else
- return LLDB_INVALID_THREAD_ID;
+const char *BreakpointLocation::GetQueueName() const {
+ if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
+ return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetQueueName();
+ else
+ return nullptr;
}
-void
-BreakpointLocation::SetThreadIndex (uint32_t index)
-{
- if (index != 0)
- GetLocationOptions()->GetThreadSpec()->SetIndex(index);
- else
- {
- // If we're resetting this to an invalid thread id, then
- // don't make an options pointer just to do that.
- if (m_options_ap.get() != nullptr)
- m_options_ap->GetThreadSpec()->SetIndex(index);
- }
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
+bool BreakpointLocation::InvokeCallback(StoppointCallbackContext *context) {
+ if (m_options_ap.get() != nullptr && m_options_ap->HasCallback())
+ return m_options_ap->InvokeCallback(context, m_owner.GetID(), GetID());
+ else
+ return m_owner.InvokeCallback(context, GetID());
}
-uint32_t
-BreakpointLocation::GetThreadIndex() const
-{
- if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
- return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetIndex();
- else
- return 0;
+void BreakpointLocation::SetCallback(BreakpointHitCallback callback,
+ void *baton, bool is_synchronous) {
+ // The default "Baton" class will keep a copy of "baton" and won't free
+ // or delete it when it goes goes out of scope.
+ GetLocationOptions()->SetCallback(callback, BatonSP(new Baton(baton)),
+ is_synchronous);
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeCommandChanged);
}
-void
-BreakpointLocation::SetThreadName (const char *thread_name)
-{
- if (thread_name != nullptr)
- GetLocationOptions()->GetThreadSpec()->SetName(thread_name);
- else
- {
- // If we're resetting this to an invalid thread id, then
- // don't make an options pointer just to do that.
- if (m_options_ap.get() != nullptr)
- m_options_ap->GetThreadSpec()->SetName(thread_name);
- }
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
+void BreakpointLocation::SetCallback(BreakpointHitCallback callback,
+ const BatonSP &baton_sp,
+ bool is_synchronous) {
+ GetLocationOptions()->SetCallback(callback, baton_sp, is_synchronous);
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeCommandChanged);
}
-const char *
-BreakpointLocation::GetThreadName () const
-{
- if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
- return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetName();
- else
- return nullptr;
+void BreakpointLocation::ClearCallback() {
+ GetLocationOptions()->ClearCallback();
}
-void
-BreakpointLocation::SetQueueName (const char *queue_name)
-{
- if (queue_name != nullptr)
- GetLocationOptions()->GetThreadSpec()->SetQueueName(queue_name);
- else
- {
- // If we're resetting this to an invalid thread id, then
- // don't make an options pointer just to do that.
- if (m_options_ap.get() != nullptr)
- m_options_ap->GetThreadSpec()->SetQueueName(queue_name);
- }
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
+void BreakpointLocation::SetCondition(const char *condition) {
+ GetLocationOptions()->SetCondition(condition);
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeConditionChanged);
}
-const char *
-BreakpointLocation::GetQueueName () const
-{
- if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
- return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetQueueName();
- else
- return nullptr;
+const char *BreakpointLocation::GetConditionText(size_t *hash) const {
+ return GetOptionsNoCreate()->GetConditionText(hash);
}
-bool
-BreakpointLocation::InvokeCallback (StoppointCallbackContext *context)
-{
- if (m_options_ap.get() != nullptr && m_options_ap->HasCallback())
- return m_options_ap->InvokeCallback (context, m_owner.GetID(), GetID());
- else
- return m_owner.InvokeCallback (context, GetID());
-}
+bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
+ Error &error) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
-void
-BreakpointLocation::SetCallback (BreakpointHitCallback callback, void *baton,
- bool is_synchronous)
-{
- // The default "Baton" class will keep a copy of "baton" and won't free
- // or delete it when it goes goes out of scope.
- GetLocationOptions()->SetCallback(callback, BatonSP (new Baton(baton)), is_synchronous);
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeCommandChanged);
-}
+ std::lock_guard<std::mutex> guard(m_condition_mutex);
-void
-BreakpointLocation::SetCallback (BreakpointHitCallback callback, const BatonSP &baton_sp,
- bool is_synchronous)
-{
- GetLocationOptions()->SetCallback (callback, baton_sp, is_synchronous);
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeCommandChanged);
-}
+ size_t condition_hash;
+ const char *condition_text = GetConditionText(&condition_hash);
-void
-BreakpointLocation::ClearCallback ()
-{
- GetLocationOptions()->ClearCallback();
-}
+ if (!condition_text) {
+ m_user_expression_sp.reset();
+ return false;
+ }
-void
-BreakpointLocation::SetCondition (const char *condition)
-{
- GetLocationOptions()->SetCondition (condition);
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeConditionChanged);
-}
+ error.Clear();
-const char *
-BreakpointLocation::GetConditionText (size_t *hash) const
-{
- return GetOptionsNoCreate()->GetConditionText(hash);
-}
+ DiagnosticManager diagnostics;
-bool
-BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error)
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
+ if (condition_hash != m_condition_hash || !m_user_expression_sp ||
+ !m_user_expression_sp->MatchesContext(exe_ctx)) {
+ LanguageType language = eLanguageTypeUnknown;
+ // See if we can figure out the language from the frame, otherwise use the
+ // default language:
+ CompileUnit *comp_unit = m_address.CalculateSymbolContextCompileUnit();
+ if (comp_unit)
+ language = comp_unit->GetLanguage();
- std::lock_guard<std::mutex> guard(m_condition_mutex);
+ m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(
+ condition_text, nullptr, language, Expression::eResultTypeAny,
+ EvaluateExpressionOptions(), error));
+ if (error.Fail()) {
+ if (log)
+ log->Printf("Error getting condition expression: %s.",
+ error.AsCString());
+ m_user_expression_sp.reset();
+ return true;
+ }
- size_t condition_hash;
- const char *condition_text = GetConditionText(&condition_hash);
-
- if (!condition_text)
- {
- m_user_expression_sp.reset();
- return false;
+ if (!m_user_expression_sp->Parse(diagnostics, exe_ctx,
+ eExecutionPolicyOnlyWhenNeeded, true,
+ false)) {
+ error.SetErrorStringWithFormat(
+ "Couldn't parse conditional expression:\n%s",
+ diagnostics.GetString().c_str());
+ m_user_expression_sp.reset();
+ return true;
}
- error.Clear();
-
- DiagnosticManager diagnostics;
-
- if (condition_hash != m_condition_hash || !m_user_expression_sp || !m_user_expression_sp->MatchesContext(exe_ctx))
- {
- LanguageType language = eLanguageTypeUnknown;
- // See if we can figure out the language from the frame, otherwise use the default language:
- CompileUnit *comp_unit = m_address.CalculateSymbolContextCompileUnit();
- if (comp_unit)
- language = comp_unit->GetLanguage();
-
- m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(condition_text,
- nullptr,
- language,
- Expression::eResultTypeAny,
- EvaluateExpressionOptions(),
- error));
- if (error.Fail())
- {
- if (log)
- log->Printf("Error getting condition expression: %s.", error.AsCString());
- m_user_expression_sp.reset();
- return true;
- }
+ m_condition_hash = condition_hash;
+ }
- if (!m_user_expression_sp->Parse(diagnostics, exe_ctx, eExecutionPolicyOnlyWhenNeeded, true, false))
- {
- error.SetErrorStringWithFormat("Couldn't parse conditional expression:\n%s",
- diagnostics.GetString().c_str());
- m_user_expression_sp.reset();
- return true;
- }
+ // We need to make sure the user sees any parse errors in their condition, so
+ // we'll hook the
+ // constructor errors up to the debugger's Async I/O.
+
+ ValueObjectSP result_value_sp;
- m_condition_hash = condition_hash;
+ EvaluateExpressionOptions options;
+ options.SetUnwindOnError(true);
+ options.SetIgnoreBreakpoints(true);
+ options.SetTryAllThreads(true);
+ options.SetResultIsInternal(
+ true); // Don't generate a user variable for condition expressions.
+
+ Error expr_error;
+
+ diagnostics.Clear();
+
+ ExpressionVariableSP result_variable_sp;
+
+ ExpressionResults result_code = m_user_expression_sp->Execute(
+ diagnostics, exe_ctx, options, m_user_expression_sp, result_variable_sp);
+
+ bool ret;
+
+ if (result_code == eExpressionCompleted) {
+ if (!result_variable_sp) {
+ error.SetErrorString("Expression did not return a result");
+ return false;
}
- // We need to make sure the user sees any parse errors in their condition, so we'll hook the
- // constructor errors up to the debugger's Async I/O.
-
- ValueObjectSP result_value_sp;
-
- EvaluateExpressionOptions options;
- options.SetUnwindOnError(true);
- options.SetIgnoreBreakpoints(true);
- options.SetTryAllThreads(true);
- options.SetResultIsInternal(true); // Don't generate a user variable for condition expressions.
-
- Error expr_error;
-
- diagnostics.Clear();
-
- ExpressionVariableSP result_variable_sp;
-
- ExpressionResults result_code =
- m_user_expression_sp->Execute(diagnostics, exe_ctx, options, m_user_expression_sp, result_variable_sp);
-
- bool ret;
-
- if (result_code == eExpressionCompleted)
- {
- if (!result_variable_sp)
- {
- error.SetErrorString("Expression did not return a result");
- return false;
- }
-
- result_value_sp = result_variable_sp->GetValueObject();
+ result_value_sp = result_variable_sp->GetValueObject();
- if (result_value_sp)
- {
- ret = result_value_sp->IsLogicalTrue(error);
- if (log)
- {
- if (error.Success())
- {
- log->Printf("Condition successfully evaluated, result is %s.\n",
- ret ? "true" : "false");
- }
- else
- {
- error.SetErrorString("Failed to get an integer result from the expression");
- ret = false;
- }
-
- }
+ if (result_value_sp) {
+ ret = result_value_sp->IsLogicalTrue(error);
+ if (log) {
+ if (error.Success()) {
+ log->Printf("Condition successfully evaluated, result is %s.\n",
+ ret ? "true" : "false");
+ } else {
+ error.SetErrorString(
+ "Failed to get an integer result from the expression");
+ ret = false;
}
- else
- {
- ret = false;
- error.SetErrorString("Failed to get any result from the expression");
- }
- }
- else
- {
- ret = false;
- error.SetErrorStringWithFormat("Couldn't execute expression:\n%s", diagnostics.GetString().c_str());
+ }
+ } else {
+ ret = false;
+ error.SetErrorString("Failed to get any result from the expression");
}
+ } else {
+ ret = false;
+ error.SetErrorStringWithFormat("Couldn't execute expression:\n%s",
+ diagnostics.GetString().c_str());
+ }
- return ret;
+ return ret;
}
-uint32_t
-BreakpointLocation::GetIgnoreCount ()
-{
- return GetOptionsNoCreate()->GetIgnoreCount();
+uint32_t BreakpointLocation::GetIgnoreCount() {
+ return GetOptionsNoCreate()->GetIgnoreCount();
}
-void
-BreakpointLocation::SetIgnoreCount (uint32_t n)
-{
- GetLocationOptions()->SetIgnoreCount(n);
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeIgnoreChanged);
+void BreakpointLocation::SetIgnoreCount(uint32_t n) {
+ GetLocationOptions()->SetIgnoreCount(n);
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeIgnoreChanged);
}
-void
-BreakpointLocation::DecrementIgnoreCount()
-{
- if (m_options_ap.get() != nullptr)
- {
- uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
- if (loc_ignore != 0)
- m_options_ap->SetIgnoreCount(loc_ignore - 1);
- }
+void BreakpointLocation::DecrementIgnoreCount() {
+ if (m_options_ap.get() != nullptr) {
+ uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
+ if (loc_ignore != 0)
+ m_options_ap->SetIgnoreCount(loc_ignore - 1);
+ }
}
-bool
-BreakpointLocation::IgnoreCountShouldStop()
-{
- if (m_options_ap.get() != nullptr)
- {
- uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
- if (loc_ignore != 0)
- {
- m_owner.DecrementIgnoreCount();
- DecrementIgnoreCount(); // Have to decrement our owners' ignore count, since it won't get a
- // chance to.
- return false;
- }
+bool BreakpointLocation::IgnoreCountShouldStop() {
+ if (m_options_ap.get() != nullptr) {
+ uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
+ if (loc_ignore != 0) {
+ m_owner.DecrementIgnoreCount();
+ DecrementIgnoreCount(); // Have to decrement our owners' ignore count,
+ // since it won't get a
+ // chance to.
+ return false;
}
- return true;
+ }
+ return true;
}
-const BreakpointOptions *
-BreakpointLocation::GetOptionsNoCreate () const
-{
- if (m_options_ap.get() != nullptr)
- return m_options_ap.get();
- else
- return m_owner.GetOptions ();
+const BreakpointOptions *BreakpointLocation::GetOptionsNoCreate() const {
+ if (m_options_ap.get() != nullptr)
+ return m_options_ap.get();
+ else
+ return m_owner.GetOptions();
}
-BreakpointOptions *
-BreakpointLocation::GetLocationOptions ()
-{
- // If we make the copy we don't copy the callbacks because that is potentially
- // expensive and we don't want to do that for the simple case where someone is
- // just disabling the location.
- if (m_options_ap.get() == nullptr)
- m_options_ap.reset(BreakpointOptions::CopyOptionsNoCallback(*m_owner.GetOptions ()));
-
- return m_options_ap.get();
+BreakpointOptions *BreakpointLocation::GetLocationOptions() {
+ // If we make the copy we don't copy the callbacks because that is potentially
+ // expensive and we don't want to do that for the simple case where someone is
+ // just disabling the location.
+ if (m_options_ap.get() == nullptr)
+ m_options_ap.reset(
+ BreakpointOptions::CopyOptionsNoCallback(*m_owner.GetOptions()));
+
+ return m_options_ap.get();
}
-bool
-BreakpointLocation::ValidForThisThread (Thread *thread)
-{
- return thread->MatchesSpec(GetOptionsNoCreate()->GetThreadSpecNoCreate());
+bool BreakpointLocation::ValidForThisThread(Thread *thread) {
+ return thread->MatchesSpec(GetOptionsNoCreate()->GetThreadSpecNoCreate());
}
// RETURNS - true if we should stop at this breakpoint, false if we
@@ -447,309 +362,275 @@ BreakpointLocation::ValidForThisThread (
// here, since if the breakpoint is not for this thread, then the event won't
// even get reported, so the check is redundant.
-bool
-BreakpointLocation::ShouldStop (StoppointCallbackContext *context)
-{
- bool should_stop = true;
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
-
- // Do this first, if a location is disabled, it shouldn't increment its hit count.
- if (!IsEnabled())
- return false;
-
- if (!IgnoreCountShouldStop())
- return false;
-
- if (!m_owner.IgnoreCountShouldStop())
- return false;
-
- // We only run synchronous callbacks in ShouldStop:
- context->is_synchronous = true;
- should_stop = InvokeCallback (context);
-
- if (log)
- {
- StreamString s;
- GetDescription (&s, lldb::eDescriptionLevelVerbose);
- log->Printf ("Hit breakpoint location: %s, %s.\n", s.GetData(), should_stop ? "stopping" : "continuing");
- }
-
- return should_stop;
+bool BreakpointLocation::ShouldStop(StoppointCallbackContext *context) {
+ bool should_stop = true;
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
+
+ // Do this first, if a location is disabled, it shouldn't increment its hit
+ // count.
+ if (!IsEnabled())
+ return false;
+
+ if (!IgnoreCountShouldStop())
+ return false;
+
+ if (!m_owner.IgnoreCountShouldStop())
+ return false;
+
+ // We only run synchronous callbacks in ShouldStop:
+ context->is_synchronous = true;
+ should_stop = InvokeCallback(context);
+
+ if (log) {
+ StreamString s;
+ GetDescription(&s, lldb::eDescriptionLevelVerbose);
+ log->Printf("Hit breakpoint location: %s, %s.\n", s.GetData(),
+ should_stop ? "stopping" : "continuing");
+ }
+
+ return should_stop;
}
-void
-BreakpointLocation::BumpHitCount()
-{
- if (IsEnabled())
- {
- // Step our hit count, and also step the hit count of the owner.
- IncrementHitCount();
- m_owner.IncrementHitCount();
- }
+void BreakpointLocation::BumpHitCount() {
+ if (IsEnabled()) {
+ // Step our hit count, and also step the hit count of the owner.
+ IncrementHitCount();
+ m_owner.IncrementHitCount();
+ }
}
-void
-BreakpointLocation::UndoBumpHitCount()
-{
- if (IsEnabled())
- {
- // Step our hit count, and also step the hit count of the owner.
- DecrementHitCount();
- m_owner.DecrementHitCount();
- }
+void BreakpointLocation::UndoBumpHitCount() {
+ if (IsEnabled()) {
+ // Step our hit count, and also step the hit count of the owner.
+ DecrementHitCount();
+ m_owner.DecrementHitCount();
+ }
}
-bool
-BreakpointLocation::IsResolved () const
-{
- return m_bp_site_sp.get() != nullptr;
-}
-
-lldb::BreakpointSiteSP
-BreakpointLocation::GetBreakpointSite() const
-{
- return m_bp_site_sp;
-}
-
-bool
-BreakpointLocation::ResolveBreakpointSite ()
-{
- if (m_bp_site_sp)
- return true;
-
- Process *process = m_owner.GetTarget().GetProcessSP().get();
- if (process == nullptr)
- return false;
-
- lldb::break_id_t new_id = process->CreateBreakpointSite (shared_from_this(), m_owner.IsHardware());
-
- if (new_id == LLDB_INVALID_BREAK_ID)
- {
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
- if (log)
- log->Warning ("Tried to add breakpoint site at 0x%" PRIx64 " but it was already present.\n",
- m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()));
- return false;
- }
+bool BreakpointLocation::IsResolved() const {
+ return m_bp_site_sp.get() != nullptr;
+}
- return true;
+lldb::BreakpointSiteSP BreakpointLocation::GetBreakpointSite() const {
+ return m_bp_site_sp;
}
-bool
-BreakpointLocation::SetBreakpointSite (BreakpointSiteSP& bp_site_sp)
-{
- m_bp_site_sp = bp_site_sp;
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeLocationsResolved);
+bool BreakpointLocation::ResolveBreakpointSite() {
+ if (m_bp_site_sp)
return true;
-}
-bool
-BreakpointLocation::ClearBreakpointSite ()
-{
- if (m_bp_site_sp.get())
- {
- ProcessSP process_sp(m_owner.GetTarget().GetProcessSP());
- // If the process exists, get it to remove the owner, it will remove the physical implementation
- // of the breakpoint as well if there are no more owners. Otherwise just remove this owner.
- if (process_sp)
- process_sp->RemoveOwnerFromBreakpointSite (GetBreakpoint().GetID(),
- GetID(), m_bp_site_sp);
- else
- m_bp_site_sp->RemoveOwner(GetBreakpoint().GetID(), GetID());
-
- m_bp_site_sp.reset();
- return true;
- }
+ Process *process = m_owner.GetTarget().GetProcessSP().get();
+ if (process == nullptr)
return false;
-}
-void
-BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
- SymbolContext sc;
-
- // If the description level is "initial" then the breakpoint is printing out our initial state,
- // and we should let it decide how it wants to print our label.
- if (level != eDescriptionLevelInitial)
- {
- s->Indent();
- BreakpointID::GetCanonicalReference(s, m_owner.GetID(), GetID());
- }
-
- if (level == lldb::eDescriptionLevelBrief)
- return;
-
- if (level != eDescriptionLevelInitial)
- s->PutCString(": ");
-
- if (level == lldb::eDescriptionLevelVerbose)
- s->IndentMore();
-
- if (m_address.IsSectionOffset())
- {
- m_address.CalculateSymbolContext(&sc);
-
- if (level == lldb::eDescriptionLevelFull || level == eDescriptionLevelInitial)
- {
- if (IsReExported())
- s->PutCString ("re-exported target = ");
- else
- s->PutCString("where = ");
- sc.DumpStopContext (s, m_owner.GetTarget().GetProcessSP().get(), m_address, false, true, false, true, true);
- }
- else
- {
- if (sc.module_sp)
- {
- s->EOL();
- s->Indent("module = ");
- sc.module_sp->GetFileSpec().Dump (s);
- }
-
- if (sc.comp_unit != nullptr)
- {
- s->EOL();
- s->Indent("compile unit = ");
- static_cast<FileSpec*>(sc.comp_unit)->GetFilename().Dump (s);
-
- if (sc.function != nullptr)
- {
- s->EOL();
- s->Indent("function = ");
- s->PutCString (sc.function->GetName().AsCString("<unknown>"));
- }
-
- if (sc.line_entry.line > 0)
- {
- s->EOL();
- s->Indent("location = ");
- sc.line_entry.DumpStopContext (s, true);
- }
-
- }
- else
- {
- // If we don't have a comp unit, see if we have a symbol we can print.
- if (sc.symbol)
- {
- s->EOL();
- if (IsReExported())
- s->Indent ("re-exported target = ");
- else
- s->Indent("symbol = ");
- s->PutCString(sc.symbol->GetName().AsCString("<unknown>"));
- }
- }
- }
- }
+ lldb::break_id_t new_id =
+ process->CreateBreakpointSite(shared_from_this(), m_owner.IsHardware());
- if (level == lldb::eDescriptionLevelVerbose)
- {
- s->EOL();
- s->Indent();
- }
-
- if (m_address.IsSectionOffset() && (level == eDescriptionLevelFull || level == eDescriptionLevelInitial))
- s->Printf (", ");
- s->Printf ("address = ");
-
- ExecutionContextScope *exe_scope = nullptr;
- Target *target = &m_owner.GetTarget();
- if (target)
- exe_scope = target->GetProcessSP().get();
- if (exe_scope == nullptr)
- exe_scope = target;
+ if (new_id == LLDB_INVALID_BREAK_ID) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
+ if (log)
+ log->Warning("Tried to add breakpoint site at 0x%" PRIx64
+ " but it was already present.\n",
+ m_address.GetOpcodeLoadAddress(&m_owner.GetTarget()));
+ return false;
+ }
- if (level == eDescriptionLevelInitial)
- m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
- else
- m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress);
-
- if (IsIndirect() && m_bp_site_sp)
- {
- Address resolved_address;
- resolved_address.SetLoadAddress(m_bp_site_sp->GetLoadAddress(), target);
- Symbol *resolved_symbol = resolved_address.CalculateSymbolContextSymbol();
- if (resolved_symbol)
- {
- if (level == eDescriptionLevelFull || level == eDescriptionLevelInitial)
- s->Printf (", ");
- else if (level == lldb::eDescriptionLevelVerbose)
- {
- s->EOL();
- s->Indent();
- }
- s->Printf ("indirect target = %s", resolved_symbol->GetName().GetCString());
- }
- }
+ return true;
+}
- if (level == lldb::eDescriptionLevelVerbose)
- {
- s->EOL();
- s->Indent();
- s->Printf("resolved = %s\n", IsResolved() ? "true" : "false");
+bool BreakpointLocation::SetBreakpointSite(BreakpointSiteSP &bp_site_sp) {
+ m_bp_site_sp = bp_site_sp;
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeLocationsResolved);
+ return true;
+}
- s->Indent();
- s->Printf ("hit count = %-4u\n", GetHitCount());
+bool BreakpointLocation::ClearBreakpointSite() {
+ if (m_bp_site_sp.get()) {
+ ProcessSP process_sp(m_owner.GetTarget().GetProcessSP());
+ // If the process exists, get it to remove the owner, it will remove the
+ // physical implementation
+ // of the breakpoint as well if there are no more owners. Otherwise just
+ // remove this owner.
+ if (process_sp)
+ process_sp->RemoveOwnerFromBreakpointSite(GetBreakpoint().GetID(),
+ GetID(), m_bp_site_sp);
+ else
+ m_bp_site_sp->RemoveOwner(GetBreakpoint().GetID(), GetID());
- if (m_options_ap.get())
- {
- s->Indent();
- m_options_ap->GetDescription (s, level);
- s->EOL();
- }
- s->IndentLess();
- }
- else if (level != eDescriptionLevelInitial)
- {
- s->Printf(", %sresolved, hit count = %u ",
- (IsResolved() ? "" : "un"),
- GetHitCount());
- if (m_options_ap.get())
- {
- m_options_ap->GetDescription (s, level);
- }
- }
+ m_bp_site_sp.reset();
+ return true;
+ }
+ return false;
}
-void
-BreakpointLocation::Dump(Stream *s) const
-{
- if (s == nullptr)
- return;
-
- s->Printf("BreakpointLocation %u: tid = %4.4" PRIx64 " load addr = 0x%8.8" PRIx64 " state = %s type = %s breakpoint "
- "hw_index = %i hit_count = %-4u ignore_count = %-4u",
- GetID(),
- GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(),
- (uint64_t) m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()),
- (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled()) ? "enabled " : "disabled",
- IsHardware() ? "hardware" : "software",
- GetHardwareIndex(),
- GetHitCount(),
- GetOptionsNoCreate()->GetIgnoreCount());
-}
-
-void
-BreakpointLocation::SendBreakpointLocationChangedEvent (lldb::BreakpointEventType eventKind)
-{
- if (!m_being_created
- && !m_owner.IsInternal()
- && m_owner.GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- {
- Breakpoint::BreakpointEventData *data = new Breakpoint::BreakpointEventData (eventKind,
- m_owner.shared_from_this());
- data->GetBreakpointLocationCollection().Add (shared_from_this());
- m_owner.GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, data);
- }
-}
+void BreakpointLocation::GetDescription(Stream *s,
+ lldb::DescriptionLevel level) {
+ SymbolContext sc;
+
+ // If the description level is "initial" then the breakpoint is printing out
+ // our initial state,
+ // and we should let it decide how it wants to print our label.
+ if (level != eDescriptionLevelInitial) {
+ s->Indent();
+ BreakpointID::GetCanonicalReference(s, m_owner.GetID(), GetID());
+ }
+
+ if (level == lldb::eDescriptionLevelBrief)
+ return;
+
+ if (level != eDescriptionLevelInitial)
+ s->PutCString(": ");
+
+ if (level == lldb::eDescriptionLevelVerbose)
+ s->IndentMore();
+
+ if (m_address.IsSectionOffset()) {
+ m_address.CalculateSymbolContext(&sc);
+
+ if (level == lldb::eDescriptionLevelFull ||
+ level == eDescriptionLevelInitial) {
+ if (IsReExported())
+ s->PutCString("re-exported target = ");
+ else
+ s->PutCString("where = ");
+ sc.DumpStopContext(s, m_owner.GetTarget().GetProcessSP().get(), m_address,
+ false, true, false, true, true);
+ } else {
+ if (sc.module_sp) {
+ s->EOL();
+ s->Indent("module = ");
+ sc.module_sp->GetFileSpec().Dump(s);
+ }
-void
-BreakpointLocation::SwapLocation (BreakpointLocationSP swap_from)
-{
- m_address = swap_from->m_address;
- m_should_resolve_indirect_functions = swap_from->m_should_resolve_indirect_functions;
- m_is_reexported = swap_from->m_is_reexported;
- m_is_indirect = swap_from->m_is_indirect;
- m_user_expression_sp.reset();
+ if (sc.comp_unit != nullptr) {
+ s->EOL();
+ s->Indent("compile unit = ");
+ static_cast<FileSpec *>(sc.comp_unit)->GetFilename().Dump(s);
+
+ if (sc.function != nullptr) {
+ s->EOL();
+ s->Indent("function = ");
+ s->PutCString(sc.function->GetName().AsCString("<unknown>"));
+ }
+
+ if (sc.line_entry.line > 0) {
+ s->EOL();
+ s->Indent("location = ");
+ sc.line_entry.DumpStopContext(s, true);
+ }
+
+ } else {
+ // If we don't have a comp unit, see if we have a symbol we can print.
+ if (sc.symbol) {
+ s->EOL();
+ if (IsReExported())
+ s->Indent("re-exported target = ");
+ else
+ s->Indent("symbol = ");
+ s->PutCString(sc.symbol->GetName().AsCString("<unknown>"));
+ }
+ }
+ }
+ }
+
+ if (level == lldb::eDescriptionLevelVerbose) {
+ s->EOL();
+ s->Indent();
+ }
+
+ if (m_address.IsSectionOffset() &&
+ (level == eDescriptionLevelFull || level == eDescriptionLevelInitial))
+ s->Printf(", ");
+ s->Printf("address = ");
+
+ ExecutionContextScope *exe_scope = nullptr;
+ Target *target = &m_owner.GetTarget();
+ if (target)
+ exe_scope = target->GetProcessSP().get();
+ if (exe_scope == nullptr)
+ exe_scope = target;
+
+ if (level == eDescriptionLevelInitial)
+ m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress,
+ Address::DumpStyleFileAddress);
+ else
+ m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress,
+ Address::DumpStyleModuleWithFileAddress);
+
+ if (IsIndirect() && m_bp_site_sp) {
+ Address resolved_address;
+ resolved_address.SetLoadAddress(m_bp_site_sp->GetLoadAddress(), target);
+ Symbol *resolved_symbol = resolved_address.CalculateSymbolContextSymbol();
+ if (resolved_symbol) {
+ if (level == eDescriptionLevelFull || level == eDescriptionLevelInitial)
+ s->Printf(", ");
+ else if (level == lldb::eDescriptionLevelVerbose) {
+ s->EOL();
+ s->Indent();
+ }
+ s->Printf("indirect target = %s",
+ resolved_symbol->GetName().GetCString());
+ }
+ }
+
+ if (level == lldb::eDescriptionLevelVerbose) {
+ s->EOL();
+ s->Indent();
+ s->Printf("resolved = %s\n", IsResolved() ? "true" : "false");
+
+ s->Indent();
+ s->Printf("hit count = %-4u\n", GetHitCount());
+
+ if (m_options_ap.get()) {
+ s->Indent();
+ m_options_ap->GetDescription(s, level);
+ s->EOL();
+ }
+ s->IndentLess();
+ } else if (level != eDescriptionLevelInitial) {
+ s->Printf(", %sresolved, hit count = %u ", (IsResolved() ? "" : "un"),
+ GetHitCount());
+ if (m_options_ap.get()) {
+ m_options_ap->GetDescription(s, level);
+ }
+ }
+}
+
+void BreakpointLocation::Dump(Stream *s) const {
+ if (s == nullptr)
+ return;
+
+ s->Printf(
+ "BreakpointLocation %u: tid = %4.4" PRIx64 " load addr = 0x%8.8" PRIx64
+ " state = %s type = %s breakpoint "
+ "hw_index = %i hit_count = %-4u ignore_count = %-4u",
+ GetID(), GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(),
+ (uint64_t)m_address.GetOpcodeLoadAddress(&m_owner.GetTarget()),
+ (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled())
+ ? "enabled "
+ : "disabled",
+ IsHardware() ? "hardware" : "software", GetHardwareIndex(), GetHitCount(),
+ GetOptionsNoCreate()->GetIgnoreCount());
+}
+
+void BreakpointLocation::SendBreakpointLocationChangedEvent(
+ lldb::BreakpointEventType eventKind) {
+ if (!m_being_created && !m_owner.IsInternal() &&
+ m_owner.GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitBreakpointChanged)) {
+ Breakpoint::BreakpointEventData *data = new Breakpoint::BreakpointEventData(
+ eventKind, m_owner.shared_from_this());
+ data->GetBreakpointLocationCollection().Add(shared_from_this());
+ m_owner.GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged,
+ data);
+ }
+}
+
+void BreakpointLocation::SwapLocation(BreakpointLocationSP swap_from) {
+ m_address = swap_from->m_address;
+ m_should_resolve_indirect_functions =
+ swap_from->m_should_resolve_indirect_functions;
+ m_is_reexported = swap_from->m_is_reexported;
+ m_is_indirect = swap_from->m_is_indirect;
+ m_user_expression_sp.reset();
}
Modified: lldb/trunk/source/Breakpoint/BreakpointLocationCollection.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocationCollection.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointLocationCollection.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointLocationCollection.cpp Tue Sep 6 15:57:50 2016
@@ -7,15 +7,14 @@
//
//===----------------------------------------------------------------------===//
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
-#include "lldb/Core/ModuleList.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Core/ModuleList.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
@@ -25,189 +24,162 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// BreakpointLocationCollection constructor
//----------------------------------------------------------------------
-BreakpointLocationCollection::BreakpointLocationCollection() :
- m_break_loc_collection(),
- m_collection_mutex()
-{
-}
+BreakpointLocationCollection::BreakpointLocationCollection()
+ : m_break_loc_collection(), m_collection_mutex() {}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-BreakpointLocationCollection::~BreakpointLocationCollection()
-{
-}
-
-void
-BreakpointLocationCollection::Add(const BreakpointLocationSP &bp_loc)
-{
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- BreakpointLocationSP old_bp_loc = FindByIDPair (bp_loc->GetBreakpoint().GetID(), bp_loc->GetID());
- if (!old_bp_loc.get())
- m_break_loc_collection.push_back(bp_loc);
-}
-
-bool
-BreakpointLocationCollection::Remove (lldb::break_id_t bp_id, lldb::break_id_t bp_loc_id)
-{
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- collection::iterator pos = GetIDPairIterator(bp_id, bp_loc_id); // Predicate
- if (pos != m_break_loc_collection.end())
- {
- m_break_loc_collection.erase(pos);
- return true;
- }
- return false;
+BreakpointLocationCollection::~BreakpointLocationCollection() {}
+void BreakpointLocationCollection::Add(const BreakpointLocationSP &bp_loc) {
+ std::lock_guard<std::mutex> guard(m_collection_mutex);
+ BreakpointLocationSP old_bp_loc =
+ FindByIDPair(bp_loc->GetBreakpoint().GetID(), bp_loc->GetID());
+ if (!old_bp_loc.get())
+ m_break_loc_collection.push_back(bp_loc);
+}
+
+bool BreakpointLocationCollection::Remove(lldb::break_id_t bp_id,
+ lldb::break_id_t bp_loc_id) {
+ std::lock_guard<std::mutex> guard(m_collection_mutex);
+ collection::iterator pos = GetIDPairIterator(bp_id, bp_loc_id); // Predicate
+ if (pos != m_break_loc_collection.end()) {
+ m_break_loc_collection.erase(pos);
+ return true;
+ }
+ return false;
}
-class BreakpointIDPairMatches
-{
+class BreakpointIDPairMatches {
public:
- BreakpointIDPairMatches (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) :
- m_break_id(break_id),
- m_break_loc_id (break_loc_id)
- {
- }
-
- bool operator() (const BreakpointLocationSP &bp_loc) const
- {
- return m_break_id == bp_loc->GetBreakpoint().GetID()
- && m_break_loc_id == bp_loc->GetID();
- }
+ BreakpointIDPairMatches(lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id)
+ : m_break_id(break_id), m_break_loc_id(break_loc_id) {}
+
+ bool operator()(const BreakpointLocationSP &bp_loc) const {
+ return m_break_id == bp_loc->GetBreakpoint().GetID() &&
+ m_break_loc_id == bp_loc->GetID();
+ }
private:
- const lldb::break_id_t m_break_id;
- const lldb::break_id_t m_break_loc_id;
+ const lldb::break_id_t m_break_id;
+ const lldb::break_id_t m_break_loc_id;
};
BreakpointLocationCollection::collection::iterator
-BreakpointLocationCollection::GetIDPairIterator (lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
-{
- return std::find_if(m_break_loc_collection.begin(), m_break_loc_collection.end(), // Search full range
- BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
+BreakpointLocationCollection::GetIDPairIterator(lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id) {
+ return std::find_if(
+ m_break_loc_collection.begin(),
+ m_break_loc_collection.end(), // Search full range
+ BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
}
BreakpointLocationCollection::collection::const_iterator
-BreakpointLocationCollection::GetIDPairConstIterator (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const
-{
- return std::find_if(m_break_loc_collection.begin(), m_break_loc_collection.end(), // Search full range
- BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
+BreakpointLocationCollection::GetIDPairConstIterator(
+ lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const {
+ return std::find_if(
+ m_break_loc_collection.begin(),
+ m_break_loc_collection.end(), // Search full range
+ BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
}
BreakpointLocationSP
-BreakpointLocationCollection::FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
-{
- BreakpointLocationSP stop_sp;
- collection::iterator pos = GetIDPairIterator(break_id, break_loc_id);
- if (pos != m_break_loc_collection.end())
- stop_sp = *pos;
+BreakpointLocationCollection::FindByIDPair(lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id) {
+ BreakpointLocationSP stop_sp;
+ collection::iterator pos = GetIDPairIterator(break_id, break_loc_id);
+ if (pos != m_break_loc_collection.end())
+ stop_sp = *pos;
+
+ return stop_sp;
+}
+
+const BreakpointLocationSP BreakpointLocationCollection::FindByIDPair(
+ lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const {
+ BreakpointLocationSP stop_sp;
+ collection::const_iterator pos =
+ GetIDPairConstIterator(break_id, break_loc_id);
+ if (pos != m_break_loc_collection.end())
+ stop_sp = *pos;
+
+ return stop_sp;
+}
+
+BreakpointLocationSP BreakpointLocationCollection::GetByIndex(size_t i) {
+ std::lock_guard<std::mutex> guard(m_collection_mutex);
+ BreakpointLocationSP stop_sp;
+ if (i < m_break_loc_collection.size())
+ stop_sp = m_break_loc_collection[i];
- return stop_sp;
+ return stop_sp;
}
const BreakpointLocationSP
-BreakpointLocationCollection::FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const
-{
- BreakpointLocationSP stop_sp;
- collection::const_iterator pos = GetIDPairConstIterator(break_id, break_loc_id);
- if (pos != m_break_loc_collection.end())
- stop_sp = *pos;
-
- return stop_sp;
-}
-
-BreakpointLocationSP
-BreakpointLocationCollection::GetByIndex (size_t i)
-{
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- BreakpointLocationSP stop_sp;
- if (i < m_break_loc_collection.size())
- stop_sp = m_break_loc_collection[i];
-
- return stop_sp;
+BreakpointLocationCollection::GetByIndex(size_t i) const {
+ std::lock_guard<std::mutex> guard(m_collection_mutex);
+ BreakpointLocationSP stop_sp;
+ if (i < m_break_loc_collection.size())
+ stop_sp = m_break_loc_collection[i];
+
+ return stop_sp;
+}
+
+bool BreakpointLocationCollection::ShouldStop(
+ StoppointCallbackContext *context) {
+ bool shouldStop = false;
+ size_t i = 0;
+ size_t prev_size = GetSize();
+ while (i < prev_size) {
+ // ShouldStop can remove the breakpoint from the list
+ if (GetByIndex(i)->ShouldStop(context))
+ shouldStop = true;
+
+ if (prev_size == GetSize())
+ i++;
+ prev_size = GetSize();
+ }
+ return shouldStop;
+}
+
+bool BreakpointLocationCollection::ValidForThisThread(Thread *thread) {
+ std::lock_guard<std::mutex> guard(m_collection_mutex);
+ collection::iterator pos, begin = m_break_loc_collection.begin(),
+ end = m_break_loc_collection.end();
+
+ for (pos = begin; pos != end; ++pos) {
+ if ((*pos)->ValidForThisThread(thread))
+ return true;
+ }
+ return false;
+}
+
+bool BreakpointLocationCollection::IsInternal() const {
+ std::lock_guard<std::mutex> guard(m_collection_mutex);
+ collection::const_iterator pos, begin = m_break_loc_collection.begin(),
+ end = m_break_loc_collection.end();
+
+ bool is_internal = true;
+
+ for (pos = begin; pos != end; ++pos) {
+ if (!(*pos)->GetBreakpoint().IsInternal()) {
+ is_internal = false;
+ break;
+ }
+ }
+ return is_internal;
+}
+
+void BreakpointLocationCollection::GetDescription(
+ Stream *s, lldb::DescriptionLevel level) {
+ std::lock_guard<std::mutex> guard(m_collection_mutex);
+ collection::iterator pos, begin = m_break_loc_collection.begin(),
+ end = m_break_loc_collection.end();
+
+ for (pos = begin; pos != end; ++pos) {
+ if (pos != begin)
+ s->PutChar(' ');
+ (*pos)->GetDescription(s, level);
+ }
}
-
-const BreakpointLocationSP
-BreakpointLocationCollection::GetByIndex (size_t i) const
-{
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- BreakpointLocationSP stop_sp;
- if (i < m_break_loc_collection.size())
- stop_sp = m_break_loc_collection[i];
-
- return stop_sp;
-}
-
-bool
-BreakpointLocationCollection::ShouldStop (StoppointCallbackContext *context)
-{
- bool shouldStop = false;
- size_t i = 0;
- size_t prev_size = GetSize();
- while (i < prev_size)
- {
- // ShouldStop can remove the breakpoint from the list
- if (GetByIndex(i)->ShouldStop(context))
- shouldStop = true;
-
- if (prev_size == GetSize())
- i++;
- prev_size = GetSize();
- }
- return shouldStop;
-}
-
-bool
-BreakpointLocationCollection::ValidForThisThread (Thread *thread)
-{
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- collection::iterator pos,
- begin = m_break_loc_collection.begin(),
- end = m_break_loc_collection.end();
-
- for (pos = begin; pos != end; ++pos)
- {
- if ((*pos)->ValidForThisThread (thread))
- return true;
- }
- return false;
-}
-
-bool
-BreakpointLocationCollection::IsInternal () const
-{
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- collection::const_iterator pos,
- begin = m_break_loc_collection.begin(),
- end = m_break_loc_collection.end();
-
- bool is_internal = true;
-
- for (pos = begin; pos != end; ++pos)
- {
- if (!(*pos)->GetBreakpoint().IsInternal ())
- {
- is_internal = false;
- break;
- }
- }
- return is_internal;
-}
-
-void
-BreakpointLocationCollection::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- collection::iterator pos,
- begin = m_break_loc_collection.begin(),
- end = m_break_loc_collection.end();
-
- for (pos = begin; pos != end; ++pos)
- {
- if (pos != begin)
- s->PutChar(' ');
- (*pos)->GetDescription(s, level);
- }
-}
-
Modified: lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp Tue Sep 6 15:57:50 2016
@@ -13,8 +13,8 @@
// Project includes
#include "lldb/Breakpoint/BreakpointLocationList.h"
-#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/Breakpoint.h"
+#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
@@ -25,339 +25,286 @@ using namespace lldb;
using namespace lldb_private;
BreakpointLocationList::BreakpointLocationList(Breakpoint &owner)
- : m_owner(owner), m_locations(), m_address_to_location(), m_mutex(), m_next_id(0), m_new_location_recorder(nullptr)
-{
-}
+ : m_owner(owner), m_locations(), m_address_to_location(), m_mutex(),
+ m_next_id(0), m_new_location_recorder(nullptr) {}
BreakpointLocationList::~BreakpointLocationList() = default;
BreakpointLocationSP
-BreakpointLocationList::Create (const Address &addr, bool resolve_indirect_symbols)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- // The location ID is just the size of the location list + 1
- lldb::break_id_t bp_loc_id = ++m_next_id;
- BreakpointLocationSP bp_loc_sp (new BreakpointLocation (bp_loc_id, m_owner, addr, LLDB_INVALID_THREAD_ID, m_owner.IsHardware(), resolve_indirect_symbols));
- m_locations.push_back (bp_loc_sp);
- m_address_to_location[addr] = bp_loc_sp;
- return bp_loc_sp;
-}
-
-bool
-BreakpointLocationList::ShouldStop (StoppointCallbackContext *context, lldb::break_id_t break_id)
-{
- BreakpointLocationSP bp = FindByID (break_id);
- if (bp)
- {
- // Let the BreakpointLocation decide if it should stop here (could not have
- // reached it's target hit count yet, or it could have a callback
- // that decided it shouldn't stop (shared library loads/unloads).
- return bp->ShouldStop (context);
- }
- // We should stop here since this BreakpointLocation isn't valid anymore or it
- // doesn't exist.
- return true;
-}
-
-lldb::break_id_t
-BreakpointLocationList::FindIDByAddress (const Address &addr)
-{
- BreakpointLocationSP bp_loc_sp = FindByAddress (addr);
- if (bp_loc_sp)
- {
- return bp_loc_sp->GetID();
- }
- return LLDB_INVALID_BREAK_ID;
+BreakpointLocationList::Create(const Address &addr,
+ bool resolve_indirect_symbols) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ // The location ID is just the size of the location list + 1
+ lldb::break_id_t bp_loc_id = ++m_next_id;
+ BreakpointLocationSP bp_loc_sp(
+ new BreakpointLocation(bp_loc_id, m_owner, addr, LLDB_INVALID_THREAD_ID,
+ m_owner.IsHardware(), resolve_indirect_symbols));
+ m_locations.push_back(bp_loc_sp);
+ m_address_to_location[addr] = bp_loc_sp;
+ return bp_loc_sp;
+}
+
+bool BreakpointLocationList::ShouldStop(StoppointCallbackContext *context,
+ lldb::break_id_t break_id) {
+ BreakpointLocationSP bp = FindByID(break_id);
+ if (bp) {
+ // Let the BreakpointLocation decide if it should stop here (could not have
+ // reached it's target hit count yet, or it could have a callback
+ // that decided it shouldn't stop (shared library loads/unloads).
+ return bp->ShouldStop(context);
+ }
+ // We should stop here since this BreakpointLocation isn't valid anymore or it
+ // doesn't exist.
+ return true;
+}
+
+lldb::break_id_t BreakpointLocationList::FindIDByAddress(const Address &addr) {
+ BreakpointLocationSP bp_loc_sp = FindByAddress(addr);
+ if (bp_loc_sp) {
+ return bp_loc_sp->GetID();
+ }
+ return LLDB_INVALID_BREAK_ID;
}
-static bool
-Compare (BreakpointLocationSP lhs, lldb::break_id_t val)
-{
- return lhs->GetID() < val;
+static bool Compare(BreakpointLocationSP lhs, lldb::break_id_t val) {
+ return lhs->GetID() < val;
}
BreakpointLocationSP
-BreakpointLocationList::FindByID (lldb::break_id_t break_id) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::const_iterator end = m_locations.end();
- collection::const_iterator pos = std::lower_bound(m_locations.begin(), end, break_id, Compare);
- if (pos != end && (*pos)->GetID() == break_id)
- return *(pos);
- else
- return BreakpointLocationSP();
-}
-
-size_t
-BreakpointLocationList::FindInModule (Module *module,
- BreakpointLocationCollection& bp_loc_list)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- const size_t orig_size = bp_loc_list.GetSize();
- collection::iterator pos, end = m_locations.end();
-
- for (pos = m_locations.begin(); pos != end; ++pos)
- {
- BreakpointLocationSP break_loc = (*pos);
- SectionSP section_sp (break_loc->GetAddress().GetSection());
- if (section_sp && section_sp->GetModule().get() == module)
- {
- bp_loc_list.Add (break_loc);
- }
+BreakpointLocationList::FindByID(lldb::break_id_t break_id) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::const_iterator end = m_locations.end();
+ collection::const_iterator pos =
+ std::lower_bound(m_locations.begin(), end, break_id, Compare);
+ if (pos != end && (*pos)->GetID() == break_id)
+ return *(pos);
+ else
+ return BreakpointLocationSP();
+}
+
+size_t BreakpointLocationList::FindInModule(
+ Module *module, BreakpointLocationCollection &bp_loc_list) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ const size_t orig_size = bp_loc_list.GetSize();
+ collection::iterator pos, end = m_locations.end();
+
+ for (pos = m_locations.begin(); pos != end; ++pos) {
+ BreakpointLocationSP break_loc = (*pos);
+ SectionSP section_sp(break_loc->GetAddress().GetSection());
+ if (section_sp && section_sp->GetModule().get() == module) {
+ bp_loc_list.Add(break_loc);
}
- return bp_loc_list.GetSize() - orig_size;
+ }
+ return bp_loc_list.GetSize() - orig_size;
}
const BreakpointLocationSP
-BreakpointLocationList::FindByAddress (const Address &addr) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointLocationSP bp_loc_sp;
- if (!m_locations.empty())
- {
- Address so_addr;
-
- if (addr.IsSectionOffset())
- {
- so_addr = addr;
- }
- else
- {
- // Try and resolve as a load address if possible.
- m_owner.GetTarget().GetSectionLoadList().ResolveLoadAddress (addr.GetOffset(), so_addr);
- if (!so_addr.IsValid())
- {
- // The address didn't resolve, so just set to passed in addr.
- so_addr = addr;
- }
- }
-
- addr_map::const_iterator pos = m_address_to_location.find (so_addr);
- if (pos != m_address_to_location.end())
- bp_loc_sp = pos->second;
+BreakpointLocationList::FindByAddress(const Address &addr) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointLocationSP bp_loc_sp;
+ if (!m_locations.empty()) {
+ Address so_addr;
+
+ if (addr.IsSectionOffset()) {
+ so_addr = addr;
+ } else {
+ // Try and resolve as a load address if possible.
+ m_owner.GetTarget().GetSectionLoadList().ResolveLoadAddress(
+ addr.GetOffset(), so_addr);
+ if (!so_addr.IsValid()) {
+ // The address didn't resolve, so just set to passed in addr.
+ so_addr = addr;
+ }
}
- return bp_loc_sp;
-}
-
-void
-BreakpointLocationList::Dump (Stream *s) const
-{
- s->Printf("%p: ", static_cast<const void*>(this));
- //s->Indent();
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- s->Printf("BreakpointLocationList with %" PRIu64 " BreakpointLocations:\n", (uint64_t)m_locations.size());
- s->IndentMore();
- collection::const_iterator pos, end = m_locations.end();
- for (pos = m_locations.begin(); pos != end; ++pos)
- (*pos).get()->Dump(s);
- s->IndentLess();
+ addr_map::const_iterator pos = m_address_to_location.find(so_addr);
+ if (pos != m_address_to_location.end())
+ bp_loc_sp = pos->second;
+ }
+
+ return bp_loc_sp;
+}
+
+void BreakpointLocationList::Dump(Stream *s) const {
+ s->Printf("%p: ", static_cast<const void *>(this));
+ // s->Indent();
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ s->Printf("BreakpointLocationList with %" PRIu64 " BreakpointLocations:\n",
+ (uint64_t)m_locations.size());
+ s->IndentMore();
+ collection::const_iterator pos, end = m_locations.end();
+ for (pos = m_locations.begin(); pos != end; ++pos)
+ (*pos).get()->Dump(s);
+ s->IndentLess();
+}
+
+BreakpointLocationSP BreakpointLocationList::GetByIndex(size_t i) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointLocationSP bp_loc_sp;
+ if (i < m_locations.size())
+ bp_loc_sp = m_locations[i];
+
+ return bp_loc_sp;
+}
+
+const BreakpointLocationSP BreakpointLocationList::GetByIndex(size_t i) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointLocationSP bp_loc_sp;
+ if (i < m_locations.size())
+ bp_loc_sp = m_locations[i];
+
+ return bp_loc_sp;
+}
+
+void BreakpointLocationList::ClearAllBreakpointSites() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::iterator pos, end = m_locations.end();
+ for (pos = m_locations.begin(); pos != end; ++pos)
+ (*pos)->ClearBreakpointSite();
+}
+
+void BreakpointLocationList::ResolveAllBreakpointSites() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::iterator pos, end = m_locations.end();
+
+ for (pos = m_locations.begin(); pos != end; ++pos) {
+ if ((*pos)->IsEnabled())
+ (*pos)->ResolveBreakpointSite();
+ }
+}
+
+uint32_t BreakpointLocationList::GetHitCount() const {
+ uint32_t hit_count = 0;
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::const_iterator pos, end = m_locations.end();
+ for (pos = m_locations.begin(); pos != end; ++pos)
+ hit_count += (*pos)->GetHitCount();
+ return hit_count;
+}
+
+size_t BreakpointLocationList::GetNumResolvedLocations() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ size_t resolve_count = 0;
+ collection::const_iterator pos, end = m_locations.end();
+ for (pos = m_locations.begin(); pos != end; ++pos) {
+ if ((*pos)->IsResolved())
+ ++resolve_count;
+ }
+ return resolve_count;
+}
+
+void BreakpointLocationList::GetDescription(Stream *s,
+ lldb::DescriptionLevel level) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::iterator pos, end = m_locations.end();
+
+ for (pos = m_locations.begin(); pos != end; ++pos) {
+ s->Printf(" ");
+ (*pos)->GetDescription(s, level);
+ }
+}
+
+BreakpointLocationSP BreakpointLocationList::AddLocation(
+ const Address &addr, bool resolve_indirect_symbols, bool *new_location) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
+ if (new_location)
+ *new_location = false;
+ BreakpointLocationSP bp_loc_sp(FindByAddress(addr));
+ if (!bp_loc_sp) {
+ bp_loc_sp = Create(addr, resolve_indirect_symbols);
+ if (bp_loc_sp) {
+ bp_loc_sp->ResolveBreakpointSite();
+
+ if (new_location)
+ *new_location = true;
+ if (m_new_location_recorder) {
+ m_new_location_recorder->Add(bp_loc_sp);
+ }
+ }
+ }
+ return bp_loc_sp;
}
-BreakpointLocationSP
-BreakpointLocationList::GetByIndex (size_t i)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointLocationSP bp_loc_sp;
- if (i < m_locations.size())
- bp_loc_sp = m_locations[i];
+void BreakpointLocationList::SwapLocation(
+ BreakpointLocationSP to_location_sp,
+ BreakpointLocationSP from_location_sp) {
+ if (!from_location_sp || !to_location_sp)
+ return;
- return bp_loc_sp;
+ m_address_to_location.erase(to_location_sp->GetAddress());
+ to_location_sp->SwapLocation(from_location_sp);
+ RemoveLocation(from_location_sp);
+ m_address_to_location[to_location_sp->GetAddress()] = to_location_sp;
+ to_location_sp->ResolveBreakpointSite();
}
-const BreakpointLocationSP
-BreakpointLocationList::GetByIndex (size_t i) const
-{
+bool BreakpointLocationList::RemoveLocation(
+ const lldb::BreakpointLocationSP &bp_loc_sp) {
+ if (bp_loc_sp) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointLocationSP bp_loc_sp;
- if (i < m_locations.size())
- bp_loc_sp = m_locations[i];
-
- return bp_loc_sp;
-}
-void
-BreakpointLocationList::ClearAllBreakpointSites ()
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::iterator pos, end = m_locations.end();
- for (pos = m_locations.begin(); pos != end; ++pos)
- (*pos)->ClearBreakpointSite();
-}
+ m_address_to_location.erase(bp_loc_sp->GetAddress());
-void
-BreakpointLocationList::ResolveAllBreakpointSites ()
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
collection::iterator pos, end = m_locations.end();
-
- for (pos = m_locations.begin(); pos != end; ++pos)
- {
- if ((*pos)->IsEnabled())
- (*pos)->ResolveBreakpointSite();
- }
-}
-
-uint32_t
-BreakpointLocationList::GetHitCount () const
-{
- uint32_t hit_count = 0;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::const_iterator pos, end = m_locations.end();
- for (pos = m_locations.begin(); pos != end; ++pos)
- hit_count += (*pos)->GetHitCount();
- return hit_count;
-}
-
-size_t
-BreakpointLocationList::GetNumResolvedLocations() const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- size_t resolve_count = 0;
- collection::const_iterator pos, end = m_locations.end();
- for (pos = m_locations.begin(); pos != end; ++pos)
- {
- if ((*pos)->IsResolved())
- ++resolve_count;
+ for (pos = m_locations.begin(); pos != end; ++pos) {
+ if ((*pos).get() == bp_loc_sp.get()) {
+ m_locations.erase(pos);
+ return true;
+ }
}
- return resolve_count;
+ }
+ return false;
}
-void
-BreakpointLocationList::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::iterator pos, end = m_locations.end();
-
- for (pos = m_locations.begin(); pos != end; ++pos)
- {
- s->Printf(" ");
- (*pos)->GetDescription(s, level);
+void BreakpointLocationList::RemoveInvalidLocations(const ArchSpec &arch) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ size_t idx = 0;
+ // Don't cache m_location.size() as it will change since we might
+ // remove locations from our vector...
+ while (idx < m_locations.size()) {
+ BreakpointLocation *bp_loc = m_locations[idx].get();
+ if (bp_loc->GetAddress().SectionWasDeleted()) {
+ // Section was deleted which means this breakpoint comes from a module
+ // that is no longer valid, so we should remove it.
+ m_locations.erase(m_locations.begin() + idx);
+ continue;
}
-}
-
-BreakpointLocationSP
-BreakpointLocationList::AddLocation (const Address &addr, bool resolve_indirect_symbols, bool *new_location)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
-
- if (new_location)
- *new_location = false;
- BreakpointLocationSP bp_loc_sp (FindByAddress(addr));
- if (!bp_loc_sp)
- {
- bp_loc_sp = Create (addr, resolve_indirect_symbols);
- if (bp_loc_sp)
- {
- bp_loc_sp->ResolveBreakpointSite();
-
- if (new_location)
- *new_location = true;
- if(m_new_location_recorder)
- {
- m_new_location_recorder->Add(bp_loc_sp);
- }
- }
- }
- return bp_loc_sp;
-}
-
-void
-BreakpointLocationList::SwapLocation (BreakpointLocationSP to_location_sp, BreakpointLocationSP from_location_sp)
-{
- if (!from_location_sp || !to_location_sp)
- return;
-
- m_address_to_location.erase(to_location_sp->GetAddress());
- to_location_sp->SwapLocation(from_location_sp);
- RemoveLocation(from_location_sp);
- m_address_to_location[to_location_sp->GetAddress()] = to_location_sp;
- to_location_sp->ResolveBreakpointSite();
-}
-
-bool
-BreakpointLocationList::RemoveLocation (const lldb::BreakpointLocationSP &bp_loc_sp)
-{
- if (bp_loc_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
-
- m_address_to_location.erase (bp_loc_sp->GetAddress());
-
- collection::iterator pos, end = m_locations.end();
- for (pos = m_locations.begin(); pos != end; ++pos)
- {
- if ((*pos).get() == bp_loc_sp.get())
- {
- m_locations.erase (pos);
- return true;
- }
+ if (arch.IsValid()) {
+ ModuleSP module_sp(bp_loc->GetAddress().GetModule());
+ if (module_sp) {
+ if (!arch.IsCompatibleMatch(module_sp->GetArchitecture())) {
+ // The breakpoint was in a module whose architecture is no longer
+ // compatible with "arch", so we need to remove it
+ m_locations.erase(m_locations.begin() + idx);
+ continue;
}
+ }
}
- return false;
+ // Only increment the index if we didn't remove the locations at index "idx"
+ ++idx;
+ }
}
-void
-BreakpointLocationList::RemoveInvalidLocations (const ArchSpec &arch)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- size_t idx = 0;
- // Don't cache m_location.size() as it will change since we might
- // remove locations from our vector...
- while (idx < m_locations.size())
- {
- BreakpointLocation *bp_loc = m_locations[idx].get();
- if (bp_loc->GetAddress().SectionWasDeleted())
- {
- // Section was deleted which means this breakpoint comes from a module
- // that is no longer valid, so we should remove it.
- m_locations.erase(m_locations.begin() + idx);
- continue;
- }
- if (arch.IsValid())
- {
- ModuleSP module_sp (bp_loc->GetAddress().GetModule());
- if (module_sp)
- {
- if (!arch.IsCompatibleMatch(module_sp->GetArchitecture()))
- {
- // The breakpoint was in a module whose architecture is no longer
- // compatible with "arch", so we need to remove it
- m_locations.erase(m_locations.begin() + idx);
- continue;
- }
- }
- }
- // Only increment the index if we didn't remove the locations at index "idx"
- ++idx;
- }
+void BreakpointLocationList::StartRecordingNewLocations(
+ BreakpointLocationCollection &new_locations) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ assert(m_new_location_recorder == nullptr);
+ m_new_location_recorder = &new_locations;
}
-void
-BreakpointLocationList::StartRecordingNewLocations (BreakpointLocationCollection &new_locations)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- assert(m_new_location_recorder == nullptr);
- m_new_location_recorder = &new_locations;
+void BreakpointLocationList::StopRecordingNewLocations() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_new_location_recorder = nullptr;
}
-void
-BreakpointLocationList::StopRecordingNewLocations ()
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_new_location_recorder = nullptr;
-}
+void BreakpointLocationList::Compact() {
+ lldb::break_id_t highest_id = 0;
-void
-BreakpointLocationList::Compact()
-{
- lldb::break_id_t highest_id = 0;
-
- for (BreakpointLocationSP loc_sp : m_locations)
- {
- lldb::break_id_t cur_id = loc_sp->GetID();
- if (cur_id > highest_id)
- highest_id = cur_id;
- }
- m_next_id = highest_id;
+ for (BreakpointLocationSP loc_sp : m_locations) {
+ lldb::break_id_t cur_id = loc_sp->GetID();
+ if (cur_id > highest_id)
+ highest_id = cur_id;
+ }
+ m_next_id = highest_id;
}
More information about the lldb-commits
mailing list