nitesh.jain removed rL LLVM as the repository for this revision.
nitesh.jain updated this revision to Diff 73029.
nitesh.jain added a comment.

We just require ABI information so that auxv vector is parse when lldb try to 
attach a process via "attach -p pid"


https://reviews.llvm.org/D25021

Files:
  include/lldb/Core/ArchSpec.h
  source/Core/ArchSpec.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp

Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -1212,13 +1212,12 @@
       // Nothing.
       break;
     }
-
-    if (proc_triple.isArch64Bit())
-      response.PutCString("ptrsize:8;");
-    else if (proc_triple.isArch32Bit())
-      response.PutCString("ptrsize:4;");
-    else if (proc_triple.isArch16Bit())
-      response.PutCString("ptrsize:2;");
+    // In case of MIPS64, pointer size is depend on ELF ABI
+    // For N32 the pointer size is 4 and for N64 it is 8
+    std::string abi = proc_arch.GetTargetABI();
+    if (!abi.empty())
+      response.Printf("elf_abi:%s;",abi.c_str());
+    response.Printf("ptrsize:%d;", proc_arch.GetAddressByteSize()); 
   }
 }
 
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1847,6 +1847,7 @@
       std::string os_name;
       std::string vendor_name;
       std::string triple;
+      std::string elf_abi;
       uint32_t pointer_byte_size = 0;
       StringExtractor extractor;
       ByteOrder byte_order = eByteOrderInvalid;
@@ -1883,6 +1884,9 @@
         } else if (name.equals("pid")) {
           if (!value.getAsInteger(16, pid))
             ++num_keys_decoded;
+        } else if (name.equals("elf_abi")) {
+            elf_abi = value;
+            ++num_keys_decoded;
         }
       }
       if (num_keys_decoded > 0)
@@ -1895,6 +1899,7 @@
       // Set the ArchSpec from the triple if we have it.
       if (!triple.empty()) {
         m_process_arch.SetTriple(triple.c_str());
+        m_process_arch.SetFlags(elf_abi);
         if (pointer_byte_size) {
           assert(pointer_byte_size == m_process_arch.GetAddressByteSize());
         }
Index: source/Core/ArchSpec.cpp
===================================================================
--- source/Core/ArchSpec.cpp
+++ source/Core/ArchSpec.cpp
@@ -627,6 +627,42 @@
   return false;
 }
 
+std::string ArchSpec::GetTargetABI() const {
+
+  std::string abi;
+
+  if (IsMIPS()) {
+    switch (GetFlags() & ArchSpec::eMIPSABI_mask) {
+    case ArchSpec::eMIPSABI_N64:
+      abi = "n64";
+      return abi;
+    case ArchSpec::eMIPSABI_N32:
+      abi = "n32";
+      return abi;
+    case ArchSpec::eMIPSABI_O32:
+      abi = "o32";
+      return abi;
+    default:
+      return abi;
+    }
+  }
+  return abi;
+}
+
+void ArchSpec::SetFlags(std::string elf_abi) {
+
+  uint32_t flag = GetFlags();
+  if (IsMIPS()) {
+    if (elf_abi == "n64")
+      flag |= ArchSpec::eMIPSABI_N64;
+    else if (elf_abi == "n32")
+      flag |= ArchSpec::eMIPSABI_N32;
+    else if (elf_abi == "o32")
+      flag |= ArchSpec::eMIPSABI_O32;
+  }
+  SetFlags(flag);
+}
+
 std::string ArchSpec::GetClangTargetCPU() {
   std::string cpu;
   const llvm::Triple::ArchType machine = GetMachine();
Index: include/lldb/Core/ArchSpec.h
===================================================================
--- include/lldb/Core/ArchSpec.h
+++ include/lldb/Core/ArchSpec.h
@@ -307,6 +307,8 @@
   //------------------------------------------------------------------
   std::string GetClangTargetCPU();
 
+  std::string GetTargetABI() const;
+
   //------------------------------------------------------------------
   /// Clears the object state.
   ///
@@ -592,6 +594,8 @@
 
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
+  void SetFlags(std::string elf_abi);
+
 protected:
   bool IsEqualTo(const ArchSpec &rhs, bool exact_match) const;
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to