[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2019-03-06 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 189503.
mgorny added a comment.

I've attempted to rebase Kamil's patch against the current sources. Please note 
that this is not the final version; I'll add a test case and PID reading later.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D32149/new/

https://reviews.llvm.org/D32149

Files:
  lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
  lldb/source/Plugins/Process/elf-core/RegisterUtilities.h

Index: lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
===
--- lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
+++ lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
@@ -27,9 +27,42 @@
 }
 
 namespace NETBSD {
-enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33, NT_AMD64_FPREGS = 35 };
+enum { NT_PROCINFO = 1, NT_AUXV = 2 };
+
+/* Size in bytes */
+enum { NT_PROCINFO_SIZE = 160 };
+
+/* Size in bytes */
+enum {
+  NT_PROCINFO_CPI_VERSION_SIZE = 4,
+  NT_PROCINFO_CPI_CPISIZE_SIZE = 4,
+  NT_PROCINFO_CPI_SIGNO_SIZE = 4,
+  NT_PROCINFO_CPI_SIGCODE_SIZE = 4,
+  NT_PROCINFO_CPI_SIGPEND_SIZE = 16,
+  NT_PROCINFO_CPI_SIGMASK_SIZE = 16,
+  NT_PROCINFO_CPI_SIGIGNORE_SIZE = 16,
+  NT_PROCINFO_CPI_SIGCATCH_SIZE = 16,
+  NT_PROCINFO_CPI_PID_SIZE = 4,
+  NT_PROCINFO_CPI_PPID_SIZE = 4,
+  NT_PROCINFO_CPI_PGRP_SIZE = 4,
+  NT_PROCINFO_CPI_SID_SIZE = 4,
+  NT_PROCINFO_CPI_RUID_SIZE = 4,
+  NT_PROCINFO_CPI_EUID_SIZE = 4,
+  NT_PROCINFO_CPI_SVUID_SIZE = 4,
+  NT_PROCINFO_CPI_RGID_SIZE = 4,
+  NT_PROCINFO_CPI_EGID_SIZE = 4,
+  NT_PROCINFO_CPI_SVGID_SIZE = 4,
+  NT_PROCINFO_CPI_NLWPS_SIZE = 4,
+  NT_PROCINFO_CPI_NAME_SIZE = 32,
+  NT_PROCINFO_CPI_SIGLWP_SIZE = 4,
+};
+
+namespace AMD64 {
+enum { NT_REGS = 33, NT_FPREGS = 35 };
 }
 
+} // namespace NETBSD
+
 namespace OPENBSD {
 enum {
   NT_PROCINFO = 10,
@@ -91,7 +124,7 @@
 // The result from FXSAVE is in NT_PRXFPREG for i386 core files
 {llvm::Triple::Linux, llvm::Triple::x86, LINUX::NT_PRXFPREG},
 {llvm::Triple::Linux, llvm::Triple::UnknownArch, LINUX::NT_FPREGSET},
-{llvm::Triple::NetBSD, llvm::Triple::x86_64, NETBSD::NT_AMD64_FPREGS},
+{llvm::Triple::NetBSD, llvm::Triple::x86_64, NETBSD::AMD64::NT_FPREGS},
 {llvm::Triple::OpenBSD, llvm::Triple::UnknownArch, OPENBSD::NT_FPREGS},
 };
 
Index: lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -446,16 +446,47 @@
   thread_data.gpregset = DataExtractor(data, offset, len);
 }
 
