summaryrefslogtreecommitdiff
path: root/source/Plugins/Platform/POSIX
diff options
context:
space:
mode:
Diffstat (limited to 'source/Plugins/Platform/POSIX')
-rw-r--r--source/Plugins/Platform/POSIX/PlatformPOSIX.cpp91
-rw-r--r--source/Plugins/Platform/POSIX/PlatformPOSIX.h84
2 files changed, 104 insertions, 71 deletions
diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 5b72728c2b48..fe425e02103b 100644
--- a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -24,6 +24,7 @@
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
+#include "lldb/Target/Process.h"
#include "lldb/Target/ProcessLaunchInfo.h"
using namespace lldb;
@@ -49,6 +50,17 @@ PlatformPOSIX::~PlatformPOSIX()
{
}
+bool
+PlatformPOSIX::GetModuleSpec (const FileSpec& module_file_spec,
+ const ArchSpec& arch,
+ ModuleSpec &module_spec)
+{
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetModuleSpec (module_file_spec, arch, module_spec);
+
+ return Platform::GetModuleSpec (module_file_spec, arch, module_spec);
+}
+
lldb_private::OptionGroupOptions*
PlatformPOSIX::GetConnectionOptions (lldb_private::CommandInterpreter& interpreter)
{
@@ -73,12 +85,12 @@ PlatformPOSIX::IsConnected () const
}
lldb_private::Error
-PlatformPOSIX::RunShellCommand (const char *command, // Shouldn't be NULL
- const char *working_dir, // Pass NULL to use the current working directory
- int *status_ptr, // Pass NULL if you don't want the process exit status
- int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
- std::string *command_output, // Pass NULL if you don't want the command output
- uint32_t timeout_sec) // Timeout in seconds to wait for shell program to finish
+PlatformPOSIX::RunShellCommand(const char *command, // Shouldn't be NULL
+ const FileSpec &working_dir, // Pass empty FileSpec to use the current working directory
+ int *status_ptr, // Pass NULL if you don't want the process exit status
+ int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
+ std::string *command_output, // Pass NULL if you don't want the command output
+ uint32_t timeout_sec) // Timeout in seconds to wait for shell program to finish
{
if (IsHost())
return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec);
@@ -92,30 +104,30 @@ PlatformPOSIX::RunShellCommand (const char *command, // Shouldn't be N
}
Error
-PlatformPOSIX::MakeDirectory (const char *path, uint32_t file_permissions)
+PlatformPOSIX::MakeDirectory(const FileSpec &file_spec, uint32_t file_permissions)
{
if (m_remote_platform_sp)
- return m_remote_platform_sp->MakeDirectory(path, file_permissions);
+ return m_remote_platform_sp->MakeDirectory(file_spec, file_permissions);
else
- return Platform::MakeDirectory(path ,file_permissions);
+ return Platform::MakeDirectory(file_spec ,file_permissions);
}
Error
-PlatformPOSIX::GetFilePermissions (const char *path, uint32_t &file_permissions)
+PlatformPOSIX::GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions)
{
if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFilePermissions(path, file_permissions);
+ return m_remote_platform_sp->GetFilePermissions(file_spec, file_permissions);
else
- return Platform::GetFilePermissions(path ,file_permissions);
+ return Platform::GetFilePermissions(file_spec ,file_permissions);
}
Error
-PlatformPOSIX::SetFilePermissions (const char *path, uint32_t file_permissions)
+PlatformPOSIX::SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions)
{
if (m_remote_platform_sp)
- return m_remote_platform_sp->SetFilePermissions(path, file_permissions);
+ return m_remote_platform_sp->SetFilePermissions(file_spec, file_permissions);
else
- return Platform::SetFilePermissions(path ,file_permissions);
+ return Platform::SetFilePermissions(file_spec, file_permissions);
}
lldb::user_id_t
@@ -304,7 +316,7 @@ PlatformPOSIX::GetFileSize (const FileSpec& file_spec)
}
Error
-PlatformPOSIX::CreateSymlink(const char *src, const char *dst)
+PlatformPOSIX::CreateSymlink(const FileSpec &src, const FileSpec &dst)
{
if (IsHost())
return FileSystem::Symlink(src, dst);
@@ -326,19 +338,19 @@ PlatformPOSIX::GetFileExists (const FileSpec& file_spec)
}
Error
-PlatformPOSIX::Unlink (const char *path)
+PlatformPOSIX::Unlink(const FileSpec &file_spec)
{
if (IsHost())
- return FileSystem::Unlink(path);
+ return FileSystem::Unlink(file_spec);
else if (m_remote_platform_sp)
- return m_remote_platform_sp->Unlink(path);
+ return m_remote_platform_sp->Unlink(file_spec);
else
- return Platform::Unlink(path);
+ return Platform::Unlink(file_spec);
}
lldb_private::Error
-PlatformPOSIX::GetFile (const lldb_private::FileSpec& source /* remote file path */,
- const lldb_private::FileSpec& destination /* local file path */)
+PlatformPOSIX::GetFile(const lldb_private::FileSpec &source, // remote file path
+ const lldb_private::FileSpec &destination) // local file path
{
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
@@ -421,8 +433,8 @@ PlatformPOSIX::GetFile (const lldb_private::FileSpec& source /* remote file path
return Error("unable to open source file");
uint32_t permissions = 0;
- error = GetFilePermissions(source.GetPath().c_str(), permissions);
-
+ error = GetFilePermissions(source, permissions);
+
if (permissions == 0)
permissions = lldb::eFilePermissionsFileDefault;
@@ -523,7 +535,7 @@ PlatformPOSIX::CalculateMD5 (const FileSpec& file_spec,
return false;
}
-lldb_private::ConstString
+FileSpec
PlatformPOSIX::GetRemoteWorkingDirectory()
{
if (IsRemote() && m_remote_platform_sp)
@@ -533,12 +545,12 @@ PlatformPOSIX::GetRemoteWorkingDirectory()
}
bool
-PlatformPOSIX::SetRemoteWorkingDirectory(const lldb_private::ConstString &path)
+PlatformPOSIX::SetRemoteWorkingDirectory(const FileSpec &working_dir)
{
if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->SetRemoteWorkingDirectory(path);
+ return m_remote_platform_sp->SetRemoteWorkingDirectory(working_dir);
else
- return Platform::SetRemoteWorkingDirectory(path);
+ return Platform::SetRemoteWorkingDirectory(working_dir);
}
bool
@@ -653,9 +665,9 @@ PlatformPOSIX::ConnectRemote (Args& args)
if (m_options.get())
{
OptionGroupOptions* options = m_options.get();
- OptionGroupPlatformRSync* m_rsync_options = (OptionGroupPlatformRSync*)options->GetGroupWithOption('r');
- OptionGroupPlatformSSH* m_ssh_options = (OptionGroupPlatformSSH*)options->GetGroupWithOption('s');
- OptionGroupPlatformCaching* m_cache_options = (OptionGroupPlatformCaching*)options->GetGroupWithOption('c');
+ const OptionGroupPlatformRSync* m_rsync_options = (OptionGroupPlatformRSync*)options->GetGroupWithOption('r');
+ const OptionGroupPlatformSSH* m_ssh_options = (OptionGroupPlatformSSH*)options->GetGroupWithOption('s');
+ const OptionGroupPlatformCaching* m_cache_options = (OptionGroupPlatformCaching*)options->GetGroupWithOption('c');
if (m_rsync_options->m_rsync)
{
@@ -714,6 +726,18 @@ PlatformPOSIX::LaunchProcess (ProcessLaunchInfo &launch_info)
return error;
}
+lldb_private::Error
+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");
+}
+
lldb::ProcessSP
PlatformPOSIX::Attach (ProcessAttachInfo &attach_info,
Debugger &debugger,
@@ -752,9 +776,8 @@ PlatformPOSIX::Attach (ProcessAttachInfo &attach_info,
if (log)
{
ModuleSP exe_module_sp = target->GetExecutableModule ();
- log->Printf ("PlatformPOSIX::%s set selected target to %p %s", __FUNCTION__,
- target,
- exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str () : "<null>" );
+ log->Printf("PlatformPOSIX::%s set selected target to %p %s", __FUNCTION__, (void *)target,
+ exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str() : "<null>");
}
diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/source/Plugins/Platform/POSIX/PlatformPOSIX.h
index aae415e6eefa..19a3f0c4eef1 100644
--- a/source/Plugins/Platform/POSIX/PlatformPOSIX.h
+++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.h
@@ -31,7 +31,13 @@ public:
//------------------------------------------------------------
// lldb_private::Platform functions
//------------------------------------------------------------
- virtual lldb_private::OptionGroupOptions
+
+ bool
+ GetModuleSpec (const lldb_private::FileSpec& module_file_spec,
+ const lldb_private::ArchSpec& arch,
+ lldb_private::ModuleSpec &module_spec) override;
+
+ lldb_private::OptionGroupOptions
*GetConnectionOptions(
lldb_private::CommandInterpreter &interpreter) override;
@@ -44,51 +50,52 @@ public:
const char *
GetGroupName (uint32_t gid) override;
- virtual lldb_private::Error
+ lldb_private::Error
PutFile (const lldb_private::FileSpec& source,
const lldb_private::FileSpec& destination,
uint32_t uid = UINT32_MAX,
uint32_t gid = UINT32_MAX) override;
- virtual lldb::user_id_t
+ lldb::user_id_t
OpenFile (const lldb_private::FileSpec& file_spec,
uint32_t flags,
uint32_t mode,
lldb_private::Error &error) override;
- virtual bool
+ bool
CloseFile (lldb::user_id_t fd,
lldb_private::Error &error) override;
- virtual uint64_t
+ uint64_t
ReadFile (lldb::user_id_t fd,
uint64_t offset,
void *dst,
uint64_t dst_len,
lldb_private::Error &error) override;
- virtual uint64_t
+ uint64_t
WriteFile (lldb::user_id_t fd,
uint64_t offset,
const void* src,
uint64_t src_len,
lldb_private::Error &error) override;
- virtual lldb::user_id_t
+ lldb::user_id_t
GetFileSize (const lldb_private::FileSpec& file_spec) override;
- virtual lldb_private::Error
- CreateSymlink(const char *src, const char *dst) override;
+ lldb_private::Error
+ CreateSymlink(const lldb_private::FileSpec &src,
+ const lldb_private::FileSpec &dst) override;
+
+ lldb_private::Error
+ GetFile(const lldb_private::FileSpec &source,
+ const lldb_private::FileSpec &destination) override;
- virtual lldb_private::Error
- GetFile (const lldb_private::FileSpec& source,
- const lldb_private::FileSpec& destination) override;
-
- virtual lldb_private::ConstString
+ lldb_private::FileSpec
GetRemoteWorkingDirectory() override;
- virtual bool
- SetRemoteWorkingDirectory(const lldb_private::ConstString &path) override;
+ bool
+ SetRemoteWorkingDirectory(const lldb_private::FileSpec &working_dir) override;
bool
GetRemoteOSVersion () override;
@@ -108,32 +115,35 @@ public:
bool
IsConnected () const override;
- virtual lldb_private::Error
- RunShellCommand (const char *command, // Shouldn't be NULL
- const char *working_dir, // Pass NULL to use the current working directory
- int *status_ptr, // Pass NULL if you don't want the process exit status
- int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
- std::string *command_output, // Pass NULL if you don't want the command output
- uint32_t timeout_sec) override;// Timeout in seconds to wait for shell program to finish
-
- virtual lldb_private::Error
- MakeDirectory (const char *path, uint32_t mode) override;
-
- virtual lldb_private::Error
- GetFilePermissions (const char *path, uint32_t &file_permissions) override;
+ lldb_private::Error
+ RunShellCommand(const char *command, // Shouldn't be NULL
+ const lldb_private::FileSpec &working_dir, // Pass empty FileSpec to use the current working directory
+ int *status_ptr, // Pass NULL if you don't want the process exit status
+ int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
+ std::string *command_output, // Pass NULL if you don't want the command output
+ uint32_t timeout_sec) override; // Timeout in seconds to wait for shell program to finish
+
+ lldb_private::Error
+ MakeDirectory(const lldb_private::FileSpec &file_spec, uint32_t mode) override;
- virtual lldb_private::Error
- SetFilePermissions (const char *path, uint32_t file_permissions) override;
+ lldb_private::Error
+ GetFilePermissions(const lldb_private::FileSpec &file_spec, uint32_t &file_permissions) override;
+
+ lldb_private::Error
+ SetFilePermissions(const lldb_private::FileSpec &file_spec, uint32_t file_permissions) override;
- virtual bool
+ bool
GetFileExists (const lldb_private::FileSpec& file_spec) override;
- virtual lldb_private::Error
- Unlink (const char *path) override;
+ lldb_private::Error
+ Unlink(const lldb_private::FileSpec &file_spec) override;
lldb_private::Error
LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info) override;
+ lldb_private::Error
+ KillProcess (const lldb::pid_t pid) override;
+
lldb::ProcessSP
Attach (lldb_private::ProcessAttachInfo &attach_info,
lldb_private::Debugger &debugger,
@@ -146,15 +156,15 @@ public:
lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one
lldb_private::Error &error) override;
- virtual std::string
+ std::string
GetPlatformSpecificConnectionInformation() override;
- virtual bool
+ bool
CalculateMD5 (const lldb_private::FileSpec& file_spec,
uint64_t &low,
uint64_t &high) override;
- virtual void
+ void
CalculateTrapHandlerSymbolNames () override;
lldb_private::Error