<div dir="ltr">Hi Matthew,<div><br></div><div>One thing you might want to consider doing is adding a test to verify Kalimba ObjectFileELF parsing doesn't regress using this test here: test/functionalities/object-file/TestImageListMultiArchitecture.py.</div>
<div><br></div><div>Essentially you start by looking under that test's bin/ dir. You'll see a hello.cpp file and several exes built on different platforms (checked in) that represent valid object files for that platform.  You could go into that directory and do something like this:</div>
<div><br></div><div>/your/compiler/exe -o hello-kalimba-{kalimba-version}-{your-compiler} hello.cpp</div><div><br></div><div>Then edit the TestImageMultiArchitecture.py file, and add an entry to the table that specifies expected image list output for your exe.</div>
<div><br></div><div>The idea here is that, if we get a test that correctly identifies a kalimba file and have that checked in, we'll get a heads up if any other changes (likely changes to ObjectFileELF.cpp) end up unexpectedly breaking Kalimba object file support.</div>
<div><br></div><div>If you can get that together, I'll gladly help you get that checked in.</div><div><br></div><div>For this test, there's no reason to generate copious debug info since all we're really validating is the ObjectFileELF platform recognition.  I built all those exes in there optimized for small file size since we check in the exe (well, not including -g on the compiler line in particular).</div>
<div><br></div><div>Thanks!</div><div><br></div><div>-Todd</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 16, 2014 at 8:03 AM, Todd Fiala <span dir="ltr"><<a href="mailto:todd.fiala@gmail.com" target="_blank">todd.fiala@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: tfiala<br>
Date: Wed Jul 16 10:03:10 2014<br>
New Revision: 213158<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=213158&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=213158&view=rev</a><br>
Log:<br>
Add kalimba as a platform.<br>
<br>
This change comprises of additions and some minor changes in order that<br>
"kalimba" is listed as a supported platform and that debugging any<br>
kalimbas results in PlatformKalimba being associated with the target.<br>
<br>
The changes are as follows:<br>
<br>
* The PlatformKalimba implementation itself<br>
* A tweak to ArchSpec<br>
* .note parsing for Kalimba in ObjectFileELF.cpp<br>
* Plugin registration<br>
* Makefile additions<br>
<br>
Change by Matthew Gardiner<br>
<br>
Minor tweak for cmake and Xcode by Todd Fiala<br>
<br>
Tested:<br>
Ubuntu 14.04 x86_64, clang 3.5-built lldb, all tests pass.<br>
MacOSX 10.9.4, Xcode 6.0 Beta 1-built lldb, all tests pass.<br>
<br>
Added:<br>
    lldb/trunk/source/Plugins/Platform/Kalimba/<br>
    lldb/trunk/source/Plugins/Platform/Kalimba/CMakeLists.txt<br>
    lldb/trunk/source/Plugins/Platform/Kalimba/Makefile<br>
    lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp<br>
    lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.h<br>
Modified:<br>
    lldb/trunk/lib/Makefile<br>
    lldb/trunk/lldb.xcodeproj/project.pbxproj<br>
    lldb/trunk/source/CMakeLists.txt<br>
    lldb/trunk/source/Core/ArchSpec.cpp<br>
    lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp<br>
    lldb/trunk/source/Plugins/Platform/CMakeLists.txt<br>
    lldb/trunk/source/Plugins/Platform/Makefile<br>
    lldb/trunk/source/lldb.cpp<br>
<br>
Modified: lldb/trunk/lib/Makefile<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=213158&r1=213157&r2=213158&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=213158&r1=213157&r2=213158&view=diff</a><br>

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

==============================================================================<br>
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)<br>
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Jul 16 10:03:10 2014<br>
@@ -51,6 +51,7 @@<br>
 /* End PBXAggregateTarget section */<br>
<br>
 /* Begin PBXBuildFile section */<br>
+               23042D121976CA1D00621B2C /* PlatformKalimba.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23042D101976CA0A00621B2C /* PlatformKalimba.cpp */; };<br>
                23059A0719532B96007B8189 /* LinuxSignals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23059A0519532B96007B8189 /* LinuxSignals.cpp */; };<br>
                23059A101958B319007B8189 /* SBUnixSignals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23059A0F1958B319007B8189 /* SBUnixSignals.cpp */; };<br>
                23059A121958B3B2007B8189 /* SBUnixSignals.h in Headers */ = {isa = PBXBuildFile; fileRef = 23059A111958B37B007B8189 /* SBUnixSignals.h */; settings = {ATTRIBUTES = (Public, ); }; };<br>
@@ -890,6 +891,8 @@<br>
 /* End PBXCopyFilesBuildPhase section */<br>
<br>
 /* Begin PBXFileReference section */<br>
