[Lldb-commits] [lldb] r213158 - Add kalimba as a platform.

Todd Fiala todd.fiala at gmail.com
Wed Jul 16 08:03:13 PDT 2014


Author: tfiala
Date: Wed Jul 16 10:03:10 2014
New Revision: 213158

URL: http://llvm.org/viewvc/llvm-project?rev=213158&view=rev
Log:
Add kalimba as a platform.

This change comprises of additions and some minor changes in order that
"kalimba" is listed as a supported platform and that debugging any
kalimbas results in PlatformKalimba being associated with the target.

The changes are as follows:

* The PlatformKalimba implementation itself
* A tweak to ArchSpec
* .note parsing for Kalimba in ObjectFileELF.cpp
* Plugin registration
* Makefile additions

Change by Matthew Gardiner

Minor tweak for cmake and Xcode by Todd Fiala

Tested:
Ubuntu 14.04 x86_64, clang 3.5-built lldb, all tests pass.
MacOSX 10.9.4, Xcode 6.0 Beta 1-built lldb, all tests pass.

Added:
    lldb/trunk/source/Plugins/Platform/Kalimba/
    lldb/trunk/source/Plugins/Platform/Kalimba/CMakeLists.txt
    lldb/trunk/source/Plugins/Platform/Kalimba/Makefile
    lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
    lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.h
Modified:
    lldb/trunk/lib/Makefile
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/CMakeLists.txt
    lldb/trunk/source/Core/ArchSpec.cpp
    lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
    lldb/trunk/source/Plugins/Platform/CMakeLists.txt
    lldb/trunk/source/Plugins/Platform/Makefile
    lldb/trunk/source/lldb.cpp

Modified: lldb/trunk/lib/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=213158&r1=213157&r2=213158&view=diff
==============================================================================
--- lldb/trunk/lib/Makefile (original)
+++ lldb/trunk/lib/Makefile Wed Jul 16 10:03:10 2014
@@ -76,7 +76,8 @@ USEDLIBS = lldbAPI.a \
 	lldbPluginPlatformLinux.a \
 	lldbPluginPlatformWindows.a \
 	lldbPluginPlatformFreeBSD.a \
-	lldbPluginPlatformPOSIX.a
+	lldbPluginPlatformPOSIX.a \
+	lldbPluginPlatformKalimba.a
 
 # Because GCC requires RTTI enabled for lldbCore (see source/Core/Makefile) it is
 # necessary to also link the clang rewriter libraries so vtable references can

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=213158&r1=213157&r2=213158&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Jul 16 10:03:10 2014
@@ -51,6 +51,7 @@
 /* End PBXAggregateTarget section */
 
 /* Begin PBXBuildFile section */
