aboutsummaryrefslogtreecommitdiff
path: root/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Plugins/Platform/POSIX/PlatformPOSIX.cpp')
-rw-r--r--source/Plugins/Platform/POSIX/PlatformPOSIX.cpp141
1 files changed, 71 insertions, 70 deletions
diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 0032c804987c..f4cf22ad7583 100644
--- a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -88,7 +88,7 @@ bool PlatformPOSIX::IsConnected() const {
return false;
}
-lldb_private::Error PlatformPOSIX::RunShellCommand(
+lldb_private::Status PlatformPOSIX::RunShellCommand(
const char *command, // Shouldn't be NULL
const FileSpec &
working_dir, // Pass empty FileSpec to use the current working directory
@@ -109,14 +109,15 @@ lldb_private::Error PlatformPOSIX::RunShellCommand(
status_ptr, signo_ptr,
command_output, timeout_sec);
else
- return Error("unable to run a remote command without a platform");
+ return Status("unable to run a remote command without a platform");
}
}
-Error PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr) {
- Error error;
+Status
+PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec,
+ lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Status error;
// Nothing special to do here, just use the actual file and architecture
char exe_path[PATH_MAX];
@@ -250,16 +251,16 @@ Error PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec,
return error;
}
-Error PlatformPOSIX::GetFileWithUUID(const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file) {
+Status PlatformPOSIX::GetFileWithUUID(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
if (IsRemote() && m_remote_platform_sp)
return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
local_file);
// Default to the local case
local_file = platform_file;
- return Error();
+ return Status();
}
bool PlatformPOSIX::GetProcessInfo(lldb::pid_t pid,
@@ -282,16 +283,16 @@ PlatformPOSIX::FindProcesses(const ProcessInstanceInfoMatch &match_info,
return 0;
}
-Error PlatformPOSIX::MakeDirectory(const FileSpec &file_spec,
- uint32_t file_permissions) {
+Status PlatformPOSIX::MakeDirectory(const FileSpec &file_spec,
+ uint32_t file_permissions) {
if (m_remote_platform_sp)
return m_remote_platform_sp->MakeDirectory(file_spec, file_permissions);
else
return Platform::MakeDirectory(file_spec, file_permissions);
}
-Error PlatformPOSIX::GetFilePermissions(const FileSpec &file_spec,
- uint32_t &file_permissions) {
+Status PlatformPOSIX::GetFilePermissions(const FileSpec &file_spec,
+ uint32_t &file_permissions) {
if (m_remote_platform_sp)
return m_remote_platform_sp->GetFilePermissions(file_spec,
file_permissions);
@@ -299,8 +300,8 @@ Error PlatformPOSIX::GetFilePermissions(const FileSpec &file_spec,
return Platform::GetFilePermissions(file_spec, file_permissions);
}
-Error PlatformPOSIX::SetFilePermissions(const FileSpec &file_spec,
- uint32_t file_permissions) {
+Status PlatformPOSIX::SetFilePermissions(const FileSpec &file_spec,
+ uint32_t file_permissions) {
if (m_remote_platform_sp)
return m_remote_platform_sp->SetFilePermissions(file_spec,
file_permissions);
@@ -310,7 +311,7 @@ Error PlatformPOSIX::SetFilePermissions(const FileSpec &file_spec,
lldb::user_id_t PlatformPOSIX::OpenFile(const FileSpec &file_spec,
uint32_t flags, uint32_t mode,
- Error &error) {
+ Status &error) {
if (IsHost())
return FileCache::GetInstance().OpenFile(file_spec, flags, mode, error);
else if (m_remote_platform_sp)
@@ -319,7 +320,7 @@ lldb::user_id_t PlatformPOSIX::OpenFile(const FileSpec &file_spec,
return Platform::OpenFile(file_spec, flags, mode, error);
}
-bool PlatformPOSIX::CloseFile(lldb::user_id_t fd, Error &error) {
+bool PlatformPOSIX::CloseFile(lldb::user_id_t fd, Status &error) {
if (IsHost())
return FileCache::GetInstance().CloseFile(fd, error);
else if (m_remote_platform_sp)
@@ -329,7 +330,7 @@ bool PlatformPOSIX::CloseFile(lldb::user_id_t fd, Error &error) {
}
uint64_t PlatformPOSIX::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
- uint64_t dst_len, Error &error) {
+ uint64_t dst_len, Status &error) {
if (IsHost())
return FileCache::GetInstance().ReadFile(fd, offset, dst, dst_len, error);
else if (m_remote_platform_sp)
@@ -340,7 +341,7 @@ uint64_t PlatformPOSIX::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
uint64_t PlatformPOSIX::WriteFile(lldb::user_id_t fd, uint64_t offset,
const void *src, uint64_t src_len,
- Error &error) {
+ Status &error) {
if (IsHost())
return FileCache::GetInstance().WriteFile(fd, offset, src, src_len, error);
else if (m_remote_platform_sp)
@@ -370,7 +371,7 @@ static uint32_t chown_file(Platform *platform, const char *path,
return status;
}
-lldb_private::Error
+lldb_private::Status
PlatformPOSIX::PutFile(const lldb_private::FileSpec &source,
const lldb_private::FileSpec &destination, uint32_t uid,
uint32_t gid) {
@@ -378,34 +379,34 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source,
if (IsHost()) {
if (FileSpec::Equal(source, destination, true))
- return Error();
+ return Status();
// cp src dst
// chown uid:gid dst
std::string src_path(source.GetPath());
if (src_path.empty())
- return Error("unable to get file path for source");
+ return Status("unable to get file path for source");
std::string dst_path(destination.GetPath());
if (dst_path.empty())
- return Error("unable to get file path for destination");
+ return Status("unable to get file path for destination");
StreamString command;
command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str());
int status;
RunShellCommand(command.GetData(), NULL, &status, NULL, NULL, 10);
if (status != 0)
- return Error("unable to perform copy");
+ return Status("unable to perform copy");
if (uid == UINT32_MAX && gid == UINT32_MAX)
- return Error();
+ return Status();
if (chown_file(this, dst_path.c_str(), uid, gid) != 0)
- return Error("unable to perform chown");
- return Error();
+ return Status("unable to perform chown");
+ return Status();
} else if (m_remote_platform_sp) {
if (GetSupportsRSync()) {
std::string src_path(source.GetPath());
if (src_path.empty())
- return Error("unable to get file path for source");
+ return Status("unable to get file path for source");
std::string dst_path(destination.GetPath());
if (dst_path.empty())
- return Error("unable to get file path for destination");
+ return Status("unable to get file path for destination");
StreamString command;
if (GetIgnoresRemoteHostname()) {
if (!GetRSyncPrefix())
@@ -424,8 +425,8 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source,
if (retcode == 0) {
// Don't chown a local file for a remote system
// if (chown_file(this,dst_path.c_str(),uid,gid) != 0)
- // return Error("unable to perform chown");
- return Error();
+ // return Status("unable to perform chown");
+ return Status();
}
// if we are still here rsync has failed - let's try the slow way before
// giving up
@@ -446,7 +447,7 @@ lldb::user_id_t PlatformPOSIX::GetFileSize(const FileSpec &file_spec) {
return Platform::GetFileSize(file_spec);
}
-Error PlatformPOSIX::CreateSymlink(const FileSpec &src, const FileSpec &dst) {
+Status PlatformPOSIX::CreateSymlink(const FileSpec &src, const FileSpec &dst) {
if (IsHost())
return FileSystem::Symlink(src, dst);
else if (m_remote_platform_sp)
@@ -464,7 +465,7 @@ bool PlatformPOSIX::GetFileExists(const FileSpec &file_spec) {
return Platform::GetFileExists(file_spec);
}
-Error PlatformPOSIX::Unlink(const FileSpec &file_spec) {
+Status PlatformPOSIX::Unlink(const FileSpec &file_spec) {
if (IsHost())
return llvm::sys::fs::remove(file_spec.GetPath());
else if (m_remote_platform_sp)
@@ -473,7 +474,7 @@ Error PlatformPOSIX::Unlink(const FileSpec &file_spec) {
return Platform::Unlink(file_spec);
}
-lldb_private::Error PlatformPOSIX::GetFile(
+lldb_private::Status PlatformPOSIX::GetFile(
const lldb_private::FileSpec &source, // remote file path
const lldb_private::FileSpec &destination) // local file path
{
@@ -482,22 +483,22 @@ lldb_private::Error PlatformPOSIX::GetFile(
// Check the args, first.
std::string src_path(source.GetPath());
if (src_path.empty())
- return Error("unable to get file path for source");
+ return Status("unable to get file path for source");
std::string dst_path(destination.GetPath());
if (dst_path.empty())
- return Error("unable to get file path for destination");
+ return Status("unable to get file path for destination");
if (IsHost()) {
if (FileSpec::Equal(source, destination, true))
- return Error("local scenario->source and destination are the same file "
- "path: no operation performed");
+ return Status("local scenario->source and destination are the same file "
+ "path: no operation performed");
// cp src dst
StreamString cp_command;
cp_command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str());
int status;
RunShellCommand(cp_command.GetData(), NULL, &status, NULL, NULL, 10);
if (status != 0)
- return Error("unable to perform copy");
- return Error();
+ return Status("unable to perform copy");
+ return Status();
} else if (m_remote_platform_sp) {
if (GetSupportsRSync()) {
StreamString command;
@@ -517,7 +518,7 @@ lldb_private::Error PlatformPOSIX::GetFile(
int retcode;
Host::RunShellCommand(command.GetData(), NULL, &retcode, NULL, NULL, 60);
if (retcode == 0)
- return Error();
+ return Status();
// If we are here, rsync has failed - let's try the slow way before giving
// up
}
@@ -527,12 +528,12 @@ lldb_private::Error PlatformPOSIX::GetFile(
// close dst
if (log)
log->Printf("[GetFile] Using block by block transfer....\n");
- Error error;
+ Status error;
user_id_t fd_src = OpenFile(source, File::eOpenOptionRead,
lldb::eFilePermissionsFileDefault, error);
if (fd_src == UINT64_MAX)
- return Error("unable to open source file");
+ return Status("unable to open source file");
uint32_t permissions = 0;
error = GetFilePermissions(source, permissions);
@@ -710,8 +711,8 @@ const char *PlatformPOSIX::GetGroupName(uint32_t gid) {
return NULL;
}
-Error PlatformPOSIX::ConnectRemote(Args &args) {
- Error error;
+Status PlatformPOSIX::ConnectRemote(Args &args) {
+ Status error;
if (IsHost()) {
error.SetErrorStringWithFormat(
"can't connect to the host platform '%s', always connected",
@@ -753,8 +754,8 @@ Error PlatformPOSIX::ConnectRemote(Args &args) {
return error;
}
-Error PlatformPOSIX::DisconnectRemote() {
- Error error;
+Status PlatformPOSIX::DisconnectRemote() {
+ Status error;
if (IsHost()) {
error.SetErrorStringWithFormat(
@@ -769,8 +770,8 @@ Error PlatformPOSIX::DisconnectRemote() {
return error;
}
-Error PlatformPOSIX::LaunchProcess(ProcessLaunchInfo &launch_info) {
- Error error;
+Status PlatformPOSIX::LaunchProcess(ProcessLaunchInfo &launch_info) {
+ Status error;
if (IsHost()) {
error = Platform::LaunchProcess(launch_info);
@@ -783,19 +784,19 @@ Error PlatformPOSIX::LaunchProcess(ProcessLaunchInfo &launch_info) {
return error;
}
-lldb_private::Error PlatformPOSIX::KillProcess(const lldb::pid_t pid) {
+lldb_private::Status PlatformPOSIX::KillProcess(const lldb::pid_t pid) {
if (IsHost())
return Platform::KillProcess(pid);
if (m_remote_platform_sp)
return m_remote_platform_sp->KillProcess(pid);
- return Error("the platform is not currently connected");
+ return Status("the platform is not currently connected");
}
lldb::ProcessSP PlatformPOSIX::Attach(ProcessAttachInfo &attach_info,
Debugger &debugger, Target *target,
- Error &error) {
+ Status &error) {
lldb::ProcessSP process_sp;
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
@@ -855,7 +856,7 @@ lldb::ProcessSP
PlatformPOSIX::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
Target *target, // Can be NULL, if NULL create a new
// target, else use existing one
- Error &error) {
+ Status &error) {
ProcessSP process_sp;
if (IsHost()) {
@@ -881,23 +882,23 @@ void PlatformPOSIX::CalculateTrapHandlerSymbolNames() {
m_trap_handlers.push_back(ConstString("_sigtramp"));
}
-Error PlatformPOSIX::EvaluateLibdlExpression(
+Status PlatformPOSIX::EvaluateLibdlExpression(
lldb_private::Process *process, const char *expr_cstr,
const char *expr_prefix, lldb::ValueObjectSP &result_valobj_sp) {
DynamicLoader *loader = process->GetDynamicLoader();
if (loader) {
- Error error = loader->CanLoadImage();
+ Status error = loader->CanLoadImage();
if (error.Fail())
return error;
}
ThreadSP thread_sp(process->GetThreadList().GetExpressionExecutionThread());
if (!thread_sp)
- return Error("Selected thread isn't valid");
+ return Status("Selected thread isn't valid");
StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0));
if (!frame_sp)
- return Error("Frame 0 isn't valid");
+ return Status("Frame 0 isn't valid");
ExecutionContext exe_ctx;
frame_sp->CalculateExecutionContext(exe_ctx);
@@ -910,7 +911,7 @@ Error PlatformPOSIX::EvaluateLibdlExpression(
// don't do the work to trap them.
expr_options.SetTimeout(std::chrono::seconds(2));
- Error expr_error;
+ Status expr_error;
ExpressionResults result =
UserExpression::Evaluate(exe_ctx, expr_options, expr_cstr, expr_prefix,
result_valobj_sp, expr_error);
@@ -919,12 +920,12 @@ Error PlatformPOSIX::EvaluateLibdlExpression(
if (result_valobj_sp->GetError().Fail())
return result_valobj_sp->GetError();
- return Error();
+ return Status();
}
uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process,
const lldb_private::FileSpec &remote_file,
- lldb_private::Error &error) {
+ lldb_private::Status &error) {
char path[PATH_MAX];
remote_file.GetPath(path, sizeof(path));
@@ -983,18 +984,18 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process,
return LLDB_INVALID_IMAGE_TOKEN;
}
-Error PlatformPOSIX::UnloadImage(lldb_private::Process *process,
- uint32_t image_token) {
+Status PlatformPOSIX::UnloadImage(lldb_private::Process *process,
+ uint32_t image_token) {
const addr_t image_addr = process->GetImagePtrFromToken(image_token);
if (image_addr == LLDB_INVALID_ADDRESS)
- return Error("Invalid image token");
+ return Status("Invalid image token");
StreamString expr;
expr.Printf("dlclose((void *)0x%" PRIx64 ")", image_addr);
const char *prefix = GetLibdlFunctionDeclarations();
lldb::ValueObjectSP result_valobj_sp;
- Error error = EvaluateLibdlExpression(process, expr.GetData(), prefix,
- result_valobj_sp);
+ Status error = EvaluateLibdlExpression(process, expr.GetData(), prefix,
+ result_valobj_sp);
if (error.Fail())
return error;
@@ -1004,17 +1005,17 @@ Error PlatformPOSIX::UnloadImage(lldb_private::Process *process,
Scalar scalar;
if (result_valobj_sp->ResolveValue(scalar)) {
if (scalar.UInt(1))
- return Error("expression failed: \"%s\"", expr.GetData());
+ return Status("expression failed: \"%s\"", expr.GetData());
process->ResetImageToken(image_token);
}
- return Error();
+ return Status();
}
lldb::ProcessSP PlatformPOSIX::ConnectProcess(llvm::StringRef connect_url,
llvm::StringRef plugin_name,
lldb_private::Debugger &debugger,
lldb_private::Target *target,
- lldb_private::Error &error) {
+ lldb_private::Status &error) {
if (m_remote_platform_sp)
return m_remote_platform_sp->ConnectProcess(connect_url, plugin_name,
debugger, target, error);
@@ -1033,7 +1034,7 @@ const char *PlatformPOSIX::GetLibdlFunctionDeclarations() const {
}
size_t PlatformPOSIX::ConnectToWaitingProcesses(Debugger &debugger,
- Error &error) {
+ Status &error) {
if (m_remote_platform_sp)
return m_remote_platform_sp->ConnectToWaitingProcesses(debugger, error);
return Platform::ConnectToWaitingProcesses(debugger, error);