summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/lldb/source/API
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2014-03-19 13:18:42 +0000
committeremaste <emaste@FreeBSD.org>2014-03-19 13:18:42 +0000
commitde2662087f68970c151b26a2997516c216039b26 (patch)
tree6a672eef9249553426e36975397cc5973493e038 /contrib/llvm/tools/lldb/source/API
parent7327a493ea46f46df221ed1a16d03d1981a284e0 (diff)
downloadFreeBSD-src-de2662087f68970c151b26a2997516c216039b26.zip
FreeBSD-src-de2662087f68970c151b26a2997516c216039b26.tar.gz
MFC r258884: Update LLDB to upstream r196259 snapshot
Sponsored by: DARPA, AFRL
Diffstat (limited to 'contrib/llvm/tools/lldb/source/API')
-rw-r--r--contrib/llvm/tools/lldb/source/API/SBDebugger.cpp74
-rw-r--r--contrib/llvm/tools/lldb/source/API/SBExpressionOptions.cpp16
-rw-r--r--contrib/llvm/tools/lldb/source/API/SBFileSpec.cpp18
-rw-r--r--contrib/llvm/tools/lldb/source/API/SBModule.cpp21
-rw-r--r--contrib/llvm/tools/lldb/source/API/SBPlatform.cpp632
-rw-r--r--contrib/llvm/tools/lldb/source/API/SBProcess.cpp2
-rw-r--r--contrib/llvm/tools/lldb/source/API/SBStream.cpp2
-rw-r--r--contrib/llvm/tools/lldb/source/API/SBTarget.cpp13
-rw-r--r--contrib/llvm/tools/lldb/source/API/SBThread.cpp41
9 files changed, 806 insertions, 13 deletions
diff --git a/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp b/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp
index 88c991b..10c0b7d 100644
--- a/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp
+++ b/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp
@@ -38,6 +38,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/State.h"
#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/Host/DynamicLibrary.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionGroupPlatform.h"
@@ -47,6 +48,41 @@
using namespace lldb;
using namespace lldb_private;
+
+static lldb::DynamicLibrarySP
+LoadPlugin (const lldb::DebuggerSP &debugger_sp, const FileSpec& spec, Error& error)
+{
+ lldb::DynamicLibrarySP dynlib_sp(new lldb_private::DynamicLibrary(spec));
+ if (dynlib_sp && dynlib_sp->IsValid())
+ {
+ typedef bool (*LLDBCommandPluginInit) (lldb::SBDebugger& debugger);
+
+ lldb::SBDebugger debugger_sb(debugger_sp);
+ // This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger) function.
+ // TODO: mangle this differently for your system - on OSX, the first underscore needs to be removed and the second one stays
+ LLDBCommandPluginInit init_func = dynlib_sp->GetSymbol<LLDBCommandPluginInit>("_ZN4lldb16PluginInitializeENS_10SBDebuggerE");
+ if (init_func)
+ {
+ if (init_func(debugger_sb))
+ return dynlib_sp;
+ else
+ error.SetErrorString("plug-in refused to load (lldb::PluginInitialize(lldb::SBDebugger) returned false)");
+ }
+ else
+ {
+ error.SetErrorString("plug-in is missing the required initialization: lldb::PluginInitialize(lldb::SBDebugger)");
+ }
+ }
+ else
+ {
+ if (spec.Exists())
+ error.SetErrorString("this file does not represent a loadable dylib");
+ else
+ error.SetErrorString("no such file");
+ }
+ return lldb::DynamicLibrarySP();
+}
+
void
SBDebugger::Initialize ()
{
@@ -57,7 +93,7 @@ SBDebugger::Initialize ()
SBCommandInterpreter::InitializeSWIG ();
- Debugger::Initialize();
+ Debugger::Initialize(LoadPlugin);
}
void
@@ -804,6 +840,42 @@ SBDebugger::SetSelectedTarget (SBTarget &sb_target)
}
}
+SBPlatform
+SBDebugger::GetSelectedPlatform()
+{
+ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ SBPlatform sb_platform;
+ DebuggerSP debugger_sp(m_opaque_sp);
+ if (debugger_sp)
+ {
+ sb_platform.SetSP(debugger_sp->GetPlatformList().GetSelectedPlatform());
+ }
+ if (log)
+ {
+ log->Printf ("SBDebugger(%p)::GetSelectedPlatform () => SBPlatform(%p): %s", m_opaque_sp.get(),
+ sb_platform.GetSP().get(), sb_platform.GetName());
+ }
+ return sb_platform;
+}
+
+void
+SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform)
+{
+ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ DebuggerSP debugger_sp(m_opaque_sp);
+ if (debugger_sp)
+ {
+ debugger_sp->GetPlatformList().SetSelectedPlatform(sb_platform.GetSP());
+ }
+ if (log)
+ {
+ log->Printf ("SBDebugger(%p)::SetSelectedPlatform (SBPlatform(%p) %s)", m_opaque_sp.get(),
+ sb_platform.GetSP().get(), sb_platform.GetName());
+ }
+}
+
void
SBDebugger::DispatchInput (void* baton, const void *data, size_t data_len)
{
diff --git a/contrib/llvm/tools/lldb/source/API/SBExpressionOptions.cpp b/contrib/llvm/tools/lldb/source/API/SBExpressionOptions.cpp
index 127b0cf..ae1c8f9 100644
--- a/contrib/llvm/tools/lldb/source/API/SBExpressionOptions.cpp
+++ b/contrib/llvm/tools/lldb/source/API/SBExpressionOptions.cpp
@@ -104,13 +104,25 @@ SBExpressionOptions::SetTimeoutInMicroSeconds (uint32_t timeout)
bool
SBExpressionOptions::GetTryAllThreads () const
{
- return m_opaque_ap->GetRunOthers ();
+ return m_opaque_ap->GetTryAllThreads ();
}
void
SBExpressionOptions::SetTryAllThreads (bool run_others)
{
- m_opaque_ap->SetRunOthers (run_others);
+ m_opaque_ap->SetTryAllThreads (run_others);
+}
+
+bool
+SBExpressionOptions::GetTrapExceptions () const
+{
+ return m_opaque_ap->GetTrapExceptions ();
+}
+
+void
+SBExpressionOptions::SetTrapExceptions (bool trap_exceptions)
+{
+ m_opaque_ap->SetTrapExceptions (trap_exceptions);
}
EvaluateExpressionOptions *
diff --git a/contrib/llvm/tools/lldb/source/API/SBFileSpec.cpp b/contrib/llvm/tools/lldb/source/API/SBFileSpec.cpp
index fc207d0..4fd2866 100644
--- a/contrib/llvm/tools/lldb/source/API/SBFileSpec.cpp
+++ b/contrib/llvm/tools/lldb/source/API/SBFileSpec.cpp
@@ -121,6 +121,24 @@ SBFileSpec::GetDirectory() const
return s;
}
+void
+SBFileSpec::SetFilename(const char *filename)
+{
+ if (filename && filename[0])
+ m_opaque_ap->GetFilename().SetCString(filename);
+ else
+ m_opaque_ap->GetFilename().Clear();
+}
+
+void
+SBFileSpec::SetDirectory(const char *directory)
+{
+ if (directory && directory[0])
+ m_opaque_ap->GetDirectory().SetCString(directory);
+ else
+ m_opaque_ap->GetDirectory().Clear();
+}
+
uint32_t
SBFileSpec::GetPath (char *dst_path, size_t dst_len) const
{
diff --git a/contrib/llvm/tools/lldb/source/API/SBModule.cpp b/contrib/llvm/tools/lldb/source/API/SBModule.cpp
index 5f5fc92..0285cf3 100644
--- a/contrib/llvm/tools/lldb/source/API/SBModule.cpp
+++ b/contrib/llvm/tools/lldb/source/API/SBModule.cpp
@@ -162,6 +162,27 @@ SBModule::SetPlatformFileSpec (const lldb::SBFileSpec &platform_file)
return result;
}
+lldb::SBFileSpec
+SBModule::GetRemoteInstallFileSpec ()
+{
+ SBFileSpec sb_file_spec;
+ ModuleSP module_sp (GetSP ());
+ if (module_sp)
+ sb_file_spec.SetFileSpec (module_sp->GetRemoteInstallFileSpec());
+ return sb_file_spec;
+}
+
+bool
+SBModule::SetRemoteInstallFileSpec (lldb::SBFileSpec &file)
+{
+ ModuleSP module_sp (GetSP ());
+ if (module_sp)
+ {
+ module_sp->SetRemoteInstallFileSpec(file.ref());
+ return true;
+ }
+ return false;
+}
const uint8_t *
diff --git a/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp b/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp
new file mode 100644
index 0000000..9914852
--- /dev/null
+++ b/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp
@@ -0,0 +1,632 @@
+//===-- SBPlatform.cpp ------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBError.h"
+#include "lldb/API/SBFileSpec.h"
+#include "lldb/Core/ArchSpec.h"
+#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"
+
+using namespace lldb;
+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()
+ {
+ }
+
+ 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;
+};
+//----------------------------------------------------------------------
+// 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();
+}
+
+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();
+
+ if (options && options[0])
+ m_opaque_ptr->m_rsync_options = options;
+ else
+ m_opaque_ptr->m_rsync_options.clear();
+
+}
+
+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();
+}
+
+//----------------------------------------------------------------------
+// SBPlatformShellCommand
+//----------------------------------------------------------------------
+SBPlatformShellCommand::SBPlatformShellCommand (const char *shell_command) :
+ m_opaque_ptr(new PlatformShellCommand(shell_command))
+{
+}
+
+SBPlatformShellCommand::SBPlatformShellCommand (const SBPlatformShellCommand &rhs) :
+ m_opaque_ptr(new PlatformShellCommand())
+{
+ *m_opaque_ptr = *rhs.m_opaque_ptr;
+}
+
+SBPlatformShellCommand::~SBPlatformShellCommand()
+{
+ delete m_opaque_ptr;
+}
+
+void
+SBPlatformShellCommand::Clear()
+{
+ m_opaque_ptr->m_output = std::move(std::string());
+ m_opaque_ptr->m_status = 0;
+ m_opaque_ptr->m_signo = 0;
+}
+
+const char *
+SBPlatformShellCommand::GetCommand()
+{
+ if (m_opaque_ptr->m_command.empty())
+ return NULL;
+ return m_opaque_ptr->m_command.c_str();
+}
+
+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 *
+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();
+}
+
+uint32_t
+SBPlatformShellCommand::GetTimeoutSeconds ()
+{
+ return m_opaque_ptr->m_timeout_sec;
+}
+
+void
+SBPlatformShellCommand::SetTimeoutSeconds (uint32_t sec)
+{
+ m_opaque_ptr->m_timeout_sec = sec;
+}
+
+int
+SBPlatformShellCommand::GetSignal ()
+{
+ return m_opaque_ptr->m_signo;
+}
+
+int
+SBPlatformShellCommand::GetStatus ()
+{
+ return m_opaque_ptr->m_status;
+}
+
+const char *
+SBPlatformShellCommand::GetOutput ()
+{
+ if (m_opaque_ptr->m_output.empty())
+ return NULL;
+ return m_opaque_ptr->m_output.c_str();
+}
+
+//----------------------------------------------------------------------
+// SBPlatform
+//----------------------------------------------------------------------
+SBPlatform::SBPlatform () :
+ m_opaque_sp ()
+{
+
+}
+
+SBPlatform::SBPlatform (const char *platform_name) :
+ m_opaque_sp ()
+{
+ Error error;
+ m_opaque_sp = Platform::Create (platform_name, 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;
+}
+
+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();
+ return NULL;
+}
+
+bool
+SBPlatform::SetWorkingDirectory(const char *path)
+{
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp)
+ {
+ if (path)
+ platform_sp->SetWorkingDirectory(ConstString(path));
+ else
+ platform_sp->SetWorkingDirectory(ConstString());
+ return true;
+ }
+ return false;
+}
+
+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;
+}
+
+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->GetRemoteSystemArchitecture());
+ 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)
+{
+ SBError sb_error;
+
+ PlatformSP platform_sp(GetSP());
+ if (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;
+ }
+
+ sb_error.ref() = platform_sp->PutFile(src.ref(),
+ dst.ref(),
+ permissions);
+ }
+ else
+ {
+ sb_error.ref().SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", src.ref().GetPath().c_str());
+ }
+ }
+ else
+ {
+ sb_error.SetErrorString("invalid platform");
+ }
+ return sb_error;
+}
+
+SBError
+SBPlatform::Install (SBFileSpec &src,
+ SBFileSpec &dst)
+{
+ SBError sb_error;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp)
+ {
+ if (src.Exists())
+ {
+ sb_error.ref() = platform_sp->Install(src.ref(), dst.ref());
+ }
+ else
+ {
+ sb_error.ref().SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", src.ref().GetPath().c_str());
+ }
+ }
+ else
+ {
+ sb_error.SetErrorString("invalid platform");
+ }
+ return sb_error;
+}
+
+
+SBError
+SBPlatform::Run (SBPlatformShellCommand &shell_command)
+{
+ SBError sb_error;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp)
+ {
+ if (platform_sp->IsConnected())
+ {
+ const char *command = shell_command.GetCommand();
+ if (command)
+ {
+ 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);
+ }
+ sb_error.ref() = platform_sp->RunShellCommand(command,
+ working_dir,
+ &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);
+ }
+ else
+ {
+ sb_error.SetErrorString("invalid shell command (empty)");
+ }
+ }
+ else
+ {
+ sb_error.SetErrorString("not connected");
+ }
+ }
+ else
+ {
+ sb_error.SetErrorString("invalid platform");
+ }
+ return sb_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(path, 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(path, 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(path, file_permissions);
+ }
+ else
+ {
+ sb_error.SetErrorString("invalid platform");
+ }
+ return sb_error;
+
+}
+
diff --git a/contrib/llvm/tools/lldb/source/API/SBProcess.cpp b/contrib/llvm/tools/lldb/source/API/SBProcess.cpp
index d690da7..557006f 100644
--- a/contrib/llvm/tools/lldb/source/API/SBProcess.cpp
+++ b/contrib/llvm/tools/lldb/source/API/SBProcess.cpp
@@ -1278,7 +1278,7 @@ SBProcess::GetExtendedBacktraceTypeAtIndex (uint32_t idx)
if (process_sp && process_sp->GetSystemRuntime())
{
SystemRuntime *runtime = process_sp->GetSystemRuntime();
- std::vector<ConstString> names = runtime->GetExtendedBacktraceTypes();
+ const std::vector<ConstString> &names = runtime->GetExtendedBacktraceTypes();
if (idx < names.size())
{
return names[idx].AsCString();
diff --git a/contrib/llvm/tools/lldb/source/API/SBStream.cpp b/contrib/llvm/tools/lldb/source/API/SBStream.cpp
index dc8eb05..531ab9f 100644
--- a/contrib/llvm/tools/lldb/source/API/SBStream.cpp
+++ b/contrib/llvm/tools/lldb/source/API/SBStream.cpp
@@ -82,7 +82,7 @@ SBStream::RedirectToFile (const char *path, bool append)
uint32_t open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate;
if (append)
open_options |= File::eOpenOptionAppend;
- stream_file->GetFile().Open (path, open_options, File::ePermissionsDefault);
+ stream_file->GetFile().Open (path, open_options, lldb::eFilePermissionsFileDefault);
m_opaque_ap.reset (stream_file);
diff --git a/contrib/llvm/tools/lldb/source/API/SBTarget.cpp b/contrib/llvm/tools/lldb/source/API/SBTarget.cpp
index cff6e4e..c8bc217 100644
--- a/contrib/llvm/tools/lldb/source/API/SBTarget.cpp
+++ b/contrib/llvm/tools/lldb/source/API/SBTarget.cpp
@@ -605,6 +605,19 @@ SBTarget::LaunchSimple
error);
}
+SBError
+SBTarget::Install()
+{
+ SBError sb_error;
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ {
+ Mutex::Locker api_locker (target_sp->GetAPIMutex());
+ sb_error.ref() = target_sp->Install(NULL);
+ }
+ return sb_error;
+}
+
SBProcess
SBTarget::Launch
(
diff --git a/contrib/llvm/tools/lldb/source/API/SBThread.cpp b/contrib/llvm/tools/lldb/source/API/SBThread.cpp
index 4b54b1c..4170d5b 100644
--- a/contrib/llvm/tools/lldb/source/API/SBThread.cpp
+++ b/contrib/llvm/tools/lldb/source/API/SBThread.cpp
@@ -433,7 +433,6 @@ SBThread::SetThread (const ThreadSP& lldb_object_sp)
m_opaque_sp->SetThreadSP (lldb_object_sp);
}
-
lldb::tid_t
SBThread::GetThreadID () const
{
@@ -1283,7 +1282,7 @@ SBThread::GetDescription (SBStream &description) const
}
SBThread
-SBThread::GetExtendedBacktrace (const char *type)
+SBThread::GetExtendedBacktraceThread (const char *type)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
@@ -1295,24 +1294,50 @@ SBThread::GetExtendedBacktrace (const char *type)
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
{
- ThreadSP real_thread(exe_ctx.GetThreadPtr());
+ ThreadSP real_thread(exe_ctx.GetThreadSP());
if (real_thread)
{
ConstString type_const (type);
- SystemRuntime *runtime = exe_ctx.GetProcessPtr()->GetSystemRuntime();
- if (runtime)
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process)
{
- ThreadSP origin_thread = runtime->GetExtendedBacktrace (real_thread, type_const);
- sb_origin_thread.SetThread (origin_thread);
+ 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'", exe_ctx.GetThreadPtr(), new_thread_sp.get(), new_thread_sp->GetQueueID(), queue_name);
+ }
+ }
+ }
}
}
}
else
{
if (log)
- log->Printf ("SBThread(%p)::GetExtendedBacktrace() => error: process is running", exe_ctx.GetThreadPtr());
+ log->Printf ("SBThread(%p)::GetExtendedBacktraceThread() => error: process is running", 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;
+}
OpenPOWER on IntegriCloud