+		23042D121976CA1D00621B2C /* PlatformKalimba.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23042D101976CA0A00621B2C /* PlatformKalimba.cpp */; };
 		23059A0719532B96007B8189 /* LinuxSignals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23059A0519532B96007B8189 /* LinuxSignals.cpp */; };
 		23059A101958B319007B8189 /* SBUnixSignals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23059A0F1958B319007B8189 /* SBUnixSignals.cpp */; };
 		23059A121958B3B2007B8189 /* SBUnixSignals.h in Headers */ = {isa = PBXBuildFile; fileRef = 23059A111958B37B007B8189 /* SBUnixSignals.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -890,6 +891,8 @@
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
+		23042D101976CA0A00621B2C /* PlatformKalimba.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformKalimba.cpp; sourceTree = "<group>"; };
+		23042D111976CA0A00621B2C /* PlatformKalimba.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformKalimba.h; sourceTree = "<group>"; };
 		23059A0519532B96007B8189 /* LinuxSignals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LinuxSignals.cpp; path = Utility/LinuxSignals.cpp; sourceTree = "<group>"; };
 		23059A0619532B96007B8189 /* LinuxSignals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LinuxSignals.h; path = Utility/LinuxSignals.h; sourceTree = "<group>"; };
 		23059A0F1958B319007B8189 /* SBUnixSignals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBUnixSignals.cpp; path = source/API/SBUnixSignals.cpp; sourceTree = "<group>"; };
@@ -2207,6 +2210,15 @@
 			sourceTree = "<group>";
 			usesTabs = 0;
 		};
+		23042D0F1976C9D800621B2C /* Kalimba */ = {
+			isa = PBXGroup;
+			children = (
+				23042D111976CA0A00621B2C /* PlatformKalimba.h */,
+				23042D101976CA0A00621B2C /* PlatformKalimba.cpp */,
+			);
+			path = Kalimba;
+			sourceTree = "<group>";
+		};
 		233B008B196106E90090E598 /* Linux */ = {
 			isa = PBXGroup;
 			children = (
@@ -3662,6 +3674,7 @@
 			children = (
 				2694E99814FC0BB30076DE67 /* FreeBSD */,
 				264A97BC133918A30017F0BE /* GDB Server */,
+				23042D0F1976C9D800621B2C /* Kalimba */,
 				2694E99F14FC0BBD0076DE67 /* Linux */,
 				26C5577F132575C8008FD8FE /* MacOSX */,
 				9457596415349416005A9070 /* POSIX */,
@@ -4648,6 +4661,7 @@
 				2689000F13353DB600698AC0 /* StoppointLocation.cpp in Sources */,
 				2689001113353DB600698AC0 /* Watchpoint.cpp in Sources */,
 				2689001213353DDE00698AC0 /* CommandObjectApropos.cpp in Sources */,
+				23042D121976CA1D00621B2C /* PlatformKalimba.cpp in Sources */,
 				2689001313353DDE00698AC0 /* CommandObjectArgs.cpp in Sources */,
 				2689001413353DDE00698AC0 /* CommandObjectBreakpoint.cpp in Sources */,
 				2689001513353DDE00698AC0 /* CommandObjectBreakpointCommand.cpp in Sources */,

Modified: lldb/trunk/source/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/CMakeLists.txt?rev=213158&r1=213157&r2=213158&view=diff
==============================================================================
--- lldb/trunk/source/CMakeLists.txt (original)
+++ lldb/trunk/source/CMakeLists.txt Wed Jul 16 10:03:10 2014
@@ -61,6 +61,7 @@ set( LLDB_USED_LIBS
   lldbPluginProcessUtility
   lldbPluginPlatformGDB
   lldbPluginPlatformFreeBSD
+  lldbPluginPlatformKalimba
   lldbPluginPlatformLinux
   lldbPluginPlatformPOSIX
   lldbPluginPlatformWindows

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=213158&r1=213157&r2=213158&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Wed Jul 16 10:03:10 2014
@@ -115,7 +115,7 @@ static const CoreDefinition g_core_defin
     { eByteOrderLittle, 4, 4, 4 , llvm::Triple::UnknownArch , ArchSpec::eCore_uknownMach32  , "unknown-mach-32" },
     { eByteOrderLittle, 8, 4, 4 , llvm::Triple::UnknownArch , ArchSpec::eCore_uknownMach64  , "unknown-mach-64" },
 
-    { eByteOrderLittle, 4, 1, 1 , llvm::Triple::UnknownArch , ArchSpec::eCore_kalimba  , "kalimba" }
+    { eByteOrderLittle, 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba  , "kalimba" }
 };
 
 struct ArchDefinitionEntry

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=213158&r1=213157&r2=213158&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Wed Jul 16 10:03:10 2014
@@ -46,6 +46,7 @@ namespace {
 const char *const LLDB_NT_OWNER_FREEBSD = "FreeBSD";
 const char *const LLDB_NT_OWNER_GNU     = "GNU";
 const char *const LLDB_NT_OWNER_NETBSD  = "NetBSD";
+const char *const LLDB_NT_OWNER_CSR     = "csr";
 
 // ELF note type definitions
 const elf_word LLDB_NT_FREEBSD_ABI_TAG  = 0x01;
@@ -1221,6 +1222,24 @@ ObjectFileELF::RefineModuleDetailsFromNo
             if (log)
                 log->Printf ("ObjectFileELF::%s detected NetBSD, min version constant %" PRIu32, __FUNCTION__, version_info);
         }
+        // Process CSR kalimba notes
+        else if ((note.n_type == LLDB_NT_GNU_ABI_TAG) &&
+                (note.n_name == LLDB_NT_OWNER_CSR))
+        {
+            // We'll consume the payload below.
+            processed = true;
+            arch_spec.GetTriple().setOS(llvm::Triple::OSType::UnknownOS);
+            arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::CSR);
+
+            // TODO At some point the description string could be processed.
+            // It could provide a steer towards the kalimba variant which
+            // this ELF targets.
+            if(note.n_descsz)
+            {
+                const char *cstr = data.GetCStr(&offset, llvm::RoundUpToAlignment (note.n_descsz, 4));
+                (void)cstr;
+            }
+        }
 
         if (!processed)
             offset += llvm::RoundUpToAlignment(note.n_descsz, 4);

Modified: lldb/trunk/source/Plugins/Platform/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/CMakeLists.txt?rev=213158&r1=213157&r2=213158&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/Platform/CMakeLists.txt Wed Jul 16 10:03:10 2014
@@ -10,3 +10,4 @@
 
 add_subdirectory(POSIX)
 add_subdirectory(gdb-server)
+add_subdirectory(Kalimba)

Added: lldb/trunk/source/Plugins/Platform/Kalimba/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Kalimba/CMakeLists.txt?rev=213158&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Kalimba/CMakeLists.txt (added)
+++ lldb/trunk/source/Plugins/Platform/Kalimba/CMakeLists.txt Wed Jul 16 10:03:10 2014
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginPlatformKalimba
+  PlatformKalimba.cpp
+  )

Added: lldb/trunk/source/Plugins/Platform/Kalimba/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Kalimba/Makefile?rev=213158&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Kalimba/Makefile (added)
+++ lldb/trunk/source/Plugins/Platform/Kalimba/Makefile Wed Jul 16 10:03:10 2014
@@ -0,0 +1,14 @@
+##===- source/Plugins/Platform/Kalimba/Makefile --------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LLDB_LEVEL := ../../../..
+LIBRARYNAME := lldbPluginPlatformKalimba
+BUILD_ARCHIVE = 1
+
+include $(LLDB_LEVEL)/Makefile

Added: lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp?rev=213158&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp (added)
+++ lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp Wed Jul 16 10:03:10 2014
@@ -0,0 +1,331 @@
+//===-- PlatformKalimba.cpp ---------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/lldb-python.h"
+
+#include "PlatformKalimba.h"
+#include "lldb/Host/Config.h"
+
+// C Includes
+#include <stdio.h>
+#ifndef LLDB_DISABLE_POSIX
+#include <sys/utsname.h>
+#endif
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleList.h"
+#include "lldb/Core/ModuleSpec.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;
+
+static uint32_t g_initialize_count = 0;
+
+Platform *
+PlatformKalimba::CreateInstance (bool force, const ArchSpec *arch)
+{
+    bool create = force;
+    if (create == false && arch && arch->IsValid())
+    {
+        const llvm::Triple &triple = arch->GetTriple();
+        switch (triple.getVendor())
+        {
+            case llvm::Triple::CSR:
+                create = true;
+                break;
+
+            default:
+                break;
+        }
+    }
+    if (create)
+        return new PlatformKalimba(false);
+    return NULL;
+}
+
+lldb_private::ConstString
+PlatformKalimba::GetPluginNameStatic (bool /*is_host*/)
+{
+    static ConstString g_remote_name("kalimba");
+    return g_remote_name;
+}
+
+const char *
+PlatformKalimba::GetPluginDescriptionStatic (bool /*is_host*/)
+{
+    return "Kalimba user platform plug-in.";
+}
+
+lldb_private::ConstString
+PlatformKalimba::GetPluginName()
+{
+    return GetPluginNameStatic(false);
+}
+
+void
+PlatformKalimba::Initialize ()
+{
+    if (g_initialize_count++ == 0)
+    {
+        PluginManager::RegisterPlugin(PlatformKalimba::GetPluginNameStatic(false),
+                                      PlatformKalimba::GetPluginDescriptionStatic(false),
+                                      PlatformKalimba::CreateInstance);
+    }
+}
+
+void
+PlatformKalimba::Terminate ()
+{
+    if (g_initialize_count > 0)
+    {
+        if (--g_initialize_count == 0)
+        {
+            PluginManager::UnregisterPlugin (PlatformKalimba::CreateInstance);
+        }
+    }
+}
+
+Error
+PlatformKalimba::ResolveExecutable (const FileSpec &exe_file,
+                                  const ArchSpec &exe_arch,
+                                  lldb::ModuleSP &exe_module_sp,
+                                  const FileSpecList *module_search_paths_ptr)
+{
+    Error error;
+    char exe_path[PATH_MAX];
+    FileSpec resolved_exe_file (exe_file);
+
+    if (!resolved_exe_file.Exists())
+    {
+        exe_file.GetPath(exe_path, sizeof(exe_path));
+        error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path);
+    }
+
+    if (error.Success())
+    {
+        ModuleSpec module_spec (resolved_exe_file, exe_arch);
+        if (exe_arch.IsValid())
+        {
+            error = ModuleList::GetSharedModule (module_spec, 
+                                                 exe_module_sp, 
+                                                 NULL, 
+                                                 NULL,
+                                                 NULL);
+            if (error.Fail())
+            {
+                // If we failed, it may be because the vendor and os aren't known. If that is the
+                // case, try setting them to the host architecture and give it another try.
+                llvm::Triple &module_triple = module_spec.GetArchitecture().GetTriple(); 
+                bool is_vendor_specified = (module_triple.getVendor() != llvm::Triple::UnknownVendor);
+                bool is_os_specified = (module_triple.getOS() != llvm::Triple::UnknownOS);
+                if (!is_vendor_specified || !is_os_specified)
+                {
+                    const llvm::Triple &host_triple = Host::GetArchitecture (Host::eSystemDefaultArchitecture).GetTriple();
+
+                    if (!is_vendor_specified)
+                        module_triple.setVendorName (host_triple.getVendorName());
+                    if (!is_os_specified)
+                        module_triple.setOSName (host_triple.getOSName());
+
+                    error = ModuleList::GetSharedModule (module_spec, 
+                                                         exe_module_sp, 
+                                                         NULL, 
+                                                         NULL,
+                                                         NULL);
+                }
+            }
+        
+            // TODO find out why exe_module_sp might be NULL            
+            if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL)
+            {
+                exe_module_sp.reset();
+                error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",
+                                                exe_file.GetPath().c_str(),
+                                                exe_arch.GetArchitectureName());
+            }
+        }
+        else
+        {
+            // 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
+            StreamString arch_names;
+            for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx)
+            {
+                error = ModuleList::GetSharedModule (module_spec, 
+                                                     exe_module_sp, 
+                                                     NULL, 
+                                                     NULL,
+                                                     NULL);
+                // Did we find an executable using one of the 
+                if (error.Success())
+                {
+                    if (exe_module_sp && exe_module_sp->GetObjectFile())
+                        break;
+                    else
+                        error.SetErrorToGenericError();
+                }
+                
+                if (idx > 0)
+                    arch_names.PutCString (", ");
+                arch_names.PutCString (module_spec.GetArchitecture().GetArchitectureName());
+            }
+            
+            if (error.Fail() || !exe_module_sp)
+            {
+                error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
+                                                exe_file.GetPath().c_str(),
+                                                GetPluginName().GetCString(),
+                                                arch_names.GetString().c_str());
+            }
+        }
+    }
+
+    return error;
+}
+
+Error
+PlatformKalimba::GetFileWithUUID (const FileSpec &/*platform_file*/, 
+                                const UUID */*uuid_ptr*/, FileSpec &/*local_file*/)
+{
+    return Error();
+}
+
+
+//------------------------------------------------------------------
+/// Default Constructor
+//------------------------------------------------------------------
+PlatformKalimba::PlatformKalimba (bool is_host) :
+    Platform(is_host),  // This is the local host platform
+    m_remote_platform_sp ()
+{
+}
+
+//------------------------------------------------------------------
+/// Destructor.
+///
+/// The destructor is virtual since this class is designed to be
+/// inherited from by the plug-in instance.
+//------------------------------------------------------------------
+PlatformKalimba::~PlatformKalimba()
+{
+}
+
+bool
+PlatformKalimba::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
+{
+    bool success = false;
+    if (IsHost())
+    {
+        success = false;
+    }
+    else
+    {
+        if (m_remote_platform_sp) 
+            success = m_remote_platform_sp->GetProcessInfo (pid, process_info);
+    }
+    return success;
+}
+
+bool
+PlatformKalimba::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
+{
+    if (idx == 0)
+    {
+        arch = ArchSpec("kalimba-csr-unknown");
+        return true;
+    }
+    return false;
+}
+
+void
+PlatformKalimba::GetStatus (Stream &strm)
+{
+    Platform::GetStatus(strm);
+}
+
+size_t
+PlatformKalimba::GetSoftwareBreakpointTrapOpcode (Target &/*target*/, 
+                                                BreakpointSite */*bp_site*/)
+{
+    // the target hardware does not support software breakpoints
+    return 0;
+}
+
+Error
+PlatformKalimba::LaunchProcess (ProcessLaunchInfo &launch_info)
+{
+    Error error;
+    
+    if (IsHost())
+    {
+        error.SetErrorString ("native execution is not possible");
+    }
+    else
+    {
+        error.SetErrorString ("the platform is not currently connected");
+    }
+    return error;
+}
+
+lldb::ProcessSP
+PlatformKalimba::Attach(ProcessAttachInfo &attach_info,
+                      Debugger &debugger,
+                      Target *target,
+                      Listener &listener,
+                      Error &error)
+{
+    lldb::ProcessSP process_sp;
+    if (IsHost())
+    {
+        error.SetErrorString ("native execution is not possible");
+    }
+    else
+    {
+        if (m_remote_platform_sp)
+            process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, listener, error);
+        else
+            error.SetErrorString ("the platform is not currently connected");
+    }
+    return process_sp;
+}
+
+void
+PlatformKalimba::CalculateTrapHandlerSymbolNames ()
+{   
+}   
+
+Error
+PlatformKalimba::LaunchNativeProcess (
+    ProcessLaunchInfo &,
+    lldb_private::NativeProcessProtocol::NativeDelegate &,
+    NativeProcessProtocolSP &)
+{
+    return Error();
+}
+
+Error
+PlatformKalimba::AttachNativeProcess (lldb::pid_t,
+                                    lldb_private::NativeProcessProtocol::NativeDelegate &,
+                                    NativeProcessProtocolSP &)
+{
+    return Error();
+}
+