-static void ParseNetBSDProcInfo(ThreadData _data,
-const DataExtractor ) {
+static llvm::Error ParseNetBSDProcInfo(const DataExtractor ,
+   uint32_t _nlwps,
+   uint32_t _signo,
+   uint32_t _siglwp) {
   lldb::offset_t offset = 0;
 
-  int version = data.GetU32();
+  uint32_t version = data.GetU32();
   if (version != 1)
-return;
+return llvm::make_error(
+"Error parsing NetBSD core(5) notes: Unsupported procinfo version",
+llvm::inconvertibleErrorCode());
 
-  offset += 4;
-  thread_data.signo = data.GetU32();
+  uint32_t cpisize = data.GetU32();
+  if (cpisize != NETBSD::NT_PROCINFO_SIZE)
+return llvm::make_error(
+"Error parsing NetBSD core(5) notes: Unsupported procinfo size",
+llvm::inconvertibleErrorCode());
+
+  cpi_signo = data.GetU32(); /* killing signal */
+
+  offset += NETBSD::NT_PROCINFO_CPI_SIGCODE_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGPEND_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGMASK_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGIGNORE_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGCATCH_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_PID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_PPID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_PGRP_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_RUID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_EUID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SVUID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_RGID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_EGID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SVGID_SIZE;
+  cpi_nlwps = data.GetU32(); /* number of LWPs */
+
+  offset += NETBSD::NT_PROCINFO_CPI_NAME_SIZE;
+  cpi_siglwp = data.GetU32(); /* LWP target of killing signal */
+
+  return llvm::Error::success();
 }
 
 static void ParseOpenBSDProcInfo(ThreadData _data,
@@ -541,37 +572,140 @@
   return llvm::Error::success();
 }
 
+/// 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 

[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-05-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Affirmative. Tests should go in together with the feature they are testing.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-05-24 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

In https://reviews.llvm.org/D32149#763008, @labath wrote:

> What was your decision on the core files? I was under the impression you were 
> gonna add the zip files as well. If so, then they should go in at the same 
> time.


In the same commit? If so I will try to amend the patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-05-24 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

What was your decision on the core files? I was under the impression you were 
gonna add the zip files as well. If so, then they should go in at the same time.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-05-23 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

Can we go with this change?


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-05-23 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski updated this revision to Diff 100035.
krytarowski added a comment.

Rebase to HEAD.
Apply "Error" -> "Status" rename.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.h

Index: source/Plugins/Process/elf-core/ProcessElfCore.h
===
--- source/Plugins/Process/elf-core/ProcessElfCore.h
+++ source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -125,6 +125,18 @@
 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
   //--
Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -27,6 +27,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"
 
@@ -458,9 +459,42 @@
 
 namespace NETBSD {
 
-enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33, NT_AMD64_FPREGS = 35 };
+enum { NT_PROCINFO = 1, NT_AUXV = 2 };
+
+/* Size in bytes */
+enum { NT_PROCINFO_SIZE = 160 };
+
+/* Size in bytes */
+enum {
+  NT_PROCINFO_CPI_VERSION_SIZE = 4,
+  NT_PROCINFO_CPI_CPISIZE_SIZE = 4,
+  NT_PROCINFO_CPI_SIGNO_SIZE = 4,
+  NT_PROCINFO_CPI_SIGCODE_SIZE = 4,
+  NT_PROCINFO_CPI_SIGPEND_SIZE = 16,
+  NT_PROCINFO_CPI_SIGMASK_SIZE = 16,
+  NT_PROCINFO_CPI_SIGIGNORE_SIZE = 16,
+  NT_PROCINFO_CPI_SIGCATCH_SIZE = 16,
+  NT_PROCINFO_CPI_PID_SIZE = 4,
+  NT_PROCINFO_CPI_PPID_SIZE = 4,
+  NT_PROCINFO_CPI_PGRP_SIZE = 4,
+  NT_PROCINFO_CPI_SID_SIZE = 4,
+  NT_PROCINFO_CPI_RUID_SIZE = 4,
+  NT_PROCINFO_CPI_EUID_SIZE = 4,
+  NT_PROCINFO_CPI_SVUID_SIZE = 4,
+  NT_PROCINFO_CPI_RGID_SIZE = 4,
+  NT_PROCINFO_CPI_EGID_SIZE = 4,
+  NT_PROCINFO_CPI_SVGID_SIZE = 4,
+  NT_PROCINFO_CPI_NLWPS_SIZE = 4,
+  NT_PROCINFO_CPI_NAME_SIZE = 32,
+  NT_PROCINFO_CPI_SIGLWP_SIZE = 4,
+};
+
+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 _data, DataExtractor ,
  ArchSpec ) {
@@ -497,15 +531,43 @@
   thread_data.name = data.GetCStr(, 20);
 }
 
-static void ParseNetBSDProcInfo(ThreadData _data, DataExtractor ) {
+static Status ParseNetBSDProcInfo(DataExtractor , uint32_t _nlwps,
+ uint32_t _signo, uint32_t _siglwp) {
   lldb::offset_t offset = 0;
 
-  int version = data.GetU32();
+  uint32_t version = data.GetU32();
   if (version != 1)
-return;
+return Status(
+"Error parsing NetBSD core(5) notes: Unsupported procinfo version");
+
+  uint32_t cpisize = data.GetU32();
+  if (cpisize != NETBSD::NT_PROCINFO_SIZE)
+return Status(
+"Error parsing NetBSD core(5) notes: Unsupported procinfo size");
+
+  cpi_signo = data.GetU32(); /* killing signal */
+
+  offset += NETBSD::NT_PROCINFO_CPI_SIGCODE_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGPEND_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGMASK_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGIGNORE_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGCATCH_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_PID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_PPID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_PGRP_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_RUID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_EUID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SVUID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_RGID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_EGID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SVGID_SIZE;
+  cpi_nlwps = data.GetU32(); /* number of LWPs */
+
+  offset += NETBSD::NT_PROCINFO_CPI_NAME_SIZE;
+  cpi_siglwp = data.GetU32(); /* LWP target of killing signal */
 
-  offset += 4;
-  thread_data.signo = data.GetU32();
+  return Status();
 }
 
 static void ParseOpenBSDProcInfo(ThreadData _data, DataExtractor ) {
@@ -524,12 +586,28 @@
 /// 1) A PT_NOTE segment is composed of one or more NOTE entries.
 /// 2) NOTE Entry contains a standard 

[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-28 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski updated this revision to Diff 97150.
krytarowski added a comment.

Remove another unrelated style improvement.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.h

Index: source/Plugins/Process/elf-core/ProcessElfCore.h
===
--- source/Plugins/Process/elf-core/ProcessElfCore.h
+++ source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -125,6 +125,18 @@
 lldb_private::ConstString path;
   };
 
+  // Parse thread(s) data structuresNetBSD(prstatus, prpsinfo) from given NOTE
+  // segment
+  lldb_private::Error ParseThreadContextsFromNoteSegmentNetBSD(
+  const elf::ELFProgramHeader *segment_header,
+  lldb_private::DataExtractor segment_data);
+
+  // Parse thread(s) data structuresGeneric(prstatus, prpsinfo) from given NOTE
+  // segment
+  lldb_private::Error ParseThreadContextsFromNoteSegmentGeneric(
+  const elf::ELFProgramHeader *segment_header,
+  lldb_private::DataExtractor segment_data);
+
   //--
   // For ProcessElfCore only
   //--
Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -27,6 +27,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"
 
@@ -458,9 +459,42 @@
 
 namespace NETBSD {
 
-enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33, NT_AMD64_FPREGS = 35 };
+enum { NT_PROCINFO = 1, NT_AUXV = 2 };
+
+/* Size in bytes */
+enum { NT_PROCINFO_SIZE = 160 };
+
+/* Size in bytes */
+enum {
+  NT_PROCINFO_CPI_VERSION_SIZE = 4,
+  NT_PROCINFO_CPI_CPISIZE_SIZE = 4,
+  NT_PROCINFO_CPI_SIGNO_SIZE = 4,
+  NT_PROCINFO_CPI_SIGCODE_SIZE = 4,
+  NT_PROCINFO_CPI_SIGPEND_SIZE = 16,
+  NT_PROCINFO_CPI_SIGMASK_SIZE = 16,
+  NT_PROCINFO_CPI_SIGIGNORE_SIZE = 16,
+  NT_PROCINFO_CPI_SIGCATCH_SIZE = 16,
+  NT_PROCINFO_CPI_PID_SIZE = 4,
+  NT_PROCINFO_CPI_PPID_SIZE = 4,
+  NT_PROCINFO_CPI_PGRP_SIZE = 4,
+  NT_PROCINFO_CPI_SID_SIZE = 4,
+  NT_PROCINFO_CPI_RUID_SIZE = 4,
+  NT_PROCINFO_CPI_EUID_SIZE = 4,
+  NT_PROCINFO_CPI_SVUID_SIZE = 4,
+  NT_PROCINFO_CPI_RGID_SIZE = 4,
+  NT_PROCINFO_CPI_EGID_SIZE = 4,
+  NT_PROCINFO_CPI_SVGID_SIZE = 4,
+  NT_PROCINFO_CPI_NLWPS_SIZE = 4,
+  NT_PROCINFO_CPI_NAME_SIZE = 32,
+  NT_PROCINFO_CPI_SIGLWP_SIZE = 4,
+};
+
+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 _data, DataExtractor ,
  ArchSpec ) {
@@ -497,15 +531,43 @@
   thread_data.name = data.GetCStr(, 20);
 }
 
-static void ParseNetBSDProcInfo(ThreadData _data, DataExtractor ) {
+static Error ParseNetBSDProcInfo(DataExtractor , uint32_t _nlwps,
+ uint32_t _signo, uint32_t _siglwp) {
   lldb::offset_t offset = 0;
 
-  int version = data.GetU32();
+  uint32_t version = data.GetU32();
   if (version != 1)
-return;
+return Error(
+"Error parsing NetBSD core(5) notes: Unsupported procinfo version");
+
+  uint32_t cpisize = data.GetU32();
+  if (cpisize != NETBSD::NT_PROCINFO_SIZE)
+return Error(
+"Error parsing NetBSD core(5) notes: Unsupported procinfo size");
+
+  cpi_signo = data.GetU32(); /* killing signal */
+
+  offset += NETBSD::NT_PROCINFO_CPI_SIGCODE_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGPEND_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGMASK_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGIGNORE_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGCATCH_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_PID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_PPID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_PGRP_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_RUID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_EUID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SVUID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_RGID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_EGID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SVGID_SIZE;
+  cpi_nlwps = data.GetU32(); /* number of LWPs */
+
+  offset += NETBSD::NT_PROCINFO_CPI_NAME_SIZE;
+  cpi_siglwp = data.GetU32(); /* LWP target of killing signal */
 
-  offset += 4;
-  thread_data.signo = data.GetU32();
+  return Error();
 }
 
 static void ParseOpenBSDProcInfo(ThreadData _data, DataExtractor ) {
@@ -524,12 +586,28 @@
 /// 1) A PT_NOTE segment is composed of one or more NOTE entries.
 /// 2) NOTE Entry contains a standard header followed 

[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-28 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski updated this revision to Diff 97149.
krytarowski added a comment.

Strip non-functional style improvements in unrelated code-parts.

Apply changes to address comments from Joerg.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.h

Index: source/Plugins/Process/elf-core/ProcessElfCore.h
===
--- source/Plugins/Process/elf-core/ProcessElfCore.h
+++ source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -125,6 +125,18 @@
 lldb_private::ConstString path;
   };
 
+  // Parse thread(s) data structuresNetBSD(prstatus, prpsinfo) from given NOTE
+  // segment
+  lldb_private::Error ParseThreadContextsFromNoteSegmentNetBSD(
+  const elf::ELFProgramHeader *segment_header,
+  lldb_private::DataExtractor segment_data);
+
+  // Parse thread(s) data structuresGeneric(prstatus, prpsinfo) from given NOTE
+  // segment
+  lldb_private::Error ParseThreadContextsFromNoteSegmentGeneric(
+  const elf::ELFProgramHeader *segment_header,
+  lldb_private::DataExtractor segment_data);
+
   //--
   // For ProcessElfCore only
   //--
Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -27,6 +27,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"
 
@@ -458,9 +459,42 @@
 
 namespace NETBSD {
 
-enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33, NT_AMD64_FPREGS = 35 };
+enum { NT_PROCINFO = 1, NT_AUXV = 2 };
+
+/* Size in bytes */
+enum { NT_PROCINFO_SIZE = 160 };
+
+/* Size in bytes */
+enum {
+  NT_PROCINFO_CPI_VERSION_SIZE = 4,
+  NT_PROCINFO_CPI_CPISIZE_SIZE = 4,
+  NT_PROCINFO_CPI_SIGNO_SIZE = 4,
+  NT_PROCINFO_CPI_SIGCODE_SIZE = 4,
+  NT_PROCINFO_CPI_SIGPEND_SIZE = 16,
+  NT_PROCINFO_CPI_SIGMASK_SIZE = 16,
+  NT_PROCINFO_CPI_SIGIGNORE_SIZE = 16,
+  NT_PROCINFO_CPI_SIGCATCH_SIZE = 16,
+  NT_PROCINFO_CPI_PID_SIZE = 4,
+  NT_PROCINFO_CPI_PPID_SIZE = 4,
+  NT_PROCINFO_CPI_PGRP_SIZE = 4,
+  NT_PROCINFO_CPI_SID_SIZE = 4,
+  NT_PROCINFO_CPI_RUID_SIZE = 4,
+  NT_PROCINFO_CPI_EUID_SIZE = 4,
+  NT_PROCINFO_CPI_SVUID_SIZE = 4,
+  NT_PROCINFO_CPI_RGID_SIZE = 4,
+  NT_PROCINFO_CPI_EGID_SIZE = 4,
+  NT_PROCINFO_CPI_SVGID_SIZE = 4,
+  NT_PROCINFO_CPI_NLWPS_SIZE = 4,
+  NT_PROCINFO_CPI_NAME_SIZE = 32,
+  NT_PROCINFO_CPI_SIGLWP_SIZE = 4,
+};
+
+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 _data, DataExtractor ,
  ArchSpec ) {
@@ -497,15 +531,43 @@
   thread_data.name = data.GetCStr(, 20);
 }
 
-static void ParseNetBSDProcInfo(ThreadData _data, DataExtractor ) {
+static Error ParseNetBSDProcInfo(DataExtractor , uint32_t _nlwps,
+ uint32_t _signo, uint32_t _siglwp) {
   lldb::offset_t offset = 0;
 
-  int version = data.GetU32();
+  uint32_t version = data.GetU32();
   if (version != 1)
-return;
+return Error(
+"Error parsing NetBSD core(5) notes: Unsupported procinfo version");
+
+  uint32_t cpisize = data.GetU32();
+  if (cpisize != NETBSD::NT_PROCINFO_SIZE)
+return Error(
+"Error parsing NetBSD core(5) notes: Unsupported procinfo size");
+
+  cpi_signo = data.GetU32(); /* killing signal */
+
+  offset += NETBSD::NT_PROCINFO_CPI_SIGCODE_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGPEND_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGMASK_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGIGNORE_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGCATCH_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_PID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_PPID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_PGRP_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_RUID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_EUID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SVUID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_RGID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_EGID_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SVGID_SIZE;
+  cpi_nlwps = data.GetU32(); /* number of LWPs */
+
+  offset += NETBSD::NT_PROCINFO_CPI_NAME_SIZE;
+  cpi_siglwp = data.GetU32(); /* LWP target of killing signal */
 
-  offset += 4;
-  thread_data.signo = data.GetU32();
+  return Error();
 }
 
 static void ParseOpenBSDProcInfo(ThreadData _data, DataExtractor ) {
@@ -524,12 +586,28 @@
 /// 1) A PT_NOTE segment is composed of one or more 

[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-27 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

In https://reviews.llvm.org/D32149#739727, @labath wrote:

> In https://reviews.llvm.org/D32149#738250, @krytarowski wrote:
>
> > ping?
>
>
> Sorry, I wasn't responding partially because I was waiting to see how the 
> discussion on https://reviews.llvm.org/D32434 settles, as I think it may have 
> effect on the test strategy. I'll write more tomorrow. :)


Thanks for working on it. I will upload soon changes to address notes by Joerg.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-27 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D32149#738250, @krytarowski wrote:

> ping?


Sorry, I wasn't responding partially because I was waiting to see how the 
discussion on https://reviews.llvm.org/D32434 settles, as I think it may have 
effect on the test strategy. I'll write more tomorrow. :)


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-27 Thread Kamil Rytarowski via lldb-commits
Thanks, I will give it a try!

On 27.04.2017 17:59, Zachary Turner wrote:
> In case it's not obvious, note the space in the command I said to run.
>  `git-clang-format` has a dash, and when you run `git clang-format`
> (with a space), it will run the file with the dash.
> 
> On Thu, Apr 27, 2017 at 8:58 AM Zachary Turner  > wrote:
> 
> There is a file in the repo called git-clang-format.  Make sure that
> file is on your PATH somewhere, then just run `git clang-format`. 
> It will only touch lines that are part of your diff, and leave
> surrounding lines alone.  When making a diff, we only want to
> clang-format the lines we touched, not the entire files.
> 
> On Thu, Apr 27, 2017 at 8:56 AM Kamil Rytarowski via Phabricator
> > wrote:
> 
> krytarowski added inline comments.
> 
> 
> 
> Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:302
> +  // default 32 or 64 bit arch (without any architecture
> revision) based on
> +  // object file's class.
>if (header.e_type == ET_CORE) {
> 
> joerg wrote:
> > Unrelated cosmetic change.
> I let clang-format to go and alter minor things. I can run
> clang-format over original files - commit, and add my diff again.
> 
> 
> 
> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:463
> 
> -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 };
> +
> 
> joerg wrote:
> > Either sort them by value or by name, but not randomly
> I will split this enum{} into two enums.
> 
> 
> 
> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:523
> +
> +  offset += 108;
> +  cpi_nlwps = data.GetU32(); /* number of LWPs */
> 
> joerg wrote:
> > Can you define a constant for the offset here below instead of
> a magic number?
> I will try to get something to define aliases for these magic
> numbers.
> 
> 
> 
> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:844
> +  if (m_thread_data.size() != nlwps)
> +return Error("rror parsing NetBSD core(5) notes: Mismatch
> between the "
> + "number of LWPs in netbsd_elfcore_procinfo and
> the number of "
> 
> joerg wrote:
> > Typo
> OK
> 
> 
> 
> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:854
> +  /* Signal destinated for a particular LWP */
> +  else {
> +bool passed = false;
> 
> joerg wrote:
> > Move the else to the } and the comment after the {
> OK
> 
> 
> Repository:
>   rL LLVM
> 
> https://reviews.llvm.org/D32149
> 
> 
> 




signature.asc
Description: OpenPGP digital signature
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-27 Thread Zachary Turner via lldb-commits
In case it's not obvious, note the space in the command I said to run.
 `git-clang-format` has a dash, and when you run `git clang-format` (with a
space), it will run the file with the dash.

On Thu, Apr 27, 2017 at 8:58 AM Zachary Turner  wrote:

> There is a file in the repo called git-clang-format.  Make sure that file
> is on your PATH somewhere, then just run `git clang-format`.  It will only
> touch lines that are part of your diff, and leave surrounding lines alone.
> When making a diff, we only want to clang-format the lines we touched, not
> the entire files.
>
> On Thu, Apr 27, 2017 at 8:56 AM Kamil Rytarowski via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> krytarowski added inline comments.
>>
>>
>> 
>> Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:302
>> +  // default 32 or 64 bit arch (without any architecture revision) based
>> on
>> +  // object file's class.
>>if (header.e_type == ET_CORE) {
>> 
>> joerg wrote:
>> > Unrelated cosmetic change.
>> I let clang-format to go and alter minor things. I can run clang-format
>> over original files - commit, and add my diff again.
>>
>>
>> 
>> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:463
>>
>> -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 };
>> +
>> 
>> joerg wrote:
>> > Either sort them by value or by name, but not randomly
>> I will split this enum{} into two enums.
>>
>>
>> 
>> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:523
>> +
>> +  offset += 108;
>> +  cpi_nlwps = data.GetU32(); /* number of LWPs */
>> 
>> joerg wrote:
>> > Can you define a constant for the offset here below instead of a magic
>> number?
>> I will try to get something to define aliases for these magic numbers.
>>
>>
>> 
>> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:844
>> +  if (m_thread_data.size() != nlwps)
>> +return Error("rror parsing NetBSD core(5) notes: Mismatch between
>> the "
>> + "number of LWPs in netbsd_elfcore_procinfo and the
>> number of "
>> 
>> joerg wrote:
>> > Typo
>> OK
>>
>>
>> 
>> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:854
>> +  /* Signal destinated for a particular LWP */
>> +  else {
>> +bool passed = false;
>> 
>> joerg wrote:
>> > Move the else to the } and the comment after the {
>> OK
>>
>>
>> Repository:
>>   rL LLVM
>>
>> https://reviews.llvm.org/D32149
>>
>>
>>
>>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-27 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added inline comments.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:302
+  // default 32 or 64 bit arch (without any architecture revision) based on
+  // object file's class.
   if (header.e_type == ET_CORE) {

joerg wrote:
> Unrelated cosmetic change.
I let clang-format to go and alter minor things. I can run clang-format over 
original files - commit, and add my diff again.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:463
 
-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 };
+

joerg wrote:
> Either sort them by value or by name, but not randomly
I will split this enum{} into two enums.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:523
+
+  offset += 108;
+  cpi_nlwps = data.GetU32(); /* number of LWPs */

joerg wrote:
> Can you define a constant for the offset here below instead of a magic number?
I will try to get something to define aliases for these magic numbers.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:844
+  if (m_thread_data.size() != nlwps)
+return Error("rror parsing NetBSD core(5) notes: Mismatch between the "
+ "number of LWPs in netbsd_elfcore_procinfo and the number of "

joerg wrote:
> Typo
OK



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:854
+  /* Signal destinated for a particular LWP */
+  else {
+bool passed = false;

joerg wrote:
> Move the else to the } and the comment after the {
OK


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-27 Thread Joerg Sonnenberger via Phabricator via lldb-commits
joerg added inline comments.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:55
 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";

Not your fault, but is there a reason why this are all pointers to strings and 
not just const char[] ?



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:302
+  // default 32 or 64 bit arch (without any architecture revision) based on
+  // object file's class.
   if (header.e_type == ET_CORE) {

Unrelated cosmetic change.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:412
+data_sp = DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length,
+  file_offset);
 if (!data_sp)

Unrelated cosmetic change.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:775
+data_sp = DataBufferLLVM::CreateSliceFromPath(file.GetPath(),
+  -1, file_offset);
 if (data_sp) {

Dito.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1488
   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")) {

Unrelated.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:3042
+  [this, symbol_table, section_list,
+   _symbols](lldb::addr_t file_addr, uint32_t size, dw_offset_t) {
+Symbol *symbol = symbol_table->FindSymbolAtFileAddress(file_addr);

Unrelated.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:3066
+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

Unrelated.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:378
+  // Don't proceed if core file doesn't contain the actual data for this 
address
+  // range.
   if (file_start == file_end)

Unrelated.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:463
 
-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 };
+

Either sort them by value or by name, but not randomly



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:523
+
+  offset += 108;
+  cpi_nlwps = data.GetU32(); /* number of LWPs */

Can you define a constant for the offset here below instead of a magic number?



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:685
   thread_data->fpregset = note_data;
-else if(arch.IsMIPS())
+else if (arch.IsMIPS())
   thread_data->fpregset = note_data;

Unrelated.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:844
+  if (m_thread_data.size() != nlwps)
+return Error("rror parsing NetBSD core(5) notes: Mismatch between the "
+ "number of LWPs in netbsd_elfcore_procinfo and the number of "

Typo



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:854
+  /* Signal destinated for a particular LWP */
+  else {
+bool passed = false;

Move the else to the } and the comment after the {


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-26 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

ping?


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-21 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski updated this revision to Diff 96272.
krytarowski edited the summary of this revision.
krytarowski added a comment.
Herald added a subscriber: srhines.

Fix handling executable and shared library triple detection.

Apply changes from review.

Update revision summary.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.h

Index: source/Plugins/Process/elf-core/ProcessElfCore.h
===
--- source/Plugins/Process/elf-core/ProcessElfCore.h
+++ source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -125,6 +125,18 @@
 lldb_private::ConstString path;
   };
 
+  // Parse thread(s) data structuresNetBSD(prstatus, prpsinfo) from given NOTE
+  // segment
+  lldb_private::Error ParseThreadContextsFromNoteSegmentNetBSD(
+  const elf::ELFProgramHeader *segment_header,
+  lldb_private::DataExtractor segment_data);
+
+  // Parse thread(s) data structuresGeneric(prstatus, prpsinfo) from given NOTE
+  // segment
+  lldb_private::Error ParseThreadContextsFromNoteSegmentGeneric(
+  const elf::ELFProgramHeader *segment_header,
+  lldb_private::DataExtractor segment_data);
+
   //--
   // For ProcessElfCore only
   //--
Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -27,6 +27,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 +220,7 @@
   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 +374,8 @@
   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 +460,14 @@
 
 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 _data, DataExtractor ,
  ArchSpec ) {
@@ -497,15 +504,29 @@
   thread_data.name = data.GetCStr(, 20);
 }
 
-static void ParseNetBSDProcInfo(ThreadData _data, DataExtractor ) {
+static Error ParseNetBSDProcInfo(DataExtractor , uint32_t _nlwps,
+ uint32_t _signo, uint32_t _siglwp) {
   lldb::offset_t offset = 0;
 
-  int version = data.GetU32();
+  uint32_t version = data.GetU32();
   if (version != 1)
-return;
+return Error(
+"Error parsing NetBSD core(5) notes: Unsupported procinfo version");
 
-  offset += 4;
-  thread_data.signo = data.GetU32();
+  uint32_t cpisize = data.GetU32();
+  if (cpisize != NETBSD::NT_PROCINFO_SIZE)
+return Error(
+"Error parsing NetBSD core(5) notes: Unsupported procinfo size");
+
+  cpi_signo = data.GetU32(); /* killing signal */
+
+  offset += 108;
+  cpi_nlwps = data.GetU32(); /* number of LWPs */
+
+  offset += 32;
+  cpi_siglwp = data.GetU32(); /* LWP target of killing signal */
+
+  return Error();
 }
 
 static void ParseOpenBSDProcInfo(ThreadData _data, DataExtractor ) {
@@ -524,12 +545,28 @@
 /// 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.
+Error 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, 

Re: [Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-21 Thread Kamil Rytarowski via lldb-commits
Thanks! I'm working on this, I will test new code soon and submit to review.

On 20.04.2017 15:51, Zachary Turner wrote:
> Note that getAsInteger returns false on success, so be careful!
> On Thu, Apr 20, 2017 at 6:09 AM Pavel Labath via Phabricator
> > wrote:
> 
> labath added a comment.
> 
> In https://reviews.llvm.org/D32149#731920, @krytarowski wrote:
> 
> > In https://reviews.llvm.org/D32149#731887, @labath wrote:
> >
> > > A test would infinitely times more valuable then a demo script.
> What is the tiniest core file you can produce on NetBSD? (on linux
> we've gotten them down to about 20K) Then we could check that in and
> write a test for it...
> >
> >
> > This is something I wanted to bring to the dev mailing list.
> >
> > I wanted to prepare at least three tests, if possible four:
> >
> > - one thread (if possible two variations: signal to one particular
> thread + signal to all threads)
> > - multiple threads (signal to one particular thread + signal to
> all threads)
> >
> >   And this in combination of all supported targets (x86_64, i386,
> etc).
> >
> >   Emitting SIGABRT for such program gives core of size 97kilobytes:
> >
> >   ``` int main(){for(;;);} ```
> >
> >   I will write assembly programs for the above cases, without libc.
> 
> 
> Cool, I am looking forward to the results.
> 
> 
> 
> 
> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:795
> +
> +if ((note.n_name == "NetBSD-CORE") &&
> +(note.n_type == NETBSD::NT_PROCINFO)) {
> 
> How about `StringRef name = note.n_name;`
> 
> 
> 
> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:803
> +  m_auxv = DataExtractor(note_data);
> +} else if ((note.n_name.substr(0, 12) == "NetBSD-CORE@")) {
> +  switch (arch.GetMachine()) {
> 
> Then this can be
> ```
> else if (name.consume_front("NetBSD-CORE@")) {
>   ...
>   if (name.getAsInteger(0, tid))
> error...
> ```
> 
> 
> 
> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:848
> +  if (siglwp == 0) {
> +std::for_each(
> +m_thread_data.begin(), m_thread_data.end(),
> 
> `for (auto : m_thread_data) data.signo = signo` seems shorter,
> more understandable, and consistent with other usages in this file.
> 
> 
> 
> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:856
> +
> +for (auto it = m_thread_data.begin(); it !=
> m_thread_data.end(); ++it) {
> +  if (it->tid == siglwp) {
> 
> This could also be a range-based for.
> 
> 
> Repository:
>   rL LLVM
> 
> https://reviews.llvm.org/D32149
> 
> 
> 




signature.asc
Description: OpenPGP digital signature
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-20 Thread Zachary Turner via lldb-commits
Note that getAsInteger returns false on success, so be careful!
On Thu, Apr 20, 2017 at 6:09 AM Pavel Labath via Phabricator <
revi...@reviews.llvm.org> wrote:

> labath added a comment.
>
> In https://reviews.llvm.org/D32149#731920, @krytarowski wrote:
>
> > In https://reviews.llvm.org/D32149#731887, @labath wrote:
> >
> > > A test would infinitely times more valuable then a demo script. What
> is the tiniest core file you can produce on NetBSD? (on linux we've gotten
> them down to about 20K) Then we could check that in and write a test for
> it...
> >
> >
> > This is something I wanted to bring to the dev mailing list.
> >
> > I wanted to prepare at least three tests, if possible four:
> >
> > - one thread (if possible two variations: signal to one particular
> thread + signal to all threads)
> > - multiple threads (signal to one particular thread + signal to all
> threads)
> >
> >   And this in combination of all supported targets (x86_64, i386, etc).
> >
> >   Emitting SIGABRT for such program gives core of size 97kilobytes:
> >
> >   ``` int main(){for(;;);} ```
> >
> >   I will write assembly programs for the above cases, without libc.
>
>
> Cool, I am looking forward to the results.
>
>
>
> 
> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:795
> +
> +if ((note.n_name == "NetBSD-CORE") &&
> +(note.n_type == NETBSD::NT_PROCINFO)) {
> 
> How about `StringRef name = note.n_name;`
>
>
> 
> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:803
> +  m_auxv = DataExtractor(note_data);
> +} else if ((note.n_name.substr(0, 12) == "NetBSD-CORE@")) {
> +  switch (arch.GetMachine()) {
> 
> Then this can be
> ```
> else if (name.consume_front("NetBSD-CORE@")) {
>   ...
>   if (name.getAsInteger(0, tid))
> error...
> ```
>
>
> 
> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:848
> +  if (siglwp == 0) {
> +std::for_each(
> +m_thread_data.begin(), m_thread_data.end(),
> 
> `for (auto : m_thread_data) data.signo = signo` seems shorter, more
> understandable, and consistent with other usages in this file.
>
>
> 
> Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:856
> +
> +for (auto it = m_thread_data.begin(); it != m_thread_data.end();
> ++it) {
> +  if (it->tid == siglwp) {
> 
> This could also be a range-based for.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D32149
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D32149#731920, @krytarowski wrote:

> In https://reviews.llvm.org/D32149#731887, @labath wrote:
>
> > A test would infinitely times more valuable then a demo script. What is the 
> > tiniest core file you can produce on NetBSD? (on linux we've gotten them 
> > down to about 20K) Then we could check that in and write a test for it...
>
>
> This is something I wanted to bring to the dev mailing list.
>
> I wanted to prepare at least three tests, if possible four:
>
> - one thread (if possible two variations: signal to one particular thread + 
> signal to all threads)
> - multiple threads (signal to one particular thread + signal to all threads)
>
>   And this in combination of all supported targets (x86_64, i386, etc).
>
>   Emitting SIGABRT for such program gives core of size 97kilobytes:
>
>   ``` int main(){for(;;);} ```
>
>   I will write assembly programs for the above cases, without libc.


Cool, I am looking forward to the results.




Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:795
+
+if ((note.n_name == "NetBSD-CORE") &&
+(note.n_type == NETBSD::NT_PROCINFO)) {

How about `StringRef name = note.n_name;`



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:803
+  m_auxv = DataExtractor(note_data);
+} else if ((note.n_name.substr(0, 12) == "NetBSD-CORE@")) {
+  switch (arch.GetMachine()) {

Then this can be
```
else if (name.consume_front("NetBSD-CORE@")) {
  ...
  if (name.getAsInteger(0, tid))
error...
```



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:848
+  if (siglwp == 0) {
+std::for_each(
+m_thread_data.begin(), m_thread_data.end(),

`for (auto : m_thread_data) data.signo = signo` seems shorter, more 
understandable, and consistent with other usages in this file.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:856
+
+for (auto it = m_thread_data.begin(); it != m_thread_data.end(); ++it) {
+  if (it->tid == siglwp) {

This could also be a range-based for.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-20 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added inline comments.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1374
+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.

kettenis wrote:
> krytarowski wrote:
> > kettenis wrote:
> > > By making this change you risk losing recognition of "normal" NetBSD ELF 
> > > files, i.e. executables and shared libraries.
> > Hmm, do you mean these notes:
> > 
> > ```
> > $ readelf -n /bin/cat   
> >   
> > 
> > Displaying notes found at file offset 0x0214 with length 0x0018:
> >   Owner Data size   Description
> >   NetBSD0x0004  IDENT 799005900 (7.99.59)
> > 
> > Displaying notes found at file offset 0x022c with length 0x0014:
> >   Owner Data size   Description
> >   NetBSD0x0004  PaX <>
> > ```
> In particular the first one of these.  On OpenBSD I just have a generic check 
> on the name which catches both these and the core file notes.  But on NetBSD 
> those use different names.
I will test it and add switch to support both types of ELF files: core(5) and 
executables.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:563
+
+/// Generic (Linux, ...) specific Thread context from PT_NOTE segment
+/// 1) A Thread Context in a core file usually described by 3 NOTE entries.

kettenis wrote:
> krytarowski wrote:
> > kettenis wrote:
> > > A bit strange to call something both generic and specific...
> > > 
> > > I think some of these note types originated on SVR4/Solaris, but I'm not 
> > > sure how much Linux deviated from that design through the years.
> > Can we call it: Type1 core (as of now: NetBSD) and Type2 core (Linux, 
> > Android, FreeBSD, OpenBSD)?
> > 
> > I don't care which would be 1 and which 2.
> I'd just drop word "specific" from the comment. And OpenBSD will obviously be 
> handled in a similar way as NetBSD in the near future.
Assuming that NetBSD and OpenBSD will share the same function - we can go 
pickup appropriate name now.

As far as I can tell FreeBSD shares similar concept to Linux.

A thread specific data is defined by multiplication of the following notes:

```
  FreeBSD   0x00e0  NT_PRSTATUS (prstatus structure)
  FreeBSD   0x0200  NT_FPREGSET (floating point registers)
  FreeBSD   0x0018  NT_THRMISC (thrmisc structure)
```


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-20 Thread Mark Kettenis via Phabricator via lldb-commits
kettenis added inline comments.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1374
+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.

krytarowski wrote:
> kettenis wrote:
> > By making this change you risk losing recognition of "normal" NetBSD ELF 
> > files, i.e. executables and shared libraries.
> Hmm, do you mean these notes:
> 
> ```
> $ readelf -n /bin/cat 
> 
> 
> Displaying notes found at file offset 0x0214 with length 0x0018:
>   Owner Data size Description
>   NetBSD  0x0004  IDENT 799005900 (7.99.59)
> 
> Displaying notes found at file offset 0x022c with length 0x0014:
>   Owner Data size Description
>   NetBSD  0x0004  PaX <>
> ```
In particular the first one of these.  On OpenBSD I just have a generic check 
on the name which catches both these and the core file notes.  But on NetBSD 
those use different names.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:563
+
+/// Generic (Linux, ...) specific Thread context from PT_NOTE segment
+/// 1) A Thread Context in a core file usually described by 3 NOTE entries.

krytarowski wrote:
> kettenis wrote:
> > A bit strange to call something both generic and specific...
> > 
> > I think some of these note types originated on SVR4/Solaris, but I'm not 
> > sure how much Linux deviated from that design through the years.
> Can we call it: Type1 core (as of now: NetBSD) and Type2 core (Linux, 
> Android, FreeBSD, OpenBSD)?
> 
> I don't care which would be 1 and which 2.
I'd just drop word "specific" from the comment. And OpenBSD will obviously be 
handled in a similar way as NetBSD in the near future.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-20 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added inline comments.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1374
+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.

kettenis wrote:
> By making this change you risk losing recognition of "normal" NetBSD ELF 
> files, i.e. executables and shared libraries.
Hmm, do you mean these notes:

```
$ readelf -n /bin/cat   
  

Displaying notes found at file offset 0x0214 with length 0x0018:
  Owner Data size   Description
  NetBSD0x0004  IDENT 799005900 (7.99.59)

Displaying notes found at file offset 0x022c with length 0x0014:
  Owner Data size   Description
  NetBSD0x0004  PaX <>
```



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:563
+
+/// Generic (Linux, ...) specific Thread context from PT_NOTE segment
+/// 1) A Thread Context in a core file usually described by 3 NOTE entries.

kettenis wrote:
> A bit strange to call something both generic and specific...
> 
> I think some of these note types originated on SVR4/Solaris, but I'm not sure 
> how much Linux deviated from that design through the years.
Can we call it: Type1 core (as of now: NetBSD) and Type2 core (Linux, Android, 
FreeBSD, OpenBSD)?

I don't care which would be 1 and which 2.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:815
+return Error("Error parsing NetBSD core(5) notes: Cannot convert "
+ "LWP ID to integer");
+} else if (note.n_type == NETBSD::AMD64::NT_FPREGS) {

kettenis wrote:
> Wouldn't it make sense to move the parsing of the LWP ID before the switch. 
> Otherwise you'll have to duplicate the code for every NetBSD architecture 
> you'll add.
Sounds good.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-20 Thread Mark Kettenis via Phabricator via lldb-commits
kettenis added a comment.

In https://reviews.llvm.org/D32149#731887, @labath wrote:

> A test would infinitely times more valuable then a demo script. What is the 
> tiniest core file you can produce on NetBSD? (on linux we've gotten them down 
> to about 20K) Then we could check that in and write a test for it...


The smalles core dumps I managed to create for OpenBSD so far are a bit over 4M.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-20 Thread Mark Kettenis via Phabricator via lldb-commits
kettenis added a comment.

Generally looks reasonable to me.  A few comments inline.




Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1374
+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.

By making this change you risk losing recognition of "normal" NetBSD ELF files, 
i.e. executables and shared libraries.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:563
+
+/// Generic (Linux, ...) specific Thread context from PT_NOTE segment
+/// 1) A Thread Context in a core file usually described by 3 NOTE entries.

A bit strange to call something both generic and specific...

I think some of these note types originated on SVR4/Solaris, but I'm not sure 
how much Linux deviated from that design through the years.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:815
+return Error("Error parsing NetBSD core(5) notes: Cannot convert "
+ "LWP ID to integer");
+} else if (note.n_type == NETBSD::AMD64::NT_FPREGS) {

Wouldn't it make sense to move the parsing of the LWP ID before the switch. 
Otherwise you'll have to duplicate the code for every NetBSD architecture 
you'll add.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-20 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

In https://reviews.llvm.org/D32149#731887, @labath wrote:

> A test would infinitely times more valuable then a demo script. What is the 
> tiniest core file you can produce on NetBSD? (on linux we've gotten them down 
> to about 20K) Then we could check that in and write a test for it...


This is something I wanted to bring to the dev mailing list.

I wanted to prepare at least three tests, if possible four:

- one thread (if possible two variations: signal to one particular thread + 
signal to all threads)
- multiple threads (signal to one particular thread + signal to all threads)

And this in combination of all supported targets (x86_64, i386, etc).

Emitting SIGABRT for such program gives core of size 97kilobytes:

  int main(){for(;;);}

I will write assembly programs for the above cases, without libc.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

A test would infinitely times more valuable then a demo script. What is the 
tiniest core file you can produce on NetBSD? (on linux we've gotten them down 
to about 20K) Then we could check that in and write a test for it...


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-19 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

Demo:

http://netbsd.org/~kamil/lldb/firefox-core.typescript

Replay:

  script -p ./firefox-core.typescript

BSD `script`(1) is incompatible with the GNU one, so I prepared a quick port to 
Linux:

http://netbsd.org/~kamil/lldb/nbscript.c

`gcc nbscript.c -lutil -o nbscript`


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-04-17 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski created this revision.
krytarowski added a project: LLDB.

Correct detection of the NetBSD specific core(5) files.
The original code was apparently copied from FreeBSD
and it was buggy, because these BSDs are different and
do not share the same ELF layout for core(5) files.

Split ProcessElfCore::ParseThreadContextsFromNoteSegment
into two functions: NetBSD-specific and Generic. I presume
that other BSDs should follow this or share concepts with
NetBSD. The Linux threading and NOTE layout is very different
to the NetBSD one, and it is not easily doable, without a
monstrous design, to introduce there support for threads.

OpenBSD could reuse NetBSD code and perhaps share the same
functions, as these systems have very similar ELF core(5) layout.

Obligatory demo:

  (lldb) target create "/usr/pkg/bin/rtorrent" --core "rtorrent.core"
  Core file '/public/lldb_devel/rtorrent.core' (x86_64) was loaded.
  (lldb) thread list
  Process 0 stopped
  * thread #1: tid = 3, 0x7a59d623b51a libc.so.12`_sys___kevent50 + 10, 
stop reason = signal SIGSTOP
thread #2: tid = 2, 0x7a59d623b51a libc.so.12`_sys___kevent50 + 10, 
stop reason = signal SIGSTOP
thread #3: tid = 1, 0x7a59d623b21a libc.so.12`__select50 + 10, stop 
reason = signal SIGSTOP
  (lldb) thread select 2
  * thread #2, stop reason = signal SIGSTOP
  frame #0: 0x7a59d623b51a libc.so.12`_sys___kevent50 + 10
  libc.so.12`_sys___kevent50:
  ->  0x7a59d623b51a <+10>: addb   %al, (%rax)
  0x7a59d623b51c <+12>: addb   %al, (%rax)
  0x7a59d623b51e <+14>: addb   %al, (%rax)
  0x7a59d623b520 <+16>: addb   %al, (%rax)
  (lldb) bt
  * thread #2, stop reason = signal SIGSTOP
* frame #0: 0x7a59d623b51a libc.so.12`_sys___kevent50 + 10
  frame #1: 0x7a59d6606c97 libpthread.so.1`__kevent50(fd=, 
ev=, nev=, rev=, nrev=, 
ts=) at pthread_cancelstub.c:176
  frame #2: 0x7a59d91167f2 
libtorrent.so.19`torrent::PollKQueue::poll(this=0x7a59da153200, msec=10001) 
at poll_kqueue.cc:167
  frame #3: 0x7a59d9116d98 
libtorrent.so.19`torrent::PollKQueue::do_poll(this=0x7a59da153200, 
timeout_usec=1000, flags=1) at poll_kqueue.cc:268
  frame #4: 0x7a59d91396d6 
libtorrent.so.19`torrent::thread_base::event_loop(thread=0x7a59da1a6700) at 
thread_base.cc:174
  frame #5: 0x7a59d660b6e1 
libpthread.so.1`pthread__create_tramp(cookie=0x7a59da1fd000) at 
pthread.c:576
  frame #6: 0x7a59d6287ac0 libc.so.12

Sponsored by 


Repository:
  rL LLVM

https://reviews.llvm.org/D32149

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.h

Index: source/Plugins/Process/elf-core/ProcessElfCore.h
===
--- source/Plugins/Process/elf-core/ProcessElfCore.h
+++ source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -125,6 +125,18 @@
 lldb_private::ConstString path;
   };
 
+  // Parse thread(s) data structuresNetBSD(prstatus, prpsinfo) from given NOTE
+  // segment
+  lldb_private::Error ParseThreadContextsFromNoteSegmentNetBSD(
+  const elf::ELFProgramHeader *segment_header,
+  lldb_private::DataExtractor segment_data);
+
+  // Parse thread(s) data structuresGeneric(prstatus, prpsinfo) from given NOTE
+  // segment
+  lldb_private::Error ParseThreadContextsFromNoteSegmentGeneric(
+  const elf::ELFProgramHeader *segment_header,
+  lldb_private::DataExtractor segment_data);
+
   //--
   // For ProcessElfCore only
   //--
Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ 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"
@@ -219,7 +220,7 @@
   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 +374,8 @@
   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 +460,14 @@
 
 namespace NETBSD {
 
-enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33,