pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lldb-netbsd: Upgrade to 314651 and reset patches



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Mon Oct 16 22:00:11 2017 +0200
Changeset:	421cff0a2b30e0eb625eab49fcd90f3ace824ce2

Modified Files:
	lldb-netbsd/Makefile
	lldb-netbsd/distinfo
Removed Files:
	lldb-netbsd/patches/patch-source_Plugins_ObjectFile_ELF_ObjectFileELF.cpp
	lldb-netbsd/patches/patch-source_Plugins_Process_elf-core_ProcessElfCore.cpp
	lldb-netbsd/patches/patch-source_Plugins_Process_elf-core_ProcessElfCore.h

Log Message:
lldb-netbsd: Upgrade to 314651 and reset patches

Temporarily remove local patches for multiple threads in core files.
This code will be needed later, after resurrection of tracing
running processes.

Sponsored by <The NetBSD Foundation>

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=421cff0a2b30e0eb625eab49fcd90f3ace824ce2

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 lldb-netbsd/Makefile                               |   2 +-
 lldb-netbsd/distinfo                               |   3 -
 ...source_Plugins_ObjectFile_ELF_ObjectFileELF.cpp | 253 -----------------
 ...rce_Plugins_Process_elf-core_ProcessElfCore.cpp | 310 ---------------------
 ...ource_Plugins_Process_elf-core_ProcessElfCore.h |  23 --
 5 files changed, 1 insertion(+), 590 deletions(-)

diffs:
diff --git a/lldb-netbsd/Makefile b/lldb-netbsd/Makefile
index b2cb4719ea..cd9460e835 100644
--- a/lldb-netbsd/Makefile
+++ b/lldb-netbsd/Makefile
@@ -5,7 +5,7 @@ CATEGORIES=	lang devel
 
 SVN_REPOSITORIES=	lldb
 SVN_REPO.lldb=		http://llvm.org/svn/llvm-project/lldb/trunk
-SVN_REVISION.lldb=	305692
+SVN_REVISION.lldb=	314651
 
 MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
 HOMEPAGE=	http://lldb.org/
diff --git a/lldb-netbsd/distinfo b/lldb-netbsd/distinfo
index fe8c4d2755..7931384fd5 100644
--- a/lldb-netbsd/distinfo
+++ b/lldb-netbsd/distinfo
@@ -12,6 +12,3 @@ Size (libcxx-3.6.2.src.tar.xz) = 944020 bytes
 SHA1 (llvm-3.6.2.src.tar.xz) = 7a00257eb2bc9431e4c77c3a36b033072c54bc7e
 RMD160 (llvm-3.6.2.src.tar.xz) = 521cbc5fe2925ea3c6e90c7a31f752a04045c972
 Size (llvm-3.6.2.src.tar.xz) = 12802380 bytes