Added: lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.h?rev=213158&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.h (added)
+++ lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.h Wed Jul 16 10:03:10 2014
@@ -0,0 +1,125 @@
+//===-- PlatformKalimba.h -----------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_PlatformKalimba_h_
+#define liblldb_PlatformKalimba_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Target/Platform.h"
+
+namespace lldb_private {
+
+    class PlatformKalimba : public Platform
+    {
+    public:
+
+        static void
+        Initialize ();
+
+        static void
+        Terminate ();
+        
+        PlatformKalimba (bool is_host);
+
+        virtual
+        ~PlatformKalimba();
+
+        //------------------------------------------------------------
+        // lldb_private::PluginInterface functions
+        //------------------------------------------------------------
+        static Platform *
+        CreateInstance (bool force, const lldb_private::ArchSpec *arch);
+
+        static lldb_private::ConstString
+        GetPluginNameStatic (bool is_host);
+
+        static const char *
+        GetPluginDescriptionStatic (bool is_host);
+
+        virtual lldb_private::ConstString
+        GetPluginName();
+        
+        virtual uint32_t
+        GetPluginVersion()
+        {
+            return 1;
+        }
+
+        //------------------------------------------------------------
+        // lldb_private::Platform functions
+        //------------------------------------------------------------
+        virtual Error
+        ResolveExecutable (const FileSpec &exe_file,
+                           const ArchSpec &arch,
+                           lldb::ModuleSP &module_sp,
+                           const FileSpecList *module_search_paths_ptr);
+
+        virtual const char *
+        GetDescription ()
+        {
+            return GetPluginDescriptionStatic(IsHost());
+        }
+
+        virtual void
+        GetStatus (Stream &strm);
+
+        virtual Error
+        GetFileWithUUID (const FileSpec &platform_file,
+                         const UUID* uuid, FileSpec &local_file);
+
+        virtual bool
+        GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info);
+
+        virtual bool
+        GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch);
+
+        virtual size_t
+        GetSoftwareBreakpointTrapOpcode (Target &target, 
+                                         BreakpointSite *bp_site);
+
+        virtual lldb_private::Error
+        LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info);
+
+        virtual lldb::ProcessSP
+        Attach(ProcessAttachInfo &attach_info, Debugger &debugger,
+               Target *target, Listener &listener, Error &error);
+
+        // Kalimba processes can not be launched by spawning and attaching.
+        virtual bool
+        CanDebugProcess ()
+        {
+            return false;
+        }
+
+        virtual void
+        CalculateTrapHandlerSymbolNames ();
+
+        Error
+        LaunchNativeProcess (
+            ProcessLaunchInfo &launch_info,
+            lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate,
+            NativeProcessProtocolSP &process_sp) override;
+
+        Error
+        AttachNativeProcess (lldb::pid_t pid,
+                             lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate,
+                             NativeProcessProtocolSP &process_sp) override;
+
+    protected:
+        lldb::PlatformSP m_remote_platform_sp;
+
+    private:
+        DISALLOW_COPY_AND_ASSIGN (PlatformKalimba);
+    };
+} // namespace lldb_private
+
+#endif  // liblldb_PlatformKalimba_h_