+               23042D101976CA0A00621B2C /* PlatformKalimba.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformKalimba.cpp; sourceTree = "<group>"; };<br>
+               23042D111976CA0A00621B2C /* PlatformKalimba.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformKalimba.h; sourceTree = "<group>"; };<br>
                23059A0519532B96007B8189 /* LinuxSignals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LinuxSignals.cpp; path = Utility/LinuxSignals.cpp; sourceTree = "<group>"; };<br>

                23059A0619532B96007B8189 /* LinuxSignals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LinuxSignals.h; path = Utility/LinuxSignals.h; sourceTree = "<group>"; };<br>

                23059A0F1958B319007B8189 /* SBUnixSignals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBUnixSignals.cpp; path = source/API/SBUnixSignals.cpp; sourceTree = "<group>"; };<br>

@@ -2207,6 +2210,15 @@<br>
                        sourceTree = "<group>";<br>
                        usesTabs = 0;<br>
                };<br>
+               23042D0F1976C9D800621B2C /* Kalimba */ = {<br>
+                       isa = PBXGroup;<br>
+                       children = (<br>
+                               23042D111976CA0A00621B2C /* PlatformKalimba.h */,<br>
+                               23042D101976CA0A00621B2C /* PlatformKalimba.cpp */,<br>
+                       );<br>
+                       path = Kalimba;<br>
+                       sourceTree = "<group>";<br>
+               };<br>
                233B008B196106E90090E598 /* Linux */ = {<br>
                        isa = PBXGroup;<br>
                        children = (<br>
@@ -3662,6 +3674,7 @@<br>
                        children = (<br>
                                2694E99814FC0BB30076DE67 /* FreeBSD */,<br>
                                264A97BC133918A30017F0BE /* GDB Server */,<br>
+                               23042D0F1976C9D800621B2C /* Kalimba */,<br>
                                2694E99F14FC0BBD0076DE67 /* Linux */,<br>
                                26C5577F132575C8008FD8FE /* MacOSX */,<br>
                                9457596415349416005A9070 /* POSIX */,<br>
@@ -4648,6 +4661,7 @@<br>
                                2689000F13353DB600698AC0 /* StoppointLocation.cpp in Sources */,<br>
                                2689001113353DB600698AC0 /* Watchpoint.cpp in Sources */,<br>
                                2689001213353DDE00698AC0 /* CommandObjectApropos.cpp in Sources */,<br>
+                               23042D121976CA1D00621B2C /* PlatformKalimba.cpp in Sources */,<br>
                                2689001313353DDE00698AC0 /* CommandObjectArgs.cpp in Sources */,<br>
                                2689001413353DDE00698AC0 /* CommandObjectBreakpoint.cpp in Sources */,<br>
                                2689001513353DDE00698AC0 /* CommandObjectBreakpointCommand.cpp in Sources */,<br>
<br>
Modified: lldb/trunk/source/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/CMakeLists.txt?rev=213158&r1=213157&r2=213158&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/CMakeLists.txt?rev=213158&r1=213157&r2=213158&view=diff</a><br>

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

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

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

==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/CMakeLists.txt (original)<br>
+++ lldb/trunk/source/Plugins/Platform/CMakeLists.txt Wed Jul 16 10:03:10 2014<br>
@@ -10,3 +10,4 @@<br>
<br>
 add_subdirectory(POSIX)<br>
 add_subdirectory(gdb-server)<br>
+add_subdirectory(Kalimba)<br>
<br>
Added: lldb/trunk/source/Plugins/Platform/Kalimba/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Kalimba/CMakeLists.txt?rev=213158&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Kalimba/CMakeLists.txt?rev=213158&view=auto</a><br>

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

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

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

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

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

==============================================================================<br>
--- lldb/trunk/source/lldb.cpp (original)<br>
+++ lldb/trunk/source/lldb.cpp Wed Jul 16 10:03:10 2014<br>
@@ -43,6 +43,7 @@<br>
 #include "Plugins/Platform/Linux/PlatformLinux.h"<br>
 #include "Plugins/Platform/POSIX/PlatformPOSIX.h"<br>
 #include "Plugins/Platform/Windows/PlatformWindows.h"<br>
+#include "Plugins/Platform/Kalimba/PlatformKalimba.h"<br>
 #include "Plugins/Process/elf-core/ProcessElfCore.h"<br>
 #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"<br>
 #include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"<br>
@@ -123,6 +124,7 @@ lldb_private::Initialize ()<br>
         PlatformFreeBSD::Initialize();<br>
         PlatformLinux::Initialize();<br>
         PlatformWindows::Initialize();<br>
+        PlatformKalimba::Initialize();<br>
         SymbolFileDWARFDebugMap::Initialize();<br>
         ItaniumABILanguageRuntime::Initialize();<br>
 #ifndef LLDB_DISABLE_PYTHON<br>
@@ -210,6 +212,7 @@ lldb_private::Terminate ()<br>
     PlatformFreeBSD::Terminate();<br>
     PlatformLinux::Terminate();<br>
     PlatformWindows::Terminate();<br>
+    PlatformKalimba::Terminate();<br>
     SymbolFileDWARFDebugMap::Terminate();<br>
     ItaniumABILanguageRuntime::Terminate();<br>
 #ifndef LLDB_DISABLE_PYTHON<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu">lldb-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">-Todd</div>
</div>