-SHA1 (patch-source_Plugins_ObjectFile_ELF_ObjectFileELF.cpp) = 76d47d654951d36dc493611dfa636c1dcff0c3af
-SHA1 (patch-source_Plugins_Process_elf-core_ProcessElfCore.cpp) = cdfb65a14116c3bd3d3ad977328e2b0c4ae4f9aa
-SHA1 (patch-source_Plugins_Process_elf-core_ProcessElfCore.h) = 510ab7ce38a7ec88375333eb1483d07d6be743b6
diff --git a/lldb-netbsd/patches/patch-source_Plugins_ObjectFile_ELF_ObjectFileELF.cpp b/lldb-netbsd/patches/patch-source_Plugins_ObjectFile_ELF_ObjectFileELF.cpp
deleted file mode 100644
index d81ca2e296..0000000000
--- a/lldb-netbsd/patches/patch-source_Plugins_ObjectFile_ELF_ObjectFileELF.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-$NetBSD$
-
---- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp.orig	2017-04-07 18:27:43.000000000 +0000
-+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
-@@ -52,6 +52,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_NETBSDCORE = "NetBSD-CORE";
- const char *const LLDB_NT_OWNER_OPENBSD = "OpenBSD";
- const char *const LLDB_NT_OWNER_CSR = "csr";
- const char *const LLDB_NT_OWNER_ANDROID = "Android";
-@@ -67,8 +68,10 @@ const elf_word LLDB_NT_GNU_ABI_SIZE = 16
- 
- const elf_word LLDB_NT_GNU_BUILD_ID_TAG = 0x03;
- 
--const elf_word LLDB_NT_NETBSD_ABI_TAG = 0x01;
--const elf_word LLDB_NT_NETBSD_ABI_SIZE = 4;
-+const elf_word LLDB_NT_NETBSD_NT_NETBSD_IDENT_TAG = 1;
-+const elf_word LLDB_NT_NETBSD_NT_NETBSD_IDENT_DESCSZ = 4;
-+const elf_word LLDB_NT_NETBSD_NT_NETBSD_IDENT_NAMESZ = 7;
-+const elf_word LLDB_NT_NETBSD_NT_PROCINFO = 1;
- 
- // GNU ABI note OS constants
- const elf_word LLDB_NT_GNU_ABI_OS_LINUX = 0x00;
-@@ -288,14 +291,15 @@ static uint32_t kalimbaVariantFromElfFla
-   return kal_arch_variant;
- }
- 
--static uint32_t mipsVariantFromElfFlags (const elf::ELFHeader &header) {
-+static uint32_t mipsVariantFromElfFlags(const elf::ELFHeader &header) {
-   const uint32_t mips_arch = header.e_flags & llvm::ELF::EF_MIPS_ARCH;
-   uint32_t endian = header.e_ident[EI_DATA];
-   uint32_t arch_variant = ArchSpec::eMIPSSubType_unknown;
-   uint32_t fileclass = header.e_ident[EI_CLASS];
- 
--  // If there aren't any elf flags available (e.g core elf file) then return default 
--  // 32 or 64 bit arch (without any architecture revision) based on object file's class.
-+  // If there aren't any elf flags available (e.g core elf file) then return
-+  // default 32 or 64 bit arch (without any architecture revision) based on
-+  // object file's class.
-   if (header.e_type == ET_CORE) {
-     switch (fileclass) {
-     case llvm::ELF::ELFCLASS32:
-@@ -404,8 +408,8 @@ ObjectFile *ObjectFileELF::CreateInstanc
-                                           lldb::offset_t file_offset,
-                                           lldb::offset_t length) {
-   if (!data_sp) {
--    data_sp =
--        DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length, file_offset);
-+    data_sp = DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length,
-+                                                  file_offset);
-     if (!data_sp)
-       return nullptr;
-     data_offset = 0;
-@@ -422,8 +426,8 @@ ObjectFile *ObjectFileELF::CreateInstanc
- 
-   // Update the data to contain the entire file if it doesn't already
-   if (data_sp->GetByteSize() < length) {
--    data_sp =
--        DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length, file_offset);
-+    data_sp = DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length,
-+                                                  file_offset);
-     if (!data_sp)
-       return nullptr;
-     data_offset = 0;
-@@ -681,7 +685,7 @@ size_t ObjectFileELF::GetModuleSpecifica
-           // with a bigger data source to get the actual values.
-           size_t section_header_end = header.e_shoff + header.e_shentsize;
-           if (header.HasHeaderExtension() &&
--            section_header_end > data_sp->GetByteSize()) {
-+              section_header_end > data_sp->GetByteSize()) {
-             data_sp = DataBufferLLVM::CreateSliceFromPath(
-                 file.GetPath(), section_header_end, file_offset);
-             if (data_sp) {
-@@ -767,8 +771,8 @@ size_t ObjectFileELF::GetModuleSpecifica
-                     CalculateELFNotesSegmentsCRC32(program_headers, data);
-               } else {
-                 // Need to map entire file into memory to calculate the crc.
--                data_sp = DataBufferLLVM::CreateSliceFromPath(file.GetPath(), -1,
--                                                         file_offset);
-+                data_sp = DataBufferLLVM::CreateSliceFromPath(file.GetPath(),
-+                                                              -1, file_offset);
-                 if (data_sp) {
-                   data.SetData(data_sp);
-                   gnu_debuglink_crc = calc_gnu_debuglink_crc32(
-@@ -1370,25 +1374,41 @@ ObjectFileELF::RefineModuleDetailsFromNo
-         // The note.n_name == LLDB_NT_OWNER_GNU is valid for Linux platform
-         arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
-     }
--    // Process NetBSD ELF notes.
-+    // Process NetBSD ELF executables and shared libraries
-     else if ((note.n_name == LLDB_NT_OWNER_NETBSD) &&
--             (note.n_type == LLDB_NT_NETBSD_ABI_TAG) &&
--             (note.n_descsz == LLDB_NT_NETBSD_ABI_SIZE)) {
--      // Pull out the min version info.
-+             (note.n_type == LLDB_NT_NETBSD_NT_NETBSD_IDENT_TAG) &&
-+             (note.n_descsz == LLDB_NT_NETBSD_NT_NETBSD_IDENT_DESCSZ) &&
-+             (note.n_namesz == LLDB_NT_NETBSD_NT_NETBSD_IDENT_NAMESZ)) {
-+      // Pull out the version info
-       uint32_t version_info;
-       if (data.GetU32(&offset, &version_info, 1) == nullptr) {
-         error.SetErrorString("failed to read NetBSD ABI note payload");
-         return error;
-       }
--
-+      // Convert the version info into a major/minor/patch number.
-+      //     #define __NetBSD_Version__ MMmmrrpp00
-+      //
-+      //     M = major version
-+      //     m = minor version; a minor number of 99 indicates current.
-+      //     r = 0 (since NetBSD 3.0 not used)
-+      //     p = patchlevel
-+      const uint32_t version_major = version_info / 100000000;
-+      const uint32_t version_minor = (version_info % 100000000) / 1000000;
-+      const uint32_t version_patch = (version_info % 10000) / 100;
-+      char os_name[32];
-+      snprintf(os_name, sizeof(os_name),
-+               "netbsd%" PRIu32 ".%" PRIu32 ".%" PRIu32, version_major,
-+               version_minor, version_patch);
-+      // Set the elf OS version to NetBSD.  Also clear the vendor.
-+      arch_spec.GetTriple().setOSName(os_name);
-+      arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::UnknownVendor);
-+    }
-+    // Process NetBSD ELF core(5) notes
-+    else if ((note.n_name == LLDB_NT_OWNER_NETBSDCORE) &&
-+             (note.n_type == LLDB_NT_NETBSD_NT_PROCINFO)) {
-       // Set the elf OS version to NetBSD.  Also clear the vendor.
-       arch_spec.GetTriple().setOS(llvm::Triple::OSType::NetBSD);
-       arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::UnknownVendor);
--
--      if (log)
--        log->Printf(
--            "ObjectFileELF::%s detected NetBSD, min version constant %" PRIu32,
--            __FUNCTION__, version_info);
-     }
-     // Process OpenBSD ELF notes.
-     else if (note.n_name == LLDB_NT_OWNER_OPENBSD) {
-@@ -1465,7 +1485,8 @@ ObjectFileELF::RefineModuleDetailsFromNo
-             return error;
-           }
-           llvm::StringRef path(cstr);
--          if (path.contains("/lib/x86_64-linux-gnu") || path.contains("/lib/i386-linux-gnu")) {
-+          if (path.contains("/lib/x86_64-linux-gnu") ||
-+              path.contains("/lib/i386-linux-gnu")) {
-             arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
-             break;
-           }
-@@ -1475,7 +1496,7 @@ ObjectFileELF::RefineModuleDetailsFromNo
-           // In case of MIPSR6, the LLDB_NT_OWNER_GNU note is missing
-           // for some cases (e.g. compile with -nostdlib)
-           // Hence set OS to Linux
--          arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux); 
-+          arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
-       }
-     }
- 
-@@ -1579,7 +1600,7 @@ size_t ObjectFileELF::GetSectionHeaderIn
-     const uint32_t sub_type = subTypeFromElfHeader(header);
-     arch_spec.SetArchitecture(eArchTypeELF, header.e_machine, sub_type,
-                               header.e_ident[EI_OSABI]);
--    
-+
-     // Validate if it is ok to remove GetOsFromOSABI.
-     // Note, that now the OS is determined based on EI_OSABI flag and
-     // the info extracted from ELF notes (see RefineModuleDetailsFromNote).
-@@ -2357,7 +2378,7 @@ unsigned ObjectFileELF::ParseSymbols(Sym
-        * flag to check whether the symbol is microMIPS and then set the address
-        * class
-        * accordingly.
--      */
-+       */
-       const llvm::Triple::ArchType llvm_arch = arch.GetMachine();
-       if (llvm_arch == llvm::Triple::mips ||
-           llvm_arch == llvm::Triple::mipsel ||
-@@ -3016,41 +3037,42 @@ void ObjectFileELF::ParseUnwindSymbols(S
-   // it have to recalculate the index first.
-   std::vector<Symbol> new_symbols;
- 
--  eh_frame->ForEachFDEEntries([this, symbol_table, section_list, &new_symbols](
--      lldb::addr_t file_addr, uint32_t size, dw_offset_t) {
--    Symbol *symbol = symbol_table->FindSymbolAtFileAddress(file_addr);
--    if (symbol) {
--      if (!symbol->GetByteSizeIsValid()) {
--        symbol->SetByteSize(size);
--        symbol->SetSizeIsSynthesized(true);
--      }
--    } else {
--      SectionSP section_sp =
--          section_list->FindSectionContainingFileAddress(file_addr);
--      if (section_sp) {
--        addr_t offset = file_addr - section_sp->GetFileAddress();
--        const char *symbol_name = GetNextSyntheticSymbolName().GetCString();
--        uint64_t symbol_id = symbol_table->GetNumSymbols();
--        Symbol eh_symbol(
--            symbol_id,       // Symbol table index.
--            symbol_name,     // Symbol name.
--            false,           // Is the symbol name mangled?
--            eSymbolTypeCode, // Type of this symbol.
--            true,            // Is this globally visible?
--            false,           // Is this symbol debug info?
--            false,           // Is this symbol a trampoline?
--            true,            // Is this symbol artificial?
--            section_sp,      // Section in which this symbol is defined or null.
--            offset,          // Offset in section or symbol value.
--            0,     // Size:          Don't specify the size as an FDE can
--            false, // Size is valid: cover multiple symbols.
--            false, // Contains linker annotations?
--            0);    // Symbol flags.
--        new_symbols.push_back(eh_symbol);
--      }
--    }
--    return true;
--  });
-+  eh_frame->ForEachFDEEntries(
-+      [this, symbol_table, section_list,
-+       &new_symbols](lldb::addr_t file_addr, uint32_t size, dw_offset_t) {
-+        Symbol *symbol = symbol_table->FindSymbolAtFileAddress(file_addr);
-+        if (symbol) {
-+          if (!symbol->GetByteSizeIsValid()) {
-+            symbol->SetByteSize(size);
-+            symbol->SetSizeIsSynthesized(true);
-+          }
-+        } else {
-+          SectionSP section_sp =
-+              section_list->FindSectionContainingFileAddress(file_addr);
-+          if (section_sp) {
-+            addr_t offset = file_addr - section_sp->GetFileAddress();
-+            const char *symbol_name = GetNextSyntheticSymbolName().GetCString();
-+            uint64_t symbol_id = symbol_table->GetNumSymbols();
-+            Symbol eh_symbol(
-+                symbol_id,       // Symbol table index.
-+                symbol_name,     // Symbol name.
-+                false,           // Is the symbol name mangled?
-+                eSymbolTypeCode, // Type of this symbol.
-+                true,            // Is this globally visible?
-+                false,           // Is this symbol debug info?
-+                false,           // Is this symbol a trampoline?
-+                true,            // Is this symbol artificial?
-+                section_sp, // Section in which this symbol is defined or null.
-+                offset,     // Offset in section or symbol value.
-+                0,     // Size:          Don't specify the size as an FDE can
-+                false, // Size is valid: cover multiple symbols.
-+                false, // Contains linker annotations?
-+                0);    // Symbol flags.
-+            new_symbols.push_back(eh_symbol);
-+          }
-+        }
-+        return true;
-+      });
- 
-   for (const Symbol &s : new_symbols)
-     symbol_table->AddSymbol(s);
diff --git a/lldb-netbsd/patches/patch-source_Plugins_Process_elf-core_ProcessElfCore.cpp b/lldb-netbsd/patches/patch-source_Plugins_Process_elf-core_ProcessElfCore.cpp
deleted file mode 100644
index aedb04f6f0..0000000000
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_elf-core_ProcessElfCore.cpp
+++ /dev/null
@@ -1,310 +0,0 @@
-$NetBSD$
-
---- source/Plugins/Process/elf-core/ProcessElfCore.cpp.orig	2017-04-07 18:27:43.000000000 +0000
-+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
-@@ -19,6 +19,7 @@
- #include "lldb/Core/PluginManager.h"
- #include "lldb/Core/Section.h"
- #include "lldb/Core/State.h"
-+#include "lldb/Host/StringConvert.h"
- #include "lldb/Target/DynamicLoader.h"
- #include "lldb/Target/MemoryRegionInfo.h"
- #include "lldb/Target/Target.h"
-@@ -27,6 +28,7 @@
- #include "lldb/Utility/DataBufferLLVM.h"
- #include "lldb/Utility/Log.h"
- 
-+#include "llvm/ADT/StringRef.h"
- #include "llvm/Support/ELF.h"
- #include "llvm/Support/Threading.h"
- 
-@@ -219,7 +221,7 @@ Status ProcessElfCore::DoLoadCore() {
-   ArchSpec core_arch(m_core_module_sp->GetArchitecture());
-   target_arch.MergeFrom(core_arch);
-   GetTarget().SetArchitecture(target_arch);
-- 
-+
-   SetUnixSignals(UnixSignals::Create(GetArchitecture()));
- 
-   // Ensure we found at least one thread that was stopped on a signal.
-@@ -373,7 +375,8 @@ size_t ProcessElfCore::DoReadMemory(lldb
-   lldb::addr_t bytes_left =
-       0; // Number of bytes available in the core file from the given address
- 
--  // Don't proceed if core file doesn't contain the actual data for this address range.
-+  // Don't proceed if core file doesn't contain the actual data for this address
-+  // range.
-   if (file_start == file_end)
-     return 0;
- 
-@@ -458,9 +461,14 @@ enum {
- 
- namespace NETBSD {
- 
--enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33, NT_AMD64_FPREGS = 35 };
-+enum { NT_PROCINFO = 1, NT_PROCINFO_SIZE = 160, NT_AUXV = 2 };
-+
-+namespace AMD64 {
-+enum { NT_REGS = 33, NT_FPREGS = 35 };
- }
- 
-+} // namespace NETBSD
-+
- // Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details.
- static void ParseFreeBSDPrStatus(ThreadData &thread_data, DataExtractor &data,
-                                  ArchSpec &arch) {
-@@ -497,15 +505,29 @@ static void ParseFreeBSDThrMisc(ThreadDa
-   thread_data.name = data.GetCStr(&offset, 20);
- }
- 
--static void ParseNetBSDProcInfo(ThreadData &thread_data, DataExtractor &data) {
-+static Status ParseNetBSDProcInfo(DataExtractor &data, uint32_t &cpi_nlwps,
-+                                 uint32_t &cpi_signo, uint32_t &cpi_siglwp) {
-   lldb::offset_t offset = 0;
- 
--  int version = data.GetU32(&offset);
-+  uint32_t version = data.GetU32(&offset);
-   if (version != 1)
--    return;
-+    return Status(
-+        "Status parsing NetBSD core(5) notes: Unsupported procinfo version");
- 
--  offset += 4;
--  thread_data.signo = data.GetU32(&offset);
-+  uint32_t cpisize = data.GetU32(&offset);
-+  if (cpisize != NETBSD::NT_PROCINFO_SIZE)
-+    return Status(
-+        "Status parsing NetBSD core(5) notes: Unsupported procinfo size");
-+
-+  cpi_signo = data.GetU32(&offset); /* killing signal */
-+
-+  offset += 108;
-+  cpi_nlwps = data.GetU32(&offset); /* number of LWPs */
-+
-+  offset += 32;
-+  cpi_siglwp = data.GetU32(&offset); /* LWP target of killing signal */
-+
-+  return Status();
- }
- 
- static void ParseOpenBSDProcInfo(ThreadData &thread_data, DataExtractor &data) {
-@@ -524,12 +546,28 @@ static void ParseOpenBSDProcInfo(ThreadD
- /// 1) A PT_NOTE segment is composed of one or more NOTE entries.
- /// 2) NOTE Entry contains a standard header followed by variable size data.
- ///   (see ELFNote structure)
--/// 3) A Thread Context in a core file usually described by 3 NOTE entries.
-+Status ProcessElfCore::ParseThreadContextsFromNoteSegment(
-+    const elf::ELFProgramHeader *segment_header, DataExtractor segment_data) {
-+
-+  assert(segment_header && segment_header->p_type == llvm::ELF::PT_NOTE);
-+
-+  switch (GetArchitecture().GetTriple().getOS()) {
-+  case llvm::Triple::NetBSD:
-+    return ParseThreadContextsFromNoteSegmentNetBSD(segment_header,
-+                                                    segment_data);
-+  default:
-+    return ParseThreadContextsFromNoteSegmentGeneric(segment_header,
-+                                                     segment_data);
-+  }
-+}
-+
-+/// Generic (Linux, Android, FreeBSD, ...) Thread context from PT_NOTE segment
-+/// 1) A Thread Context in a core file usually described by 3 NOTE entries.
- ///    a) NT_PRSTATUS - Register context
- ///    b) NT_PRPSINFO - Process info(pid..)
- ///    c) NT_FPREGSET - Floating point registers
--/// 4) The NOTE entries can be in any order
--/// 5) If a core file contains multiple thread contexts then there is two data
-+/// 2) The NOTE entries can be in any order
-+/// 3) If a core file contains multiple thread contexts then there is two data
- /// forms
- ///    a) Each thread context(2 or more NOTE entries) contained in its own
- ///    segment (PT_NOTE)
-@@ -540,8 +578,9 @@ static void ParseOpenBSDProcInfo(ThreadD
- ///        new thread when it finds NT_PRSTATUS or NT_PRPSINFO NOTE entry.
- ///    For case (b) there may be either one NT_PRPSINFO per thread, or a single
- ///    one that applies to all threads (depending on the platform type).
--Status ProcessElfCore::ParseThreadContextsFromNoteSegment(
-+Status ProcessElfCore::ParseThreadContextsFromNoteSegmentGeneric(
-     const elf::ELFProgramHeader *segment_header, DataExtractor segment_data) {
-+
-   assert(segment_header && segment_header->p_type == llvm::ELF::PT_NOTE);
- 
-   lldb::offset_t offset = 0;
-@@ -607,21 +646,6 @@ Status ProcessElfCore::ParseThreadContext
-       default:
-         break;
-       }
--    } else if (note.n_name.substr(0, 11) == "NetBSD-CORE") {
--      // NetBSD per-thread information is stored in notes named
--      // "NetBSD-CORE@nnn" so match on the initial part of the string.
--      m_os = llvm::Triple::NetBSD;
--      if (note.n_type == NETBSD::NT_PROCINFO) {
--        ParseNetBSDProcInfo(*thread_data, note_data);
--      } else if (note.n_type == NETBSD::NT_AUXV) {
--        m_auxv = DataExtractor(note_data);
--      } else if (arch.GetMachine() == llvm::Triple::x86_64 &&
--                 note.n_type == NETBSD::NT_AMD64_REGS) {
--        thread_data->gpregset = note_data;
--      } else if (arch.GetMachine() == llvm::Triple::x86_64 &&
--                 note.n_type == NETBSD::NT_AMD64_FPREGS) {
--        thread_data->fpregset = note_data;
--      }
-     } else if (note.n_name.substr(0, 7) == "OpenBSD") {
-       // OpenBSD per-thread information is stored in notes named
-       // "OpenBSD@nnn" so match on the initial part of the string.
-@@ -659,7 +683,7 @@ Status ProcessElfCore::ParseThreadContext
-         // The result from FXSAVE is in NT_PRXFPREG for i386 core files
-         if (arch.GetCore() == ArchSpec::eCore_x86_64_x86_64)
-           thread_data->fpregset = note_data;
--        else if(arch.IsMIPS())
-+        else if (arch.IsMIPS())
-           thread_data->fpregset = note_data;
-         break;
-       case NT_PRPSINFO:
-@@ -717,6 +741,136 @@ Status ProcessElfCore::ParseThreadContext
-   return error;
- }
- 
-+/// NetBSD specific Thread context from PT_NOTE segment
-+///
-+/// NetBSD ELF core files use notes to provide information about
-+/// the process's state.  The note name is "NetBSD-CORE" for
-+/// information that is global to the process, and "NetBSD-CORE@nn",
-+/// where "nn" is the lwpid of the LWP that the information belongs
-+/// to (such as register state).
-+///
-+/// NetBSD uses the following note identifiers:
-+///
-+///      ELF_NOTE_NETBSD_CORE_PROCINFO (value 1)
-+///             Note is a "netbsd_elfcore_procinfo" structure.
-+///      ELF_NOTE_NETBSD_CORE_AUXV     (value 2; since NetBSD 8.0)
-+///             Note is an array of AuxInfo structures.
-+///
-+/// NetBSD also uses ptrace(2) request numbers (the ones that exist in
-+/// machine-dependent space) to identify register info notes.  The
-+/// info in such notes is in the same format that ptrace(2) would
-+/// export that information.
-+///
-+/// For more information see /usr/include/sys/exec_elf.h
-+///
-+Status ProcessElfCore::ParseThreadContextsFromNoteSegmentNetBSD(
-+    const elf::ELFProgramHeader *segment_header, DataExtractor segment_data) {
-+
-+  assert(segment_header && segment_header->p_type == llvm::ELF::PT_NOTE);
-+
-+  lldb::offset_t offset = 0;
-+  ArchSpec arch = GetArchitecture();
-+  m_os = llvm::Triple::NetBSD;
-+
-+  /*
-+   * To be extracted from struct netbsd_elfcore_procinfo
-+   * Used to sanity check of the LWPs of the process
-+   */
-+  uint32_t nlwps = 0;
-+  uint32_t signo;  /* killing signal */
-+  uint32_t siglwp; /* LWP target of killing signal */
-+
-+  while (offset < segment_header->p_filesz) {
-+    ELFNote note = ELFNote();
-+    note.Parse(segment_data, &offset);
-+
-+    size_t note_start, note_size;
-+    note_start = offset;
-+    note_size = llvm::alignTo(note.n_descsz, 4);
-+
-+    // Store the NOTE information in the current thread
-+    DataExtractor note_data(segment_data, note_start, note_size);
-+    note_data.SetAddressByteSize(
-+        m_core_module_sp->GetArchitecture().GetAddressByteSize());
-+
-+    llvm::StringRef name = note.n_name;
-+
-+    if (name == "NetBSD-CORE") {
-+      if (note.n_type == NETBSD::NT_PROCINFO) {
-+        Status error = ParseNetBSDProcInfo(note_data, nlwps, signo, siglwp);
-+        if (error.Fail())
-+          return error;
-+      } else if (note.n_type == NETBSD::NT_AUXV) {
-+        m_auxv = DataExtractor(note_data);
-+      }
-+    } else if (name.consume_front("NetBSD-CORE@")) {
-+      lldb::tid_t tid;
-+      if (name.getAsInteger(10, tid))
-+        return Status("Status parsing NetBSD core(5) notes: Cannot convert "
-+                     "LWP ID to integer");
-+
-+      switch (arch.GetMachine()) {
-+      case llvm::Triple::x86_64: {
-+        /* Assume order PT_GETREGS, PT_GETFPREGS */
-+        if (note.n_type == NETBSD::AMD64::NT_REGS) {
-+          m_thread_data.push_back(ThreadData());
-+          m_thread_data.back().gpregset = note_data;
-+          m_thread_data.back().tid = tid;
-+        } else if (note.n_type == NETBSD::AMD64::NT_FPREGS) {
-+          if (m_thread_data.empty() || tid != m_thread_data.back().tid)
-+            return Status("Error parsing NetBSD core(5) notes: Unexpected order "
-+                         "of NOTEs PT_GETFPREG before PT_GETREG");
-+          m_thread_data.back().fpregset = note_data;
-+        } else {
-+          return Status(
-+              "Error parsing NetBSD core(5) notes: Unsupported AMD64 NOTE");
-+        }
-+      } break;
-+      default:
-+        return Status(
-+            "Error parsing NetBSD core(5) notes: Unsupported architecture");
-+      }
-+    } else {
-+      return Status("Error parsing NetBSD core(5) notes: Unrecognized note");
-+    }
-+
-+    offset += note_size;
-+  }
-+
-+  if (m_thread_data.empty())
-+    return Status("Error parsing NetBSD core(5) notes: No threads information "
-+                 "specified in notes");
-+
-+  if (m_thread_data.size() != nlwps)
-+    return Status("rror parsing NetBSD core(5) notes: Mismatch between the "
-+                 "number of LWPs in netbsd_elfcore_procinfo and the number of "
-+                 "LWPs specified by MD notes");
-+
-+  /* The whole process signal */
-+  if (siglwp == 0) {
-+    for (auto &data : m_thread_data)
-+      data.signo = signo;
-+  }
-+  /* Signal destinated for a particular LWP */
-+  else {
-+    bool passed = false;
-+
-+    for (auto &data : m_thread_data) {
-+      if (data.tid == siglwp) {
-+        data.signo = signo;
-+        passed = true;
-+        break;
-+      }
-+    }
-+
-+    if (!passed)
-+      return Status(
-+          "Error parsing NetBSD core(5) notes: Signal passed to unknown LWP");
-+  }
-+
-+  return Status();
-+}
-+
- uint32_t ProcessElfCore::GetNumThreadContexts() {
-   if (!m_thread_data_valid)
-     DoLoadCore();
-@@ -730,7 +884,7 @@ ArchSpec ProcessElfCore::GetArchitecture
-   core_file->GetArchitecture(arch);
- 
-   ArchSpec target_arch = GetTarget().GetArchitecture();
--  
-+
-   if (target_arch.IsMIPS())
-     return target_arch;
- 
diff --git a/lldb-netbsd/patches/patch-source_Plugins_Process_elf-core_ProcessElfCore.h b/lldb-netbsd/patches/patch-source_Plugins_Process_elf-core_ProcessElfCore.h
deleted file mode 100644
index d62e2c4b29..0000000000
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_elf-core_ProcessElfCore.h
+++ /dev/null
@@ -1,23 +0,0 @@
-$NetBSD$
-
---- source/Plugins/Process/elf-core/ProcessElfCore.h.orig	2017-05-24 01:55:02.000000000 +0000
-+++ source/Plugins/Process/elf-core/ProcessElfCore.h
-@@ -125,6 +125,18 @@ private:
-     lldb_private::ConstString path;
-   };
- 
-+  // Parse thread(s) data structuresNetBSD(prstatus, prpsinfo) from given NOTE
-+  // segment
-+  lldb_private::Status ParseThreadContextsFromNoteSegmentNetBSD(
-+      const elf::ELFProgramHeader *segment_header,
-+      lldb_private::DataExtractor segment_data);
-+
-+  // Parse thread(s) data structuresGeneric(prstatus, prpsinfo) from given NOTE
-+  // segment
-+  lldb_private::Status ParseThreadContextsFromNoteSegmentGeneric(
-+      const elf::ELFProgramHeader *segment_header,
-+      lldb_private::DataExtractor segment_data);
-+
-   //------------------------------------------------------------------
-   // For ProcessElfCore only
-   //------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index