summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2015-07-04 01:02:43 +0000
committeremaste <emaste@FreeBSD.org>2015-07-04 01:02:43 +0000
commitcea4c167517a0678c7dbf92a0324088dcbac1035 (patch)
tree02de7f7c9d5a08ae1c4d3b4c98a565ff96cd52e6 /contrib/llvm/tools/lldb/source/API/SBPlatform.cpp
parent1756896fd2b99ede7ebeb8019d4004bdfeed3bbe (diff)
parent8037fa4ee916fa20b3c63cbf531f4ee7e1c76138 (diff)
downloadFreeBSD-src-cea4c167517a0678c7dbf92a0324088dcbac1035.zip
FreeBSD-src-cea4c167517a0678c7dbf92a0324088dcbac1035.tar.gz
Update LLDB snapshot to upstream r241361
Notable upstream commits (upstream revision in parens): - Add a JSON producer to LLDB (228636) - Don't crash on bad DWARF expression (228729) - Add support of DWARFv3 DW_OP_form_tls_address (231342) - Assembly profiler for MIPS64 (232619) - Handle FreeBSD/arm64 core files (233273) - Read/Write register for MIPS64 (233685) - Rework LLDB system initialization (233758) - SysV ABI for aarch64 (236098) - MIPS software single stepping (236696) - FreeBSD/arm live debugging support (237303) - Assembly profiler for mips32 (237420) - Parse function name from DWARF DW_AT_abstract_origin (238307) - Improve LLDB prompt handling (238313) - Add real time signals support to FreeBSDSignals (238316) - Fix race in IOHandlerProcessSTDIO (238423) - MIPS64 Branch instruction emulation for SW single stepping (238820) - Improve OSType initialization in elf object file's arch_spec (239148) - Emulation of MIPS64 floating-point branch instructions (239996) - ABI Plugin for MIPS32 (239997) - ABI Plugin for MIPS64 (240123) - MIPS32 branch emulation and single stepping (240373) - Improve instruction emulation based stack unwinding on ARM (240533) - Add branch emulation to aarch64 instruction emulator (240769)
Diffstat (limited to 'contrib/llvm/tools/lldb/source/API/SBPlatform.cpp')
-rw-r--r--contrib/llvm/tools/lldb/source/API/SBPlatform.cpp169
1 files changed, 88 insertions, 81 deletions
diff --git a/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp b/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp
index d3e769a..5662f36 100644
--- a/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp
+++ b/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp
@@ -10,6 +10,7 @@
#include "lldb/API/SBPlatform.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBLaunchInfo.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/File.h"
@@ -17,6 +18,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Platform.h"
+#include <functional>
+
using namespace lldb;
using namespace lldb_private;
@@ -326,9 +329,9 @@ SBPlatform::SetWorkingDirectory(const char *path)
if (platform_sp)
{
if (path)
- platform_sp->SetWorkingDirectory(ConstString(path));
+ platform_sp->SetWorkingDirectory(FileSpec{path, false});
else
- platform_sp->SetWorkingDirectory(ConstString());
+ platform_sp->SetWorkingDirectory(FileSpec{});
return true;
}
return false;
@@ -375,7 +378,7 @@ SBPlatform::GetTriple()
PlatformSP platform_sp(GetSP());
if (platform_sp)
{
- ArchSpec arch(platform_sp->GetRemoteSystemArchitecture());
+ 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
@@ -484,104 +487,108 @@ SBError
SBPlatform::Put (SBFileSpec &src,
SBFileSpec &dst)
{
- SBError sb_error;
-
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- if (src.Exists())
+ 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)
{
- uint32_t permissions = src.ref().GetPermissions();
- if (permissions == 0)
+ 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)
{
- if (src.ref().GetFileType() == FileSpec::eFileTypeDirectory)
- permissions = eFilePermissionsDirectoryDefault;
- else
- permissions = eFilePermissionsFileDefault;
+ 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);
+ });
+}
- sb_error.ref() = platform_sp->PutFile(src.ref(),
- dst.ref(),
- permissions);
- }
- else
+SBError
+SBPlatform::Launch (SBLaunchInfo &launch_info)
+{
+ return ExecuteConnected(
+ [&](const lldb::PlatformSP& platform_sp)
{
- sb_error.ref().SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", src.ref().GetPath().c_str());
- }
- }
- else
- {
- sb_error.SetErrorString("invalid platform");
- }
- return sb_error;
+ return platform_sp->LaunchProcess(launch_info.ref());
+ });
}
SBError
-SBPlatform::Install (SBFileSpec &src,
- SBFileSpec &dst)
+SBPlatform::Kill (const lldb::pid_t pid)
{
- SBError sb_error;
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- if (src.Exists())
- {
- sb_error.ref() = platform_sp->Install(src.ref(), dst.ref());
- }
- else
+ return ExecuteConnected(
+ [&](const lldb::PlatformSP& platform_sp)
{
- sb_error.ref().SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", src.ref().GetPath().c_str());
- }
- }
- else
- {
- sb_error.SetErrorString("invalid platform");
- }
- return sb_error;
+ return platform_sp->KillProcess(pid);
+ });
}
-
SBError
-SBPlatform::Run (SBPlatformShellCommand &shell_command)
+SBPlatform::ExecuteConnected (const std::function<Error(const lldb::PlatformSP&)>& func)
{
SBError sb_error;
- PlatformSP platform_sp(GetSP());
+ const auto 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)");
- }
- }
+ sb_error.ref() = func(platform_sp);
else
- {
sb_error.SetErrorString("not connected");
- }
}
else
- {
sb_error.SetErrorString("invalid platform");
- }
- return sb_error;
+
+ return sb_error;
}
SBError
@@ -591,7 +598,7 @@ SBPlatform::MakeDirectory (const char *path, uint32_t file_permissions)
PlatformSP platform_sp(GetSP());
if (platform_sp)
{
- sb_error.ref() = platform_sp->MakeDirectory(path, file_permissions);
+ sb_error.ref() = platform_sp->MakeDirectory(FileSpec{path, false}, file_permissions);
}
else
{
@@ -607,7 +614,7 @@ SBPlatform::GetFilePermissions (const char *path)
if (platform_sp)
{
uint32_t file_permissions = 0;
- platform_sp->GetFilePermissions(path, file_permissions);
+ platform_sp->GetFilePermissions(FileSpec{path, false}, file_permissions);
return file_permissions;
}
return 0;
@@ -621,7 +628,7 @@ SBPlatform::SetFilePermissions (const char *path, uint32_t file_permissions)
PlatformSP platform_sp(GetSP());
if (platform_sp)
{
- sb_error.ref() = platform_sp->SetFilePermissions(path, file_permissions);
+ sb_error.ref() = platform_sp->SetFilePermissions(FileSpec{path, false}, file_permissions);
}
else
{
OpenPOWER on IntegriCloud