summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Platform.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-05-12 04:51:55 +0000
committerZachary Turner <zturner@google.com>2017-05-12 04:51:55 +0000
commit97206d572797bddc1bba71bb1c18c97f19d69053 (patch)
treefdf21d24485672cf97c800264d135b9d5d2ecdce /lldb/source/Target/Platform.cpp
parent3086b45a2fae833e8419885e78c598d936cc6429 (diff)
downloadbcm5719-llvm-97206d572797bddc1bba71bb1c18c97f19d69053.tar.gz
bcm5719-llvm-97206d572797bddc1bba71bb1c18c97f19d69053.zip
Rename Error -> Status.
This renames the LLDB error class to Status, as discussed on the lldb-dev mailing list. A change of this magnitude cannot easily be done without find and replace, but that has potential to catch unwanted occurrences of common strings such as "Error". Every effort was made to find all the obvious things such as the word "Error" appearing in a string, etc, but it's possible there are still some lingering occurences left around. Hopefully nothing too serious. llvm-svn: 302872
Diffstat (limited to 'lldb/source/Target/Platform.cpp')
-rw-r--r--lldb/source/Target/Platform.cpp196
1 files changed, 99 insertions, 97 deletions
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index fd909075a24..cfd971e9de6 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -39,9 +39,9 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/DataBufferHeap.h"
-#include "lldb/Utility/Error.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Status.h"
#include "llvm/Support/FileSystem.h"
@@ -170,11 +170,11 @@ void Platform::SetHostPlatform(const lldb::PlatformSP &platform_sp) {
}
}
-Error Platform::GetFileWithUUID(const FileSpec &platform_file,
- const UUID *uuid_ptr, FileSpec &local_file) {
+Status Platform::GetFileWithUUID(const FileSpec &platform_file,
+ const UUID *uuid_ptr, FileSpec &local_file) {
// Default to the local case
local_file = platform_file;
- return Error();
+ return Status();
}
FileSpecList
@@ -217,11 +217,11 @@ Platform::LocateExecutableScriptingResources(Target *target, Module &module,
// return PlatformSP();
//}
-Error Platform::GetSharedModule(const ModuleSpec &module_spec, Process *process,
- ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) {
+Status Platform::GetSharedModule(const ModuleSpec &module_spec,
+ Process *process, ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) {
if (IsHost())
return ModuleList::GetSharedModule(
module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
@@ -229,7 +229,7 @@ Error Platform::GetSharedModule(const ModuleSpec &module_spec, Process *process,
return GetRemoteSharedModule(module_spec, process, module_sp,
[&](const ModuleSpec &spec) {
- Error error = ModuleList::GetSharedModule(
+ Status error = ModuleList::GetSharedModule(
spec, module_sp, module_search_paths_ptr,
old_module_sp_ptr, did_create_ptr, false);
if (error.Success() && module_sp)
@@ -267,7 +267,7 @@ PlatformSP Platform::Find(const ConstString &name) {
return PlatformSP();
}
-PlatformSP Platform::Create(const ConstString &name, Error &error) {
+PlatformSP Platform::Create(const ConstString &name, Status &error) {
PlatformCreateInstance create_callback = nullptr;
lldb::PlatformSP platform_sp;
if (name) {
@@ -295,7 +295,7 @@ PlatformSP Platform::Create(const ConstString &name, Error &error) {
}
PlatformSP Platform::Create(const ArchSpec &arch, ArchSpec *platform_arch_ptr,
- Error &error) {
+ Status &error) {
lldb::PlatformSP platform_sp;
if (arch.IsValid()) {
// Scope for locker
@@ -540,7 +540,7 @@ FileSpec Platform::GetWorkingDirectory() {
struct RecurseCopyBaton {
const FileSpec &dst;
Platform *platform_ptr;
- Error error;
+ Status error;
};
static FileSpec::EnumerateDirectoryResult
@@ -560,7 +560,7 @@ RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
FileSpec dst_dir = rc_baton->dst;
if (!dst_dir.GetFilename())
dst_dir.GetFilename() = src.GetLastPathComponent();
- Error error = rc_baton->platform_ptr->MakeDirectory(
+ Status error = rc_baton->platform_ptr->MakeDirectory(
dst_dir, lldb::eFilePermissionsDirectoryDefault);
if (error.Fail()) {
rc_baton->error.SetErrorStringWithFormat(
@@ -575,7 +575,8 @@ RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
// when we enumerate we can quickly fill in the filename for dst copies
FileSpec recurse_dst;
recurse_dst.GetDirectory().SetCString(dst_dir.GetPath().c_str());
- RecurseCopyBaton rc_baton2 = {recurse_dst, rc_baton->platform_ptr, Error()};
+ RecurseCopyBaton rc_baton2 = {recurse_dst, rc_baton->platform_ptr,
+ Status()};
FileSpec::EnumerateDirectory(src_dir_path, true, true, true,
RecurseCopy_Callback, &rc_baton2);
if (rc_baton2.error.Fail()) {
@@ -612,7 +613,7 @@ RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
FileSpec dst_file = rc_baton->dst;
if (!dst_file.GetFilename())
dst_file.GetFilename() = src.GetFilename();
- Error err = rc_baton->platform_ptr->PutFile(src, dst_file);
+ Status err = rc_baton->platform_ptr->PutFile(src, dst_file);
if (err.Fail()) {
rc_baton->error.SetErrorString(err.AsCString());
return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
@@ -629,8 +630,8 @@ RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
llvm_unreachable("Unhandled file_type!");
}
-Error Platform::Install(const FileSpec &src, const FileSpec &dst) {
- Error error;
+Status Platform::Install(const FileSpec &src, const FileSpec &dst) {
+ Status error;
Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
if (log)
@@ -708,7 +709,7 @@ Error Platform::Install(const FileSpec &src, const FileSpec &dst) {
FileSpec recurse_dst;
recurse_dst.GetDirectory().SetCString(fixed_dst.GetCString());
std::string src_dir_path(src.GetPath());
- RecurseCopyBaton baton = {recurse_dst, this, Error()};
+ RecurseCopyBaton baton = {recurse_dst, this, Status()};
FileSpec::EnumerateDirectory(src_dir_path, true, true, true,
RecurseCopy_Callback, &baton);
return baton.error;
@@ -757,11 +758,12 @@ bool Platform::SetWorkingDirectory(const FileSpec &file_spec) {
}
}
-Error Platform::MakeDirectory(const FileSpec &file_spec, uint32_t permissions) {
+Status Platform::MakeDirectory(const FileSpec &file_spec,
+ uint32_t permissions) {
if (IsHost())
return llvm::sys::fs::create_directory(file_spec.GetPath(), permissions);
else {
- Error error;
+ Status error;
error.SetErrorStringWithFormat("remote platform %s doesn't support %s",
GetPluginName().GetCString(),
LLVM_PRETTY_FUNCTION);
@@ -769,15 +771,15 @@ Error Platform::MakeDirectory(const FileSpec &file_spec, uint32_t permissions) {
}
}
-Error Platform::GetFilePermissions(const FileSpec &file_spec,
- uint32_t &file_permissions) {
+Status Platform::GetFilePermissions(const FileSpec &file_spec,
+ uint32_t &file_permissions) {
if (IsHost()) {
auto Value = llvm::sys::fs::getPermissions(file_spec.GetPath());
if (Value)
file_permissions = Value.get();
- return Error(Value.getError());
+ return Status(Value.getError());
} else {
- Error error;
+ Status error;
error.SetErrorStringWithFormat("remote platform %s doesn't support %s",
GetPluginName().GetCString(),
LLVM_PRETTY_FUNCTION);
@@ -785,13 +787,13 @@ Error Platform::GetFilePermissions(const FileSpec &file_spec,
}
}
-Error Platform::SetFilePermissions(const FileSpec &file_spec,
- uint32_t file_permissions) {
+Status Platform::SetFilePermissions(const FileSpec &file_spec,
+ uint32_t file_permissions) {
if (IsHost()) {
auto Perms = static_cast<llvm::sys::fs::perms>(file_permissions);
return llvm::sys::fs::setPermissions(file_spec.GetPath(), Perms);
} else {
- Error error;
+ Status error;
error.SetErrorStringWithFormat("remote platform %s doesn't support %s",
GetPluginName().GetCString(),
LLVM_PRETTY_FUNCTION);
@@ -877,10 +879,11 @@ bool Platform::SetOSVersion(uint32_t major, uint32_t minor, uint32_t update) {
return false;
}
-Error Platform::ResolveExecutable(const ModuleSpec &module_spec,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr) {
- Error error;
+Status
+Platform::ResolveExecutable(const ModuleSpec &module_spec,
+ lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Status error;
if (module_spec.GetFileSpec().Exists()) {
if (module_spec.GetArchitecture().IsValid()) {
error = ModuleList::GetSharedModule(module_spec, exe_module_sp,
@@ -909,9 +912,9 @@ Error Platform::ResolveExecutable(const ModuleSpec &module_spec,
return error;
}
-Error Platform::ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec,
- FileSpec &sym_file) {
- Error error;
+Status Platform::ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec,
+ FileSpec &sym_file) {
+ Status error;
if (sym_spec.GetSymbolFileSpec().Exists())
sym_file = sym_spec.GetSymbolFileSpec();
else
@@ -960,8 +963,8 @@ const ArchSpec &Platform::GetSystemArchitecture() {
return m_system_arch;
}
-Error Platform::ConnectRemote(Args &args) {
- Error error;
+Status Platform::ConnectRemote(Args &args) {
+ Status error;
if (IsHost())
error.SetErrorStringWithFormat("The currently selected platform (%s) is "
"the host platform and is always connected.",
@@ -973,8 +976,8 @@ Error Platform::ConnectRemote(Args &args) {
return error;
}
-Error Platform::DisconnectRemote() {
- Error error;
+Status Platform::DisconnectRemote() {
+ Status error;
if (IsHost())
error.SetErrorStringWithFormat("The currently selected platform (%s) is "
"the host platform and is always connected.",
@@ -1005,8 +1008,8 @@ uint32_t Platform::FindProcesses(const ProcessInstanceInfoMatch &match_info,
return match_count;
}
-Error Platform::LaunchProcess(ProcessLaunchInfo &launch_info) {
- Error error;
+Status Platform::LaunchProcess(ProcessLaunchInfo &launch_info) {
+ Status error;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
if (log)
log->Printf("Platform::%s()", __FUNCTION__);
@@ -1057,13 +1060,13 @@ Error Platform::LaunchProcess(ProcessLaunchInfo &launch_info) {
return error;
}
-Error Platform::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
+Status Platform::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
if (IsHost())
return Host::ShellExpandArguments(launch_info);
- return Error("base lldb_private::Platform class can't expand arguments");
+ return Status("base lldb_private::Platform class can't expand arguments");
}
-Error Platform::KillProcess(const lldb::pid_t pid) {
+Status Platform::KillProcess(const lldb::pid_t pid) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
if (log)
log->Printf("Platform::%s, pid %" PRIu64, __FUNCTION__, pid);
@@ -1083,19 +1086,19 @@ Error Platform::KillProcess(const lldb::pid_t pid) {
}
if (!IsHost()) {
- return Error(
+ return Status(
"base lldb_private::Platform class can't kill remote processes unless "
"they are controlled by a process plugin");
}
Host::Kill(pid, SIGTERM);
- return Error();
+ return Status();
}
lldb::ProcessSP
Platform::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
Target *target, // Can be nullptr, if nullptr create a
// new target, else use existing one
- Error &error) {
+ Status &error) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
if (log)
log->Printf("Platform::%s entered (target %p)", __FUNCTION__,
@@ -1186,7 +1189,7 @@ lldb::PlatformSP
Platform::GetPlatformForArchitecture(const ArchSpec &arch,
ArchSpec *platform_arch_ptr) {
lldb::PlatformSP platform_sp;
- Error error;
+ Status error;
if (arch.IsValid())
platform_sp = Platform::Create(arch, platform_arch_ptr, error);
return platform_sp;
@@ -1230,8 +1233,8 @@ bool Platform::IsCompatibleArchitecture(const ArchSpec &arch,
return false;
}
-Error Platform::PutFile(const FileSpec &source, const FileSpec &destination,
- uint32_t uid, uint32_t gid) {
+Status Platform::PutFile(const FileSpec &source, const FileSpec &destination,
+ uint32_t uid, uint32_t gid) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
if (log)
log->Printf("[PutFile] Using block by block transfer....\n");
@@ -1243,13 +1246,13 @@ Error Platform::PutFile(const FileSpec &source, const FileSpec &destination,
source_open_options |= File::eOpenOptionDontFollowSymlinks;
File source_file(source, source_open_options, lldb::eFilePermissionsUserRW);
- Error error;
+ Status error;
uint32_t permissions = source_file.GetPermissions(error);
if (permissions == 0)
permissions = lldb::eFilePermissionsFileDefault;
if (!source_file.IsValid())
- return Error("PutFile: unable to open source file");
+ return Status("PutFile: unable to open source file");
lldb::user_id_t dest_file = OpenFile(
destination, File::eOpenOptionCanCreate | File::eOpenOptionWrite |
File::eOpenOptionTruncate | File::eOpenOptionCloseOnExec,
@@ -1260,7 +1263,7 @@ Error Platform::PutFile(const FileSpec &source, const FileSpec &destination,
if (error.Fail())
return error;
if (dest_file == UINT64_MAX)
- return Error("unable to open target file");
+ return Status("unable to open target file");
lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024, 0));
uint64_t offset = 0;
for (;;) {
@@ -1291,16 +1294,16 @@ Error Platform::PutFile(const FileSpec &source, const FileSpec &destination,
return error;
}
-Error Platform::GetFile(const FileSpec &source, const FileSpec &destination) {
- Error error("unimplemented");
+Status Platform::GetFile(const FileSpec &source, const FileSpec &destination) {
+ Status error("unimplemented");
return error;
}
-Error Platform::CreateSymlink(
- const FileSpec &src, // The name of the link is in src
- const FileSpec &dst) // The symlink points to dst
+Status
+Platform::CreateSymlink(const FileSpec &src, // The name of the link is in src
+ const FileSpec &dst) // The symlink points to dst
{
- Error error("unimplemented");
+ Status error("unimplemented");
return error;
}
@@ -1308,8 +1311,8 @@ bool Platform::GetFileExists(const lldb_private::FileSpec &file_spec) {
return false;
}
-Error Platform::Unlink(const FileSpec &path) {
- Error error("unimplemented");
+Status Platform::Unlink(const FileSpec &path) {
+ Status error("unimplemented");
return error;
}
@@ -1323,7 +1326,7 @@ uint64_t Platform::ConvertMmapFlagsToPlatform(const ArchSpec &arch,
return flags_platform;
}
-lldb_private::Error Platform::RunShellCommand(
+lldb_private::Status Platform::RunShellCommand(
const char *command, // Shouldn't be nullptr
const FileSpec &
working_dir, // Pass empty FileSpec to use the current working directory
@@ -1339,7 +1342,7 @@ lldb_private::Error Platform::RunShellCommand(
return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr,
command_output, timeout_sec);
else
- return Error("unimplemented");
+ return Status("unimplemented");
}
bool Platform::CalculateMD5(const FileSpec &file_spec, uint64_t &low,
@@ -1402,11 +1405,11 @@ void OptionGroupPlatformRSync::OptionParsingStarting(
m_ignores_remote_hostname = false;
}
-lldb_private::Error
+lldb_private::Status
OptionGroupPlatformRSync::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
ExecutionContext *execution_context) {
- Error error;
+ Status error;
char short_option = (char)GetDefinitions()[option_idx].short_option;
switch (short_option) {
case 'r':
@@ -1448,11 +1451,11 @@ void OptionGroupPlatformSSH::OptionParsingStarting(
m_ssh_opts.clear();
}
-lldb_private::Error
+lldb_private::Status
OptionGroupPlatformSSH::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
ExecutionContext *execution_context) {
- Error error;
+ Status error;
char short_option = (char)GetDefinitions()[option_idx].short_option;
switch (short_option) {
case 's':
@@ -1480,10 +1483,10 @@ void OptionGroupPlatformCaching::OptionParsingStarting(
m_cache_dir.clear();
}
-lldb_private::Error OptionGroupPlatformCaching::SetOptionValue(
+lldb_private::Status OptionGroupPlatformCaching::SetOptionValue(
uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) {
- Error error;
+ Status error;
char short_option = (char)GetDefinitions()[option_idx].short_option;
switch (short_option) {
case 'c':
@@ -1514,10 +1517,9 @@ const std::vector<ConstString> &Platform::GetTrapHandlerSymbolNames() {
return m_trap_handlers;
}
-Error Platform::GetCachedExecutable(ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- Platform &remote_platform) {
+Status Platform::GetCachedExecutable(
+ ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr, Platform &remote_platform) {
const auto platform_spec = module_spec.GetFileSpec();
const auto error = LoadCachedExecutable(
module_spec, module_sp, module_search_paths_ptr, remote_platform);
@@ -1529,7 +1531,7 @@ Error Platform::GetCachedExecutable(ModuleSpec &module_spec,
return error;
}
-Error Platform::LoadCachedExecutable(
+Status Platform::LoadCachedExecutable(
const ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr, Platform &remote_platform) {
return GetRemoteSharedModule(module_spec, nullptr, module_sp,
@@ -1540,11 +1542,11 @@ Error Platform::LoadCachedExecutable(
nullptr);
}
-Error Platform::GetRemoteSharedModule(const ModuleSpec &module_spec,
- Process *process,
- lldb::ModuleSP &module_sp,
- const ModuleResolver &module_resolver,
- bool *did_create_ptr) {
+Status Platform::GetRemoteSharedModule(const ModuleSpec &module_spec,
+ Process *process,
+ lldb::ModuleSP &module_sp,
+ const ModuleResolver &module_resolver,
+ bool *did_create_ptr) {
// Get module information from a target.
ModuleSpec resolved_module_spec;
bool got_module_spec = false;
@@ -1561,7 +1563,7 @@ Error Platform::GetRemoteSharedModule(const ModuleSpec &module_spec,
}
if (module_spec.GetArchitecture().IsValid() == false) {
- Error error;
+ Status error;
// No valid architecture was specified, ask the platform for
// the architectures that we should be using (in the correct order)
// and see if we can find a match that way
@@ -1600,7 +1602,7 @@ Error Platform::GetRemoteSharedModule(const ModuleSpec &module_spec,
const auto error = module_resolver(resolved_module_spec);
if (error.Fail()) {
if (GetCachedSharedModule(resolved_module_spec, module_sp, did_create_ptr))
- return Error();
+ return Status();
}
return error;
@@ -1640,11 +1642,11 @@ bool Platform::GetCachedSharedModule(const ModuleSpec &module_spec,
return false;
}
-Error Platform::DownloadModuleSlice(const FileSpec &src_file_spec,
- const uint64_t src_offset,
- const uint64_t src_size,
- const FileSpec &dst_file_spec) {
- Error error;
+Status Platform::DownloadModuleSlice(const FileSpec &src_file_spec,
+ const uint64_t src_offset,
+ const uint64_t src_size,
+ const FileSpec &dst_file_spec) {
+ Status error;
std::error_code EC;
llvm::raw_fd_ostream dst(dst_file_spec.GetPath(), EC, llvm::sys::fs::F_None);
@@ -1682,15 +1684,15 @@ Error Platform::DownloadModuleSlice(const FileSpec &src_file_spec,
dst.write(&buffer[0], n_read);
}
- Error close_error;
+ Status close_error;
CloseFile(src_fd, close_error); // Ignoring close error.
return error;
}
-Error Platform::DownloadSymbolFile(const lldb::ModuleSP &module_sp,
- const FileSpec &dst_file_spec) {
- return Error(
+Status Platform::DownloadSymbolFile(const lldb::ModuleSP &module_sp,
+ const FileSpec &dst_file_spec) {
+ return Status(
"Symbol file downloading not supported by the default platform.");
}
@@ -1716,7 +1718,7 @@ const UnixSignalsSP &Platform::GetUnixSignals() {
uint32_t Platform::LoadImage(lldb_private::Process *process,
const lldb_private::FileSpec &local_file,
const lldb_private::FileSpec &remote_file,
- lldb_private::Error &error) {
+ lldb_private::Status &error) {
if (local_file && remote_file) {
// Both local and remote file was specified. Install the local file to the
// given location.
@@ -1752,21 +1754,21 @@ uint32_t Platform::LoadImage(lldb_private::Process *process,
uint32_t Platform::DoLoadImage(lldb_private::Process *process,
const lldb_private::FileSpec &remote_file,
- lldb_private::Error &error) {
+ lldb_private::Status &error) {
error.SetErrorString("LoadImage is not supported on the current platform");
return LLDB_INVALID_IMAGE_TOKEN;
}
-Error Platform::UnloadImage(lldb_private::Process *process,
- uint32_t image_token) {
- return Error("UnloadImage is not supported on the current platform");
+Status Platform::UnloadImage(lldb_private::Process *process,
+ uint32_t image_token) {
+ return Status("UnloadImage is not supported on the current platform");
}
lldb::ProcessSP Platform::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) {
error.Clear();
if (!target) {
@@ -1795,7 +1797,7 @@ lldb::ProcessSP Platform::ConnectProcess(llvm::StringRef connect_url,
}
size_t Platform::ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
- lldb_private::Error &error) {
+ lldb_private::Status &error) {
error.Clear();
return 0;
}
OpenPOWER on IntegriCloud