<div dir="ltr">> <span style="font-family:arial,sans-serif;font-size:12.7272720336914px"> So I've written a specific routine which extracts the variant spec from the e_flags. What I'm not too happy about, and would appreciate lldb-dev's opinion on, is if it is ok for the extraction routine (kalimbaVariantFromElfFlags) to remain in ObjectFileELF.cpp?</span><div>
<span style="font-family:arial,sans-serif;font-size:12.7272720336914px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:12.7272720336914px">Currently we have Linux/*BSD detection logic (i.e. OS detection code) within ObjectFileELF.  Based on that precedent, I think having cpu_arch-specific detection in ObjectFileELF is fine.  We could abstract that all and register them somehow to separate them out, but at this point I don't think the extra complexity is worth it.  We can always revisit later.</span></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Aug 26, 2014 at 8:14 AM, Todd Fiala <span dir="ltr"><<a href="mailto:tfiala@google.com" target="_blank">tfiala@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class=""><span style="font-family:arial,sans-serif;font-size:12.7272720336914px">> Furthermore how do I get any new files into the xcode project file, given that I have no xcode system - shall I just change the make and cmake build and rely on an Apple person to fix any xcode build breakage?</span><br>

<div><span style="font-family:arial,sans-serif;font-size:12.7272720336914px"><br></span></div></div><div><span style="font-family:arial,sans-serif;font-size:12.7272720336914px">That's correct.  One of the community will fix it up.  Enough of us build with enough build systems that I'm sure we'll catch it relatively quickly.  (We ultimately expect build bots to catch these but we are still having to do this "manually" while we get that together).</span></div>

</div><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">On Tue, Aug 26, 2014 at 5:56 AM, Matthew Gardiner <span dir="ltr"><<a href="mailto:mg11@csr.com" target="_blank">mg11@csr.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi folks,<br>
<br>
The kalimba architecture has a number of variants. The ones of interest to me being 3, 4 and 5. I have added some additional entries to the g_elf_arch_entries to describe these variants. However, up until now, no subtypes (architecture variants), for ELF objectfiles exist in lldb. So I've found it necessary to modify the invocation of ArchSpec.SetArchitecture from ObjectFileELF to deal with this.<br>


<br>
Now the kalimba variant specification can be deduced by parsing the e_flags field from the ELF header. So I've written a specific routine which extracts the variant spec from the e_flags. What I'm not too happy about, and would appreciate lldb-dev's opinion on, is if it is ok for the extraction routine (kalimbaVariantFromElfFlags) to remain in ObjectFileELF.cpp? If not, where should the routine go? Furthermore how do I get any new files into the xcode project file, given that I have no xcode system - shall I just change the make and cmake build and rely on an Apple person to fix any xcode build breakage?<br>


<br>
Below is a diff of what I have done recognize kalimba variants, basically:<br>
<br>
1. add new entries to ArchSpec::enum Core, and g_elf_arch_entries<br>
2. supply routine to extract the kalimba variant from the e_flags<br>
3. if e_machine == EM_CSR_KALIMBA, extract the kalimba variant and pass it to SetArchitecture as the cpu sub type.<br>
<br>
--- a/include/lldb/Core/ArchSpec.h    2014-08-18<br>
+++ b/include/lldb/Core/ArchSpec.h    2014-08-18<br>
@@ -103,6 +103,9 @@<br>
         eCore_uknownMach64,<br>
<br>
         eCore_kalimba,<br>
+        eCore_kalimba3,<br>
+        eCore_kalimba4,<br>
+        eCore_kalimba5,<br>
<br>
         kNumCores,<br>
<br>
--- a/source/Core/ArchSpec.cpp    2014-08-05<br>
+++ b/source/Core/ArchSpec.cpp    2014-08-05<br>
@@ -115,7 +115,10 @@<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::kalimba , ArchSpec::eCore_kalimba  , "kalimba" }<br>
+    { eByteOrderLittle, 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba  , "kalimba" },<br>
+    { eByteOrderLittle, 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba3  , "kalimba3" },<br>
+    { eByteOrderLittle, 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba4  , "kalimba4" },<br>
+    { eByteOrderLittle, 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba5  , "kalimba5" }<br>
 };<br>
<br>
 // Ensure that we have an entry in the g_core_definitions for each core. If you comment out an entry above,<br>
@@ -257,7 +260,10 @@<br>
     { ArchSpec::eCore_x86_64_x86_64   , llvm::ELF::EM_X86_64 , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // AMD64<br>
     { ArchSpec::eCore_mips64          , llvm::ELF::EM_MIPS   , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // MIPS<br>
     { ArchSpec::eCore_hexagon_<u></u>generic , llvm::ELF::EM_HEXAGON, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // HEXAGON<br>
-    { ArchSpec::eCore_kalimba , llvm::ELF::EM_CSR_KALIMBA, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }  // KALIMBA<br>
+    { ArchSpec::eCore_kalimba , llvm::ELF::EM_CSR_KALIMBA, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu },  // KALIMBA<br>
+    { ArchSpec::eCore_kalimba3 , llvm::ELF::EM_CSR_KALIMBA, 3, 0xFFFFFFFFu, 0xFFFFFFFFu },  // KALIMBA<br>
+    { ArchSpec::eCore_kalimba4 , llvm::ELF::EM_CSR_KALIMBA, 4, 0xFFFFFFFFu, 0xFFFFFFFFu },  // KALIMBA<br>
+    { ArchSpec::eCore_kalimba5 , llvm::ELF::EM_CSR_KALIMBA, 5, 0xFFFFFFFFu, 0xFFFFFFFFu }  // KALIMBA<br>
<br>
 };<br>
<br>
--- a/source/Plugins/ObjectFile/<u></u>ELF/ObjectFileELF.cpp 2014-07-22<br>
+++ b/source/Plugins/ObjectFile/<u></u>ELF/ObjectFileELF.cpp 2014-07-22<br>
@@ -257,6 +257,27 @@<br>
     return true;<br>
 }<br>
<br>
+static uint32_t<br>
+kalimbaVariantFromElfFlags(<u></u>const elf::elf_word e_flags)<br>
+{<br>
+    const uint32_t dsp_rev = e_flags & 0xFF;<br>
+    uint32_t kal_arch_variant = LLDB_INVALID_CPUTYPE;<br>
+    switch(dsp_rev)<br>
+    {<br>
+        // TODO(mg11) Support more variants<br>
+        case 10:<br>
+            kal_arch_variant = 3;<br>
+            break;<br>
+        case 14:<br>
+            kal_arch_variant = 4;<br>
+            break;<br>
+        default:<br>
+            break;<br>
+    }<br>
+    return kal_arch_variant;<br>
+}<br>
+<br>
+<br>
 // Arbitrary constant used as UUID prefix for core files.<br>
 const uint32_t<br>
 ObjectFileELF::g_core_uuid_<u></u>magic(0xE210C);<br>
@@ -544,9 +565,15 @@<br>
             {<br>
                 ModuleSpec spec;<br>
                 spec.GetFileSpec() = file;<br>
+<br>
+                const uint32_t sub_type =<br>
+                    llvm::ELF::EM_CSR_KALIMBA == header.e_machine ?<br>
+ kalimbaVariantFromElfFlags(<u></u>header.e_flags) :<br>
+                    LLDB_INVALID_CPUTYPE;<br>
spec.GetArchitecture().<u></u>SetArchitecture(eArchTypeELF,<br>
header.e_machine,<br>
- LLDB_INVALID_CPUTYPE);<br>
+ sub_type);<br>
+<br>
                 if (spec.GetArchitecture().<u></u>IsValid())<br>
                 {<br>
                     llvm::Triple::OSType ostype;<br>
@@ -1269,7 +1296,12 @@<br>
     // We'll refine this with note data as we parse the notes.<br>
     if (arch_spec.GetTriple ().getOS () == llvm::Triple::OSType::<u></u>UnknownOS)<br>
     {<br>
-        arch_spec.SetArchitecture (eArchTypeELF, header.e_machine, LLDB_INVALID_CPUTYPE);<br>
+        const uint32_t sub_type =<br>
+            llvm::ELF::EM_CSR_KALIMBA == header.e_machine ?<br>
+            kalimbaVariantFromElfFlags(<u></u>header.e_flags) :<br>
+            LLDB_INVALID_CPUTYPE;<br>
+        arch_spec.SetArchitecture (eArchTypeELF, header.e_machine, sub_type);<br>
+<br>
         switch (arch_spec.GetAddressByteSize(<u></u>))<br>
         {<br>
         case 4:<br>
<br>
I'd appreciate people's opinion on this diff, before I commit anything. (The reason I need to know the variant type, is because some kalimba variants have a different notion of "byte-size" i.e. minimum addressable unit. For example for kalimba3 the minimum addressable unit from the data bus is 24-bits, whereas for kalimba4 it is the more conventional 8-bits. I'd like to reserve the problems/challenges this presents for me, regarding my kalimba lldb port, to a future email).<br>


<br>
thanks<br>
Matt<br>
<br>
<br>
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom<br>


More information can be found at <a href="http://www.csr.com" target="_blank">www.csr.com</a>. Keep up to date with CSR on our technical blog, <a href="http://www.csr.com/blog" target="_blank">www.csr.com/blog</a>, CSR people blog, <a href="http://www.csr.com/people" target="_blank">www.csr.com/people</a>, YouTube, <a href="http://www.youtube.com/user/CSRplc" target="_blank">www.youtube.com/user/CSRplc</a>, Facebook, <a href="http://www.facebook.com/pages/CSR/191038434253534" target="_blank">www.facebook.com/pages/CSR/<u></u>191038434253534</a>, or follow us on Twitter at <a href="http://www.twitter.com/CSR_plc" target="_blank">www.twitter.com/CSR_plc</a>.<br>


New for 2014, you can now access the wide range of products powered by aptX at <a href="http://www.aptx.com" target="_blank">www.aptx.com</a>.<br>
______________________________<u></u>_________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/lldb-dev</a><br>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div dir="ltr"><table cellspacing="0" cellpadding="0" style="color:rgb(136,136,136);font-family:'Times New Roman'">
<tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small">
<td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Todd Fiala |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td>

<td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tfiala@google.com" style="color:rgb(17,85,204)" target="_blank"><span style="background-color:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">tfiala@google.com</span></a> |</td>

<td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"><font color="#1155cc"> <a>650-943-3180</a></font></td></tr></tbody></table><br></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><table cellspacing="0" cellpadding="0" style="color:rgb(136,136,136);font-family:'Times New Roman'"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small">
<td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Todd Fiala |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tfiala@google.com" style="color:rgb(17,85,204)" target="_blank"><span style="background-color:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">tfiala@google.com</span></a> |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"><font color="#1155cc"> <a>650-943-3180</a></font></td></tr></tbody></table><br></div>
</div>