summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp82
-rw-r--r--lldb/source/Plugins/Platform/Linux/PlatformLinux.h28
2 files changed, 100 insertions, 10 deletions
diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
index a118a2b031d..f7b278ac281 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -10,27 +10,57 @@
#include "PlatformLinux.h"
// C Includes
+#include <stdio.h>
+#include <sys/utsname.h>
+
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Error.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
+#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
using namespace lldb;
using namespace lldb_private;
-
+
+Platform *
+PlatformLinux::CreateInstance ()
+{
+ return new PlatformLinux();
+}
+
+const char *
+PlatformLinux::GetPluginNameStatic()
+{
+ return "plugin.platform.linux";
+}
+
+const char *
+PlatformLinux::GetPluginDescriptionStatic()
+{
+ return "Default platform plugin for Linux";
+}
+
void
PlatformLinux::Initialize ()
{
-#if defined (__linux__)
- PlatformSP default_platform_sp (new PlatformLinux());
- Platform::SetDefaultPlatform (default_platform_sp);
-#endif
+ static bool g_initialized = false;
+
+ if (!g_initialized)
+ {
+ PlatformSP default_platform_sp (CreateInstance());
+ Platform::SetDefaultPlatform (default_platform_sp);
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(),
+ CreateInstance);
+ g_initialized = true;
+ }
}
void
@@ -146,7 +176,7 @@ PlatformLinux::GetFile (const FileSpec &platform_file, FileSpec &local_file)
/// Default Constructor
//------------------------------------------------------------------
PlatformLinux::PlatformLinux () :
- Platform()
+ Platform(true)
{
}
@@ -184,3 +214,43 @@ PlatformLinux::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
}
return false;
}
+
+void
+PlatformLinux::GetStatus (Stream &strm)
+{
+ struct utsname un;
+
+ if (uname(&un)) {
+ strm << "Linux";
+ return;
+ }
+
+ strm << un.sysname << ' ' << un.release << ' ' << un.version << '\n';
+}
+
+size_t
+PlatformLinux::GetSoftwareBreakpointTrapOpcode (Target &target,
+ BreakpointSite *bp_site)
+{
+ static const uint8_t g_i386_opcode[] = { 0xCC };
+
+ ArchSpec arch = target.GetArchitecture();
+ const uint8_t *opcode = NULL;
+ size_t opcode_size = 0;
+
+ switch (arch.GetCore())
+ {
+ default:
+ assert(false && "CPU type not supported!");
+ break;
+
+ case ArchSpec::eCore_x86_32_i386:
+ case ArchSpec::eCore_x86_64_x86_64:
+ opcode = g_i386_opcode;
+ opcode_size = sizeof(g_i386_opcode);
+ break;
+ }
+
+ bp_site->SetTrapOpcode(opcode, opcode_size);
+ return opcode_size;
+}
diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h
index c6ede767d5f..91fc3ecc14c 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h
@@ -36,16 +36,25 @@ namespace lldb_private {
//------------------------------------------------------------
// lldb_private::PluginInterface functions
//------------------------------------------------------------
+ static Platform *
+ CreateInstance ();
+
+ static const char *
+ GetPluginNameStatic();
+
+ static const char *
+ GetPluginDescriptionStatic();
+
virtual const char *
GetPluginName()
{
- return "PlatformLinux";
+ return GetPluginNameStatic();
}
virtual const char *
GetShortPluginName()
{
- return "platform.linux";
+ return "PlatformLinux";
}
virtual uint32_t
@@ -53,7 +62,6 @@ namespace lldb_private {
{
return 1;
}
-
//------------------------------------------------------------
// lldb_private::Platform functions
@@ -63,6 +71,15 @@ namespace lldb_private {
const ArchSpec &arch,
lldb::ModuleSP &module_sp);
+ virtual const char *
+ GetDescription ()
+ {
+ return GetPluginDescriptionStatic();
+ }
+
+ virtual void
+ GetStatus (Stream &strm);
+
virtual Error
GetFile (const FileSpec &platform_file, FileSpec &local_file);
@@ -77,12 +94,15 @@ namespace lldb_private {
virtual bool
GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch);
+ virtual size_t
+ GetSoftwareBreakpointTrapOpcode (Target &target,
+ BreakpointSite *bp_site);
+
protected:
private:
DISALLOW_COPY_AND_ASSIGN (PlatformLinux);
-
};
} // namespace lldb_private
OpenPOWER on IntegriCloud