[Lldb-commits] [PATCH] D31825: Fix loading core(5) files from NetBSD 7.99.67

Kamil Rytarowski via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 10 11:52:47 PDT 2017


krytarowski created this revision.
krytarowski added a project: LLDB.

This change has been authored by Zachary Turner.

It fixes loading into the debugger core(5) files generated
by NetBSD x86_64 v. 7.99.67. These core(5) files have the
e_ident[EI_OSABI] property set to ELFOSABI_SYSV.

It might change in future versions to ELFOSABI_NETBSD.

However it still should not crash the debugger. With this
change applied, LLDB can be loaded properly with:

  `
  lldb -c ./core
  `


Repository:
  rL LLVM

https://reviews.llvm.org/D31825

Files:
  source/Core/ArchSpec.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.cpp


Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===================================================================
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -220,7 +220,7 @@
   target_arch.MergeFrom(core_arch);
   GetTarget().SetArchitecture(target_arch);
  
-  SetUnixSignals(UnixSignals::Create(GetArchitecture()));
+  SetUnixSignals(UnixSignals::Create(target_arch));
 
   // Ensure we found at least one thread that was stopped on a signal.
   bool siginfo_signal_found = false;
@@ -724,17 +724,7 @@
 }
 
 ArchSpec ProcessElfCore::GetArchitecture() {
-  ObjectFileELF *core_file =
-      (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
-  ArchSpec arch;
-  core_file->GetArchitecture(arch);
-
-  ArchSpec target_arch = GetTarget().GetArchitecture();
-  
-  if (target_arch.IsMIPS())
-    return target_arch;
-
-  return arch;
+  return GetTarget().GetArchitecture();
 }
 
 const lldb::DataBufferSP ProcessElfCore::GetAuxvData() {
Index: source/Core/ArchSpec.cpp
===================================================================
--- source/Core/ArchSpec.cpp
+++ source/Core/ArchSpec.cpp
@@ -989,29 +989,34 @@
 }
 
 void ArchSpec::MergeFrom(const ArchSpec &other) {
-  if (TripleVendorIsUnspecifiedUnknown() &&
-      !other.TripleVendorIsUnspecifiedUnknown())
-    GetTriple().setVendor(other.GetTriple().getVendor());
-  if (TripleOSIsUnspecifiedUnknown() && !other.TripleOSIsUnspecifiedUnknown())
-    GetTriple().setOS(other.GetTriple().getOS());
-  if (GetTriple().getArch() == llvm::Triple::UnknownArch)
-    GetTriple().setArch(other.GetTriple().getArch());
-  if (GetTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
-      !TripleVendorWasSpecified()) {
-    if (other.TripleVendorWasSpecified())
-      GetTriple().setEnvironment(other.GetTriple().getEnvironment());
-  }
   // If this and other are both arm ArchSpecs and this ArchSpec is a generic
-  // "some kind of arm"
-  // spec but the other ArchSpec is a specific arm core, adopt the specific arm
-  // core.
+  // "some kind of arm" spec but the other ArchSpec is a specific arm core, adopt
+  // the specific arm core.
+  bool ShouldOverrideCore = false;
+
+  if (GetCore() == ArchSpec::kCore_invalid && other.GetCore() != ArchSpec::kCore_invalid)
+    ShouldOverrideCore = true;
   if (GetTriple().getArch() == llvm::Triple::arm &&
-      other.GetTriple().getArch() == llvm::Triple::arm &&
-      IsCompatibleMatch(other) && GetCore() == ArchSpec::eCore_arm_generic &&
-      other.GetCore() != ArchSpec::eCore_arm_generic) {
+    other.GetTriple().getArch() == llvm::Triple::arm &&
+    IsCompatibleMatch(other) && GetCore() == ArchSpec::eCore_arm_generic &&
+    other.GetCore() != ArchSpec::eCore_arm_generic)
+    ShouldOverrideCore = true;
+  if (ShouldOverrideCore) {
     m_core = other.GetCore();
     CoreUpdated(true);
   }
+
+  if (GetTriple().getVendor() == llvm::Triple::UnknownVendor)
+    GetTriple().setVendor(other.GetTriple().getVendor());
+
+  if (GetTriple().getOS() == llvm::Triple::UnknownOS)
+    GetTriple().setOS(other.GetTriple().getOS());
+
+  if (GetTriple().getArch() == llvm::Triple::UnknownArch)
+    GetTriple().setArch(other.GetTriple().getArch());
+
+  if (GetTriple().getEnvironment() == llvm::Triple::UnknownEnvironment)
+    GetTriple().setEnvironment(other.GetTriple().getEnvironment());
 }
 
 bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31825.94553.patch
Type: text/x-patch
Size: 3485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20170410/5bb95bfe/attachment-0001.bin>


More information about the lldb-commits mailing list