Modified: lldb/trunk/source/Plugins/Platform/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Makefile?rev=213158&r1=213157&r2=213158&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Makefile (original)
+++ lldb/trunk/source/Plugins/Platform/Makefile Wed Jul 16 10:03:10 2014
@@ -11,7 +11,7 @@ LLDB_LEVEL := ../../..
 
 include $(LLDB_LEVEL)/../../Makefile.config
 
-DIRS := gdb-server MacOSX Linux FreeBSD POSIX Windows
+DIRS := gdb-server MacOSX Linux FreeBSD POSIX Windows Kalimba
 
 # ifeq ($(HOST_OS),Darwin)
 #   DIRS += MacOSX

Modified: lldb/trunk/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=213158&r1=213157&r2=213158&view=diff
==============================================================================
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Wed Jul 16 10:03:10 2014
@@ -43,6 +43,7 @@
 #include "Plugins/Platform/Linux/PlatformLinux.h"
 #include "Plugins/Platform/POSIX/PlatformPOSIX.h"
 #include "Plugins/Platform/Windows/PlatformWindows.h"
+#include "Plugins/Platform/Kalimba/PlatformKalimba.h"
 #include "Plugins/Process/elf-core/ProcessElfCore.h"
 #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
 #include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
@@ -123,6 +124,7 @@ lldb_private::Initialize ()
         PlatformFreeBSD::Initialize();
         PlatformLinux::Initialize();
         PlatformWindows::Initialize();
+        PlatformKalimba::Initialize();
         SymbolFileDWARFDebugMap::Initialize();
         ItaniumABILanguageRuntime::Initialize();
 #ifndef LLDB_DISABLE_PYTHON
@@ -210,6 +212,7 @@ lldb_private::Terminate ()
     PlatformFreeBSD::Terminate();
     PlatformLinux::Terminate();
     PlatformWindows::Terminate();
+    PlatformKalimba::Terminate();
     SymbolFileDWARFDebugMap::Terminate();
     ItaniumABILanguageRuntime::Terminate();
 #ifndef LLDB_DISABLE_PYTHON





More information about the lldb-commits mailing list