[Lldb-commits] [PATCH] D26300: ELF core: Adding parsing of the floating-point and SSE registers on x86 32/64 bit elf core files

2016-11-20 Thread Dimitar Vlahovski via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287506: ELF core: Adding parsing of the floating-point and 
SSE registers on x86 32/64… (authored by dvlahovski).

Changed prior to commit:
  https://reviews.llvm.org/D26300?vs=77626&id=78667#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26300

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/fpr_sse.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-fpr_sse_i386.core
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-fpr_sse_x86_64.core
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
  lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h
  lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
  lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
  lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h

Index: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -400,7 +400,8 @@
   NT_TASKSTRUCT,
   NT_PLATFORM,
   NT_AUXV,
-  NT_FILE = 0x46494c45
+  NT_FILE = 0x46494c45,
+  NT_PRXFPREG = 0x46e62b7f,
 };
 
 namespace FREEBSD {
@@ -552,7 +553,11 @@
 thread_data->gpregset = DataExtractor(note_data, header_size, len);
 break;
   case NT_FPREGSET:
-thread_data->fpregset = note_data;
+// In a i386 core file NT_FPREGSET is present, but it's not the result
+// of the FXSAVE instruction like in 64 bit files.
+// 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;
 break;
   case NT_PRPSINFO:
 have_prpsinfo = true;
@@ -586,6 +591,11 @@
   default:
 break;
   }
+} else if (note.n_name == "LINUX") {
+  switch (note.n_type) {
+  case NT_PRXFPREG:
+thread_data->fpregset = note_data;
+  }
 }
 
 offset += note_size;
Index: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
===
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
@@ -24,8 +24,6 @@
   const lldb_private::DataExtractor &gpregset,
   const lldb_private::DataExtractor &fpregset);
 
-  ~RegisterContextCorePOSIX_x86_64() override;
-
   bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
 lldb_private::RegisterValue &value) override;
 
@@ -48,7 +46,8 @@
   bool WriteFPR() override;
 
 private:
-  uint8_t *m_gpregset;
+  std::unique_ptr m_gpregset;
+  std::unique_ptr m_fpregset;
 };
 
 #endif // liblldb_RegisterContextCorePOSIX_x86_64_h_
Index: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
===
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
@@ -21,18 +21,27 @@
   size_t size, len;
 
   size = GetGPRSize();
-  m_gpregset = new uint8_t[size];
-  len = gpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_gpregset);
-  assert(len == size);
+  m_gpregset.reset(new uint8_t[size]);
+  len =
+  gpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_gpregset.get());
+  if (len != size)
+m_gpregset.reset();
+
+  size = sizeof(FXSAVE);
+  m_fpregset.reset(new uint8_t[size]);
+  len =
+  fpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_fpregset.get());
+  if (len != size)
+m_fpregset.reset();
 }
 
-RegisterContextCorePOSIX_x86_64::~RegisterContextCorePOSIX_x86_64() {
-  delete[] m_gpregset;
+bool RegisterContextCorePOSIX_x86_64::ReadGPR() {
+  return m_gpregset != nullptr;
 }
 
-bool RegisterContextCorePOSIX_x86_64::ReadGPR() { return m_gpregset != NULL; }
-
-bool RegisterContextCorePOSIX_x86_64::ReadFPR() { return false; }
+bool RegisterContextCorePOSIX_x86_64::ReadFPR() {
+  return m_fpregset != nullptr;
+}
 
 bool RegisterContextCorePOSIX_x86_64::WriteGPR() {
   assert(0);
@@ -46,15 +55,27 @@
 
 bo

[Lldb-commits] [lldb] r287506 - ELF core: Adding parsing of the floating-point and SSE registers on x86 32/64 bit elf core files

2016-11-20 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Sun Nov 20 15:24:49 2016
New Revision: 287506

URL: http://llvm.org/viewvc/llvm-project?rev=287506&view=rev
Log:
ELF core: Adding parsing of the floating-point and SSE registers on x86 32/64 
bit elf core files

Summary:
The floating-point and SSE registers could be present in the elf-core
file in the note NT_FPREGSET for 64 bit ones, and in the note
NT_PRXFPREG for 32 bit ones.

The entire note is a binary blob matching the layout of the x87 save
area that gets generated by the FXSAVE instruction (see Intel developers
manual for more information).

This CL mainly modifies the RegisterRead function in
RegisterContextPOSIXCore_x86_64 for it to return the correct data both
for GPR and FPR/SSE registers, and return false (meaning "this register
is not available") for other registers.

I added a test to TestElfCore.py that tests reading FPR/SSE registers
both from a 32 and 64 bit elf-core file and I have inluded the source
which I used to generate the core files.

I tried to also add support for the AVX registers, because this info could
also be present in the elf-core file (note NT_X86_XSTATE - that is the result of
the newer XSAVE instruction). Parsing the contents from the file is
easy. The problem is that the ymm registers are split into two halves
and they are in different places in the note. For making this work one
would either make a "hacky" approach, because there won't be
any other way with the current state of the register contexts - they
assume that "this register is of size N and at offset M" and
don't have the notion of discontinuos registers.

Reviewers: labath

Subscribers: emaste, lldb-commits

Differential Revision: https://reviews.llvm.org/D26300

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/fpr_sse.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-fpr_sse_i386.core

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-fpr_sse_x86_64.core
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp

lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py?rev=287506&r1=287505&r2=287506&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
 Sun Nov 20 15:24:49 2016
@@ -104,6 +104,56 @@ class LinuxCoreTestCase(TestBase):
 # same pid
 self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions)
 
+@skipIf(oslist=['windows'])
+@skipIf(triple='^mips')
+def test_FPR_SSE(self):
+# check x86_64 core file
+target = self.dbg.CreateTarget(None)
+self.assertTrue(target, VALID_TARGET)
+process = target.LoadCore("linux-fpr_sse_x86_64.core")
+
+values = {}
+values["fctrl"] = "0x037f"
+values["fstat"] = "0x"
+values["ftag"] = "0xff"
+values["fop"] = "0x"
+values["fiseg"] = "0x"
+values["fioff"] = "0x0040011e"
+values["foseg"] = "0x"
+values["fooff"] = "0x"
+values["mxcsr"] = "0x1f80"
+values["mxcsrmask"] = "0x"
+values["st0"] = "{0x99 0xf7 0xcf 0xfb 0x84 0x9a 0x20 0x9a 0xfd 0x3f}"
+values["st1"] = "{0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0x3f}"
+values["st2"] = "{0xfe 0x8a 0x1b 0xcd 0x4b 0x78 0x9a 0xd4 0x00 0x40}"
+values["st3"] = "{0xac 0x79 0xcf 0xd1 0xf7 0x17 0x72 0xb1 0xfe 0x3f}"
+values["st4"] = "{0xbc 0xf0 0x17 0x5c 0x29 0x3b 0xaa 0xb8 0xff 0x3f}"
+values["st5"] = "{0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0x3f}"
+values["st6"] = "{0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}"
+values["st7"] = "{0x35 0xc2 0x68 0x21 0xa2 0xda 0x0f 0xc9 0x00 0x40}"
+values["xmm0"] 

[Lldb-commits] [PATCH] D26300: ELF core: Adding parsing of the floating-point and SSE registers on x86 32/64 bit elf core files

2016-11-11 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 77626.
dvlahovski marked an inline comment as done.
dvlahovski added a comment.

Use unique_ptr instead of shared_ptr


https://reviews.llvm.org/D26300

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/TestLinuxCore.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/fpr_sse.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/linux-fpr_sse_i386.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/linux-fpr_sse_x86_64.core
  source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_i386.h
  source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
  source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
  source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
  source/Plugins/Process/Utility/RegisterInfoInterface.h
  source/Plugins/Process/elf-core/ProcessElfCore.cpp
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h

Index: source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
===
--- source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
+++ source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
@@ -24,8 +24,6 @@
   const lldb_private::DataExtractor &gpregset,
   const lldb_private::DataExtractor &fpregset);
 
-  ~RegisterContextCorePOSIX_x86_64() override;
-
   bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
 lldb_private::RegisterValue &value) override;
 
@@ -48,7 +46,8 @@
   bool WriteFPR() override;
 
 private:
-  uint8_t *m_gpregset;
+  std::unique_ptr m_gpregset;
+  std::unique_ptr m_fpregset;
 };
 
 #endif // liblldb_RegisterContextCorePOSIX_x86_64_h_
Index: source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
===
--- source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
+++ source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
@@ -21,18 +21,27 @@
   size_t size, len;
 
   size = GetGPRSize();
-  m_gpregset = new uint8_t[size];
-  len = gpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_gpregset);
-  assert(len == size);
-}
+  m_gpregset.reset(new uint8_t[size]);
+  len =
+  gpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_gpregset.get());
+  if (len != size)
+m_gpregset.reset();
 
-RegisterContextCorePOSIX_x86_64::~RegisterContextCorePOSIX_x86_64() {
-  delete[] m_gpregset;
+  size = sizeof(FXSAVE);
+  m_fpregset.reset(new uint8_t[size]);
+  len =
+  fpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_fpregset.get());
+  if (len != size)
+m_fpregset.reset();
 }
 
-bool RegisterContextCorePOSIX_x86_64::ReadGPR() { return m_gpregset != NULL; }
+bool RegisterContextCorePOSIX_x86_64::ReadGPR() {
+  return m_gpregset != nullptr;
+}
 
-bool RegisterContextCorePOSIX_x86_64::ReadFPR() { return false; }
+bool RegisterContextCorePOSIX_x86_64::ReadFPR() {
+  return m_fpregset != nullptr;
+}
 
 bool RegisterContextCorePOSIX_x86_64::WriteGPR() {
   assert(0);
@@ -46,15 +55,27 @@
 
 bool RegisterContextCorePOSIX_x86_64::ReadRegister(const RegisterInfo *reg_info,
RegisterValue &value) {
-  switch (reg_info->byte_size) {
-  case 4:
-value = *(uint32_t *)(m_gpregset + reg_info->byte_offset);
-return true;
-  case 8:
-value = *(uint64_t *)(m_gpregset + reg_info->byte_offset);
-return true;
+  const uint8_t *src;
+  size_t offset;
+  const size_t fxsave_offset = reg_info->byte_offset - GetFXSAVEOffset();
+  // make the offset relative to the beginning of the FXSAVE structure
+  // because this is the data that we have (not the entire UserArea)
+
+  if (m_gpregset && reg_info->byte_offset < GetGPRSize()) {
+src = m_gpregset.get();
+offset = reg_info->byte_offset;
+  } else if (m_fpregset && fxsave_offset < sizeof(FXSAVE)) {
+src = m_fpregset.get();
+offset = fxsave_offset;
+  } else {
+return false;
   }
-  return false;
+
+  Error error;
+  value.SetFromMemoryData(reg_info, src + offset, reg_info->byte_size,
+  lldb::eByteOrderLittle, error);
+
+  return error.Success();
 }
 
 bool RegisterContextCorePOSIX_x86_64::ReadAllRegisterValues(
Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -400,7 +400,8 @@
   NT_TASKSTRUCT,
   NT_PLATFORM,
   NT_AUXV,
-  NT_FILE = 0x46494c45
+  NT_FILE = 0x46494c45,
+  NT_PRXFPREG = 0x46e62b7f,
 };
 
 namespace FREEBSD {
@@ -552,7 +553,11 @@
 thread_da

[Lldb-commits] [PATCH] D26300: ELF core: Adding parsing of the floating-point and SSE registers on x86 32/64 bit elf core files

2016-11-10 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 77477.
dvlahovski added a comment.

Generated the core files with make-core.sh


https://reviews.llvm.org/D26300

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/TestLinuxCore.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/fpr_sse.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/fpr_sse_i386.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/fpr_sse_x86_64.core
  source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_i386.h
  source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
  source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
  source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
  source/Plugins/Process/Utility/RegisterInfoInterface.h
  source/Plugins/Process/elf-core/ProcessElfCore.cpp
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h

Index: source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
===
--- source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
+++ source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
@@ -24,8 +24,6 @@
   const lldb_private::DataExtractor &gpregset,
   const lldb_private::DataExtractor &fpregset);
 
-  ~RegisterContextCorePOSIX_x86_64() override;
-
   bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
 lldb_private::RegisterValue &value) override;
 
@@ -48,7 +46,8 @@
   bool WriteFPR() override;
 
 private:
-  uint8_t *m_gpregset;
+  std::shared_ptr m_gpregset;
+  std::shared_ptr m_fpregset;
 };
 
 #endif // liblldb_RegisterContextCorePOSIX_x86_64_h_
Index: source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
===
--- source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
+++ source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
@@ -21,18 +21,27 @@
   size_t size, len;
 
   size = GetGPRSize();
-  m_gpregset = new uint8_t[size];
-  len = gpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_gpregset);
-  assert(len == size);
-}
+  m_gpregset.reset(new uint8_t[size], std::default_delete());
+  len =
+  gpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_gpregset.get());
+  if (len != size)
+m_gpregset.reset();
 
-RegisterContextCorePOSIX_x86_64::~RegisterContextCorePOSIX_x86_64() {
-  delete[] m_gpregset;
+  size = sizeof(FXSAVE);
+  m_fpregset.reset(new uint8_t[size], std::default_delete());
+  len =
+  fpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_fpregset.get());
+  if (len != size)
+m_fpregset.reset();
 }
 
-bool RegisterContextCorePOSIX_x86_64::ReadGPR() { return m_gpregset != NULL; }
+bool RegisterContextCorePOSIX_x86_64::ReadGPR() {
+  return m_gpregset != nullptr;
+}
 
-bool RegisterContextCorePOSIX_x86_64::ReadFPR() { return false; }
+bool RegisterContextCorePOSIX_x86_64::ReadFPR() {
+  return m_fpregset != nullptr;
+}
 
 bool RegisterContextCorePOSIX_x86_64::WriteGPR() {
   assert(0);
@@ -46,15 +55,27 @@
 
 bool RegisterContextCorePOSIX_x86_64::ReadRegister(const RegisterInfo *reg_info,
RegisterValue &value) {
-  switch (reg_info->byte_size) {
-  case 4:
-value = *(uint32_t *)(m_gpregset + reg_info->byte_offset);
-return true;
-  case 8:
-value = *(uint64_t *)(m_gpregset + reg_info->byte_offset);
-return true;
+  std::shared_ptr src;
+  size_t offset;
+  const size_t fxsave_offset = reg_info->byte_offset - GetFXSAVEOffset();
+  // make the offset relative to the beginning of the FXSAVE structure
+  // because this is the data that we have (not the entire UserArea)
+
+  if (m_gpregset && reg_info->byte_offset < GetGPRSize()) {
+src = m_gpregset;
+offset = reg_info->byte_offset;
+  } else if (m_fpregset && fxsave_offset < sizeof(FXSAVE)) {
+src = m_fpregset;
+offset = fxsave_offset;
+  } else {
+return false;
   }
-  return false;
+
+  Error error;
+  value.SetFromMemoryData(reg_info, src.get() + offset, reg_info->byte_size,
+  lldb::eByteOrderLittle, error);
+
+  return error.Success();
 }
 
 bool RegisterContextCorePOSIX_x86_64::ReadAllRegisterValues(
Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -400,7 +400,8 @@
   NT_TASKSTRUCT,
   NT_PLATFORM,
   NT_AUXV,
-  NT_FILE = 0x46494c45
+  NT_FILE = 0x46494c45,
+  NT_PRXFPREG = 0x46e62b7f,
 };
 
 namespace FREEBSD {
@@ -552,7 +553,11 @@
 thread_data->gpregs

[Lldb-commits] [PATCH] D26300: ELF core: Adding parsing of the floating-point and SSE registers on x86 32/64 bit elf core files

2016-11-10 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added a comment.

I will generate the core files with the `make-core.sh` script  and update the 
revision today or tomorrow.




Comment at: 
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/TestLinuxCore.py:107
 
+@skipIf(oslist=['windows'])
+@skipIf(triple='^mips')

labath wrote:
> emaste wrote:
> > Curious, why are these skipped only on windows?
> My guess would be that we fail to select the correct platform instance when 
> opening the core there, so we end up trying to debug a linux core file with 
> PlatformWindows, or something like that. I'll need to look into that at some 
> point.
To be honest, I copied this from the other ELF core tests without investigating 
why they skip windows.


https://reviews.llvm.org/D26300



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


[Lldb-commits] [PATCH] D26300: ELF core: Adding parsing of the floating-point and SSE registers on x86 32/64 bit elf core files

2016-11-04 Thread Dimitar Vlahovski via lldb-commits
dvlahovski created this revision.
dvlahovski added a reviewer: labath.
dvlahovski added a subscriber: lldb-commits.

The floating-point and SSE registers could be present in the elf-core
file in the note NT_FPREGSET for 64 bit ones, and in the note
NT_PRXFPREG for 32 bit ones.

The entire note is a binary blob matching the layout of the x87 save
area that gets generated by the FXSAVE instruction (see Intel developers
manual for more information).

This CL mainly modifies the RegisterRead function in
RegisterContextPOSIXCore_x86_64 for it to return the correct data both
for GPR and FPR/SSE registers, and return false (meaning "this register
is not available") for other registers.

I added a test to TestElfCore.py that tests reading FPR/SSE registers
both from a 32 and 64 bit elf-core file and I have inluded the source
which I used to generate the core files.

I tried to also add support for the AVX registers, because this info could
also be present in the elf-core file (note NT_X86_XSTATE - that is the result of
the newer XSAVE instruction). Parsing the contents from the file is
easy. The problem is that the ymm registers are split into two halves
and they are in different places in the note. For making this work one
would either make a "hacky" approach, because there won't be
any other way with the current state of the register contexts - they
assume that "this register is of size N and at offset M" and
don't have the notion of discontinuos registers.


https://reviews.llvm.org/D26300

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/TestLinuxCore.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/fpr_sse.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/fpr_sse_i386.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/fpr_sse_x86_64.core
  source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_i386.h
  source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
  source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
  source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
  source/Plugins/Process/Utility/RegisterInfoInterface.h
  source/Plugins/Process/elf-core/ProcessElfCore.cpp
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h

Index: source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
===
--- source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
+++ source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
@@ -24,8 +24,6 @@
   const lldb_private::DataExtractor &gpregset,
   const lldb_private::DataExtractor &fpregset);
 
-  ~RegisterContextCorePOSIX_x86_64() override;
-
   bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
 lldb_private::RegisterValue &value) override;
 
@@ -48,7 +46,8 @@
   bool WriteFPR() override;
 
 private:
-  uint8_t *m_gpregset;
+  std::shared_ptr m_gpregset;
+  std::shared_ptr m_fpregset;
 };
 
 #endif // liblldb_RegisterContextCorePOSIX_x86_64_h_
Index: source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
===
--- source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
+++ source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
@@ -21,18 +21,27 @@
   size_t size, len;
 
   size = GetGPRSize();
-  m_gpregset = new uint8_t[size];
-  len = gpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_gpregset);
-  assert(len == size);
-}
+  m_gpregset.reset(new uint8_t[size], std::default_delete());
+  len =
+  gpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_gpregset.get());
+  if (len != size)
+m_gpregset.reset();
 
-RegisterContextCorePOSIX_x86_64::~RegisterContextCorePOSIX_x86_64() {
-  delete[] m_gpregset;
+  size = sizeof(FXSAVE);
+  m_fpregset.reset(new uint8_t[size], std::default_delete());
+  len =
+  fpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_fpregset.get());
+  if (len != size)
+m_fpregset.reset();
 }
 
-bool RegisterContextCorePOSIX_x86_64::ReadGPR() { return m_gpregset != NULL; }
+bool RegisterContextCorePOSIX_x86_64::ReadGPR() {
+  return m_gpregset != nullptr;
+}
 
-bool RegisterContextCorePOSIX_x86_64::ReadFPR() { return false; }
+bool RegisterContextCorePOSIX_x86_64::ReadFPR() {
+  return m_fpregset != nullptr;
+}
 
 bool RegisterContextCorePOSIX_x86_64::WriteGPR() {
   assert(0);
@@ -46,15 +55,27 @@
 
 bool RegisterContextCorePOSIX_x86_64::ReadRegister(const RegisterInfo *reg_info,
RegisterValue &value) {
-  switch (reg_info->byte_size) {
-  case 4:
-value = *(uint32_t *)(m_gpregset + reg_info->byte_offset);
-return

[Lldb-commits] [lldb] r285698 - Minidump plugin: Fix flaky test

2016-11-01 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Tue Nov  1 10:48:24 2016
New Revision: 285698

URL: http://llvm.org/viewvc/llvm-project?rev=285698&view=rev
Log:
Minidump plugin: Fix flaky test

Summary:
One of the tests was flaky, because similarly to
https://reviews.llvm.org/D18697 (rL265391) - if there is a process running
which is with the same PID as in the core file, the minidump
core file debugging will fail, because we get some information from the
running process.
The fix is routing the ProcessInfo requests through the Process class
and overriding it in ProcessMinidump to return correct data.

Reviewers: labath

Subscribers: lldb-commits, beanz

Differential Revision: https://reviews.llvm.org/D26193

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py?rev=285698&r1=285697&r2=285698&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 Tue Nov  1 10:48:24 2016
@@ -5,6 +5,7 @@ Test basics of Minidump debugging.
 from __future__ import print_function
 from six import iteritems
 
+import shutil
 
 import lldb
 from lldbsuite.test.decorators import *
@@ -18,6 +19,10 @@ class MiniDumpNewTestCase(TestBase):
 
 NO_DEBUG_INFO_TESTCASE = True
 
+_linux_x86_64_pid = 29917
+_linux_x86_64_not_crashed_pid = 29939
+_linux_x86_64_not_crashed_pid_offset = 0xD967
+
 def test_process_info_in_minidump(self):
 """Test that lldb can read the process information from the 
Minidump."""
 # target create -c linux-x86_64.dmp
@@ -26,7 +31,7 @@ class MiniDumpNewTestCase(TestBase):
 self.process = self.target.LoadCore("linux-x86_64.dmp")
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertEqual(self.process.GetNumThreads(), 1)
-self.assertEqual(self.process.GetProcessID(), 29917)
+self.assertEqual(self.process.GetProcessID(), self._linux_x86_64_pid)
 
 def test_thread_info_in_minidump(self):
 """Test that lldb can read the thread information from the Minidump."""
@@ -49,6 +54,7 @@ class MiniDumpNewTestCase(TestBase):
 self.target = self.dbg.GetSelectedTarget()
 self.process = self.target.LoadCore("linux-x86_64.dmp")
 self.assertEqual(self.process.GetNumThreads(), 1)
+self.assertEqual(self.process.GetProcessID(), self._linux_x86_64_pid)
 thread = self.process.GetThreadAtIndex(0)
 # frame #0: linux-x86_64`crash()
 # frame #1: linux-x86_64`_start
@@ -61,7 +67,8 @@ class MiniDumpNewTestCase(TestBase):
 self.assertEqual(pc, eip.GetValueAsUnsigned())
 
 def test_snapshot_minidump(self):
-"""Test that if we load a snapshot minidump file (meaning the process 
did not crash) there is no stop reason."""
+"""Test that if we load a snapshot minidump file (meaning the process
+did not crash) there is no stop reason."""
 # target create -c linux-x86_64_not_crashed.dmp
 self.dbg.CreateTarget(None)
 self.target = self.dbg.GetSelectedTarget()
@@ -72,14 +79,13 @@ class MiniDumpNewTestCase(TestBase):
 stop_description = thread.GetStopDescription(256)
 self.assertEqual(stop_description, None)
 
-def test_deeper_stack_in_minidump(self):
-"""Test that we can examine a more interesting stack in a Minidump."""
-# Launch with the Minidump, and inspect the stack.
-# target create linux-x86_64_not_crashed -c 
linux-x86_64_not_crashed.dmp
-target = self.dbg.CreateTarget("linux-x86_64_not_crashed")
-process = target.LoadCore("linux-x86_64_not_crashed.dmp")
+def do_test_deeper_stack(self, binary, core, pid):
+target = self.dbg.CreateTarget(binary)
+process = target.LoadCore(core)
 thread = process.GetThreadAtIndex(0)
 
+self.assertEqual(process.GetProcessID(), pid)
+
 expected_stack = {1: 'bar', 2: 'foo', 3: '_start'}
 self.assertGreaterEqual(thread.GetNumFrames(), len(expected_stack))
 for index, name in iteritems(expected_stack):
@@ -88,6 +94,60 @@ class MiniDumpNewTestCase(TestBase):
 function_name = frame.GetFunctionName()
 self.assertTrue(name in function_name)
 
+def test_deeper_stack_in_minidump(self):
+"""Test that we can examine a more interesting stack in a Minidump."""
+# Launch with the Minidump, and

[Lldb-commits] [PATCH] D26193: Minidump plugin: Fix flaky test

2016-11-01 Thread Dimitar Vlahovski via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285698: Minidump plugin: Fix flaky test (authored by 
dvlahovski).

Changed prior to commit:
  https://reviews.llvm.org/D26193?vs=76560&id=76568#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26193

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h

Index: lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
===
--- lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
+++ lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
@@ -46,8 +46,7 @@
   static const char *GetPluginDescriptionStatic();
 
   ProcessMinidump(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
-  const lldb_private::FileSpec &core_file,
-  MinidumpParser minidump_parser);
+  const FileSpec &core_file, MinidumpParser minidump_parser);
 
   ~ProcessMinidump() override;
 
@@ -81,6 +80,8 @@
   Error GetMemoryRegionInfo(lldb::addr_t load_addr,
 MemoryRegionInfo &range_info) override;
 
+  bool GetProcessInfo(ProcessInstanceInfo &info) override;
+
   MinidumpParser m_minidump_parser;
 
 protected:
Index: lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -180,14 +180,14 @@
 bool ProcessMinidump::WarnBeforeDetach() const { return false; }
 
 size_t ProcessMinidump::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
-   lldb_private::Error &error) {
+   Error &error) {
   // Don't allow the caching that lldb_private::Process::ReadMemory does
   // since we have it all cached in our dump file anyway.
   return DoReadMemory(addr, buf, size, error);
 }
 
 size_t ProcessMinidump::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
- lldb_private::Error &error) {
+ Error &error) {
 
   llvm::ArrayRef mem = m_minidump_parser.GetMemory(addr, size);
   if (mem.empty()) {
@@ -211,8 +211,8 @@
   return ArchSpec(triple);
 }
 
-Error ProcessMinidump::GetMemoryRegionInfo(
-lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &range_info) {
+Error ProcessMinidump::GetMemoryRegionInfo(lldb::addr_t load_addr,
+   MemoryRegionInfo &range_info) {
   Error error;
   auto info = m_minidump_parser.GetMemoryRegionInfo(load_addr);
   if (!info) {
@@ -225,9 +225,8 @@
 
 void ProcessMinidump::Clear() { Process::m_thread_list.Clear(); }
 
-bool ProcessMinidump::UpdateThreadList(
-lldb_private::ThreadList &old_thread_list,
-lldb_private::ThreadList &new_thread_list) {
+bool ProcessMinidump::UpdateThreadList(ThreadList &old_thread_list,
+   ThreadList &new_thread_list) {
   uint32_t num_threads = 0;
   if (m_thread_list.size() > 0)
 num_threads = m_thread_list.size();
@@ -291,3 +290,16 @@
   load_addr_changed);
   }
 }
+
+bool ProcessMinidump::GetProcessInfo(ProcessInstanceInfo &info) {
+  info.Clear();
+  info.SetProcessID(GetID());
+  info.SetArchitecture(GetArchitecture());
+  lldb::ModuleSP module_sp = GetTarget().GetExecutableModule();
+  if (module_sp) {
+const bool add_exe_file_as_first_arg = false;
+info.SetExecutableFile(GetTarget().GetExecutableModule()->GetFileSpec(),
+   add_exe_file_as_first_arg);
+  }
+  return true;
+}
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -5,6 +5,7 @@
 from __future__ import print_function
 from six import iteritems
 
+import shutil
 
 import lldb
 from lldbsuite.test.decorators import *
@@ -18,15 +19,19 @@
 
 NO_DEBUG_INFO_TESTCASE = True
 
+_linux_x86_64_pid = 29917
+_linux_x86_64_not_crashed_pid = 29939
+_linux_x86_64_not_crashed_pid_offset = 0xD967
+
 def test_process_info_in_minidump(self):
 """Test that lldb can read the process information from the Minidump."""
 # target create -c linux-x86_64.dmp
 self.dbg.CreateTarget(None)
 self.target = self.dbg.GetSelectedTarget()
 self.process = self.target.LoadCore("linux-x86_64.dmp")
 self.assertTrue(self.process, PROCESS_IS_VA

Re: [Lldb-commits] [lldb] r285587 - Minidump plugin: Adding ProcessMinidump, ThreadMinidump and register the plugin in SystemInitializerFull

2016-11-01 Thread Dimitar Vlahovski via lldb-commits
Hi,

Chris, thanks for the heads-up.
Pavel - yes, this is the case, and I have a patch that fixes it -
https://reviews.llvm.org/D26193


On Tue, Nov 1, 2016 at 10:23 AM, Pavel Labath  wrote:

> Thanks for the heads-up, Chris.
>
> Dimitar,
> we have had a similar problem for elf core file tests, where lldb
> would get confused if we get a running process with the same pid as
> the core file. I fixed this in <https://reviews.llvm.org/D18697>, and
> I suspect you will need a similar fix for your ProcessMinidump. Could
> you check if this is the case, and fix it?
>
> pl
>
> On 31 October 2016 at 23:07, Chris Bieneman via lldb-commits
>  wrote:
> > I think the new mini-dump test case added here might be flaky.
> >
> > See: http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-
> 14.04-cmake/builds/381
> >
> > The next build was successful.
> >
> > -Chris
> >
> >> On Oct 31, 2016, at 8:35 AM, Dimitar Vlahovski via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
> >>
> >> Author: dvlahovski
> >> Date: Mon Oct 31 10:35:18 2016
> >> New Revision: 285587
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=285587&view=rev
> >> Log:
> >> Minidump plugin: Adding ProcessMinidump, ThreadMinidump and register
> the plugin in SystemInitializerFull
> >>
> >> Summary:
> >> This plugin resembles the already existing Windows-only Minidump plugin.
> >> The WinMinidumpPlugin uses the Windows API for parsing Minidumps
> >> while this plugin is cross-platform because it includes a Minidump
> >> parser (which is already commited)
> >>
> >> It is able to produce a backtrace, to read the general puprose regiters,
> >> inspect local variables, show image list, do memory reads, etc.
> >>
> >> For now the only arches that this supports are x86_32 and x86_64.
> >> This is because I have only written register contexts for those.
> >> Others will come in next CLs.
> >>
> >> I copied the WinMinidump tests and adapted them a little bit for them to
> >> work with the new plugin (and they pass)
> >> I will add more tests, aiming for better code coverage.
> >>
> >> There is still functionality to be added, see TODOs in code.
> >>
> >> Reviewers: labath, zturner
> >>
> >> Subscribers: beanz, mgorny, modocache, lldb-commits, amccarth
> >>
> >> Differential Revision: https://reviews.llvm.org/D25905
> >>
> >> Added:
> >>lldb/trunk/packages/Python/lldbsuite/test/
> functionalities/postmortem/minidump-new/TestMiniDumpNew.py
> >>lldb/trunk/packages/Python/lldbsuite/test/
> functionalities/postmortem/minidump-new/install_breakpad.cpp
> >>lldb/trunk/packages/Python/lldbsuite/test/
> functionalities/postmortem/minidump-new/linux-x86_64   (with props)
> >>lldb/trunk/packages/Python/lldbsuite/test/
> functionalities/postmortem/minidump-new/linux-x86_64.cpp
> >>lldb/trunk/packages/Python/lldbsuite/test/
> functionalities/postmortem/minidump-new/linux-x86_64.dmp
> >>lldb/trunk/packages/Python/lldbsuite/test/
> functionalities/postmortem/minidump-new/linux-x86_64_not_crashed   (with
> props)
> >>lldb/trunk/packages/Python/lldbsuite/test/
> functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
> >>lldb/trunk/packages/Python/lldbsuite/test/
> functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
> >>lldb/trunk/packages/Python/lldbsuite/test/
> functionalities/postmortem/minidump-new/makefile.txt
> >>lldb/trunk/source/Plugins/Process/minidump/NtStructures.h
> >>lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
> >>lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
> >>lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp
> >>lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.h
> >> Modified:
> >>lldb/trunk/source/API/SystemInitializerFull.cpp
> >>lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
> >>lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
> >>lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
> >>lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
> >>lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
> >>
> >> Added: lldb/trunk/packages/Python/lldbsuite/test/
> functionalities/postmortem/minidump-new/TestMiniDumpNew.py
> >> URL: http://llvm.org/viewvc/llvm-project/

[Lldb-commits] [PATCH] D26193: Minidump plugin: Fix flaky test

2016-11-01 Thread Dimitar Vlahovski via lldb-commits
dvlahovski created this revision.
dvlahovski added a reviewer: labath.
dvlahovski added subscribers: beanz, lldb-commits.

One of the tests was flaky, because similarly to
https://reviews.llvm.org/D18697 (https://reviews.llvm.org/rL265391) - if there 
is a process running
which is with the same PID as in the core file, the minidump
core file debugging will fail, because we get some information from the
running process.
The fix is routing the ProcessInfo requests through the Process class
and overriding it in ProcessMinidump to return correct data.


https://reviews.llvm.org/D26193

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/ProcessMinidump.h

Index: source/Plugins/Process/minidump/ProcessMinidump.h
===
--- source/Plugins/Process/minidump/ProcessMinidump.h
+++ source/Plugins/Process/minidump/ProcessMinidump.h
@@ -46,8 +46,7 @@
   static const char *GetPluginDescriptionStatic();
 
   ProcessMinidump(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
-  const lldb_private::FileSpec &core_file,
-  MinidumpParser minidump_parser);
+  const FileSpec &core_file, MinidumpParser minidump_parser);
 
   ~ProcessMinidump() override;
 
@@ -81,6 +80,8 @@
   Error GetMemoryRegionInfo(lldb::addr_t load_addr,
 MemoryRegionInfo &range_info) override;
 
+  bool GetProcessInfo(ProcessInstanceInfo &info) override;
+
   MinidumpParser m_minidump_parser;
 
 protected:
Index: source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -180,14 +180,14 @@
 bool ProcessMinidump::WarnBeforeDetach() const { return false; }
 
 size_t ProcessMinidump::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
-   lldb_private::Error &error) {
+   Error &error) {
   // Don't allow the caching that lldb_private::Process::ReadMemory does
   // since we have it all cached in our dump file anyway.
   return DoReadMemory(addr, buf, size, error);
 }
 
 size_t ProcessMinidump::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
- lldb_private::Error &error) {
+ Error &error) {
 
   llvm::ArrayRef mem = m_minidump_parser.GetMemory(addr, size);
   if (mem.empty()) {
@@ -211,8 +211,8 @@
   return ArchSpec(triple);
 }
 
-Error ProcessMinidump::GetMemoryRegionInfo(
-lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &range_info) {
+Error ProcessMinidump::GetMemoryRegionInfo(lldb::addr_t load_addr,
+   MemoryRegionInfo &range_info) {
   Error error;
   auto info = m_minidump_parser.GetMemoryRegionInfo(load_addr);
   if (!info) {
@@ -225,9 +225,8 @@
 
 void ProcessMinidump::Clear() { Process::m_thread_list.Clear(); }
 
-bool ProcessMinidump::UpdateThreadList(
-lldb_private::ThreadList &old_thread_list,
-lldb_private::ThreadList &new_thread_list) {
+bool ProcessMinidump::UpdateThreadList(ThreadList &old_thread_list,
+   ThreadList &new_thread_list) {
   uint32_t num_threads = 0;
   if (m_thread_list.size() > 0)
 num_threads = m_thread_list.size();
@@ -291,3 +290,16 @@
   load_addr_changed);
   }
 }
+
+bool ProcessMinidump::GetProcessInfo(ProcessInstanceInfo &info) {
+  info.Clear();
+  info.SetProcessID(GetID());
+  info.SetArchitecture(GetArchitecture());
+  lldb::ModuleSP module_sp = GetTarget().GetExecutableModule();
+  if (module_sp) {
+const bool add_exe_file_as_first_arg = false;
+info.SetExecutableFile(GetTarget().GetExecutableModule()->GetFileSpec(),
+   add_exe_file_as_first_arg);
+  }
+  return true;
+}
Index: packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -5,6 +5,7 @@
 from __future__ import print_function
 from six import iteritems
 
+import shutil
 
 import lldb
 from lldbsuite.test.decorators import *
@@ -18,15 +19,19 @@
 
 NO_DEBUG_INFO_TESTCASE = True
 
+_linux_x86_64_pid = 29917
+_linux_x86_64_not_crashed_pid = 29939
+_linux_x86_64_not_crashed_pid_offset = 0xD967
+
 def test_process_info_in_minidump(self):
 """Test that lldb can read the process information from the Minidump."""
 # target create -c linux-x86_64.dmp
 self.dbg.CreateTarget(None)
 se

[Lldb-commits] [PATCH] D25905: Minidump plugin: Adding ProcessMinidump, ThreadMinidump and register the plugin in SystemInitializerFull

2016-10-31 Thread Dimitar Vlahovski via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285587: Minidump plugin: Adding ProcessMinidump, 
ThreadMinidump and register the plugin… (authored by dvlahovski).

Changed prior to commit:
  https://reviews.llvm.org/D25905?vs=76176&id=76416#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25905

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/install_breakpad.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/makefile.txt
  lldb/trunk/source/API/SystemInitializerFull.cpp
  lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
  lldb/trunk/source/Plugins/Process/minidump/NtStructures.h
  lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
  lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp
  lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.h
  lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Index: lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -134,7 +134,7 @@
 llvm::Optional name =
 parser->GetMinidumpString(modules[i].module_name_rva);
 ASSERT_TRUE(name.hasValue());
-ASSERT_EQ(module_names[i], name.getValue());
+EXPECT_EQ(module_names[i], name.getValue());
   }
 }
 
@@ -275,8 +275,46 @@
   ASSERT_EQ(4440UL, pid.getValue());
 }
 
-// Register stuff
-// TODO probably split register stuff tests into different file?
+// wow64
+TEST_F(MinidumpParserTest, GetPidWow64) {
+  SetUpData("fizzbuzz_wow64.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(7836UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetModuleListWow64) {
+  SetUpData("fizzbuzz_wow64.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  ASSERT_EQ(16UL, modules.size());
+  std::string module_names[16] = {
+  R"(D:\src\llvm\llvm\tools\lldb\packages\Python\lldbsuite\test\functionalities\postmortem\wow64_minidump\fizzbuzz.exe)",
+  R"(C:\Windows\System32\ntdll.dll)",
+  R"(C:\Windows\System32\wow64.dll)",
+  R"(C:\Windows\System32\wow64win.dll)",
+  R"(C:\Windows\System32\wow64cpu.dll)",
+  R"(D:\src\llvm\llvm\tools\lldb\packages\Python\lldbsuite\test\functionalities\postmortem\wow64_minidump\fizzbuzz.exe)",
+  R"(C:\Windows\SysWOW64\ntdll.dll)",
+  R"(C:\Windows\SysWOW64\kernel32.dll)",
+  R"(C:\Windows\SysWOW64\KERNELBASE.dll)",
+  R"(C:\Windows\SysWOW64\advapi32.dll)",
+  R"(C:\Windows\SysWOW64\msvcrt.dll)",
+  R"(C:\Windows\SysWOW64\sechost.dll)",
+  R"(C:\Windows\SysWOW64\rpcrt4.dll)",
+  R"(C:\Windows\SysWOW64\sspicli.dll)",
+  R"(C:\Windows\SysWOW64\CRYPTBASE.dll)",
+  R"(C:\Windows\System32\api-ms-win-core-synch-l1-2-0.DLL)",
+  };
+
+  for (int i = 0; i < 16; ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(modules[i].module_name_rva);
+ASSERT_TRUE(name.hasValue());
+EXPECT_EQ(module_names[i], name.getValue());
+  }
+}
+
+// Register tests
 #define REG_VAL32(x) *(reinterpret_cast(x))
 #define REG_VAL64(x) *(reinterpret_cast(x))
 
@@ -371,3 +409,45 @@
 }
   }
 }
+
+TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_32_wow64) {
+  SetUpData("fizzbuzz_wow64.dmp");
+  llvm::ArrayRef thread_list = parser->GetThreads();
+  const MinidumpThread thread = thread_list[0];
+  llvm::ArrayRef registers(parser->GetThreadContextWow64(thread));
+
+  ArchSpec arch = parser->GetArchitecture();
+  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  lldb::DataBufferSP buf =
+  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
+
+  const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
+
+  std::map reg_values

[Lldb-commits] [lldb] r285587 - Minidump plugin: Adding ProcessMinidump, ThreadMinidump and register the plugin in SystemInitializerFull

2016-10-31 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Mon Oct 31 10:35:18 2016
New Revision: 285587

URL: http://llvm.org/viewvc/llvm-project?rev=285587&view=rev
Log:
Minidump plugin: Adding ProcessMinidump, ThreadMinidump and register the plugin 
in SystemInitializerFull

Summary:
This plugin resembles the already existing Windows-only Minidump plugin.
The WinMinidumpPlugin uses the Windows API for parsing Minidumps
while this plugin is cross-platform because it includes a Minidump
parser (which is already commited)

It is able to produce a backtrace, to read the general puprose regiters,
inspect local variables, show image list, do memory reads, etc.

For now the only arches that this supports are x86_32 and x86_64.
This is because I have only written register contexts for those.
Others will come in next CLs.

I copied the WinMinidump tests and adapted them a little bit for them to
work with the new plugin (and they pass)
I will add more tests, aiming for better code coverage.

There is still functionality to be added, see TODOs in code.

Reviewers: labath, zturner

Subscribers: beanz, mgorny, modocache, lldb-commits, amccarth

Differential Revision: https://reviews.llvm.org/D25905

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/install_breakpad.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64
   (with props)

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed
   (with props)

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/makefile.txt
lldb/trunk/source/Plugins/Process/minidump/NtStructures.h
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp
lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.h
Modified:
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py?rev=285587&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 Mon Oct 31 10:35:18 2016
@@ -0,0 +1,100 @@
+"""
+Test basics of Minidump debugging.
+"""
+
+from __future__ import print_function
+from six import iteritems
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class MiniDumpNewTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_process_info_in_minidump(self):
+"""Test that lldb can read the process information from the 
Minidump."""
+# target create -c linux-x86_64.dmp
+self.dbg.CreateTarget(None)
+self.target = self.dbg.GetSelectedTarget()
+self.process = self.target.LoadCore("linux-x86_64.dmp")
+self.assertTrue(self.process, PROCESS_IS_VALID)
+self.assertEqual(self.process.GetNumThreads(), 1)
+self.assertEqual(self.process.GetProcessID(), 29917)
+
+def test_thread_info_in_minidump(self):
+"""Test that lldb can read the thread information from the Minidump."""
+# target create -c linux-x86_64.dmp
+self.dbg.CreateTarget(None)
+self.target = self.dbg.GetSelectedTarget()
+self.process = self.target.LoadCore("linux-x86_64.dmp")
+# This process crashed due to a segmentation fault in its
+# one and only thread.
+self.assertEqual(self.process.GetNumThreads(), 1)
+thread = self.process.GetThreadAtIndex(0)
+self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal)
+ 

[Lldb-commits] [PATCH] D25832: Minidump plugin: Adding x86_32 register context converter

2016-10-31 Thread Dimitar Vlahovski via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285584: Minidump plugin: Adding x86_32 register context 
converter (authored by dvlahovski).

Changed prior to commit:
  https://reviews.llvm.org/D25832?vs=75578&id=76414#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25832

Files:
  lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
  lldb/trunk/unittests/Process/minidump/CMakeLists.txt
  lldb/trunk/unittests/Process/minidump/Inputs/linux-i386.dmp
  lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Index: lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -8,9 +8,11 @@
 //===--===//
 
 // Project includes
+#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
 #include "Plugins/Process/minidump/MinidumpParser.h"
 #include "Plugins/Process/minidump/MinidumpTypes.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_x86_32.h"
 #include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
 
 // Other libraries and framework includes
@@ -61,7 +63,7 @@
   std::unique_ptr parser;
 };
 
-TEST_F(MinidumpParserTest, GetThreads) {
+TEST_F(MinidumpParserTest, GetThreadsAndGetThreadContext) {
   SetUpData("linux-x86_64.dmp");
   llvm::ArrayRef thread_list;
 
@@ -275,58 +277,97 @@
 
 // Register stuff
 // TODO probably split register stuff tests into different file?
-#define REG_VAL(x) *(reinterpret_cast(x))
+#define REG_VAL32(x) *(reinterpret_cast(x))
+#define REG_VAL64(x) *(reinterpret_cast(x))
 
-TEST_F(MinidumpParserTest, ConvertRegisterContext) {
+TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_32) {
+  SetUpData("linux-i386.dmp");
+  llvm::ArrayRef thread_list = parser->GetThreads();
+  const MinidumpThread thread = thread_list[0];
+  llvm::ArrayRef registers(parser->GetThreadContext(thread));
+
+  ArchSpec arch = parser->GetArchitecture();
+  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  lldb::DataBufferSP buf =
+  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
+
+  const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
+
+  std::map reg_values;
+
+  reg_values[lldb_eax_i386] = 0x;
+  reg_values[lldb_ebx_i386] = 0xf7778000;
+  reg_values[lldb_ecx_i386] = 0x0001;
+  reg_values[lldb_edx_i386] = 0xff9dd4a3;
+  reg_values[lldb_edi_i386] = 0x080482a8;
+  reg_values[lldb_esi_i386] = 0xff9dd55c;
+  reg_values[lldb_ebp_i386] = 0xff9dd53c;
+  reg_values[lldb_esp_i386] = 0xff9dd52c;
+  reg_values[lldb_eip_i386] = 0x080482a0;
+  reg_values[lldb_eflags_i386] = 0x00010282;
+  reg_values[lldb_cs_i386] = 0x0023;
+  reg_values[lldb_fs_i386] = 0x;
+  reg_values[lldb_gs_i386] = 0x0063;
+  reg_values[lldb_ss_i386] = 0x002b;
+  reg_values[lldb_ds_i386] = 0x002b;
+  reg_values[lldb_es_i386] = 0x002b;
+
+  for (uint32_t reg_index = 0; reg_index < reg_interface->GetRegisterCount();
+   ++reg_index) {
+if (reg_values.find(reg_index) != reg_values.end()) {
+  EXPECT_EQ(reg_values[reg_index],
+REG_VAL32(buf->GetBytes() + reg_info[reg_index].byte_offset));
+}
+  }
+}
+
+TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_64) {
   SetUpData("linux-x86_64.dmp");
   llvm::ArrayRef thread_list = parser->GetThreads();
   const MinidumpThread thread = thread_list[0];
-  llvm::ArrayRef registers(parser->GetData().data() +
-thread.thread_context.rva,
-thread.thread_context.data_size);
+  llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
   RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContextToRegIface(registers, reg_interface);
+  ConvertMinidumpContext_x86_64(registers, reg_interface);
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
 
   std::map reg_values;
 
-  // clang-format off
-  reg_values[lldb_rax_x86_64]=  0x;
-  reg_values[lldb_rbx_x86_64]=  0x;
-  reg_values[lldb_rcx_x86_64]=  0x0010;
-  reg_values[lldb_rdx_x86_64]=  0x;
- 

[Lldb-commits] [lldb] r285584 - Minidump plugin: Adding x86_32 register context converter

2016-10-31 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Mon Oct 31 10:26:44 2016
New Revision: 285584

URL: http://llvm.org/viewvc/llvm-project?rev=285584&view=rev
Log:
Minidump plugin: Adding x86_32 register context converter

Summary:
This, like the x86_64 case, reads the register values from the minidump
file, and emits a binary buffer that is ordered using the offsets from
the RegisterInfoInterface argument. That way we can reuse an existing
register context.
Added unit tests.

Reviewers: labath, zturner

Subscribers: beanz, mgorny, modocache, amccarth, lldb-commits

Differential Revision: https://reviews.llvm.org/D25832

Added:

lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h
lldb/trunk/unittests/Process/minidump/Inputs/linux-i386.dmp
Modified:
lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt

lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
lldb/trunk/unittests/Process/minidump/CMakeLists.txt
lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Modified: lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt?rev=285584&r1=285583&r2=285584&view=diff
==
--- lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt Mon Oct 31 
10:26:44 2016
@@ -3,5 +3,6 @@ include_directories(../Utility)
 add_lldb_library(lldbPluginProcessMinidump
   MinidumpTypes.cpp
   MinidumpParser.cpp
+  RegisterContextMinidump_x86_32.cpp
   RegisterContextMinidump_x86_64.cpp
   )

Added: 
lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp?rev=285584&view=auto
==
--- 
lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp 
(added)
+++ 
lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp 
Mon Oct 31 10:26:44 2016
@@ -0,0 +1,99 @@
+//===-- RegisterContextMinidump_x86_32.cpp --*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Project includes
+#include "RegisterContextMinidump_x86_32.h"
+
+// Other libraries and framework includes
+#include "lldb/Core/DataBufferHeap.h"
+
+// C includes
+// C++ includes
+
+using namespace lldb_private;
+using namespace minidump;
+
+static void writeRegister(const void *reg_src,
+  llvm::MutableArrayRef reg_dest) {
+  memcpy(reg_dest.data(), reg_src, reg_dest.size());
+}
+
+lldb::DataBufferSP lldb_private::minidump::ConvertMinidumpContext_x86_32(
+llvm::ArrayRef source_data,
+RegisterInfoInterface *target_reg_interface) {
+
+  const RegisterInfo *reg_info = target_reg_interface->GetRegisterInfo();
+
+  lldb::DataBufferSP result_context_buf(
+  new DataBufferHeap(target_reg_interface->GetGPRSize(), 0));
+  uint8_t *result_base = result_context_buf->GetBytes();
+
+  if (source_data.size() < sizeof(MinidumpContext_x86_32))
+return nullptr;
+
+  const MinidumpContext_x86_32 *context;
+  consumeObject(source_data, context);
+
+  const MinidumpContext_x86_32_Flags context_flags =
+  static_cast(
+  static_cast(context->context_flags));
+  auto x86_32_Flag = MinidumpContext_x86_32_Flags::x86_32_Flag;
+  auto ControlFlag = MinidumpContext_x86_32_Flags::Control;
+  auto IntegerFlag = MinidumpContext_x86_32_Flags::Integer;
+  auto SegmentsFlag = MinidumpContext_x86_32_Flags::Segments;
+
+  if ((context_flags & x86_32_Flag) != x86_32_Flag) {
+return nullptr;
+  }
+
+  if ((context_flags & ControlFlag) == ControlFlag) {
+writeRegister(&context->ebp,
+  reg_info[lldb_ebp_i386].mutable_data(result_base));
+writeRegister(&context->eip,
+  reg_info[lldb_eip_i386].mutable_data(result_base));
+writeRegister(&context->cs,
+  reg_info[lldb_cs_i386].mutable_data(result_base));
+writeRegister(&context->eflags,
+  reg_info[lldb_eflags_i386].mutable_data(result_base));
+writeRegister(&context->esp,
+  reg_info[lldb_esp_i386].mutable_data(result_base));
+writeRegister(&context->ss,
+  reg_info[lldb_ss_i386].mutable_data(result_base));
+  }
+
+  if ((context_flags & SegmentsFlag) == SegmentsFlag) {
+writeRegister(&context->ds,
+  reg_info[lld

[Lldb-commits] [PATCH] D25905: Minidump plugin: Adding ProcessMinidump, ThreadMinidump and register the plugin in SystemInitializerFull

2016-10-28 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 76176.
dvlahovski added a comment.

Hopefully removing code that's not for this CL


https://reviews.llvm.org/D25905

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/install_breakpad.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/makefile.txt
  source/API/SystemInitializerFull.cpp
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.h
  source/Plugins/Process/minidump/NtStructures.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/ProcessMinidump.h
  source/Plugins/Process/minidump/ThreadMinidump.cpp
  source/Plugins/Process/minidump/ThreadMinidump.h
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -134,7 +134,7 @@
 llvm::Optional name =
 parser->GetMinidumpString(modules[i].module_name_rva);
 ASSERT_TRUE(name.hasValue());
-ASSERT_EQ(module_names[i], name.getValue());
+EXPECT_EQ(module_names[i], name.getValue());
   }
 }
 
@@ -275,8 +275,46 @@
   ASSERT_EQ(4440UL, pid.getValue());
 }
 
-// Register stuff
-// TODO probably split register stuff tests into different file?
+// wow64
+TEST_F(MinidumpParserTest, GetPidWow64) {
+  SetUpData("fizzbuzz_wow64.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(7836UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetModuleListWow64) {
+  SetUpData("fizzbuzz_wow64.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  ASSERT_EQ(16UL, modules.size());
+  std::string module_names[16] = {
+  R"(D:\src\llvm\llvm\tools\lldb\packages\Python\lldbsuite\test\functionalities\postmortem\wow64_minidump\fizzbuzz.exe)",
+  R"(C:\Windows\System32\ntdll.dll)",
+  R"(C:\Windows\System32\wow64.dll)",
+  R"(C:\Windows\System32\wow64win.dll)",
+  R"(C:\Windows\System32\wow64cpu.dll)",
+  R"(D:\src\llvm\llvm\tools\lldb\packages\Python\lldbsuite\test\functionalities\postmortem\wow64_minidump\fizzbuzz.exe)",
+  R"(C:\Windows\SysWOW64\ntdll.dll)",
+  R"(C:\Windows\SysWOW64\kernel32.dll)",
+  R"(C:\Windows\SysWOW64\KERNELBASE.dll)",
+  R"(C:\Windows\SysWOW64\advapi32.dll)",
+  R"(C:\Windows\SysWOW64\msvcrt.dll)",
+  R"(C:\Windows\SysWOW64\sechost.dll)",
+  R"(C:\Windows\SysWOW64\rpcrt4.dll)",
+  R"(C:\Windows\SysWOW64\sspicli.dll)",
+  R"(C:\Windows\SysWOW64\CRYPTBASE.dll)",
+  R"(C:\Windows\System32\api-ms-win-core-synch-l1-2-0.DLL)",
+  };
+
+  for (int i = 0; i < 16; ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(modules[i].module_name_rva);
+ASSERT_TRUE(name.hasValue());
+EXPECT_EQ(module_names[i], name.getValue());
+  }
+}
+
+// Register tests
 #define REG_VAL32(x) *(reinterpret_cast(x))
 #define REG_VAL64(x) *(reinterpret_cast(x))
 
@@ -371,3 +409,45 @@
 }
   }
 }
+
+TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_32_wow64) {
+  SetUpData("fizzbuzz_wow64.dmp");
+  llvm::ArrayRef thread_list = parser->GetThreads();
+  const MinidumpThread thread = thread_list[0];
+  llvm::ArrayRef registers(parser->GetThreadContextWow64(thread));
+
+  ArchSpec arch = parser->GetArchitecture();
+  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  lldb::DataBufferSP buf =
+  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
+
+  const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
+
+  std::map reg_values;
+
+  reg_values[lldb_eax_i386] = 0x;
+  reg_values[lldb_ebx_i386] = 0x0037f608;
+  reg_values[lldb_ecx_i386] = 0x00e61578;
+  reg_values[lldb_edx_i386] = 0x0008;
+  reg_values[lldb_edi_i386] = 0x;
+  reg_values[lldb_esi_i386] = 0x0002;
+  reg_values[lldb_ebp_i386] = 0x0037f654;
+  reg_values[lldb_esp_i386] = 0x0037f5b8;
+  reg_values[lldb_eip_i386] = 0x77ce01fd;
+  reg_values[lldb_eflags_i386] = 0x0246;
+  re

[Lldb-commits] [PATCH] D25905: Minidump plugin: Adding ProcessMinidump, ThreadMinidump and register the plugin in SystemInitializerFull

2016-10-25 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added inline comments.



Comment at: source/Plugins/Process/minidump/ProcessMinidump.cpp:67
+  // skip if the Minidump file is Windows generated, because we are still
+  // work-in-progress
+  if (!minidump_parser ||

labath wrote:
> Zach, Adrian: IIUC, the new plugin should generally have feature parity with 
> the windows-only plugin. (Dimitar: could you say exactly what bits are 
> missing?). You should be able to test out this plugin on windows minidumps by 
> removing the windows check below.
> 
> After this goes in, we'll be looking to remove the windows-only plugin.
Yes, I think that now my plugin has full feature parity with the windows-only 
one.


https://reviews.llvm.org/D25905



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


[Lldb-commits] [PATCH] D25905: Minidump plugin: Adding ProcessMinidump, ThreadMinidump and register the plugin in SystemInitializerFull

2016-10-25 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 75709.
dvlahovski marked 4 inline comments as done.
dvlahovski added a comment.

Formatting correctly the test files source code, and added explanation in their 
makefile
ReadModuleList() is called in DoLoadCore()


https://reviews.llvm.org/D25905

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/install_breakpad.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/makefile.txt
  source/API/SystemInitializerFull.cpp
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.h
  source/Plugins/Process/minidump/NtStructures.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/ProcessMinidump.h
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
  source/Plugins/Process/minidump/ThreadMinidump.cpp
  source/Plugins/Process/minidump/ThreadMinidump.h
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/linux-i386.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -8,9 +8,11 @@
 //===--===//
 
 // Project includes
+#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
 #include "Plugins/Process/minidump/MinidumpParser.h"
 #include "Plugins/Process/minidump/MinidumpTypes.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_x86_32.h"
 #include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
 
 // Other libraries and framework includes
@@ -61,7 +63,7 @@
   std::unique_ptr parser;
 };
 
-TEST_F(MinidumpParserTest, GetThreads) {
+TEST_F(MinidumpParserTest, GetThreadsAndGetThreadContext) {
   SetUpData("linux-x86_64.dmp");
   llvm::ArrayRef thread_list;
 
@@ -132,7 +134,7 @@
 llvm::Optional name =
 parser->GetMinidumpString(modules[i].module_name_rva);
 ASSERT_TRUE(name.hasValue());
-ASSERT_EQ(module_names[i], name.getValue());
+EXPECT_EQ(module_names[i], name.getValue());
   }
 }
 
@@ -273,60 +275,179 @@
   ASSERT_EQ(4440UL, pid.getValue());
 }
 
-// Register stuff
-// TODO probably split register stuff tests into different file?
-#define REG_VAL(x) *(reinterpret_cast(x))
+// wow64
+TEST_F(MinidumpParserTest, GetPidWow64) {
+  SetUpData("fizzbuzz_wow64.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(7836UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetModuleListWow64) {
+  SetUpData("fizzbuzz_wow64.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  ASSERT_EQ(16UL, modules.size());
+  std::string module_names[16] = {
+  R"(D:\src\llvm\llvm\tools\lldb\packages\Python\lldbsuite\test\functionalities\postmortem\wow64_minidump\fizzbuzz.exe)",
+  R"(C:\Windows\System32\ntdll.dll)",
+  R"(C:\Windows\System32\wow64.dll)",
+  R"(C:\Windows\System32\wow64win.dll)",
+  R"(C:\Windows\System32\wow64cpu.dll)",
+  R"(D:\src\llvm\llvm\tools\lldb\packages\Python\lldbsuite\test\functionalities\postmortem\wow64_minidump\fizzbuzz.exe)",
+  R"(C:\Windows\SysWOW64\ntdll.dll)",
+  R"(C:\Windows\SysWOW64\kernel32.dll)",
+  R"(C:\Windows\SysWOW64\KERNELBASE.dll)",
+  R"(C:\Windows\SysWOW64\advapi32.dll)",
+  R"(C:\Windows\SysWOW64\msvcrt.dll)",
+  R"(C:\Windows\SysWOW64\sechost.dll)",
+  R"(C:\Windows\SysWOW64\rpcrt4.dll)",
+  R"(C:\Windows\SysWOW64\sspicli.dll)",
+  R"(C:\Windows\SysWOW64\CRYPTBASE.dll)",
+  R"(C:\Windows\System32\api-ms-win-core-synch-l1-2-0.DLL)",
+  };
+
+  for (int i = 0; i < 16; ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(modules[i].module_name_rva);
+ASSERT_TRUE(name.hasVal

[Lldb-commits] [PATCH] D25905: Minidump plugin: Adding ProcessMinidump, ThreadMinidump and register the plugin in SystemInitializerFull

2016-10-24 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added a comment.

Please ignore the `RegisterContextMinidump_x86_*` changes. Can't seem to make 
`arc diff` understand what I want.


https://reviews.llvm.org/D25905



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


[Lldb-commits] [PATCH] D25905: Minidump plugin: Adding ProcessMinidump, ThreadMinidump and register the plugin in SystemInitializerFull

2016-10-24 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 75617.
dvlahovski marked 6 inline comments as done.
dvlahovski added a comment.

Addressed Pavel's comments.


https://reviews.llvm.org/D25905

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/install_breakpad.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/makefile.txt
  source/API/SystemInitializerFull.cpp
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.h
  source/Plugins/Process/minidump/NtStructures.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/ProcessMinidump.h
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
  source/Plugins/Process/minidump/ThreadMinidump.cpp
  source/Plugins/Process/minidump/ThreadMinidump.h
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/linux-i386.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -8,9 +8,11 @@
 //===--===//
 
 // Project includes
+#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
 #include "Plugins/Process/minidump/MinidumpParser.h"
 #include "Plugins/Process/minidump/MinidumpTypes.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_x86_32.h"
 #include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
 
 // Other libraries and framework includes
@@ -61,7 +63,7 @@
   std::unique_ptr parser;
 };
 
-TEST_F(MinidumpParserTest, GetThreads) {
+TEST_F(MinidumpParserTest, GetThreadsAndGetThreadContext) {
   SetUpData("linux-x86_64.dmp");
   llvm::ArrayRef thread_list;
 
@@ -132,7 +134,7 @@
 llvm::Optional name =
 parser->GetMinidumpString(modules[i].module_name_rva);
 ASSERT_TRUE(name.hasValue());
-ASSERT_EQ(module_names[i], name.getValue());
+EXPECT_EQ(module_names[i], name.getValue());
   }
 }
 
@@ -273,60 +275,179 @@
   ASSERT_EQ(4440UL, pid.getValue());
 }
 
-// Register stuff
-// TODO probably split register stuff tests into different file?
-#define REG_VAL(x) *(reinterpret_cast(x))
+// wow64
+TEST_F(MinidumpParserTest, GetPidWow64) {
+  SetUpData("fizzbuzz_wow64.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(7836UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetModuleListWow64) {
+  SetUpData("fizzbuzz_wow64.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  ASSERT_EQ(16UL, modules.size());
+  std::string module_names[16] = {
+  R"(D:\src\llvm\llvm\tools\lldb\packages\Python\lldbsuite\test\functionalities\postmortem\wow64_minidump\fizzbuzz.exe)",
+  R"(C:\Windows\System32\ntdll.dll)",
+  R"(C:\Windows\System32\wow64.dll)",
+  R"(C:\Windows\System32\wow64win.dll)",
+  R"(C:\Windows\System32\wow64cpu.dll)",
+  R"(D:\src\llvm\llvm\tools\lldb\packages\Python\lldbsuite\test\functionalities\postmortem\wow64_minidump\fizzbuzz.exe)",
+  R"(C:\Windows\SysWOW64\ntdll.dll)",
+  R"(C:\Windows\SysWOW64\kernel32.dll)",
+  R"(C:\Windows\SysWOW64\KERNELBASE.dll)",
+  R"(C:\Windows\SysWOW64\advapi32.dll)",
+  R"(C:\Windows\SysWOW64\msvcrt.dll)",
+  R"(C:\Windows\SysWOW64\sechost.dll)",
+  R"(C:\Windows\SysWOW64\rpcrt4.dll)",
+  R"(C:\Windows\SysWOW64\sspicli.dll)",
+  R"(C:\Windows\SysWOW64\CRYPTBASE.dll)",
+  R"(C:\Windows\System32\api-ms-win-core-synch-l1-2-0.DLL)",
+  };
+
+  for (int i = 0; i < 16; ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(modules[i].module_name_rva);
+ASSERT_TRUE(name.hasValue());
+EXPECT_EQ(module_names[i], name.getValue());
+  }
+}
+
+// Register tests
+#define REG_VAL32(

[Lldb-commits] [PATCH] D25832: Minidump plugin: Adding x86_32 register context converter

2016-10-24 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added inline comments.



Comment at: unittests/Process/minidump/MinidumpParserTest.cpp:279
 // Register stuff
 // TODO probably split register stuff tests into different file?
+#define REG_VAL32(x) *(reinterpret_cast(x))

labath wrote:
> If you want to split them off to a different file, do it now. If not, remove 
> the todo. (I don't see a reason for the split btw)
Yes, I removed the TODO in my next CL. I'll leave the tests here.


https://reviews.llvm.org/D25832



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


[Lldb-commits] [PATCH] D25832: Minidump plugin: Adding x86_32 register context converter

2016-10-24 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 75578.
dvlahovski marked 3 inline comments as done.
dvlahovski added a comment.

Fixes regarding Pavel's comments


https://reviews.llvm.org/D25832

Files:
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/linux-i386.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -8,9 +8,11 @@
 //===--===//
 
 // Project includes
+#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
 #include "Plugins/Process/minidump/MinidumpParser.h"
 #include "Plugins/Process/minidump/MinidumpTypes.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_x86_32.h"
 #include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
 
 // Other libraries and framework includes
@@ -61,7 +63,7 @@
   std::unique_ptr parser;
 };
 
-TEST_F(MinidumpParserTest, GetThreads) {
+TEST_F(MinidumpParserTest, GetThreadsAndGetThreadContext) {
   SetUpData("linux-x86_64.dmp");
   llvm::ArrayRef thread_list;
 
@@ -275,58 +277,97 @@
 
 // Register stuff
 // TODO probably split register stuff tests into different file?
-#define REG_VAL(x) *(reinterpret_cast(x))
+#define REG_VAL32(x) *(reinterpret_cast(x))
+#define REG_VAL64(x) *(reinterpret_cast(x))
 
-TEST_F(MinidumpParserTest, ConvertRegisterContext) {
+TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_32) {
+  SetUpData("linux-i386.dmp");
+  llvm::ArrayRef thread_list = parser->GetThreads();
+  const MinidumpThread thread = thread_list[0];
+  llvm::ArrayRef registers(parser->GetThreadContext(thread));
+
+  ArchSpec arch = parser->GetArchitecture();
+  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  lldb::DataBufferSP buf =
+  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
+
+  const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
+
+  std::map reg_values;
+
+  reg_values[lldb_eax_i386] = 0x;
+  reg_values[lldb_ebx_i386] = 0xf7778000;
+  reg_values[lldb_ecx_i386] = 0x0001;
+  reg_values[lldb_edx_i386] = 0xff9dd4a3;
+  reg_values[lldb_edi_i386] = 0x080482a8;
+  reg_values[lldb_esi_i386] = 0xff9dd55c;
+  reg_values[lldb_ebp_i386] = 0xff9dd53c;
+  reg_values[lldb_esp_i386] = 0xff9dd52c;
+  reg_values[lldb_eip_i386] = 0x080482a0;
+  reg_values[lldb_eflags_i386] = 0x00010282;
+  reg_values[lldb_cs_i386] = 0x0023;
+  reg_values[lldb_fs_i386] = 0x;
+  reg_values[lldb_gs_i386] = 0x0063;
+  reg_values[lldb_ss_i386] = 0x002b;
+  reg_values[lldb_ds_i386] = 0x002b;
+  reg_values[lldb_es_i386] = 0x002b;
+
+  for (uint32_t reg_index = 0; reg_index < reg_interface->GetRegisterCount();
+   ++reg_index) {
+if (reg_values.find(reg_index) != reg_values.end()) {
+  EXPECT_EQ(reg_values[reg_index],
+REG_VAL32(buf->GetBytes() + reg_info[reg_index].byte_offset));
+}
+  }
+}
+
+TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_64) {
   SetUpData("linux-x86_64.dmp");
   llvm::ArrayRef thread_list = parser->GetThreads();
   const MinidumpThread thread = thread_list[0];
-  llvm::ArrayRef registers(parser->GetData().data() +
-thread.thread_context.rva,
-thread.thread_context.data_size);
+  llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
   RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContextToRegIface(registers, reg_interface);
+  ConvertMinidumpContext_x86_64(registers, reg_interface);
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
 
   std::map reg_values;
 
-  // clang-format off
-  reg_values[lldb_rax_x86_64]=  0x;
-  reg_values[lldb_rbx_x86_64]=  0x;
-  reg_values[lldb_rcx_x86_64]=  0x0010;
-  reg_values[lldb_rdx_x86_64]=  0x;
-  reg_values[lldb_rdi_x86_64]=  0x7ffceb349cf0;
-  reg_values[lldb_rsi_x86_64]=  0x;
-  reg_values[lldb_rbp_x86_64]=  0x7ffceb34a210;
-  reg_values[lldb_rsp_x86_64]=  0x7ffceb34a210;
-  reg_values[lldb_r8_x86_64] 

[Lldb-commits] [PATCH] D25905: Minidump plugin: Adding ProcessMinidump, ThreadMinidump and register the plugin in SystemInitializerFull

2016-10-24 Thread Dimitar Vlahovski via lldb-commits
dvlahovski created this revision.
dvlahovski added reviewers: labath, zturner.
dvlahovski added subscribers: amccarth, lldb-commits.
Herald added subscribers: modocache, mgorny, beanz.

This plugin resembles the already existing Windows-only Minidump plugin.
The WinMinidumpPlugin uses the Windows API for parsing Minidumps
while this plugin is cross-platform because it includes a Minidump
parser (which is already commited)

It is able to produce a backtrace, to read the general puprose regiters,
inspect local variables, show image list, do memory reads, etc.

For now the only arches that this supports are x86_32 and x86_64.
This is because I have only written register contexts for those.
Others will come in next CLs.

I copied the WinMinidump tests and adapted them a little bit for them to
work with the new plugin (and they pass)
I will add more tests, aiming for better code coverage.

There is still functionality to be added, see TODOs in code.


https://reviews.llvm.org/D25905

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/install_breakpad.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/makefile.txt
  source/API/SystemInitializerFull.cpp
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.h
  source/Plugins/Process/minidump/NtStructures.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/ProcessMinidump.h
  source/Plugins/Process/minidump/ThreadMinidump.cpp
  source/Plugins/Process/minidump/ThreadMinidump.h
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -134,7 +134,7 @@
 llvm::Optional name =
 parser->GetMinidumpString(modules[i].module_name_rva);
 ASSERT_TRUE(name.hasValue());
-ASSERT_EQ(module_names[i], name.getValue());
+EXPECT_EQ(module_names[i], name.getValue());
   }
 }
 
@@ -275,8 +275,46 @@
   ASSERT_EQ(4440UL, pid.getValue());
 }
 
-// Register stuff
-// TODO probably split register stuff tests into different file?
+// wow64
+TEST_F(MinidumpParserTest, GetPidWow64) {
+  SetUpData("fizzbuzz_wow64.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(7836UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetModuleListWow64) {
+  SetUpData("fizzbuzz_wow64.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  ASSERT_EQ(16UL, modules.size());
+  std::string module_names[16] = {
+  "D:"
+  "\\src\\llvm\\llvm\\tools\\lldb\\packages\\Python\\lldbsuite\\test\\funct"
+  "ionalities\\postmortem\\wow64_minidump\\fizzbuzz.exe",
+  "C:\\Windows\\System32\\ntdll.dll", "C:\\Windows\\System32\\wow64.dll",
+  "C:\\Windows\\System32\\wow64win.dll",
+  "C:\\Windows\\System32\\wow64cpu.dll",
+  "D:"
+  "\\src\\llvm\\llvm\\tools\\lldb\\packages\\Python\\lldbsuite\\test\\funct"
+  "ionalities\\postmortem\\wow64_minidump\\fizzbuzz.exe",
+  "C:\\Windows\\SysWOW64\\ntdll.dll", "C:\\Windows\\SysWOW64\\kernel32.dll",
+  "C:\\Windows\\SysWOW64\\KERNELBASE.dll",
+  "C:\\Windows\\SysWOW64\\advapi32.dll",
+  "C:\\Windows\\SysWOW64\\msvcrt.dll", "C:\\Windows\\SysWOW64\\sechost.dll",
+  "C:\\Windows\\SysWOW64\\rpcrt4.dll", "C:\\Windows\\SysWOW64\\sspicli.dll",
+  "C:\\Windows\\SysWOW64\\CRYPTBASE.dll",
+  "C:\\Windows\\System32\\api-ms-win-core-synch-l1-2-0.DLL",
+  };
+
+  for (int i = 0; i < 16; ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(modules[i].module_name_rva);
+ASSERT_TRUE(name.hasValue());
+EXPECT_EQ(module_names[i], name.getValue());
+  }
+}
+
+// Register tests
 #define REG_VAL32(x) *(reinterpret_cast(x))
 #define REG_VAL64(x) *(reinterpret_cast(x))
 
@@ -371,3 +409,45 @@
 }
   }
 }
+
+TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_32_WithRegIface_wow64) {
+  SetUpData("fizzbuzz_wow64.dmp");
+  llvm::ArrayRef thread_list = parser->GetThreads();
+  const MinidumpThread thread = thread_list[0];
+  llv

[Lldb-commits] [PATCH] D25832: Minidump plugin: Adding x86_32 register context converter

2016-10-20 Thread Dimitar Vlahovski via lldb-commits
dvlahovski created this revision.
dvlahovski added reviewers: labath, zturner.
dvlahovski added subscribers: lldb-commits, amccarth.
Herald added subscribers: modocache, mgorny, beanz.

This, like the x86_64 case, reads the register values from the minidump
file, and emits a binary buffer that is ordered using the offsets from
the RegisterInfoInterface argument. That way we can reuse an existing
register context.
Added unit tests.


https://reviews.llvm.org/D25832

Files:
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/linux-i386.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -8,9 +8,11 @@
 //===--===//
 
 // Project includes
+#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
 #include "Plugins/Process/minidump/MinidumpParser.h"
 #include "Plugins/Process/minidump/MinidumpTypes.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_x86_32.h"
 #include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
 
 // Other libraries and framework includes
@@ -61,7 +63,7 @@
   std::unique_ptr parser;
 };
 
-TEST_F(MinidumpParserTest, GetThreads) {
+TEST_F(MinidumpParserTest, GetThreadsAndGetThreadContext) {
   SetUpData("linux-x86_64.dmp");
   llvm::ArrayRef thread_list;
 
@@ -275,58 +277,97 @@
 
 // Register stuff
 // TODO probably split register stuff tests into different file?
-#define REG_VAL(x) *(reinterpret_cast(x))
+#define REG_VAL32(x) *(reinterpret_cast(x))
+#define REG_VAL64(x) *(reinterpret_cast(x))
 
-TEST_F(MinidumpParserTest, ConvertRegisterContext) {
+TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_32_WithRegIface) {
+  SetUpData("linux-i386.dmp");
+  llvm::ArrayRef thread_list = parser->GetThreads();
+  const MinidumpThread thread = thread_list[0];
+  llvm::ArrayRef registers(parser->GetThreadContext(thread));
+
+  ArchSpec arch = parser->GetArchitecture();
+  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  lldb::DataBufferSP buf =
+  ConvertMinidumpContext_x86_32_WithRegIface(registers, reg_interface);
+  ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
+
+  const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
+
+  std::map reg_values;
+
+  reg_values[lldb_eax_i386] = 0x;
+  reg_values[lldb_ebx_i386] = 0xf7778000;
+  reg_values[lldb_ecx_i386] = 0x0001;
+  reg_values[lldb_edx_i386] = 0xff9dd4a3;
+  reg_values[lldb_edi_i386] = 0x080482a8;
+  reg_values[lldb_esi_i386] = 0xff9dd55c;
+  reg_values[lldb_ebp_i386] = 0xff9dd53c;
+  reg_values[lldb_esp_i386] = 0xff9dd52c;
+  reg_values[lldb_eip_i386] = 0x080482a0;
+  reg_values[lldb_eflags_i386] = 0x00010282;
+  reg_values[lldb_cs_i386] = 0x0023;
+  reg_values[lldb_fs_i386] = 0x;
+  reg_values[lldb_gs_i386] = 0x0063;
+  reg_values[lldb_ss_i386] = 0x002b;
+  reg_values[lldb_ds_i386] = 0x002b;
+  reg_values[lldb_es_i386] = 0x002b;
+
+  for (uint32_t reg_index = 0; reg_index < reg_interface->GetRegisterCount();
+   ++reg_index) {
+if (reg_values.find(reg_index) != reg_values.end()) {
+  EXPECT_EQ(reg_values[reg_index],
+REG_VAL32(buf->GetBytes() + reg_info[reg_index].byte_offset));
+}
+  }
+}
+
+TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_64_WithRegIface) {
   SetUpData("linux-x86_64.dmp");
   llvm::ArrayRef thread_list = parser->GetThreads();
   const MinidumpThread thread = thread_list[0];
-  llvm::ArrayRef registers(parser->GetData().data() +
-thread.thread_context.rva,
-thread.thread_context.data_size);
+  llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
   RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContextToRegIface(registers, reg_interface);
+  ConvertMinidumpContext_x86_64_WithRegIface(registers, reg_interface);
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
 
   std::map reg_values;
 
-  // clang-format off
-  reg_values[lldb_rax_x86_64]=  0x;
-  reg_values[lldb_rbx_x86_64]=  0x;
-  reg_values[lldb_rcx_x86_64]=  0x0

[Lldb-commits] [PATCH] D25677: Minidump plugin: redesign the x86_64 register context

2016-10-20 Thread Dimitar Vlahovski via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284741: Minidump plugin: redesign the x86_64 register 
context (authored by dvlahovski).

Changed prior to commit:
  https://reviews.llvm.org/D25677?vs=75154&id=75309#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25677

Files:
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h

Index: lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
===
--- lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
+++ lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
@@ -21,81 +21,145 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitmaskEnum.h"
+#include "llvm/Support/Endian.h"
 
 // C includes
 // C++ includes
 
 namespace lldb_private {
 
 namespace minidump {
 
-// The content of the Minidump register context is as follows:
-// (for reference see breakpad's source or WinNT.h)
-// Register parameter home addresses: (p1_home .. p6_home)
-// - uint64_t p1_home
-// - uint64_t p2_home
-// - uint64_t p3_home
-// - uint64_t p4_home
-// - uint64_t p5_home
-// - uint64_t p6_home
-//
-// - uint32_t context_flags - field that determines the layout of the structure
-// and which parts of it are populated
-// - uint32_t mx_csr
-//
-// - uint16_t cs - included if MinidumpContext_x86_64_Flags::Control
-//
-// - uint16_t ds - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t es - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t fs - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t gs - included if MinidumpContext_x86_64_Flags::Segments
-//
-// - uint16_t ss - included if MinidumpContext_x86_64_Flags::Control
-// - uint32_t rflags - included if MinidumpContext_x86_64_Flags::Control
-//
-// Debug registers: (included if MinidumpContext_x86_64_Flags::DebugRegisters)
-// - uint64_t dr0
-// - uint64_t dr1
-// - uint64_t dr2
-// - uint64_t dr3
-// - uint64_t dr6
-// - uint64_t dr7
-//
-// The next 4 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rax
-// - uint64_t rcx
-// - uint64_t rdx
-// - uint64_t rbx
-//
-// - uint64_t rsp - included if MinidumpContext_x86_64_Flags::Control
-//
-// The next 11 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rbp
-// - uint64_t rsi
-// - uint64_t rdi
-// - uint64_t r8
-// - uint64_t r9
-// - uint64_t r10
-// - uint64_t r11
-// - uint64_t r12
-// - uint64_t r13
-// - uint64_t r14
-// - uint64_t r15
-//
-// - uint64_t rip - included if MinidumpContext_x86_64_Flags::Control
-//
-// TODO: add floating point registers here
-
 // This function receives an ArrayRef pointing to the bytes of the Minidump
 // register context and returns a DataBuffer that's ordered by the offsets
 // specified in the RegisterInfoInterface argument
 // This way we can reuse the already existing register contexts
 lldb::DataBufferSP
 ConvertMinidumpContextToRegIface(llvm::ArrayRef source_data,
  RegisterInfoInterface *target_reg_interface);
 
+struct Uint128 {
+  llvm::support::ulittle64_t high;
+  llvm::support::ulittle64_t low;
+};
+
+// Reference: see breakpad/crashpad source or WinNT.h
+struct MinidumpXMMSaveArea32AMD64 {
+  llvm::support::ulittle16_t control_word;
+  llvm::support::ulittle16_t status_word;
+  uint8_t tag_word;
+  uint8_t reserved1;
+  llvm::support::ulittle16_t error_opcode;
+  llvm::support::ulittle32_t error_offset;
+  llvm::support::ulittle16_t error_selector;
+  llvm::support::ulittle16_t reserved2;
+  llvm::support::ulittle32_t data_offset;
+  llvm::support::ulittle16_t data_selector;
+  llvm::support::ulittle16_t reserved3;
+  llvm::support::ulittle32_t mx_csr;
+  llvm::support::ulittle32_t mx_csr_mask;
+  Uint128 float_registers[8];
+  Uint128 xmm_registers[16];
+  uint8_t reserved4[96];
+};
+
+struct MinidumpContext_x86_64 {
+  // Register parameter home addresses.
+  llvm::support::ulittle64_t p1_home;
+  llvm::support::ulittle64_t p2_home;
+  llvm::support::ulittle64_t p3_home;
+  llvm::support::ulittle64_t p4_home;
+  llvm::support::ulittle64_t p5_home;
+  llvm::support::ulittle64_t p6_home;
+
+  // The context_flags field determines and which parts
+  // of the structure are populated (have valid values)
+  llvm::support::ulittle32_t context_flags;
+  llvm::support::ulittle32_t mx_csr;
+
+  // The next register is included with
+  // MinidumpContext_x86_64_Flags::Control
+  llvm::support::ulittle16_t cs;
+
+  // The next 4 registers are included with
+  // MinidumpContext_x86_64_Flags::Segments
+  llvm::support::ulittle16_t ds;
+  llvm::support::ulittle16_t es;
+  llvm::support::ulittle16_t fs;
+  llvm::support::ulittle16_t gs;
+
+  // The next 2 registers are included with
+  // MinidumpContext_x86_64_

[Lldb-commits] [lldb] r284741 - Minidump plugin: redesign the x86_64 register context

2016-10-20 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Thu Oct 20 11:01:36 2016
New Revision: 284741

URL: http://llvm.org/viewvc/llvm-project?rev=284741&view=rev
Log:
Minidump plugin: redesign the x86_64 register context

Summary:
I misunderstood the format of the register context layout.
I thought it was a dynamically changing structure, and that it's size
depended on context_flags.
It turned out that it always has the same fixed layout and size,
and the context_flags says which fields of the
struct have valid values.
This required a minor redesign of the register context class.

The layout inconsistency, however, was not a "problem" before (e.g. the plugin 
was working)
because there also was a bug with checking context_flags - the code was
parsing the entire struct regardless of context_flags.
This bug is also fixed in this commit.

Reviewers: labath, zturner

Subscribers: lldb-commits, amccarth

Differential Revision: https://reviews.llvm.org/D25677

Modified:

lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h

Modified: 
lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp?rev=284741&r1=284740&r2=284741&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp 
Thu Oct 20 11:01:36 2016
@@ -19,18 +19,11 @@
 using namespace lldb_private;
 using namespace minidump;
 
-void writeRegister(llvm::ArrayRef ®_src,
-   llvm::MutableArrayRef reg_dest) {
-  memcpy(reg_dest.data(), reg_src.data(), reg_dest.size());
-  reg_src = reg_src.drop_front(reg_dest.size());
-}
-
 llvm::MutableArrayRef getDestRegister(uint8_t *context,
-   uint32_t lldb_reg_num,
const RegisterInfo ®) {
   auto bytes = reg.mutable_data(context);
 
-  switch (lldb_reg_num) {
+  switch (reg.kinds[lldb::eRegisterKindLLDB]) {
   case lldb_cs_x86_64:
   case lldb_ds_x86_64:
   case lldb_es_x86_64:
@@ -48,6 +41,12 @@ llvm::MutableArrayRef getDestRe
   }
 }
 
+void writeRegister(const void *reg_src, uint8_t *context,
+   const RegisterInfo ®) {
+  llvm::MutableArrayRef reg_dest = getDestRegister(context, reg);
+  memcpy(reg_dest.data(), reg_src, reg_dest.size());
+}
+
 lldb::DataBufferSP lldb_private::minidump::ConvertMinidumpContextToRegIface(
 llvm::ArrayRef source_data,
 RegisterInfoInterface *target_reg_interface) {
@@ -58,98 +57,54 @@ lldb::DataBufferSP lldb_private::minidum
   new DataBufferHeap(target_reg_interface->GetGPRSize(), 0));
   uint8_t *result_base = result_context_buf->GetBytes();
 
-  source_data = source_data.drop_front(6 * 8); // p[1-6] home registers
-  const uint32_t *context_flags;
-  consumeObject(source_data, context_flags);
-  const uint32_t x86_64_Flag =
-  static_cast(MinidumpContext_x86_64_Flags::x86_64_Flag);
-  const uint32_t ControlFlag =
-  static_cast(MinidumpContext_x86_64_Flags::Control);
-  const uint32_t IntegerFlag =
-  static_cast(MinidumpContext_x86_64_Flags::Integer);
-  const uint32_t SegmentsFlag =
-  static_cast(MinidumpContext_x86_64_Flags::Segments);
-  const uint32_t DebugRegistersFlag =
-  static_cast(MinidumpContext_x86_64_Flags::DebugRegisters);
-
-  if (!(*context_flags & x86_64_Flag)) {
-return result_context_buf; // error
-  }
-
-  source_data = source_data.drop_front(4); // mx_csr
-
-  if (*context_flags & ControlFlag) {
-writeRegister(source_data, getDestRegister(result_base, lldb_cs_x86_64,
-   reg_info[lldb_cs_x86_64]));
-  }
-
-  if (*context_flags & SegmentsFlag) {
-writeRegister(source_data, getDestRegister(result_base, lldb_ds_x86_64,
-   reg_info[lldb_ds_x86_64]));
-writeRegister(source_data, getDestRegister(result_base, lldb_es_x86_64,
-   reg_info[lldb_es_x86_64]));
-writeRegister(source_data, getDestRegister(result_base, lldb_fs_x86_64,
-   reg_info[lldb_fs_x86_64]));
-writeRegister(source_data, getDestRegister(result_base, lldb_gs_x86_64,
-   reg_info[lldb_gs_x86_64]));
-  }
-
-  if (*context_flags & ControlFlag) {
-writeRegister(source_data, getDestRegister(result_base, lldb_ss_x86_64,
-   reg_info[lldb_ss_x86_64]));
-writeRegister(source_data, getDestRegister(result_base, lldb_rflags_x86_64,
-   reg_info[lldb_rflags_x86_64]));
-  }
-
-  if (*context_flags & DebugReg

[Lldb-commits] [PATCH] D25677: Minidump plugin: redesign the x86_64 register context

2016-10-19 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 75154.
dvlahovski marked an inline comment as done.
dvlahovski added a comment.

Simplified writeRegister function

s/uint128_struct/Uint128/


https://reviews.llvm.org/D25677

Files:
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h

Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
===
--- source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
+++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
@@ -21,81 +21,145 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitmaskEnum.h"
+#include "llvm/Support/Endian.h"
 
 // C includes
 // C++ includes
 
 namespace lldb_private {
 
 namespace minidump {
 
-// The content of the Minidump register context is as follows:
-// (for reference see breakpad's source or WinNT.h)
-// Register parameter home addresses: (p1_home .. p6_home)
-// - uint64_t p1_home
-// - uint64_t p2_home
-// - uint64_t p3_home
-// - uint64_t p4_home
-// - uint64_t p5_home
-// - uint64_t p6_home
-//
-// - uint32_t context_flags - field that determines the layout of the structure
-// and which parts of it are populated
-// - uint32_t mx_csr
-//
-// - uint16_t cs - included if MinidumpContext_x86_64_Flags::Control
-//
-// - uint16_t ds - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t es - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t fs - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t gs - included if MinidumpContext_x86_64_Flags::Segments
-//
-// - uint16_t ss - included if MinidumpContext_x86_64_Flags::Control
-// - uint32_t rflags - included if MinidumpContext_x86_64_Flags::Control
-//
-// Debug registers: (included if MinidumpContext_x86_64_Flags::DebugRegisters)
-// - uint64_t dr0
-// - uint64_t dr1
-// - uint64_t dr2
-// - uint64_t dr3
-// - uint64_t dr6
-// - uint64_t dr7
-//
-// The next 4 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rax
-// - uint64_t rcx
-// - uint64_t rdx
-// - uint64_t rbx
-//
-// - uint64_t rsp - included if MinidumpContext_x86_64_Flags::Control
-//
-// The next 11 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rbp
-// - uint64_t rsi
-// - uint64_t rdi
-// - uint64_t r8
-// - uint64_t r9
-// - uint64_t r10
-// - uint64_t r11
-// - uint64_t r12
-// - uint64_t r13
-// - uint64_t r14
-// - uint64_t r15
-//
-// - uint64_t rip - included if MinidumpContext_x86_64_Flags::Control
-//
-// TODO: add floating point registers here
-
 // This function receives an ArrayRef pointing to the bytes of the Minidump
 // register context and returns a DataBuffer that's ordered by the offsets
 // specified in the RegisterInfoInterface argument
 // This way we can reuse the already existing register contexts
 lldb::DataBufferSP
 ConvertMinidumpContextToRegIface(llvm::ArrayRef source_data,
  RegisterInfoInterface *target_reg_interface);
 
+struct Uint128 {
+  llvm::support::ulittle64_t high;
+  llvm::support::ulittle64_t low;
+};
+
+// Reference: see breakpad/crashpad source or WinNT.h
+struct MinidumpXMMSaveArea32AMD64 {
+  llvm::support::ulittle16_t control_word;
+  llvm::support::ulittle16_t status_word;
+  uint8_t tag_word;
+  uint8_t reserved1;
+  llvm::support::ulittle16_t error_opcode;
+  llvm::support::ulittle32_t error_offset;
+  llvm::support::ulittle16_t error_selector;
+  llvm::support::ulittle16_t reserved2;
+  llvm::support::ulittle32_t data_offset;
+  llvm::support::ulittle16_t data_selector;
+  llvm::support::ulittle16_t reserved3;
+  llvm::support::ulittle32_t mx_csr;
+  llvm::support::ulittle32_t mx_csr_mask;
+  Uint128 float_registers[8];
+  Uint128 xmm_registers[16];
+  uint8_t reserved4[96];
+};
+
+struct MinidumpContext_x86_64 {
+  // Register parameter home addresses.
+  llvm::support::ulittle64_t p1_home;
+  llvm::support::ulittle64_t p2_home;
+  llvm::support::ulittle64_t p3_home;
+  llvm::support::ulittle64_t p4_home;
+  llvm::support::ulittle64_t p5_home;
+  llvm::support::ulittle64_t p6_home;
+
+  // The context_flags field determines and which parts
+  // of the structure are populated (have valid values)
+  llvm::support::ulittle32_t context_flags;
+  llvm::support::ulittle32_t mx_csr;
+
+  // The next register is included with
+  // MinidumpContext_x86_64_Flags::Control
+  llvm::support::ulittle16_t cs;
+
+  // The next 4 registers are included with
+  // MinidumpContext_x86_64_Flags::Segments
+  llvm::support::ulittle16_t ds;
+  llvm::support::ulittle16_t es;
+  llvm::support::ulittle16_t fs;
+  llvm::support::ulittle16_t gs;
+
+  // The next 2 registers are included with
+  // MinidumpContext_x86_64_Flags::Control
+  llvm::support::ulittle16_t ss;
+  llvm::support::ulittle32_t eflags;
+
+  // The next 6 registers are included with
+  // MinidumpContext_x8

[Lldb-commits] [PATCH] D25569: Minidump plugin: functions parsing memory structures and filtering module list

2016-10-19 Thread Dimitar Vlahovski via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284593: Minidump plugin: functions parsing memory structures 
and filtering module list (authored by dvlahovski).

Changed prior to commit:
  https://reviews.llvm.org/D25569?vs=74824&id=75147#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25569

Files:
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
  lldb/trunk/unittests/Process/minidump/CMakeLists.txt
  lldb/trunk/unittests/Process/minidump/Inputs/fizzbuzz_wow64.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/linux-x86_64_not_crashed.dmp
  lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Index: lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Host/FileSpec.h"
+#include "lldb/Target/MemoryRegionInfo.h"
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
@@ -68,7 +69,11 @@
   ASSERT_EQ(1UL, thread_list.size());
 
   const MinidumpThread thread = thread_list[0];
-  ASSERT_EQ(16001UL, thread.thread_id);
+
+  EXPECT_EQ(16001UL, thread.thread_id);
+
+  llvm::ArrayRef context = parser->GetThreadContext(thread);
+  EXPECT_EQ(1232UL, context.size());
 }
 
 TEST_F(MinidumpParserTest, GetThreadsTruncatedFile) {
@@ -131,14 +136,111 @@
   }
 }
 
+TEST_F(MinidumpParserTest, GetFilteredModuleList) {
+  SetUpData("linux-x86_64_not_crashed.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  std::vector filtered_modules =
+  parser->GetFilteredModuleList();
+  EXPECT_EQ(10UL, modules.size());
+  EXPECT_EQ(9UL, filtered_modules.size());
+  // EXPECT_GT(modules.size(), filtered_modules.size());
+  bool found = false;
+  for (size_t i = 0; i < filtered_modules.size(); ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(filtered_modules[i]->module_name_rva);
+ASSERT_TRUE(name.hasValue());
+if (name.getValue() == "/tmp/test/linux-x86_64_not_crashed") {
+  ASSERT_FALSE(found) << "There should be only one module with this name "
+ "in the filtered module list";
+  found = true;
+  ASSERT_EQ(0x40UL, filtered_modules[i]->base_of_image);
+}
+  }
+}
+
 TEST_F(MinidumpParserTest, GetExceptionStream) {
   SetUpData("linux-x86_64.dmp");
   const MinidumpExceptionStream *exception_stream =
   parser->GetExceptionStream();
   ASSERT_NE(nullptr, exception_stream);
   ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
 }
 
+void check_mem_range_exists(std::unique_ptr &parser,
+const uint64_t range_start,
+const uint64_t range_size) {
+  llvm::Optional range = parser->FindMemoryRange(range_start);
+  ASSERT_TRUE(range.hasValue()) << "There is no range containing this address";
+  EXPECT_EQ(range_start, range->start);
+  EXPECT_EQ(range_start + range_size, range->start + range->range_ref.size());
+}
+
+TEST_F(MinidumpParserTest, FindMemoryRange) {
+  SetUpData("linux-x86_64.dmp");
+  // There are two memory ranges in the file (size is in bytes, decimal):
+  // 1) 0x401d46 256
+  // 2) 0x7ffceb34a000 12288
+  EXPECT_FALSE(parser->FindMemoryRange(0x00).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+
+  check_mem_range_exists(parser, 0x401d46, 256);
+  EXPECT_FALSE(parser->FindMemoryRange(0x401d46 + 256).hasValue());
+
+  check_mem_range_exists(parser, 0x7ffceb34a000, 12288);
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffceb34a000 + 12288).hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetMemory) {
+  SetUpData("linux-x86_64.dmp");
+
+  EXPECT_EQ(128UL, parser->GetMemory(0x401d46, 128).size());
+  EXPECT_EQ(256UL, parser->GetMemory(0x401d46, 512).size());
+
+  EXPECT_EQ(12288UL, parser->GetMemory(0x7ffceb34a000, 12288).size());
+  EXPECT_EQ(1024UL, parser->GetMemory(0x7ffceb34a000, 1024).size());
+
+  EXPECT_TRUE(parser->GetMemory(0x50, 512).empty());
+}
+
+TEST_F(MinidumpParserTest, FindMemoryRangeWithFullMemoryMinidump) {
+  SetUpData("fizzbuzz_wow64.dmp");
+
+  // There are a lot of ranges in the file, just testing with some of them
+  EXPECT_FALSE(parser->FindMemoryRange(0x00).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+  check_mem_range_exists(parser, 0x1, 65536); // first range
+  check_mem_range_exists(parser, 0x4, 4096);
+  EXPECT_FALSE(parser->FindMemoryRange(0x4 + 4096).hasValue());
+  check_mem_range_exists(parser, 0x77c12000, 8192);
+  check_mem_range_exists(parser, 0x7ffe, 4096); // last range
+  EXPECT_FALSE(pars

[Lldb-commits] [lldb] r284593 - Minidump plugin: functions parsing memory structures and filtering module list

2016-10-19 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Wed Oct 19 09:14:18 2016
New Revision: 284593

URL: http://llvm.org/viewvc/llvm-project?rev=284593&view=rev
Log:
Minidump plugin: functions parsing memory structures and filtering module list

Summary:
Now the Minidump parser can parse the:
1) MemoryInfoList - containing region info about memory ranges (readable,
writable, executable)
2) Memory64List - this is the stuct used when the Minidump is a
full-memory one.
3) Adding filtering of the module list (shared libraries list) - there
can be mutliple records in the module list under the same name but with
different load address (e.g. when the binary has non contigious
sections). FilterModuleList eliminates the duplicated modules, leaving
the one with the lowest load addr.

Added unit tests for everything.

Reviewers: labath, zturner

Subscribers: beanz, mgorny, modocache, lldb-commits, amccarth

Differential Revision: https://reviews.llvm.org/D25569


Added:
lldb/trunk/unittests/Process/minidump/Inputs/fizzbuzz_wow64.dmp
  - copied unchanged from r284590, 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz_wow64.dmp
lldb/trunk/unittests/Process/minidump/Inputs/linux-x86_64_not_crashed.dmp   
(with props)
Modified:
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
lldb/trunk/unittests/Process/minidump/CMakeLists.txt
lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Modified: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp?rev=284593&r1=284592&r2=284593&view=diff
==
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp Wed Oct 19 
09:14:18 2016
@@ -11,8 +11,11 @@
 #include "MinidumpParser.h"
 
 // Other libraries and framework includes
+#include "lldb/Target/MemoryRegionInfo.h"
+
 // C includes
 // C++ includes
+#include 
 
 using namespace lldb_private;
 using namespace minidump;
@@ -100,6 +103,14 @@ llvm::ArrayRef MinidumpP
   return MinidumpThread::ParseThreadList(data);
 }
 
+llvm::ArrayRef
+MinidumpParser::GetThreadContext(const MinidumpThread &td) {
+  if (td.thread_context.rva + td.thread_context.data_size > GetData().size())
+return llvm::None;
+
+  return GetData().slice(td.thread_context.rva, td.thread_context.data_size);
+}
+
 const MinidumpSystemInfo *MinidumpParser::GetSystemInfo() {
   llvm::ArrayRef data = GetStream(MinidumpStreamType::SystemInfo);
 
@@ -216,6 +227,42 @@ llvm::ArrayRef MinidumpP
   return MinidumpModule::ParseModuleList(data);
 }
 
+std::vector MinidumpParser::GetFilteredModuleList() {
+  llvm::ArrayRef modules = GetModuleList();
+  // mapping module_name to pair(load_address, pointer to module struct in
+  // memory)
+  llvm::StringMap> lowest_addr;
+
+  std::vector filtered_modules;
+
+  llvm::Optional name;
+  std::string module_name;
+
+  for (const auto &module : modules) {
+name = GetMinidumpString(module.module_name_rva);
+
+if (!name)
+  continue;
+
+module_name = name.getValue();
+
+auto iter = lowest_addr.end();
+bool exists;
+std::tie(iter, exists) = lowest_addr.try_emplace(
+module_name, std::make_pair(module.base_of_image, &module));
+
+if (exists && module.base_of_image < iter->second.first)
+  iter->second = std::make_pair(module.base_of_image, &module);
+  }
+
+  filtered_modules.reserve(lowest_addr.size());
+  for (const auto &module : lowest_addr) {
+filtered_modules.push_back(module.second.second);
+  }
+
+  return filtered_modules;
+}
+
 const MinidumpExceptionStream *MinidumpParser::GetExceptionStream() {
   llvm::ArrayRef data = GetStream(MinidumpStreamType::Exception);
 
@@ -224,3 +271,156 @@ const MinidumpExceptionStream *MinidumpP
 
   return MinidumpExceptionStream::Parse(data);
 }
+
+llvm::Optional
+MinidumpParser::FindMemoryRange(lldb::addr_t addr) {
+  llvm::ArrayRef data = GetStream(MinidumpStreamType::MemoryList);
+  llvm::ArrayRef data64 = GetStream(MinidumpStreamType::Memory64List);
+
+  if (data.empty() && data64.empty())
+return llvm::None;
+
+  if (!data.empty()) {
+llvm::ArrayRef memory_list =
+MinidumpMemoryDescriptor::ParseMemoryList(data);
+
+if (memory_list.empty())
+  return llvm::None;
+
+for (const auto &memory_desc : memory_list) {
+  const MinidumpLocationDescriptor &loc_desc = memory_desc.memory;
+  const lldb::addr_t range_start = memory_desc.start_of_memory_range;
+  const size_t range_size = loc_desc.data_size;
+
+  if (loc_desc.rva + loc_desc.data_size > GetData().size())
+return llvm::None;
+
+  

[Lldb-commits] [PATCH] D25677: Minidump plugin: redesign the x86_64 register context

2016-10-18 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 74987.
dvlahovski added a comment.

Merge if's checking the same context flag


https://reviews.llvm.org/D25677

Files:
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h

Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
===
--- source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
+++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
@@ -21,81 +21,145 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitmaskEnum.h"
+#include "llvm/Support/Endian.h"
 
 // C includes
 // C++ includes
 
 namespace lldb_private {
 
 namespace minidump {
 
-// The content of the Minidump register context is as follows:
-// (for reference see breakpad's source or WinNT.h)
-// Register parameter home addresses: (p1_home .. p6_home)
-// - uint64_t p1_home
-// - uint64_t p2_home
-// - uint64_t p3_home
-// - uint64_t p4_home
-// - uint64_t p5_home
-// - uint64_t p6_home
-//
-// - uint32_t context_flags - field that determines the layout of the structure
-// and which parts of it are populated
-// - uint32_t mx_csr
-//
-// - uint16_t cs - included if MinidumpContext_x86_64_Flags::Control
-//
-// - uint16_t ds - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t es - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t fs - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t gs - included if MinidumpContext_x86_64_Flags::Segments
-//
-// - uint16_t ss - included if MinidumpContext_x86_64_Flags::Control
-// - uint32_t rflags - included if MinidumpContext_x86_64_Flags::Control
-//
-// Debug registers: (included if MinidumpContext_x86_64_Flags::DebugRegisters)
-// - uint64_t dr0
-// - uint64_t dr1
-// - uint64_t dr2
-// - uint64_t dr3
-// - uint64_t dr6
-// - uint64_t dr7
-//
-// The next 4 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rax
-// - uint64_t rcx
-// - uint64_t rdx
-// - uint64_t rbx
-//
-// - uint64_t rsp - included if MinidumpContext_x86_64_Flags::Control
-//
-// The next 11 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rbp
-// - uint64_t rsi
-// - uint64_t rdi
-// - uint64_t r8
-// - uint64_t r9
-// - uint64_t r10
-// - uint64_t r11
-// - uint64_t r12
-// - uint64_t r13
-// - uint64_t r14
-// - uint64_t r15
-//
-// - uint64_t rip - included if MinidumpContext_x86_64_Flags::Control
-//
-// TODO: add floating point registers here
-
 // This function receives an ArrayRef pointing to the bytes of the Minidump
 // register context and returns a DataBuffer that's ordered by the offsets
 // specified in the RegisterInfoInterface argument
 // This way we can reuse the already existing register contexts
 lldb::DataBufferSP
 ConvertMinidumpContextToRegIface(llvm::ArrayRef source_data,
  RegisterInfoInterface *target_reg_interface);
 
+struct uint128_struct {
+  llvm::support::ulittle64_t high;
+  llvm::support::ulittle64_t low;
+};
+
+// Reference: see breakpad/crashpad source or WinNT.h
+struct MinidumpXMMSaveArea32AMD64 {
+  llvm::support::ulittle16_t control_word;
+  llvm::support::ulittle16_t status_word;
+  uint8_t tag_word;
+  uint8_t reserved1;
+  llvm::support::ulittle16_t error_opcode;
+  llvm::support::ulittle32_t error_offset;
+  llvm::support::ulittle16_t error_selector;
+  llvm::support::ulittle16_t reserved2;
+  llvm::support::ulittle32_t data_offset;
+  llvm::support::ulittle16_t data_selector;
+  llvm::support::ulittle16_t reserved3;
+  llvm::support::ulittle32_t mx_csr;
+  llvm::support::ulittle32_t mx_csr_mask;
+  uint128_struct float_registers[8];
+  uint128_struct xmm_registers[16];
+  uint8_t reserved4[96];
+};
+
+struct MinidumpContext_x86_64 {
+  // Register parameter home addresses.
+  llvm::support::ulittle64_t p1_home;
+  llvm::support::ulittle64_t p2_home;
+  llvm::support::ulittle64_t p3_home;
+  llvm::support::ulittle64_t p4_home;
+  llvm::support::ulittle64_t p5_home;
+  llvm::support::ulittle64_t p6_home;
+
+  // The context_flags field determines and which parts
+  // of the structure are populated (have valid values)
+  llvm::support::ulittle32_t context_flags;
+  llvm::support::ulittle32_t mx_csr;
+
+  // The next register is included with
+  // MinidumpContext_x86_64_Flags::Control
+  llvm::support::ulittle16_t cs;
+
+  // The next 4 registers are included with
+  // MinidumpContext_x86_64_Flags::Segments
+  llvm::support::ulittle16_t ds;
+  llvm::support::ulittle16_t es;
+  llvm::support::ulittle16_t fs;
+  llvm::support::ulittle16_t gs;
+
+  // The next 2 registers are included with
+  // MinidumpContext_x86_64_Flags::Control
+  llvm::support::ulittle16_t ss;
+  llvm::support::ulittle32_t eflags;
+
+  // The next 6 registers are included with
+  // MinidumpContext_x86_64_Flags::DebugRegisters
+  llvm::support

[Lldb-commits] [PATCH] D25677: Minidump plugin: redesign the x86_64 register context

2016-10-17 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 74859.
dvlahovski added a comment.

Make a single array of sse registers instead of separated fields


https://reviews.llvm.org/D25677

Files:
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h

Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
===
--- source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
+++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
@@ -21,81 +21,145 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitmaskEnum.h"
+#include "llvm/Support/Endian.h"
 
 // C includes
 // C++ includes
 
 namespace lldb_private {
 
 namespace minidump {
 
-// The content of the Minidump register context is as follows:
-// (for reference see breakpad's source or WinNT.h)
-// Register parameter home addresses: (p1_home .. p6_home)
-// - uint64_t p1_home
-// - uint64_t p2_home
-// - uint64_t p3_home
-// - uint64_t p4_home
-// - uint64_t p5_home
-// - uint64_t p6_home
-//
-// - uint32_t context_flags - field that determines the layout of the structure
-// and which parts of it are populated
-// - uint32_t mx_csr
-//
-// - uint16_t cs - included if MinidumpContext_x86_64_Flags::Control
-//
-// - uint16_t ds - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t es - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t fs - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t gs - included if MinidumpContext_x86_64_Flags::Segments
-//
-// - uint16_t ss - included if MinidumpContext_x86_64_Flags::Control
-// - uint32_t rflags - included if MinidumpContext_x86_64_Flags::Control
-//
-// Debug registers: (included if MinidumpContext_x86_64_Flags::DebugRegisters)
-// - uint64_t dr0
-// - uint64_t dr1
-// - uint64_t dr2
-// - uint64_t dr3
-// - uint64_t dr6
-// - uint64_t dr7
-//
-// The next 4 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rax
-// - uint64_t rcx
-// - uint64_t rdx
-// - uint64_t rbx
-//
-// - uint64_t rsp - included if MinidumpContext_x86_64_Flags::Control
-//
-// The next 11 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rbp
-// - uint64_t rsi
-// - uint64_t rdi
-// - uint64_t r8
-// - uint64_t r9
-// - uint64_t r10
-// - uint64_t r11
-// - uint64_t r12
-// - uint64_t r13
-// - uint64_t r14
-// - uint64_t r15
-//
-// - uint64_t rip - included if MinidumpContext_x86_64_Flags::Control
-//
-// TODO: add floating point registers here
-
 // This function receives an ArrayRef pointing to the bytes of the Minidump
 // register context and returns a DataBuffer that's ordered by the offsets
 // specified in the RegisterInfoInterface argument
 // This way we can reuse the already existing register contexts
 lldb::DataBufferSP
 ConvertMinidumpContextToRegIface(llvm::ArrayRef source_data,
  RegisterInfoInterface *target_reg_interface);
 
+struct uint128_struct {
+  llvm::support::ulittle64_t high;
+  llvm::support::ulittle64_t low;
+};
+
+// Reference: see breakpad/crashpad source or WinNT.h
+struct MinidumpXMMSaveArea32AMD64 {
+  llvm::support::ulittle16_t control_word;
+  llvm::support::ulittle16_t status_word;
+  uint8_t tag_word;
+  uint8_t reserved1;
+  llvm::support::ulittle16_t error_opcode;
+  llvm::support::ulittle32_t error_offset;
+  llvm::support::ulittle16_t error_selector;
+  llvm::support::ulittle16_t reserved2;
+  llvm::support::ulittle32_t data_offset;
+  llvm::support::ulittle16_t data_selector;
+  llvm::support::ulittle16_t reserved3;
+  llvm::support::ulittle32_t mx_csr;
+  llvm::support::ulittle32_t mx_csr_mask;
+  uint128_struct float_registers[8];
+  uint128_struct xmm_registers[16];
+  uint8_t reserved4[96];
+};
+
+struct MinidumpContext_x86_64 {
+  // Register parameter home addresses.
+  llvm::support::ulittle64_t p1_home;
+  llvm::support::ulittle64_t p2_home;
+  llvm::support::ulittle64_t p3_home;
+  llvm::support::ulittle64_t p4_home;
+  llvm::support::ulittle64_t p5_home;
+  llvm::support::ulittle64_t p6_home;
+
+  // The context_flags field determines and which parts
+  // of the structure are populated (have valid values)
+  llvm::support::ulittle32_t context_flags;
+  llvm::support::ulittle32_t mx_csr;
+
+  // The next register is included with
+  // MinidumpContext_x86_64_Flags::Control
+  llvm::support::ulittle16_t cs;
+
+  // The next 4 registers are included with
+  // MinidumpContext_x86_64_Flags::Segments
+  llvm::support::ulittle16_t ds;
+  llvm::support::ulittle16_t es;
+  llvm::support::ulittle16_t fs;
+  llvm::support::ulittle16_t gs;
+
+  // The next 2 registers are included with
+  // MinidumpContext_x86_64_Flags::Control
+  llvm::support::ulittle16_t ss;
+  llvm::support::ulittle32_t eflags;
+
+  // The next 6 registers are included with
+  // MinidumpContext_x86_64_Flags::DebugReg

[Lldb-commits] [PATCH] D25677: Minidump plugin: redesign the x86_64 register context

2016-10-17 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 74856.
dvlahovski added a comment.

Return a nullptr in case of an error


https://reviews.llvm.org/D25677

Files:
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h

Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
===
--- source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
+++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
@@ -21,81 +21,160 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitmaskEnum.h"
+#include "llvm/Support/Endian.h"
 
 // C includes
 // C++ includes
 
 namespace lldb_private {
 
 namespace minidump {
 
-// The content of the Minidump register context is as follows:
-// (for reference see breakpad's source or WinNT.h)
-// Register parameter home addresses: (p1_home .. p6_home)
-// - uint64_t p1_home
-// - uint64_t p2_home
-// - uint64_t p3_home
-// - uint64_t p4_home
-// - uint64_t p5_home
-// - uint64_t p6_home
-//
-// - uint32_t context_flags - field that determines the layout of the structure
-// and which parts of it are populated
-// - uint32_t mx_csr
-//
-// - uint16_t cs - included if MinidumpContext_x86_64_Flags::Control
-//
-// - uint16_t ds - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t es - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t fs - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t gs - included if MinidumpContext_x86_64_Flags::Segments
-//
-// - uint16_t ss - included if MinidumpContext_x86_64_Flags::Control
-// - uint32_t rflags - included if MinidumpContext_x86_64_Flags::Control
-//
-// Debug registers: (included if MinidumpContext_x86_64_Flags::DebugRegisters)
-// - uint64_t dr0
-// - uint64_t dr1
-// - uint64_t dr2
-// - uint64_t dr3
-// - uint64_t dr6
-// - uint64_t dr7
-//
-// The next 4 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rax
-// - uint64_t rcx
-// - uint64_t rdx
-// - uint64_t rbx
-//
-// - uint64_t rsp - included if MinidumpContext_x86_64_Flags::Control
-//
-// The next 11 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rbp
-// - uint64_t rsi
-// - uint64_t rdi
-// - uint64_t r8
-// - uint64_t r9
-// - uint64_t r10
-// - uint64_t r11
-// - uint64_t r12
-// - uint64_t r13
-// - uint64_t r14
-// - uint64_t r15
-//
-// - uint64_t rip - included if MinidumpContext_x86_64_Flags::Control
-//
-// TODO: add floating point registers here
-
 // This function receives an ArrayRef pointing to the bytes of the Minidump
 // register context and returns a DataBuffer that's ordered by the offsets
 // specified in the RegisterInfoInterface argument
 // This way we can reuse the already existing register contexts
 lldb::DataBufferSP
 ConvertMinidumpContextToRegIface(llvm::ArrayRef source_data,
  RegisterInfoInterface *target_reg_interface);
 
+struct uint128_struct {
+  llvm::support::ulittle64_t high;
+  llvm::support::ulittle64_t low;
+};
+
+// Reference: see breakpad/crashpad source or WinNT.h
+struct MinidumpXMMSaveArea32AMD64 {
+  llvm::support::ulittle16_t control_word;
+  llvm::support::ulittle16_t status_word;
+  uint8_t tag_word;
+  uint8_t reserved1;
+  llvm::support::ulittle16_t error_opcode;
+  llvm::support::ulittle32_t error_offset;
+  llvm::support::ulittle16_t error_selector;
+  llvm::support::ulittle16_t reserved2;
+  llvm::support::ulittle32_t data_offset;
+  llvm::support::ulittle16_t data_selector;
+  llvm::support::ulittle16_t reserved3;
+  llvm::support::ulittle32_t mx_csr;
+  llvm::support::ulittle32_t mx_csr_mask;
+  uint128_struct float_registers[8];
+  uint128_struct xmm_registers[16];
+  uint8_t reserved4[96];
+};
+
+struct MinidumpContext_x86_64 {
+  // Register parameter home addresses.
+  llvm::support::ulittle64_t p1_home;
+  llvm::support::ulittle64_t p2_home;
+  llvm::support::ulittle64_t p3_home;
+  llvm::support::ulittle64_t p4_home;
+  llvm::support::ulittle64_t p5_home;
+  llvm::support::ulittle64_t p6_home;
+
+  // The context_flags field determines and which parts
+  // of the structure are populated (have valid values)
+  llvm::support::ulittle32_t context_flags;
+  llvm::support::ulittle32_t mx_csr;
+
+  // The next register is included with
+  // MinidumpContext_x86_64_Flags::Control
+  llvm::support::ulittle16_t cs;
+
+  // The next 4 registers are included with
+  // MinidumpContext_x86_64_Flags::Segments
+  llvm::support::ulittle16_t ds;
+  llvm::support::ulittle16_t es;
+  llvm::support::ulittle16_t fs;
+  llvm::support::ulittle16_t gs;
+
+  // The next 2 registers are included with
+  // MinidumpContext_x86_64_Flags::Control
+  llvm::support::ulittle16_t ss;
+  llvm::support::ulittle32_t eflags;
+
+  // The next 6 registers are included with
+  // MinidumpContext_x86_64_Flags::DebugRegisters
+  llvm::support::uli

[Lldb-commits] [PATCH] D25677: Minidump plugin: redesign the x86_64 register context

2016-10-17 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 74852.
dvlahovski added a comment.

Adding sanity check for the context's size


https://reviews.llvm.org/D25677

Files:
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h

Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
===
--- source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
+++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
@@ -21,81 +21,160 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitmaskEnum.h"
+#include "llvm/Support/Endian.h"
 
 // C includes
 // C++ includes
 
 namespace lldb_private {
 
 namespace minidump {
 
-// The content of the Minidump register context is as follows:
-// (for reference see breakpad's source or WinNT.h)
-// Register parameter home addresses: (p1_home .. p6_home)
-// - uint64_t p1_home
-// - uint64_t p2_home
-// - uint64_t p3_home
-// - uint64_t p4_home
-// - uint64_t p5_home
-// - uint64_t p6_home
-//
-// - uint32_t context_flags - field that determines the layout of the structure
-// and which parts of it are populated
-// - uint32_t mx_csr
-//
-// - uint16_t cs - included if MinidumpContext_x86_64_Flags::Control
-//
-// - uint16_t ds - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t es - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t fs - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t gs - included if MinidumpContext_x86_64_Flags::Segments
-//
-// - uint16_t ss - included if MinidumpContext_x86_64_Flags::Control
-// - uint32_t rflags - included if MinidumpContext_x86_64_Flags::Control
-//
-// Debug registers: (included if MinidumpContext_x86_64_Flags::DebugRegisters)
-// - uint64_t dr0
-// - uint64_t dr1
-// - uint64_t dr2
-// - uint64_t dr3
-// - uint64_t dr6
-// - uint64_t dr7
-//
-// The next 4 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rax
-// - uint64_t rcx
-// - uint64_t rdx
-// - uint64_t rbx
-//
-// - uint64_t rsp - included if MinidumpContext_x86_64_Flags::Control
-//
-// The next 11 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rbp
-// - uint64_t rsi
-// - uint64_t rdi
-// - uint64_t r8
-// - uint64_t r9
-// - uint64_t r10
-// - uint64_t r11
-// - uint64_t r12
-// - uint64_t r13
-// - uint64_t r14
-// - uint64_t r15
-//
-// - uint64_t rip - included if MinidumpContext_x86_64_Flags::Control
-//
-// TODO: add floating point registers here
-
 // This function receives an ArrayRef pointing to the bytes of the Minidump
 // register context and returns a DataBuffer that's ordered by the offsets
 // specified in the RegisterInfoInterface argument
 // This way we can reuse the already existing register contexts
 lldb::DataBufferSP
 ConvertMinidumpContextToRegIface(llvm::ArrayRef source_data,
  RegisterInfoInterface *target_reg_interface);
 
+struct uint128_struct {
+  llvm::support::ulittle64_t high;
+  llvm::support::ulittle64_t low;
+};
+
+// Reference: see breakpad/crashpad source or WinNT.h
+struct MinidumpXMMSaveArea32AMD64 {
+  llvm::support::ulittle16_t control_word;
+  llvm::support::ulittle16_t status_word;
+  uint8_t tag_word;
+  uint8_t reserved1;
+  llvm::support::ulittle16_t error_opcode;
+  llvm::support::ulittle32_t error_offset;
+  llvm::support::ulittle16_t error_selector;
+  llvm::support::ulittle16_t reserved2;
+  llvm::support::ulittle32_t data_offset;
+  llvm::support::ulittle16_t data_selector;
+  llvm::support::ulittle16_t reserved3;
+  llvm::support::ulittle32_t mx_csr;
+  llvm::support::ulittle32_t mx_csr_mask;
+  uint128_struct float_registers[8];
+  uint128_struct xmm_registers[16];
+  uint8_t reserved4[96];
+};
+
+struct MinidumpContext_x86_64 {
+  // Register parameter home addresses.
+  llvm::support::ulittle64_t p1_home;
+  llvm::support::ulittle64_t p2_home;
+  llvm::support::ulittle64_t p3_home;
+  llvm::support::ulittle64_t p4_home;
+  llvm::support::ulittle64_t p5_home;
+  llvm::support::ulittle64_t p6_home;
+
+  // The context_flags field determines and which parts
+  // of the structure are populated (have valid values)
+  llvm::support::ulittle32_t context_flags;
+  llvm::support::ulittle32_t mx_csr;
+
+  // The next register is included with
+  // MinidumpContext_x86_64_Flags::Control
+  llvm::support::ulittle16_t cs;
+
+  // The next 4 registers are included with
+  // MinidumpContext_x86_64_Flags::Segments
+  llvm::support::ulittle16_t ds;
+  llvm::support::ulittle16_t es;
+  llvm::support::ulittle16_t fs;
+  llvm::support::ulittle16_t gs;
+
+  // The next 2 registers are included with
+  // MinidumpContext_x86_64_Flags::Control
+  llvm::support::ulittle16_t ss;
+  llvm::support::ulittle32_t eflags;
+
+  // The next 6 registers are included with
+  // MinidumpContext_x86_64_Flags::DebugRegisters
+  llvm::suppor

[Lldb-commits] [PATCH] D25677: Minidump plugin: redesign the x86_64 register context

2016-10-17 Thread Dimitar Vlahovski via lldb-commits
dvlahovski created this revision.
dvlahovski added reviewers: labath, zturner.
dvlahovski added subscribers: amccarth, lldb-commits.

I misunderstood the format of the register context layout.
I thought it was a dynamically changing structure, and that it's size
depended on context_flags.
It turned out that it always has the same fixed layout and size,
and the context_flags says which fields of the
struct have valid values.
This required a minor redesign of the register context class.

The layout inconsistency, however, was not a "problem" before (e.g. the plugin 
was working)
because there also was a bug with checking context_flags - the code was
parsing the entire struct regardless of context_flags.
This bug is also fixed in this commit.


https://reviews.llvm.org/D25677

Files:
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h

Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
===
--- source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
+++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
@@ -21,81 +21,160 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitmaskEnum.h"
+#include "llvm/Support/Endian.h"
 
 // C includes
 // C++ includes
 
 namespace lldb_private {
 
 namespace minidump {
 
-// The content of the Minidump register context is as follows:
-// (for reference see breakpad's source or WinNT.h)
-// Register parameter home addresses: (p1_home .. p6_home)
-// - uint64_t p1_home
-// - uint64_t p2_home
-// - uint64_t p3_home
-// - uint64_t p4_home
-// - uint64_t p5_home
-// - uint64_t p6_home
-//
-// - uint32_t context_flags - field that determines the layout of the structure
-// and which parts of it are populated
-// - uint32_t mx_csr
-//
-// - uint16_t cs - included if MinidumpContext_x86_64_Flags::Control
-//
-// - uint16_t ds - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t es - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t fs - included if MinidumpContext_x86_64_Flags::Segments
-// - uint16_t gs - included if MinidumpContext_x86_64_Flags::Segments
-//
-// - uint16_t ss - included if MinidumpContext_x86_64_Flags::Control
-// - uint32_t rflags - included if MinidumpContext_x86_64_Flags::Control
-//
-// Debug registers: (included if MinidumpContext_x86_64_Flags::DebugRegisters)
-// - uint64_t dr0
-// - uint64_t dr1
-// - uint64_t dr2
-// - uint64_t dr3
-// - uint64_t dr6
-// - uint64_t dr7
-//
-// The next 4 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rax
-// - uint64_t rcx
-// - uint64_t rdx
-// - uint64_t rbx
-//
-// - uint64_t rsp - included if MinidumpContext_x86_64_Flags::Control
-//
-// The next 11 registers are included if MinidumpContext_x86_64_Flags::Integer
-// - uint64_t rbp
-// - uint64_t rsi
-// - uint64_t rdi
-// - uint64_t r8
-// - uint64_t r9
-// - uint64_t r10
-// - uint64_t r11
-// - uint64_t r12
-// - uint64_t r13
-// - uint64_t r14
-// - uint64_t r15
-//
-// - uint64_t rip - included if MinidumpContext_x86_64_Flags::Control
-//
-// TODO: add floating point registers here
-
 // This function receives an ArrayRef pointing to the bytes of the Minidump
 // register context and returns a DataBuffer that's ordered by the offsets
 // specified in the RegisterInfoInterface argument
 // This way we can reuse the already existing register contexts
 lldb::DataBufferSP
 ConvertMinidumpContextToRegIface(llvm::ArrayRef source_data,
  RegisterInfoInterface *target_reg_interface);
 
+struct uint128_struct {
+  llvm::support::ulittle64_t high;
+  llvm::support::ulittle64_t low;
+};
+
+// Reference: see breakpad/crashpad source or WinNT.h
+struct MinidumpXMMSaveArea32AMD64 {
+  llvm::support::ulittle16_t control_word;
+  llvm::support::ulittle16_t status_word;
+  uint8_t tag_word;
+  uint8_t reserved1;
+  llvm::support::ulittle16_t error_opcode;
+  llvm::support::ulittle32_t error_offset;
+  llvm::support::ulittle16_t error_selector;
+  llvm::support::ulittle16_t reserved2;
+  llvm::support::ulittle32_t data_offset;
+  llvm::support::ulittle16_t data_selector;
+  llvm::support::ulittle16_t reserved3;
+  llvm::support::ulittle32_t mx_csr;
+  llvm::support::ulittle32_t mx_csr_mask;
+  uint128_struct float_registers[8];
+  uint128_struct xmm_registers[16];
+  uint8_t reserved4[96];
+};
+
+struct MinidumpContext_x86_64 {
+  // Register parameter home addresses.
+  llvm::support::ulittle64_t p1_home;
+  llvm::support::ulittle64_t p2_home;
+  llvm::support::ulittle64_t p3_home;
+  llvm::support::ulittle64_t p4_home;
+  llvm::support::ulittle64_t p5_home;
+  llvm::support::ulittle64_t p6_home;
+
+  // The context_flags field determines and which parts
+  // of the structure are populated (have valid values)
+  llvm::support::ulittle32_t context_flags;
+  llvm::support::ulittle32_t mx_

[Lldb-commits] [PATCH] D25569: Minidump plugin: functions parsing memory structures and filtering module list

2016-10-17 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 74824.
dvlahovski marked 11 inline comments as done.
dvlahovski added a comment.

Changed std::map with llvm::StringMap
Using containter.empty() instead of containter.size() == 0
Avoiding copy by using for(const auto& ...)
Added bitwise operations to the new enum classes


https://reviews.llvm.org/D25569

Files:
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/fizzbuzz_wow64.dmp
  unittests/Process/minidump/Inputs/linux-x86_64_not_crashed.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Host/FileSpec.h"
+#include "lldb/Target/MemoryRegionInfo.h"
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
@@ -68,7 +69,11 @@
   ASSERT_EQ(1UL, thread_list.size());
 
   const MinidumpThread thread = thread_list[0];
-  ASSERT_EQ(16001UL, thread.thread_id);
+
+  EXPECT_EQ(16001UL, thread.thread_id);
+
+  llvm::ArrayRef context = parser->GetThreadContext(thread);
+  EXPECT_EQ(1232UL, context.size());
 }
 
 TEST_F(MinidumpParserTest, GetThreadsTruncatedFile) {
@@ -131,14 +136,111 @@
   }
 }
 
+TEST_F(MinidumpParserTest, GetFilteredModuleList) {
+  SetUpData("linux-x86_64_not_crashed.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  std::vector filtered_modules =
+  parser->GetFilteredModuleList();
+  EXPECT_EQ(10UL, modules.size());
+  EXPECT_EQ(9UL, filtered_modules.size());
+  // EXPECT_GT(modules.size(), filtered_modules.size());
+  bool found = false;
+  for (size_t i = 0; i < filtered_modules.size(); ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(filtered_modules[i]->module_name_rva);
+ASSERT_TRUE(name.hasValue());
+if (name.getValue() == "/tmp/test/linux-x86_64_not_crashed") {
+  ASSERT_FALSE(found) << "There should be only one module with this name "
+ "in the filtered module list";
+  found = true;
+  ASSERT_EQ(0x40UL, filtered_modules[i]->base_of_image);
+}
+  }
+}
+
 TEST_F(MinidumpParserTest, GetExceptionStream) {
   SetUpData("linux-x86_64.dmp");
   const MinidumpExceptionStream *exception_stream =
   parser->GetExceptionStream();
   ASSERT_NE(nullptr, exception_stream);
   ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
 }
 
+void check_mem_range_exists(std::unique_ptr &parser,
+const uint64_t range_start,
+const uint64_t range_size) {
+  llvm::Optional range = parser->FindMemoryRange(range_start);
+  ASSERT_TRUE(range.hasValue()) << "There is no range containing this address";
+  EXPECT_EQ(range_start, range->start);
+  EXPECT_EQ(range_start + range_size, range->start + range->range_ref.size());
+}
+
+TEST_F(MinidumpParserTest, FindMemoryRange) {
+  SetUpData("linux-x86_64.dmp");
+  // There are two memory ranges in the file (size is in bytes, decimal):
+  // 1) 0x401d46 256
+  // 2) 0x7ffceb34a000 12288
+  EXPECT_FALSE(parser->FindMemoryRange(0x00).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+
+  check_mem_range_exists(parser, 0x401d46, 256);
+  EXPECT_FALSE(parser->FindMemoryRange(0x401d46 + 256).hasValue());
+
+  check_mem_range_exists(parser, 0x7ffceb34a000, 12288);
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffceb34a000 + 12288).hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetMemory) {
+  SetUpData("linux-x86_64.dmp");
+
+  EXPECT_EQ(128UL, parser->GetMemory(0x401d46, 128).size());
+  EXPECT_EQ(256UL, parser->GetMemory(0x401d46, 512).size());
+
+  EXPECT_EQ(12288UL, parser->GetMemory(0x7ffceb34a000, 12288).size());
+  EXPECT_EQ(1024UL, parser->GetMemory(0x7ffceb34a000, 1024).size());
+
+  EXPECT_TRUE(parser->GetMemory(0x50, 512).empty());
+}
+
+TEST_F(MinidumpParserTest, FindMemoryRangeWithFullMemoryMinidump) {
+  SetUpData("fizzbuzz_wow64.dmp");
+
+  // There are a lot of ranges in the file, just testing with some of them
+  EXPECT_FALSE(parser->FindMemoryRange(0x00).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+  check_mem_range_exists(parser, 0x1, 65536); // first range
+  check_mem_range_exists(parser, 0x4, 4096);
+  EXPECT_FALSE(parser->FindMemoryRange(0x4 + 4096).hasValue());
+  check_mem_range_exists(parser, 0x77c12000, 8192);
+  check_mem_range_exists(parser, 0x7ffe, 4096); // last range
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffe + 4096).hasValue());
+}
+
+void check_region_info(std::unique_ptr &parser,
+

[Lldb-commits] [PATCH] D25569: Minidump plugin: functions parsing memory structures and filtering module list

2016-10-17 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added inline comments.



Comment at: source/Plugins/Process/minidump/MinidumpTypes.cpp:222
+
+  if (header->size_of_header > sizeof(MinidumpMemoryInfoListHeader)) {
+data = data.drop_front(header->size_of_header -

zturner wrote:
> I don't think you need the conditional here do you?  Just `data = 
> data.drop_front(sizeof_MinidumpMemoryInfoListHeader)`.
`header->size_of_header` is >= `sizeof(MinidumpMemoryInfoListHeader)` here. So, 
yes, I can simplify it like this: `data = 
data.drop_front(header->size_of_header - sizeof(MinidumpMemoryInfoListHeader));`


https://reviews.llvm.org/D25569



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


[Lldb-commits] [PATCH] D25569: Minidump plugin: functions parsing memory structures and filtering module list

2016-10-14 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 74694.
dvlahovski marked 7 inline comments as done.
dvlahovski added a comment.

Resolved Pavel's remarks.

Also added a unit test for the GetMemory function.


https://reviews.llvm.org/D25569

Files:
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/fizzbuzz_wow64.dmp
  unittests/Process/minidump/Inputs/linux-x86_64_not_crashed.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Host/FileSpec.h"
+#include "lldb/Target/MemoryRegionInfo.h"
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
@@ -68,7 +69,11 @@
   ASSERT_EQ(1UL, thread_list.size());
 
   const MinidumpThread thread = thread_list[0];
-  ASSERT_EQ(16001UL, thread.thread_id);
+
+  EXPECT_EQ(16001UL, thread.thread_id);
+
+  llvm::ArrayRef context = parser->GetThreadContext(thread);
+  EXPECT_EQ(1232UL, context.size());
 }
 
 TEST_F(MinidumpParserTest, GetThreadsTruncatedFile) {
@@ -131,14 +136,111 @@
   }
 }
 
+TEST_F(MinidumpParserTest, GetFilteredModuleList) {
+  SetUpData("linux-x86_64_not_crashed.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  std::vector filtered_modules =
+  parser->GetFilteredModuleList();
+  EXPECT_EQ(10UL, modules.size());
+  EXPECT_EQ(9UL, filtered_modules.size());
+  // EXPECT_GT(modules.size(), filtered_modules.size());
+  bool found = false;
+  for (size_t i = 0; i < filtered_modules.size(); ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(filtered_modules[i]->module_name_rva);
+ASSERT_TRUE(name.hasValue());
+if (name.getValue() == "/tmp/test/linux-x86_64_not_crashed") {
+  ASSERT_FALSE(found) << "There should be only one module with this name "
+ "in the filtered module list";
+  found = true;
+  ASSERT_EQ(0x40UL, filtered_modules[i]->base_of_image);
+}
+  }
+}
+
 TEST_F(MinidumpParserTest, GetExceptionStream) {
   SetUpData("linux-x86_64.dmp");
   const MinidumpExceptionStream *exception_stream =
   parser->GetExceptionStream();
   ASSERT_NE(nullptr, exception_stream);
   ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
 }
 
+void check_mem_range_exists(std::unique_ptr &parser,
+const uint64_t range_start,
+const uint64_t range_size) {
+  llvm::Optional range = parser->FindMemoryRange(range_start);
+  ASSERT_TRUE(range.hasValue()) << "There is no range containing this address";
+  EXPECT_EQ(range_start, range->start);
+  EXPECT_EQ(range_start + range_size, range->start + range->range_ref.size());
+}
+
+TEST_F(MinidumpParserTest, FindMemoryRange) {
+  SetUpData("linux-x86_64.dmp");
+  // There are two memory ranges in the file (size is in bytes, decimal):
+  // 1) 0x401d46 256
+  // 2) 0x7ffceb34a000 12288
+  EXPECT_FALSE(parser->FindMemoryRange(0x00).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+
+  check_mem_range_exists(parser, 0x401d46, 256);
+  EXPECT_FALSE(parser->FindMemoryRange(0x401d46 + 256).hasValue());
+
+  check_mem_range_exists(parser, 0x7ffceb34a000, 12288);
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffceb34a000 + 12288).hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetMemory) {
+  SetUpData("linux-x86_64.dmp");
+
+  EXPECT_EQ(128UL, parser->GetMemory(0x401d46, 128).size());
+  EXPECT_EQ(256UL, parser->GetMemory(0x401d46, 512).size());
+
+  EXPECT_EQ(12288UL, parser->GetMemory(0x7ffceb34a000, 12288).size());
+  EXPECT_EQ(1024UL, parser->GetMemory(0x7ffceb34a000, 1024).size());
+
+  EXPECT_EQ(0UL, parser->GetMemory(0x50, 512).size());
+}
+
+TEST_F(MinidumpParserTest, FindMemoryRangeWithFullMemoryMinidump) {
+  SetUpData("fizzbuzz_wow64.dmp");
+
+  // There are a lot of ranges in the file, just testing with some of them
+  EXPECT_FALSE(parser->FindMemoryRange(0x00).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+  check_mem_range_exists(parser, 0x1, 65536); // first range
+  check_mem_range_exists(parser, 0x4, 4096);
+  EXPECT_FALSE(parser->FindMemoryRange(0x4 + 4096).hasValue());
+  check_mem_range_exists(parser, 0x77c12000, 8192);
+  check_mem_range_exists(parser, 0x7ffe, 4096); // last range
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffe + 4096).hasValue());
+}
+
+void check_region_info(std::unique_ptr &parser,
+   const uint64_t addr, MemoryRegionInfo::OptionalBool read,
+   MemoryRegionInfo::

[Lldb-commits] [PATCH] D25569: Minidump plugin: memory stuff and filtering module list

2016-10-13 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 74551.
dvlahovski added a comment.

Forgot to run clang-format. Also changed a helper function in the tests to make 
it simpler.


https://reviews.llvm.org/D25569

Files:
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/fizzbuzz_wow64.dmp
  unittests/Process/minidump/Inputs/linux-x86_64_not_crashed.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Host/FileSpec.h"
+#include "lldb/Target/MemoryRegionInfo.h"
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
@@ -68,7 +69,11 @@
   ASSERT_EQ(1UL, thread_list.size());
 
   const MinidumpThread thread = thread_list[0];
-  ASSERT_EQ(16001UL, thread.thread_id);
+
+  EXPECT_EQ(16001UL, thread.thread_id);
+
+  llvm::ArrayRef context = parser->GetThreadContext(thread);
+  EXPECT_EQ(1232UL, context.size());
 }
 
 TEST_F(MinidumpParserTest, GetThreadsTruncatedFile) {
@@ -131,14 +136,98 @@
   }
 }
 
+TEST_F(MinidumpParserTest, FilterModuleList) {
+  SetUpData("linux-x86_64_not_crashed.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  std::vector filtered_modules =
+  parser->FilterModuleList(modules);
+  EXPECT_GT(modules.size(), filtered_modules.size());
+  bool found = false;
+  for (size_t i = 0; i < filtered_modules.size(); ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(filtered_modules[i]->module_name_rva);
+ASSERT_TRUE(name.hasValue());
+if (name.getValue() == "/tmp/test/linux-x86_64_not_crashed") {
+  ASSERT_FALSE(found) << "There should be only one module with this name "
+ "in the filtered module list";
+  found = true;
+  ASSERT_EQ(0x40UL, filtered_modules[i]->base_of_image);
+}
+  }
+}
+
 TEST_F(MinidumpParserTest, GetExceptionStream) {
   SetUpData("linux-x86_64.dmp");
   const MinidumpExceptionStream *exception_stream =
   parser->GetExceptionStream();
   ASSERT_NE(nullptr, exception_stream);
   ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
 }
 
+void check_mem_range_exists(std::unique_ptr &parser,
+const uint64_t range_start,
+const uint64_t range_size) {
+  llvm::Optional range = parser->FindMemoryRange(range_start);
+  ASSERT_TRUE(range.hasValue()) << "There is no range containing this address";
+  EXPECT_EQ(range_start, range->start);
+  EXPECT_EQ(range_start + range_size, range->start + range->range_ref.size());
+}
+
+TEST_F(MinidumpParserTest, GetMemoryRange) {
+  SetUpData("linux-x86_64.dmp");
+  // There are two memory ranges in the file (size is in bytes, decimal):
+  // 1) 0x401d46 256
+  // 2) 0x7ffceb34a000 12288
+  EXPECT_FALSE(parser->FindMemoryRange(0x00).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+
+  check_mem_range_exists(parser, 0x401d46, 256);
+  EXPECT_FALSE(parser->FindMemoryRange(0x401d46 + 256).hasValue());
+
+  check_mem_range_exists(parser, 0x7ffceb34a000, 12288);
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffceb34a000 + 12288).hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetMemoryRangeWithFullMemoryMinidump) {
+  SetUpData("fizzbuzz_wow64.dmp");
+
+  // There are a lot of ranges in the file, just testing with some of them
+  EXPECT_FALSE(parser->FindMemoryRange(0x00).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+  check_mem_range_exists(parser, 0x1, 65536); // first range
+  check_mem_range_exists(parser, 0x4, 4096);
+  EXPECT_FALSE(parser->FindMemoryRange(0x4 + 4096).hasValue());
+  check_mem_range_exists(parser, 0x77c12000, 8192);
+  check_mem_range_exists(parser, 0x7ffe, 4096); // last range
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffe + 4096).hasValue());
+}
+
+void check_region_info(std::unique_ptr &parser,
+   const uint64_t addr, MemoryRegionInfo::OptionalBool read,
+   MemoryRegionInfo::OptionalBool write,
+   MemoryRegionInfo::OptionalBool exec) {
+  lldb_private::MemoryRegionInfo range_info;
+  Error error = parser->GetMemoryRegionInfo(addr, range_info);
+  ASSERT_TRUE(error.Success());
+  EXPECT_EQ(read, range_info.GetReadable());
+  EXPECT_EQ(write, range_info.GetWritable());
+  EXPECT_EQ(exec, range_info.GetExecutable());
+}
+
+TEST_F(MinidumpParserTest, GetMemoryRegionInfo) {
+  SetUpData("fizzbuzz_wow64.dmp");
+
+  const auto yes = MemoryRegionInfo::eYes;
+  const auto no = MemoryR

[Lldb-commits] [PATCH] D25569: Minidump plugin: memory stuff and filtering module list

2016-10-13 Thread Dimitar Vlahovski via lldb-commits
dvlahovski created this revision.
dvlahovski added reviewers: labath, zturner.
dvlahovski added subscribers: amccarth, lldb-commits.
Herald added subscribers: modocache, mgorny, beanz.

Now the Minidump parser can parse the:

1. MemoryInfoList - containing region info about memory ranges (readable,

writeable, executable)

2. Memory64List - this is the stuct used when the Minidump is a

full-memory one.

3. Adding filtering of the module list (shared libraries list) - there

can be mutliple records in the module list under the same name but with
different load address (e.g. when the binary has non contigious
sections). FilterModuleList eliminates the duplicated modules, leaving
the one with the lowest load addr.

Added unit tests for everything.


https://reviews.llvm.org/D25569

Files:
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/fizzbuzz_wow64.dmp
  unittests/Process/minidump/Inputs/linux-x86_64_not_crashed.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Host/FileSpec.h"
+#include "lldb/Target/MemoryRegionInfo.h"
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
@@ -68,7 +69,11 @@
   ASSERT_EQ(1UL, thread_list.size());
 
   const MinidumpThread thread = thread_list[0];
-  ASSERT_EQ(16001UL, thread.thread_id);
+
+  EXPECT_EQ(16001UL, thread.thread_id);
+
+  llvm::ArrayRef context = parser->GetThreadContext(thread);
+  EXPECT_EQ(1232UL, context.size());
 }
 
 TEST_F(MinidumpParserTest, GetThreadsTruncatedFile) {
@@ -131,14 +136,96 @@
   }
 }
 
+TEST_F(MinidumpParserTest, FilterModuleList) {
+  SetUpData("linux-x86_64_not_crashed.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  std::vector filtered_modules = parser->FilterModuleList(modules);
+  EXPECT_GT(modules.size(), filtered_modules.size());
+  bool found = false;
+  for (size_t i = 0; i < filtered_modules.size(); ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(filtered_modules[i]->module_name_rva);
+ASSERT_TRUE(name.hasValue());
+if (name.getValue() == "/tmp/test/linux-x86_64_not_crashed") {
+  ASSERT_FALSE(found) << "There should be only one module with this name in the filtered module list";
+  found = true;
+  ASSERT_EQ(0x40UL, filtered_modules[i]->base_of_image);
+}
+  }
+}
+
 TEST_F(MinidumpParserTest, GetExceptionStream) {
   SetUpData("linux-x86_64.dmp");
   const MinidumpExceptionStream *exception_stream =
   parser->GetExceptionStream();
   ASSERT_NE(nullptr, exception_stream);
   ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
 }
 
+
+void check_mem_range_exists(std::unique_ptr &parser, const uint64_t range_start, const uint64_t range_size) {
+  llvm::Optional range = parser->FindMemoryRange(range_start);
+  ASSERT_TRUE(range.hasValue()) << "There is no range containing this address";
+  EXPECT_EQ(range_start, range->start);
+  EXPECT_EQ(range_start + range_size, range->start + range->range_ref.size());
+}
+
+TEST_F(MinidumpParserTest, GetMemoryRange) {
+  SetUpData("linux-x86_64.dmp");
+  // There are two memory ranges in the file (size is in bytes, decimal):
+  // 1) 0x401d46 256
+  // 2) 0x7ffceb34a000 12288
+  EXPECT_FALSE(parser->FindMemoryRange(0x00).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+
+  check_mem_range_exists(parser, 0x401d46, 256);
+  EXPECT_FALSE(parser->FindMemoryRange(0x401d46 + 256).hasValue());
+
+  check_mem_range_exists(parser, 0x7ffceb34a000, 12288);
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffceb34a000 + 12288).hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetMemoryRangeWithFullMemoryMinidump) {
+  SetUpData("fizzbuzz_wow64.dmp");
+
+  // There are a lot of ranges in the file, just testing with some of them
+  EXPECT_FALSE(parser->FindMemoryRange(0x00).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+  check_mem_range_exists(parser, 0x1, 65536); // first range
+  check_mem_range_exists(parser, 0x4, 4096);
+  EXPECT_FALSE(parser->FindMemoryRange(0x4 + 4096).hasValue());
+  check_mem_range_exists(parser, 0x7ffe, 4096);
+  check_mem_range_exists(parser, 0x77c12000, 8192);
+  check_mem_range_exists(parser, 0x7ffe, 4096); // last range
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffe + 4096).hasValue());
+}
+
+void check_region_info(std::unique_ptr &parser, const uint64_t addr, bool read, bool write, bool exec) {
+  lldb_private::MemoryRegionInfo range_info;
+  Error 

[Lldb-commits] [lldb] r283352 - Removing the new Minidump plugin

2016-10-05 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Wed Oct  5 13:11:45 2016
New Revision: 283352

URL: http://llvm.org/viewvc/llvm-project?rev=283352&view=rev
Log:
Removing the new Minidump plugin

Tests are failing and build is failing on windows and darwin.
Will fix and commit it later
-

Revert "xfailing minidump tests again ... :("
This reverts commit 97eade002c9e43c1e0d11475a4888083a8965044.

Revert "Fixing new Minidump plugin tests"
This reverts commit 0dd93b3ab39c8288696001dd50b9a093b813b09c.

Revert "Add the new minidump files to the Xcode project."
This reverts commit 2f638a1d046b8a88e61e212220edc40aecd2ce44.

Revert "xfailing tests for Minidump plugin"
This reverts commit 99311c0b22338a83e6a00c4fbddfd3577914c003.

Revert "Adding a new Minidump post-mortem debugging plugin"
This reverts commit b09a7e4dae231663095a84dac4be3da00b03a021.

Removed:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp
lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.h
Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=283352&r1=283351&r2=283352&view=diff
==
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Oct  5 13:11:45 2016
@@ -735,8 +735,6 @@
4C56543519D2297A002E9C44 /* SBThreadPlan.h in Headers */ = {isa 
= PBXBuildFile; fileRef = 4C56543419D2297A002E9C44 /* SBThreadPlan.h */; 
settings = {ATTRIBUTES = (Public, ); }; };
4C56543719D22B32002E9C44 /* SBThreadPlan.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 4C56543619D22B32002E9C44 /* SBThreadPlan.cpp */; 
};
4C6649A314EEE81000B0316F /* StreamCallback.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 4C6649A214EEE81000B0316F /* StreamCallback.cpp 
*/; };
-   4C6966101DA47BCE004FAE72 /* ThreadMinidump.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 4C6966081DA47BB4004FAE72 /* ThreadMinidump.cpp 
*/; };
-   4C6966111DA47BDB004FAE72 /* ProcessMinidump.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 4C69660A1DA47BB4004FAE72 /* ProcessMinidump.cpp 
*/; };
4C88BC2A1BA3722B00AA0964 /* Expression.cpp in Sources */ = {isa 
= PBXBuildFile; fileRef = 4C88BC291BA3722B00AA0964 /* Expression.cpp */; };
4C88BC2D1BA391B000AA0964 /* UserExpression.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 4C0083331B9A5DE200D5CF24 /* UserExpression.cpp 
*/; };
4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */ 
= {isa = PBXBuildFile; fileRef = 4CABA9DF134A8BCD00539BDD /* 
ValueObjectMemory.cpp */; };
@@ -958,6 +956,7 @@
AFCB2BBD1BF577F40018B553 /* PythonExceptionState.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = AFCB2BBB1BF577F40018B553 /* 
PythonExceptionState.cpp */; };
AFCB2BBE1BF577F40018B553 /* PythonExceptionState.h in Headers 
*/ = {isa = PBXBuildFile; fileRef = AFCB2BBC1BF577F40018B553 /* 
PythonExceptionState.h */; };
AFD65C811D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.cpp 
in Sources */ = {isa = PBXBuildFile; fileRef = AFD65C7F1D9B5B2E00D93120 /* 
RegisterContextMinidump_x86_64.cpp */; };
+   AFD65C821D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.h in 
Headers */ = {isa = PBXBuildFile; fileRef = AFD65C801D9B5B2E00D93120 /* 
Regist

Re: [Lldb-commits] [lldb] r283324 - xfailing minidump tests again ... :(

2016-10-05 Thread Dimitar Vlahovski via lldb-commits
The tests are failing because, as I did not realize, there is no way for
lldb (apart from the one on my machine) to find the debug symbols. So the
only thing that lldb has are the Minidump files. And I think the unwinder
gets confused because some of the frames are missing.

For a temporary solution in I will add the binaries to the test folder so
that lldb can have the debug symbols. (which will be my next CL)

When (hopefully) I add Minidump write support, the binaries could be
removed, and I can use Adrian's approach when testing - include the cpp
source in the test folder, then the test compiles it, runs the binary, sets
a breakpoint, writes Minidump, inspects the Minidump, etc.

On Wed, Oct 5, 2016 at 4:38 PM, Zachary Turner  wrote:

> If all the tests are being xfailed you should probably just revert the
> original patch until the tests are fixed
>
> On Wed, Oct 5, 2016 at 8:09 AM Dimitar Vlahovski via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
>
>> Author: dvlahovski
>> Date: Wed Oct  5 10:00:29 2016
>> New Revision: 283324
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=283324&view=rev
>> Log:
>> xfailing minidump tests again ... :(
>>
>> Modified:
>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/
>> minidump-new/TestMiniDumpNew.py
>>
>> Modified: lldb/trunk/packages/Python/lldbsuite/test/
>> functionalities/postmortem/minidump-new/TestMiniDumpNew.py
>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/
>> Python/lldbsuite/test/functionalities/postmortem/
>> minidump-new/TestMiniDumpNew.py?rev=283324&r1=283323&r2=283324&view=diff
>> 
>> ==
>> --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/
>> minidump-new/TestMiniDumpNew.py (original)
>> +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/
>> minidump-new/TestMiniDumpNew.py Wed Oct  5 10:00:29 2016
>> @@ -18,6 +18,7 @@ class MiniDumpNewTestCase(TestBase):
>>
>>  NO_DEBUG_INFO_TESTCASE = True
>>
>> +@expectedFailureAll
>>  def test_process_info_in_minidump(self):
>>  """Test that lldb can read the process information from the
>> Minidump."""
>>  # target create -c linux-x86_64.dmp
>> @@ -28,6 +29,7 @@ class MiniDumpNewTestCase(TestBase):
>>  self.assertEqual(self.process.GetNumThreads(), 1)
>>  self.assertEqual(self.process.GetProcessID(), 16001)
>>
>> +@expectedFailureAll
>>  def test_thread_info_in_minidump(self):
>>  """Test that lldb can read the thread information from the
>> Minidump."""
>>  # target create -c linux-x86_64.dmp
>> @@ -42,6 +44,7 @@ class MiniDumpNewTestCase(TestBase):
>>  stop_description = thread.GetStopDescription(256)
>>  self.assertTrue("SIGSEGV" in stop_description)
>>
>> +@expectedFailureAll
>>  def test_stack_info_in_minidump(self):
>>  """Test that we can see a trivial stack in a breakpad-generated
>> Minidump."""
>>  # target create linux-x86_64 -c linux-x86_64.dmp
>> @@ -62,6 +65,7 @@ class MiniDumpNewTestCase(TestBase):
>>  self.assertTrue(eip.IsValid())
>>  self.assertEqual(pc, eip.GetValueAsUnsigned())
>>
>> +@expectedFailureAll
>>  def test_snapshot_minidump(self):
>>  """Test that if we load a snapshot minidump file (meaning the
>> process did not crash) there is no stop reason."""
>>  # target create -c linux-x86_64_not_crashed.dmp
>> @@ -74,6 +78,7 @@ class MiniDumpNewTestCase(TestBase):
>>  stop_description = thread.GetStopDescription(256)
>>  self.assertEqual(stop_description, None)
>>
>> +@expectedFailureAll
>>  def test_deeper_stack_in_minidump(self):
>>  """Test that we can examine a more interesting stack in a
>> Minidump."""
>>  # Launch with the Minidump, and inspect the stack.
>> @@ -90,6 +95,7 @@ class MiniDumpNewTestCase(TestBase):
>>  function_name = frame.GetFunctionName()
>>  self.assertTrue(name in function_name)
>>
>> +@expectedFailureAll
>>  def test_local_variables_in_minidump(self):
>>  """Test that we can examine local variables in a Minidump."""
>>  # Launch with the Minidump, and inspect a local variable.
>>
>>
>> ___
>> lldb-commits mailing list
>> lldb-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r283324 - xfailing minidump tests again ... :(

2016-10-05 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Wed Oct  5 10:00:29 2016
New Revision: 283324

URL: http://llvm.org/viewvc/llvm-project?rev=283324&view=rev
Log:
xfailing minidump tests again ... :(

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py?rev=283324&r1=283323&r2=283324&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 Wed Oct  5 10:00:29 2016
@@ -18,6 +18,7 @@ class MiniDumpNewTestCase(TestBase):
 
 NO_DEBUG_INFO_TESTCASE = True
 
+@expectedFailureAll
 def test_process_info_in_minidump(self):
 """Test that lldb can read the process information from the 
Minidump."""
 # target create -c linux-x86_64.dmp
@@ -28,6 +29,7 @@ class MiniDumpNewTestCase(TestBase):
 self.assertEqual(self.process.GetNumThreads(), 1)
 self.assertEqual(self.process.GetProcessID(), 16001)
 
+@expectedFailureAll
 def test_thread_info_in_minidump(self):
 """Test that lldb can read the thread information from the Minidump."""
 # target create -c linux-x86_64.dmp
@@ -42,6 +44,7 @@ class MiniDumpNewTestCase(TestBase):
 stop_description = thread.GetStopDescription(256)
 self.assertTrue("SIGSEGV" in stop_description)
 
+@expectedFailureAll
 def test_stack_info_in_minidump(self):
 """Test that we can see a trivial stack in a breakpad-generated 
Minidump."""
 # target create linux-x86_64 -c linux-x86_64.dmp
@@ -62,6 +65,7 @@ class MiniDumpNewTestCase(TestBase):
 self.assertTrue(eip.IsValid())
 self.assertEqual(pc, eip.GetValueAsUnsigned())
 
+@expectedFailureAll
 def test_snapshot_minidump(self):
 """Test that if we load a snapshot minidump file (meaning the process 
did not crash) there is no stop reason."""
 # target create -c linux-x86_64_not_crashed.dmp
@@ -74,6 +78,7 @@ class MiniDumpNewTestCase(TestBase):
 stop_description = thread.GetStopDescription(256)
 self.assertEqual(stop_description, None)
 
+@expectedFailureAll
 def test_deeper_stack_in_minidump(self):
 """Test that we can examine a more interesting stack in a Minidump."""
 # Launch with the Minidump, and inspect the stack.
@@ -90,6 +95,7 @@ class MiniDumpNewTestCase(TestBase):
 function_name = frame.GetFunctionName()
 self.assertTrue(name in function_name)
 
+@expectedFailureAll
 def test_local_variables_in_minidump(self):
 """Test that we can examine local variables in a Minidump."""
 # Launch with the Minidump, and inspect a local variable.


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


[Lldb-commits] [lldb] r283321 - Fixing new Minidump plugin tests

2016-10-05 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Wed Oct  5 09:35:30 2016
New Revision: 283321

URL: http://llvm.org/viewvc/llvm-project?rev=283321&view=rev
Log:
Fixing new Minidump plugin tests

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64
   (with props)

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed
   (with props)
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py?rev=283321&r1=283320&r2=283321&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 Wed Oct  5 09:35:30 2016
@@ -18,22 +18,20 @@ class MiniDumpNewTestCase(TestBase):
 
 NO_DEBUG_INFO_TESTCASE = True
 
-@expectedFailureAll
-def test_process_info_in_mini_dump(self):
+def test_process_info_in_minidump(self):
 """Test that lldb can read the process information from the 
Minidump."""
 # target create -c linux-x86_64.dmp
-self.dbg.CreateTarget("")
+self.dbg.CreateTarget(None)
 self.target = self.dbg.GetSelectedTarget()
 self.process = self.target.LoadCore("linux-x86_64.dmp")
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertEqual(self.process.GetNumThreads(), 1)
 self.assertEqual(self.process.GetProcessID(), 16001)
 
-@expectedFailureAll
-def test_thread_info_in_mini_dump(self):
+def test_thread_info_in_minidump(self):
 """Test that lldb can read the thread information from the Minidump."""
 # target create -c linux-x86_64.dmp
-self.dbg.CreateTarget("")
+self.dbg.CreateTarget(None)
 self.target = self.dbg.GetSelectedTarget()
 self.process = self.target.LoadCore("linux-x86_64.dmp")
 # This process crashed due to a segmentation fault in its
@@ -44,11 +42,10 @@ class MiniDumpNewTestCase(TestBase):
 stop_description = thread.GetStopDescription(256)
 self.assertTrue("SIGSEGV" in stop_description)
 
-@expectedFailureAll
-def test_stack_info_in_mini_dump(self):
+def test_stack_info_in_minidump(self):
 """Test that we can see a trivial stack in a breakpad-generated 
Minidump."""
-# target create -c linux-x86_64.dmp
-self.dbg.CreateTarget("")
+# target create linux-x86_64 -c linux-x86_64.dmp
+self.dbg.CreateTarget("linux-x86_64")
 self.target = self.dbg.GetSelectedTarget()
 self.process = self.target.LoadCore("linux-x86_64.dmp")
 self.assertEqual(self.process.GetNumThreads(), 1)
@@ -65,11 +62,10 @@ class MiniDumpNewTestCase(TestBase):
 self.assertTrue(eip.IsValid())
 self.assertEqual(pc, eip.GetValueAsUnsigned())
 
-@expectedFailureAll
 def test_snapshot_minidump(self):
 """Test that if we load a snapshot minidump file (meaning the process 
did not crash) there is no stop reason."""
 # target create -c linux-x86_64_not_crashed.dmp
-self.dbg.CreateTarget("")
+self.dbg.CreateTarget(None)
 self.target = self.dbg.GetSelectedTarget()
 self.process = self.target.LoadCore("linux-x86_64_not_crashed.dmp")
 self.assertEqual(self.process.GetNumThreads(), 1)
@@ -78,11 +74,11 @@ class MiniDumpNewTestCase(TestBase):
 stop_description = thread.GetStopDescription(256)
 self.assertEqual(stop_description, None)
 
-@expectedFailureAll
-def test_deeper_stack_in_mini_dump(self):
+def test_deeper_stack_in_minidump(self):
 """Test that we can examine a more interesting stack in a Minidump."""
 # Launch with the Minidump, and inspect the stack.
-target = self.dbg.CreateTarget(None)
+# target create linux-x86_64_not_crashed -c 
linux-x86_64_not_crashed.dmp
+target = self.dbg.CreateTarget("linux-x86_64_not_crashed")
 process = target.LoadCore("linux-x86_64_not_crashed.dmp")
 thread = process.GetThreadAtIndex(0)
 
@@ -94,11 +90,11 @@ class MiniDumpNewTestCase(TestBase):
 function_name = frame.GetFunctionName()
 self.assertTrue(name in function_name)
 
-@expectedFailureAll
-def test_local_variables_in_mini_dump(self):
+def test_local_variables_in_minidump(self):
 """Test that we can examine local variables in a Minidump."""
 # Launch with the Minidump, and inspect a local variable.
-target = self.dbg.CreateTarget(None)
+# target cr

Re: [Lldb-commits] [lldb] r283276 - Add the new minidump files to the Xcode project.

2016-10-05 Thread Dimitar Vlahovski via lldb-commits
Thanks :)

On Wed, Oct 5, 2016 at 1:07 AM, Jim Ingham via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Author: jingham
> Date: Tue Oct  4 19:07:01 2016
> New Revision: 283276
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283276&view=rev
> Log:
> Add the new minidump files to the Xcode project.
>
> Modified:
> lldb/trunk/lldb.xcodeproj/project.pbxproj
>
> Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.
> xcodeproj/project.pbxproj?rev=283276&r1=283275&r2=283276&view=diff
> 
> ==
> --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
> +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Oct  4 19:07:01 2016
> @@ -735,6 +735,8 @@
> 4C56543519D2297A002E9C44 /* SBThreadPlan.h in Headers */ =
> {isa = PBXBuildFile; fileRef = 4C56543419D2297A002E9C44 /* SBThreadPlan.h
> */; settings = {ATTRIBUTES = (Public, ); }; };
> 4C56543719D22B32002E9C44 /* SBThreadPlan.cpp in Sources */
> = {isa = PBXBuildFile; fileRef = 4C56543619D22B32002E9C44 /*
> SBThreadPlan.cpp */; };
> 4C6649A314EEE81000B0316F /* StreamCallback.cpp in Sources
> */ = {isa = PBXBuildFile; fileRef = 4C6649A214EEE81000B0316F /*
> StreamCallback.cpp */; };
> +   4C6966101DA47BCE004FAE72 /* ThreadMinidump.cpp in Sources
> */ = {isa = PBXBuildFile; fileRef = 4C6966081DA47BB4004FAE72 /*
> ThreadMinidump.cpp */; };
> +   4C6966111DA47BDB004FAE72 /* ProcessMinidump.cpp in Sources
> */ = {isa = PBXBuildFile; fileRef = 4C69660A1DA47BB4004FAE72 /*
> ProcessMinidump.cpp */; };
> 4C88BC2A1BA3722B00AA0964 /* Expression.cpp in Sources */ =
> {isa = PBXBuildFile; fileRef = 4C88BC291BA3722B00AA0964 /* Expression.cpp
> */; };
> 4C88BC2D1BA391B000AA0964 /* UserExpression.cpp in Sources
> */ = {isa = PBXBuildFile; fileRef = 4C0083331B9A5DE200D5CF24 /*
> UserExpression.cpp */; };
> 4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in
> Sources */ = {isa = PBXBuildFile; fileRef = 4CABA9DF134A8BCD00539BDD /*
> ValueObjectMemory.cpp */; };
> @@ -956,7 +958,6 @@
> AFCB2BBD1BF577F40018B553 /* PythonExceptionState.cpp in
> Sources */ = {isa = PBXBuildFile; fileRef = AFCB2BBB1BF577F40018B553 /*
> PythonExceptionState.cpp */; };
> AFCB2BBE1BF577F40018B553 /* PythonExceptionState.h in
> Headers */ = {isa = PBXBuildFile; fileRef = AFCB2BBC1BF577F40018B553 /*
> PythonExceptionState.h */; };
> AFD65C811D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.cpp
> in Sources */ = {isa = PBXBuildFile; fileRef = AFD65C7F1D9B5B2E00D93120 /*
> RegisterContextMinidump_x86_64.cpp */; };
> -   AFD65C821D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.h
> in Headers */ = {isa = PBXBuildFile; fileRef = AFD65C801D9B5B2E00D93120 /*
> RegisterContextMinidump_x86_64.h */; };
> AFDCDBCB19DD0F42005EA55E /* SBExecutionContext.h in
> Headers */ = {isa = PBXBuildFile; fileRef = 940B02F419DC96CB00AD0F52 /*
> SBExecutionContext.h */; settings = {ATTRIBUTES = (Public, ); }; };
> AFDFDFD119E34D3400EAE509 /* ConnectionFileDescriptorPosix.cpp
> in Sources */ = {isa = PBXBuildFile; fileRef = AFDFDFD019E34D3400EAE509 /*
> ConnectionFileDescriptorPosix.cpp */; };
> AFEC3362194A8ABA00FF05C6 /* StructuredData.cpp in Sources
> */ = {isa = PBXBuildFile; fileRef = AFEC3361194A8ABA00FF05C6 /*
> StructuredData.cpp */; };
> @@ -1335,7 +1336,6 @@
> 23E2E5201D903726006F38BB /* linux-x86_64.dmp */ = {isa =
> PBXFileReference; lastKnownFileType = file; path = "linux-x86_64.dmp";
> sourceTree = ""; };
> 23E2E52D1D90382B006F38BB /* BreakpointIDTest.cpp */ = {isa
> = PBXFileReference; fileEncoding = 4; lastKnownFileType =
> sourcecode.cpp.cpp; path = BreakpointIDTest.cpp; sourceTree = ""; };
> 23E2E52E1D90382B006F38BB /* CMakeLists.txt */ = {isa =
> PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path =
> CMakeLists.txt; sourceTree = ""; };
> -   23E2E5361D9048FB006F38BB /* CMakeLists.txt */ = {isa =
> PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path =
> CMakeLists.txt; sourceTree = ""; };
> 23E2E5371D9048FB006F38BB /* MinidumpParser.cpp */ = {isa =
> PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp;
> path = MinidumpParser.cpp; sourceTree = ""; };
> 23E2E5381D9048FB006F38BB /* MinidumpParser.h */ = {isa =
> PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
> path = MinidumpParser.h; sourceTree = ""; };
> 23E2E5391D9048FB006F38BB /* MinidumpTypes.cpp */ = {isa =
> PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp;
> path = MinidumpTypes.cpp; sourceTree = ""; };
> @@ -2531,6 +2531,10 @@
> 4C626533130F1B0A00C889F6 /* StreamTee.h */

[Lldb-commits] [lldb] r283263 - xfailing tests for Minidump plugin

2016-10-04 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Tue Oct  4 16:55:47 2016
New Revision: 283263

URL: http://llvm.org/viewvc/llvm-project?rev=283263&view=rev
Log:
xfailing tests for Minidump plugin

the tests are failing on the buildbot because there is an extra frame
(maybe) on the call stack.
Will investigate tomorrow.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py?rev=283263&r1=283262&r2=283263&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 Tue Oct  4 16:55:47 2016
@@ -18,6 +18,7 @@ class MiniDumpNewTestCase(TestBase):
 
 NO_DEBUG_INFO_TESTCASE = True
 
+@expectedFailureAll
 def test_process_info_in_mini_dump(self):
 """Test that lldb can read the process information from the 
Minidump."""
 # target create -c linux-x86_64.dmp
@@ -28,6 +29,7 @@ class MiniDumpNewTestCase(TestBase):
 self.assertEqual(self.process.GetNumThreads(), 1)
 self.assertEqual(self.process.GetProcessID(), 16001)
 
+@expectedFailureAll
 def test_thread_info_in_mini_dump(self):
 """Test that lldb can read the thread information from the Minidump."""
 # target create -c linux-x86_64.dmp
@@ -42,6 +44,7 @@ class MiniDumpNewTestCase(TestBase):
 stop_description = thread.GetStopDescription(256)
 self.assertTrue("SIGSEGV" in stop_description)
 
+@expectedFailureAll
 def test_stack_info_in_mini_dump(self):
 """Test that we can see a trivial stack in a breakpad-generated 
Minidump."""
 # target create -c linux-x86_64.dmp
@@ -62,6 +65,7 @@ class MiniDumpNewTestCase(TestBase):
 self.assertTrue(eip.IsValid())
 self.assertEqual(pc, eip.GetValueAsUnsigned())
 
+@expectedFailureAll
 def test_snapshot_minidump(self):
 """Test that if we load a snapshot minidump file (meaning the process 
did not crash) there is no stop reason."""
 # target create -c linux-x86_64_not_crashed.dmp
@@ -74,6 +78,7 @@ class MiniDumpNewTestCase(TestBase):
 stop_description = thread.GetStopDescription(256)
 self.assertEqual(stop_description, None)
 
+@expectedFailureAll
 def test_deeper_stack_in_mini_dump(self):
 """Test that we can examine a more interesting stack in a Minidump."""
 # Launch with the Minidump, and inspect the stack.
@@ -89,6 +94,7 @@ class MiniDumpNewTestCase(TestBase):
 function_name = frame.GetFunctionName()
 self.assertTrue(name in function_name)
 
+@expectedFailureAll
 def test_local_variables_in_mini_dump(self):
 """Test that we can examine local variables in a Minidump."""
 # Launch with the Minidump, and inspect a local variable.


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


[Lldb-commits] [PATCH] D25196: Adding a new Minidump post-mortem debugging plugin

2016-10-04 Thread Dimitar Vlahovski via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283259: Adding a new Minidump post-mortem debugging plugin 
(authored by dvlahovski).

Changed prior to commit:
  https://reviews.llvm.org/D25196?vs=73541&id=73551#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25196

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
  lldb/trunk/source/API/SystemInitializerFull.cpp
  lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
  lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
  lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp
  lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.h
  lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
@@ -0,0 +1,36 @@
+#include 
+#include 
+#include 
+
+#include "client/linux/handler/exception_handler.h"
+
+static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
+void* context, bool succeeded) {
+printf("Dump path: %s\n", descriptor.path());
+return succeeded;
+}
+
+int global = 42;
+
+int
+bar(int x, google_breakpad::ExceptionHandler &eh)
+{
+eh.WriteMinidump();
+int y = 4*x + global;
+return y;
+}
+
+int
+foo(int x, google_breakpad::ExceptionHandler &eh)
+{
+int y = 2*bar(3*x, eh);
+  return y;
+}
+
+
+int main(int argc, char* argv[]) {
+google_breakpad::MinidumpDescriptor descriptor("/tmp");
+google_breakpad::ExceptionHandler eh(descriptor, NULL, dumpCallback, NULL, true, -1);
+foo(1, eh);
+return 0;
+}
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -0,0 +1,100 @@
+"""
+Test basics of Minidump debugging.
+"""
+
+from __future__ import print_function
+from six import iteritems
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class MiniDumpNewTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_process_info_in_mini_dump(self):
+"""Test that lldb can read the process information from the Minidump."""
+# target create -c linux-x86_64.dmp
+self.dbg.CreateTarget("")
+self.target = self.dbg.GetSelectedTarget()
+self.process = self.target.LoadCore("linux-x86_64.dmp")
+self.assertTrue(self.process, PROCESS_IS_VALID)
+self.assertEqual(self.process.GetNumThreads(), 1)
+self.assertEqual(self.process.GetProcessID(), 16001)
+
+def test_thread_info_in_mini_dump(self):
+"""Test that lldb can read the thread information from the Minidump."""
+# target create -c linux-x86_64.dmp
+self.dbg.CreateTarget("")
+self.target = self.dbg.GetSelectedTarget()
+self.process = self.target.LoadCore("linux-x86_64.dmp")
+# This process crashed due to a segmentation fault in its
+# one and only thread.
+self.assertEqual(self.process.GetNumThreads(), 1)
+thread = self.process.GetThreadAtIndex(0)
+self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal)
+stop_description = thread.GetStopDescription(256)
+self.assertTrue("SIGSEGV" in stop_description)
+
+def test_stack_info_in_mini_dump(self):
+"""Test that we can see a trivial stack in a breakpad-generated Minidump."""
+# target cre

[Lldb-commits] [lldb] r283259 - Adding a new Minidump post-mortem debugging plugin

2016-10-04 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Tue Oct  4 16:02:13 2016
New Revision: 283259

URL: http://llvm.org/viewvc/llvm-project?rev=283259&view=rev
Log:
Adding a new Minidump post-mortem debugging plugin

Summary:
This plugin resembles the already existing Windows-only Minidump plugin.
The WinMinidumpPlugin uses the Windows API for parsing Minidumps
while this plugin is cross-platform because it includes a Minidump
parser (which is already commited)

It is able to produce a backtrace, to read the general puprose regiters,
inspect local variables, show image list, do memory reads, etc.

For now the only arch that this supports is x86 64 bit
This is because I have only written a register context for that arch.
Others will come in next CLs.

I copied the WinMinidump tests and adapted them a little bit for them to
work with the new plugin (and they pass)
I will add more tests, aiming for better code coverage.

There is still functionality to be added, see TODOs in code.

Reviewers: labath, zturner

Subscribers: beanz, mgorny, amccarth, lldb-commits, modocache

Differential Revision: https://reviews.llvm.org/D25196

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp
lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.h
Modified:
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/Makefile?rev=283259&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/Makefile
 Tue Oct  4 16:02:13 2016
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
+

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py?rev=283259&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 Tue Oct  4 16:02:13 2016
@@ -0,0 +1,100 @@
+"""
+Test basics of Minidump debugging.
+"""
+
+from __future__ import print_function
+from six import iteritems
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class MiniDumpNewTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_process_info_in_mini_dump(self):
+"""Test that lldb can read the process information from the 
Minidump."""
+# target create -c linux-x86_64.dmp
+self.dbg.CreateTarget("")
+self.target = self.dbg.GetSelectedTarget()
+self.process = self.target.LoadCore("linux-x86_64.dmp")
+self.assertTrue(self.process, PROCESS_IS_VALID)
+self.assertEqual(self.process.GetNumThreads(), 1)
+self.assertEqual(self.process.GetProcessID(), 16001)
+
+def test_thread_info_in_mini_dump(self):
+"""Test that lldb can read the thread information from the Minidump."""
+# target create -c linux-x86_64.dmp
+self.dbg.CreateTarget("")
+self.target = self.dbg.GetSelectedTarget()
+self.p

[Lldb-commits] [PATCH] D25196: Adding a new Minidump post-mortem debugging plugin

2016-10-04 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 73541.
dvlahovski marked 2 inline comments as done.
dvlahovski added a comment.

Added a sanity check for loc_descr


https://reviews.llvm.org/D25196

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/Makefile
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
  source/API/SystemInitializerFull.cpp
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/ProcessMinidump.h
  source/Plugins/Process/minidump/ThreadMinidump.cpp
  source/Plugins/Process/minidump/ThreadMinidump.h
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -60,15 +60,18 @@
   std::unique_ptr parser;
 };
 
-TEST_F(MinidumpParserTest, GetThreads) {
+TEST_F(MinidumpParserTest, GetThreadsAndGetThreadContext) {
   SetUpData("linux-x86_64.dmp");
   llvm::ArrayRef thread_list;
 
   thread_list = parser->GetThreads();
   ASSERT_EQ(1UL, thread_list.size());
 
   const MinidumpThread thread = thread_list[0];
-  ASSERT_EQ(16001UL, thread.thread_id);
+  EXPECT_EQ(16001UL, thread.thread_id);
+
+  llvm::ArrayRef context = parser->GetThreadContext(thread);
+  EXPECT_EQ(1232, context.size());
 }
 
 TEST_F(MinidumpParserTest, GetThreadsTruncatedFile) {
@@ -139,6 +142,24 @@
   ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
 }
 
+TEST_F(MinidumpParserTest, GetMemoryRange) {
+  SetUpData("linux-x86_64.dmp");
+  // There are two memory ranges in the file (size is in bytes, decimal):
+  // 1) 0x7ffceb34a000 12288
+  // 2) 0x401d46 256
+  EXPECT_TRUE(parser->FindMemoryRange(0x7ffceb34a000).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x7ffceb34a000 + 12288 / 2).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x7ffceb34a000 + 12288 - 1).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffceb34a000 + 12288).hasValue());
+
+  EXPECT_TRUE(parser->FindMemoryRange(0x401d46).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x401d46 + 256 / 2).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x401d46 + 256 - 1).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x401d46 + 256).hasValue());
+
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+}
+
 // Windows Minidump tests
 // fizzbuzz_no_heap.dmp is copied from the WinMiniDump tests
 TEST_F(MinidumpParserTest, GetArchitectureWindows) {
@@ -172,7 +193,6 @@
 }
 
 // Register stuff
-// TODO probably split register stuff tests into different file?
 #define REG_VAL(x) *(reinterpret_cast(x))
 
 TEST_F(MinidumpParserTest, ConvertRegisterContext) {
Index: source/Plugins/Process/minidump/ThreadMinidump.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/ThreadMinidump.h
@@ -0,0 +1,52 @@
+//===-- ThreadMinidump.h ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_ThreadMinidump_h_
+#define liblldb_ThreadMinidump_h_
+
+// Project includes
+#include "MinidumpTypes.h"
+
+// Other libraries and framework includes
+#include "lldb/Target/Thread.h"
+
+// C Includes
+// C++ Includes
+
+namespace lldb_private {
+
+namespace minidump {
+
+class ThreadMinidump : public Thread {
+public:
+  ThreadMinidump(Process &process, const MinidumpThread &td,
+ llvm::ArrayRef gpregset_data);
+
+  ~ThreadMinidump() override;
+
+  void RefreshStateAfterStop() override;
+
+  lldb::RegisterContextSP GetRegisterContext() override;
+
+  lldb::RegisterContextSP
+  CreateRegisterContextForFrame(StackFrame *frame) override;
+
+  void ClearStackFrames() override;
+
+protected:
+  lldb::RegisterContextSP m_thread_reg_ctx_sp;
+  llvm::ArrayRef m_gpregset_data;
+
+  bool CalculateStopInfo() override;
+};
+
+} // namespace minidump
+} // namespace lldb_private
+
+#endif // liblldb_ThreadMinidump_h_
Index: source/Plugins/Process/minidump/T

[Lldb-commits] [PATCH] D25196: Adding a new Minidump post-mortem debugging plugin

2016-10-04 Thread Dimitar Vlahovski via lldb-commits
dvlahovski marked an inline comment as done.
dvlahovski added inline comments.


> zturner wrote in MinidumpParser.cpp:81-82
> Change this line to  `return GetData().slice(iter->second.rva, 
> iter->second.data_size);`

Nice! :)

> zturner wrote in MinidumpParser.h:35-36
> If the comment is long enough to wrap, maybe better to just put it on the 
> line before.  Looks awkward this way.

This comment is for the ArrayrRef. Added a clarification

> zturner wrote in MinidumpTypes.cpp:188-190
> you can write `return llvm::makeArrayRef(reinterpret_cast MinidumpMemoryDescriptor*>(data.data()), *mem_ranges_count));` to avoid 
> specifying the type name twice.  It's a little shorter (admittedly not much 
> though).

I think it looks better with the makeArrayrRef :)

https://reviews.llvm.org/D25196



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


[Lldb-commits] [PATCH] D25196: Adding a new Minidump post-mortem debugging plugin

2016-10-04 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 73526.
dvlahovski marked 6 inline comments as done.
dvlahovski added a comment.

Changes after Zachary's comments


https://reviews.llvm.org/D25196

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/Makefile
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
  source/API/SystemInitializerFull.cpp
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/ProcessMinidump.h
  source/Plugins/Process/minidump/ThreadMinidump.cpp
  source/Plugins/Process/minidump/ThreadMinidump.h
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -60,15 +60,18 @@
   std::unique_ptr parser;
 };
 
-TEST_F(MinidumpParserTest, GetThreads) {
+TEST_F(MinidumpParserTest, GetThreadsAndGetThreadContext) {
   SetUpData("linux-x86_64.dmp");
   llvm::ArrayRef thread_list;
 
   thread_list = parser->GetThreads();
   ASSERT_EQ(1UL, thread_list.size());
 
   const MinidumpThread thread = thread_list[0];
-  ASSERT_EQ(16001UL, thread.thread_id);
+  EXPECT_EQ(16001UL, thread.thread_id);
+
+  llvm::ArrayRef context = parser->GetThreadContext(thread);
+  EXPECT_EQ(1232, context.size());
 }
 
 TEST_F(MinidumpParserTest, GetThreadsTruncatedFile) {
@@ -139,6 +142,24 @@
   ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
 }
 
+TEST_F(MinidumpParserTest, GetMemoryRange) {
+  SetUpData("linux-x86_64.dmp");
+  // There are two memory ranges in the file (size is in bytes, decimal):
+  // 1) 0x7ffceb34a000 12288
+  // 2) 0x401d46 256
+  EXPECT_TRUE(parser->FindMemoryRange(0x7ffceb34a000).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x7ffceb34a000 + 12288 / 2).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x7ffceb34a000 + 12288 - 1).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffceb34a000 + 12288).hasValue());
+
+  EXPECT_TRUE(parser->FindMemoryRange(0x401d46).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x401d46 + 256 / 2).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x401d46 + 256 - 1).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x401d46 + 256).hasValue());
+
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+}
+
 // Windows Minidump tests
 // fizzbuzz_no_heap.dmp is copied from the WinMiniDump tests
 TEST_F(MinidumpParserTest, GetArchitectureWindows) {
@@ -172,7 +193,6 @@
 }
 
 // Register stuff
-// TODO probably split register stuff tests into different file?
 #define REG_VAL(x) *(reinterpret_cast(x))
 
 TEST_F(MinidumpParserTest, ConvertRegisterContext) {
Index: source/Plugins/Process/minidump/ThreadMinidump.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/ThreadMinidump.h
@@ -0,0 +1,52 @@
+//===-- ThreadMinidump.h ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_ThreadMinidump_h_
+#define liblldb_ThreadMinidump_h_
+
+// Project includes
+#include "MinidumpTypes.h"
+
+// Other libraries and framework includes
+#include "lldb/Target/Thread.h"
+
+// C Includes
+// C++ Includes
+
+namespace lldb_private {
+
+namespace minidump {
+
+class ThreadMinidump : public Thread {
+public:
+  ThreadMinidump(Process &process, const MinidumpThread &td,
+ llvm::ArrayRef gpregset_data);
+
+  ~ThreadMinidump() override;
+
+  void RefreshStateAfterStop() override;
+
+  lldb::RegisterContextSP GetRegisterContext() override;
+
+  lldb::RegisterContextSP
+  CreateRegisterContextForFrame(StackFrame *frame) override;
+
+  void ClearStackFrames() override;
+
+protected:
+  lldb::RegisterContextSP m_thread_reg_ctx_sp;
+  llvm::ArrayRef m_gpregset_data;
+
+  bool CalculateStopInfo() override;
+};
+
+} // namespace minidump
+} // namespace lldb_private
+
+#endif // liblldb_ThreadMinidump_h_
Index: source/Plugins/Process/minidump/Thr

[Lldb-commits] [PATCH] D25196: Adding a new Minidump post-mortem debugging plugin

2016-10-04 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 73516.
dvlahovski marked 5 inline comments as done.
dvlahovski added a comment.

Second iteration over CL - regarded Pavel's comments and encapsulated m_data_sp 
more in MinidumpParser


https://reviews.llvm.org/D25196

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/Makefile
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
  source/API/SystemInitializerFull.cpp
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/ProcessMinidump.h
  source/Plugins/Process/minidump/ThreadMinidump.cpp
  source/Plugins/Process/minidump/ThreadMinidump.h
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -60,15 +60,18 @@
   std::unique_ptr parser;
 };
 
-TEST_F(MinidumpParserTest, GetThreads) {
+TEST_F(MinidumpParserTest, GetThreadsAndGetThreadContext) {
   SetUpData("linux-x86_64.dmp");
   llvm::ArrayRef thread_list;
 
   thread_list = parser->GetThreads();
   ASSERT_EQ(1UL, thread_list.size());
 
   const MinidumpThread thread = thread_list[0];
-  ASSERT_EQ(16001UL, thread.thread_id);
+  EXPECT_EQ(16001UL, thread.thread_id);
+
+  llvm::ArrayRef context = parser->GetThreadContext(thread);
+  EXPECT_EQ(1232, context.size());
 }
 
 TEST_F(MinidumpParserTest, GetThreadsTruncatedFile) {
@@ -139,6 +142,24 @@
   ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
 }
 
+TEST_F(MinidumpParserTest, GetMemoryRange) {
+  SetUpData("linux-x86_64.dmp");
+  // There are two memory ranges in the file (size is in bytes, decimal):
+  // 1) 0x7ffceb34a000 12288
+  // 2) 0x401d46 256
+  EXPECT_TRUE(parser->FindMemoryRange(0x7ffceb34a000).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x7ffceb34a000 + 12288 / 2).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x7ffceb34a000 + 12288 - 1).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffceb34a000 + 12288).hasValue());
+
+  EXPECT_TRUE(parser->FindMemoryRange(0x401d46).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x401d46 + 256 / 2).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x401d46 + 256 - 1).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x401d46 + 256).hasValue());
+
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+}
+
 // Windows Minidump tests
 // fizzbuzz_no_heap.dmp is copied from the WinMiniDump tests
 TEST_F(MinidumpParserTest, GetArchitectureWindows) {
@@ -172,7 +193,6 @@
 }
 
 // Register stuff
-// TODO probably split register stuff tests into different file?
 #define REG_VAL(x) *(reinterpret_cast(x))
 
 TEST_F(MinidumpParserTest, ConvertRegisterContext) {
Index: source/Plugins/Process/minidump/ThreadMinidump.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/ThreadMinidump.h
@@ -0,0 +1,52 @@
+//===-- ThreadMinidump.h ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_ThreadMinidump_h_
+#define liblldb_ThreadMinidump_h_
+
+// Project includes
+#include "MinidumpTypes.h"
+
+// Other libraries and framework includes
+#include "lldb/Target/Thread.h"
+
+// C Includes
+// C++ Includes
+
+namespace lldb_private {
+
+namespace minidump {
+
+class ThreadMinidump : public Thread {
+public:
+  ThreadMinidump(Process &process, const MinidumpThread &td,
+ llvm::ArrayRef gpregset_data);
+
+  ~ThreadMinidump() override;
+
+  void RefreshStateAfterStop() override;
+
+  lldb::RegisterContextSP GetRegisterContext() override;
+
+  lldb::RegisterContextSP
+  CreateRegisterContextForFrame(StackFrame *frame) override;
+
+  void ClearStackFrames() override;
+
+protected:
+  lldb::RegisterContextSP m_thread_reg_ctx_sp;
+  llvm::ArrayRef m_gpregset_data;
+
+  bool CalculateStopInfo() override;
+};
+
+} // namespace minidump
+} // namespace lldb_private
+
+#endif 

[Lldb-commits] [PATCH] D25196: Adding a new Minidump post-mortem debugging plugin

2016-10-04 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 73504.
dvlahovski marked 7 inline comments as done.
dvlahovski added a comment.

Updated the CL with regard to Pavel's comments


https://reviews.llvm.org/D25196

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/Makefile
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
  source/API/SystemInitializerFull.cpp
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/ProcessMinidump.h
  source/Plugins/Process/minidump/ThreadMinidump.cpp
  source/Plugins/Process/minidump/ThreadMinidump.h
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -60,15 +60,18 @@
   std::unique_ptr parser;
 };
 
-TEST_F(MinidumpParserTest, GetThreads) {
+TEST_F(MinidumpParserTest, GetThreadsAndGetThreadContext) {
   SetUpData("linux-x86_64.dmp");
   llvm::ArrayRef thread_list;
 
   thread_list = parser->GetThreads();
   ASSERT_EQ(1UL, thread_list.size());
 
   const MinidumpThread thread = thread_list[0];
-  ASSERT_EQ(16001UL, thread.thread_id);
+  EXPECT_EQ(16001UL, thread.thread_id);
+
+  llvm::ArrayRef context = parser->GetThreadContext(thread);
+  EXPECT_EQ(1232, context.size());
 }
 
 TEST_F(MinidumpParserTest, GetThreadsTruncatedFile) {
@@ -139,6 +142,24 @@
   ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
 }
 
+TEST_F(MinidumpParserTest, GetMemoryRange) {
+  SetUpData("linux-x86_64.dmp");
+  // There are two memory ranges in the file (size is in bytes, decimal):
+  // 1) 0x7ffceb34a000 12288
+  // 2) 0x401d46 256
+  EXPECT_TRUE(parser->FindMemoryRange(0x7ffceb34a000).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x7ffceb34a000 + 12288 / 2).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x7ffceb34a000 + 12288 - 1).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffceb34a000 + 12288).hasValue());
+
+  EXPECT_TRUE(parser->FindMemoryRange(0x401d46).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x401d46 + 256 / 2).hasValue());
+  EXPECT_TRUE(parser->FindMemoryRange(0x401d46 + 256 - 1).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x401d46 + 256).hasValue());
+
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+}
+
 // Windows Minidump tests
 // fizzbuzz_no_heap.dmp is copied from the WinMiniDump tests
 TEST_F(MinidumpParserTest, GetArchitectureWindows) {
@@ -172,7 +193,6 @@
 }
 
 // Register stuff
-// TODO probably split register stuff tests into different file?
 #define REG_VAL(x) *(reinterpret_cast(x))
 
 TEST_F(MinidumpParserTest, ConvertRegisterContext) {
Index: source/Plugins/Process/minidump/ThreadMinidump.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/ThreadMinidump.h
@@ -0,0 +1,52 @@
+//===-- ThreadMinidump.h ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_ThreadMinidump_h_
+#define liblldb_ThreadMinidump_h_
+
+// Project includes
+#include "MinidumpTypes.h"
+
+// Other libraries and framework includes
+#include "lldb/Target/Thread.h"
+
+// C Includes
+// C++ Includes
+
+namespace lldb_private {
+
+namespace minidump {
+
+class ThreadMinidump : public Thread {
+public:
+  ThreadMinidump(Process &process, const MinidumpThread &td,
+ llvm::ArrayRef gpregset_data);
+
+  ~ThreadMinidump() override;
+
+  void RefreshStateAfterStop() override;
+
+  lldb::RegisterContextSP GetRegisterContext() override;
+
+  lldb::RegisterContextSP
+  CreateRegisterContextForFrame(StackFrame *frame) override;
+
+  void ClearStackFrames() override;
+
+protected:
+  lldb::RegisterContextSP m_thread_reg_ctx_sp;
+  llvm::ArrayRef m_gpregset_data;
+
+  bool CalculateStopInfo() override;
+};
+
+} // namespace minidump
+} // namespace lldb_private
+
+#endif // liblldb_ThreadMinidump_h_
Index: source/Plugins/Proces

[Lldb-commits] [PATCH] D25196: Adding a new Minidump post-mortem debugging plugin

2016-10-04 Thread Dimitar Vlahovski via lldb-commits
dvlahovski marked 5 inline comments as done.
dvlahovski added inline comments.


> labath wrote in TestMiniDumpNew.py:19
> They are not building any code, so the would behave the same way anyway. You 
> would be just running the test 2--3 times for nothing.

Aah I understand now. Ok thanks :)

https://reviews.llvm.org/D25196



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


[Lldb-commits] [PATCH] D25196: Adding a new Minidump post-mortem debugging plugin

2016-10-03 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added inline comments.


> labath wrote in TestMiniDumpNew.py:19
> You can replace these with `NO_DEBUG_INFO_TESTCASE = True` at class level.

But, should `test_deeper_stack_in_mini_dump` and 
`test_local_variables_in_mini_dump` not have this decorator ?

https://reviews.llvm.org/D25196



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


[Lldb-commits] [PATCH] D25196: Adding a new Minidump post-mortem debugging plugin

2016-10-03 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added a comment.

In https://reviews.llvm.org/D25196#559368, @amccarth wrote:

> I was hoping that, with your new mini dump parser, you'd be able to eliminate 
> the need for the Windows-specific minidump process plugin.
>
> When I wrote the Windows mini dump plugin, I tried to isolate the Windows 
> API-specific bits using the pimpl idiom.  Now that you've written a mini dump 
> parser, we shouldn't need the Windows API calls, and nearly all the rest of 
> the code should be shareable between Windows and Linux.  Is there a plan to 
> eliminate this redundancy and merge this new mini dump process plugin with 
> the Windows-specific one?


Yes, the plan is that my plugin will replace the Windows one. (and it has 
almost the same functionality)

What I have been doing so far is actually copying all of the methods from the 
WinMinidump plugin to mine and changing them to use the new Minidump parser.

Probably I could have fitted into you pimpl implementation pattern, but I chose 
just to start a 'new' plugin and copy everything from the WinMinidump, and then 
change it accordingly.


https://reviews.llvm.org/D25196



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


[Lldb-commits] [PATCH] D25196: Adding a new Minidump post-mortem debugging plugin

2016-10-03 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added inline comments.


> labath wrote in ProcessMinidump.cpp:67
> It already is return true.
> 
> Is that correct?

What I meant here is: is there functionality that needs to be added here.
In the WinMinidump plugin, this method is only returning true (as mine) and has 
a TODO saying that it should have actual logic in it

https://reviews.llvm.org/D25196



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


[Lldb-commits] [PATCH] D25196: Adding a new Minidump post-mortem debugging plugin

2016-10-03 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added a comment.

So, there will be changes to the way I handle the case where there is no 
ExceptionStream - I will probably create a StopReason = None. But I have to 
investigate if in that case lldb still hangs because it's trying to resume a 
process (that does not exists). I will ask Jim Ingham about some insight about 
StopReasons


https://reviews.llvm.org/D25196



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


[Lldb-commits] [PATCH] D25196: Adding a new Minidump post-mortem debugging plugin

2016-10-03 Thread Dimitar Vlahovski via lldb-commits
dvlahovski created this revision.
dvlahovski added reviewers: labath, zturner.
dvlahovski added subscribers: lldb-commits, amccarth.
Herald added subscribers: modocache, mgorny, beanz.

This plugin resembles the already existing Windows-only Minidump plugin.
The WinMinidumpPlugin uses the Windows API for parsing Minidumps
while this plugin is cross-platform because it includes a Minidump
parser (which is already commited)

It is able to produce a backtrace, to read the general puprose regiters,
inspect local variables, show image list, do memory reads, etc.

For now the only arch that this supports is x86 64 bit
This is because I have only written a register context for that arch.
Others will come in next CLs.

I copied the WinMinidump tests and adapted them a little bit for them to
work with the new plugin (and they pass)
I will add more tests, aiming for better code coverage.

There is still functionality to be added, see TODOs in code.


https://reviews.llvm.org/D25196

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/Makefile
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
  source/API/SystemInitializerFull.cpp
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/ProcessMinidump.h
  source/Plugins/Process/minidump/ThreadMinidump.cpp
  source/Plugins/Process/minidump/ThreadMinidump.h
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -139,6 +139,8 @@
   ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
 }
 
+//TODO add tests for MemoryList parsing
+
 // Windows Minidump tests
 // fizzbuzz_no_heap.dmp is copied from the WinMiniDump tests
 TEST_F(MinidumpParserTest, GetArchitectureWindows) {
@@ -172,7 +174,6 @@
 }
 
 // Register stuff
-// TODO probably split register stuff tests into different file?
 #define REG_VAL(x) *(reinterpret_cast(x))
 
 TEST_F(MinidumpParserTest, ConvertRegisterContext) {
Index: source/Plugins/Process/minidump/ThreadMinidump.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/ThreadMinidump.h
@@ -0,0 +1,51 @@
+//===-- ThreadMinidump.-h ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_ThreadMinidump_h_
+#define liblldb_ThreadMinidump_h_
+
+// Project includes
+#include "MinidumpTypes.h"
+
+// Other libraries and framework includes
+#include "lldb/Target/Thread.h"
+
+// C Includes
+// C++ Includes
+
+namespace lldb_private {
+
+namespace minidump {
+
+class ThreadMinidump : public Thread {
+public:
+  ThreadMinidump(Process &process, const MinidumpThread &td);
+
+  ~ThreadMinidump() override;
+
+  void RefreshStateAfterStop() override;
+
+  lldb::RegisterContextSP GetRegisterContext() override;
+
+  lldb::RegisterContextSP
+  CreateRegisterContextForFrame(StackFrame *frame) override;
+
+  void ClearStackFrames() override;
+
+protected:
+  lldb::RegisterContextSP m_thread_reg_ctx_sp;
+  llvm::ArrayRef m_gpregset_data;
+
+  bool CalculateStopInfo() override;
+};
+
+} // namespace minidump
+} // namespace lldb_private
+
+#endif // liblldb_ThreadMinidump_h_
Index: source/Plugins/Process/minidump/ThreadMinidump.cpp
===
--- /dev/null
+++ source/Plugins/Process/minidump/ThreadMinidump.cpp
@@ -0,0 +1,121 @@
+//===-- ThreadMinidump.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Project includes
+#include "ThreadMinidump.h"
+#include "ProcessMinidump.h"
+
+#include "RegisterContextMinidump_x86_64.h"
+
+// O

Re: [Lldb-commits] [lldb] r282966 - IsValid is the way to ask a breakpoint location whether it is valid.

2016-10-03 Thread Dimitar Vlahovski via lldb-commits
Hi,
Are these build breakages somehow connected to this commit?
http://lab.llvm.org:8011/builders/lldb-windows7-android/builds/8703
http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-
14.04-android/builds/9655

Thanks,
Dimitar

On Fri, Sep 30, 2016 at 11:07 PM, Jim Ingham via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Author: jingham
> Date: Fri Sep 30 17:07:41 2016
> New Revision: 282966
>
> URL: http://llvm.org/viewvc/llvm-project?rev=282966&view=rev
> Log:
> IsValid is the way to ask a breakpoint location whether it is valid.
>
> Modified:
> lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/
> breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/
> functionalities/breakpoint/breakpoint_case_sensitivity/
> TestBreakpointCaseSensitivity.py
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/
> Python/lldbsuite/test/functionalities/breakpoint/
> breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.
> py?rev=282966&r1=282965&r2=282966&view=diff
> 
> ==
> --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/
> breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/
> breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py Fri Sep 30
> 17:07:41 2016
> @@ -27,7 +27,7 @@ class BreakpointCaseSensitivityTestCase(
>
>  @skipIf(oslist=['windows'])  # Skip for windows platforms
>  # Failing for unknown reason on non-Windows platforms.
> -@expectedFailureAll()
> +
>  def test_breakpoint_doesnt_match_file_with_different_case(self):
>  """Set breakpoint on file, shouldn't match files with different
> case on POSIX systems"""
>  self.build()
> @@ -98,7 +98,8 @@ class BreakpointCaseSensitivityTestCase(
>  # Get the breakpoint location from breakpoint after we verified
> that,
>  # indeed, it has one location.
>  location = breakpoint.GetLocationAtIndex(0)
> -self.assertEqual(location and location.IsEnabled(),
> +
> +self.assertEqual(location.IsValid(),
>   should_hit,
>   VALID_BREAKPOINT_LOCATION + desc)
>
>
>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r282866 - Again fixing windows build breakage like in rL282862

2016-09-30 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Fri Sep 30 10:41:33 2016
New Revision: 282866

URL: http://llvm.org/viewvc/llvm-project?rev=282866&view=rev
Log:
Again fixing windows build breakage like in rL282862

Modified:
lldb/trunk/source/Host/windows/Windows.cpp

Modified: lldb/trunk/source/Host/windows/Windows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Windows.cpp?rev=282866&r1=282865&r2=282866&view=diff
==
--- lldb/trunk/source/Host/windows/Windows.cpp (original)
+++ lldb/trunk/source/Host/windows/Windows.cpp Fri Sep 30 10:41:33 2016
@@ -35,7 +35,7 @@ bool utf8ToWide(const char *utf8, wchar_
   const llvm::UTF8 *sourceStart = reinterpret_cast(utf8);
   size_t sourceLen = strlen(utf8) + 1 /* convert null too */;
   llvm::UTF16 *target = reinterpret_cast(buf);
-  llvm::ConversionFlags flags = strictConversion;
+  llvm::ConversionFlags flags = llvm::strictConversion;
   return llvm::ConvertUTF8toUTF16(&sourceStart, sourceStart + sourceLen, 
&target,
 target + bufSize, flags) == llvm::conversionOK;
 }
@@ -44,7 +44,7 @@ bool wideToUtf8(const wchar_t *wide, cha
   const llvm::UTF16 *sourceStart = reinterpret_cast(wide);
   size_t sourceLen = wcslen(wide) + 1 /* convert null too */;
   llvm::UTF8 *target = reinterpret_cast(buf);
-  llvm::ConversionFlags flags = strictConversion;
+  llvm::ConversionFlags flags = llvm::strictConversion;
   return llvm::ConvertUTF16toUTF8(&sourceStart, sourceStart + sourceLen, 
&target,
 target + bufSize, flags) == llvm::conversionOK;
 }


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


[Lldb-commits] [lldb] r282862 - Fixing windows build breakage caused by rL282822

2016-09-30 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Fri Sep 30 09:36:17 2016
New Revision: 282862

URL: http://llvm.org/viewvc/llvm-project?rev=282862&view=rev
Log:
Fixing windows build breakage caused by rL282822

The breakage was because of the moving of the UTF functions to the llvm
namespace

Modified:
lldb/trunk/source/Host/windows/Windows.cpp

Modified: lldb/trunk/source/Host/windows/Windows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Windows.cpp?rev=282862&r1=282861&r2=282862&view=diff
==
--- lldb/trunk/source/Host/windows/Windows.cpp (original)
+++ lldb/trunk/source/Host/windows/Windows.cpp Fri Sep 30 09:36:17 2016
@@ -32,21 +32,21 @@ int _chdir(const char *path);
 
 namespace {
 bool utf8ToWide(const char *utf8, wchar_t *buf, size_t bufSize) {
-  const UTF8 *sourceStart = reinterpret_cast(utf8);
+  const llvm::UTF8 *sourceStart = reinterpret_cast(utf8);
   size_t sourceLen = strlen(utf8) + 1 /* convert null too */;
-  UTF16 *target = reinterpret_cast(buf);
-  ConversionFlags flags = strictConversion;
-  return ConvertUTF8toUTF16(&sourceStart, sourceStart + sourceLen, &target,
-target + bufSize, flags) == conversionOK;
+  llvm::UTF16 *target = reinterpret_cast(buf);
+  llvm::ConversionFlags flags = strictConversion;
+  return llvm::ConvertUTF8toUTF16(&sourceStart, sourceStart + sourceLen, 
&target,
+target + bufSize, flags) == llvm::conversionOK;
 }
 
 bool wideToUtf8(const wchar_t *wide, char *buf, size_t bufSize) {
-  const UTF16 *sourceStart = reinterpret_cast(wide);
+  const llvm::UTF16 *sourceStart = reinterpret_cast(wide);
   size_t sourceLen = wcslen(wide) + 1 /* convert null too */;
-  UTF8 *target = reinterpret_cast(buf);
-  ConversionFlags flags = strictConversion;
-  return ConvertUTF16toUTF8(&sourceStart, sourceStart + sourceLen, &target,
-target + bufSize, flags) == conversionOK;
+  llvm::UTF8 *target = reinterpret_cast(buf);
+  llvm::ConversionFlags flags = strictConversion;
+  return llvm::ConvertUTF16toUTF8(&sourceStart, sourceStart + sourceLen, 
&target,
+target + bufSize, flags) == llvm::conversionOK;
 }
 }
 


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


Re: [Lldb-commits] [lldb] r282683 - Add a unit test for an x86_64 assembly inspection of

2016-09-29 Thread Dimitar Vlahovski via lldb-commits
This is the first build that failed right after your CL:
http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/20083

On Thu, Sep 29, 2016 at 1:35 PM, Dimitar Vlahovski 
wrote:

> Hi,
>
> Is the work that you are currently doing the reason why the lldb build on
> i386 is failing?
> http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake
> http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-
> 14.04-cmake/builds/20099
>
> Dimitar
>
>
> On Thu, Sep 29, 2016 at 5:30 AM, Jason Molenda via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
>
>> Good suggestions, thanks.  I'll fix those when I commit the 32-bit
>> version of the same test.
>>
>> J
>>
>> > On Sep 28, 2016, at 9:28 PM, Zachary Turner  wrote:
>> >
>> >
>> >
>> > On Wed, Sep 28, 2016 at 9:10 PM Jason Molenda via lldb-commits <
>> lldb-commits@lists.llvm.org> wrote:
>> >
>> > +  EXPECT_TRUE(regloc.GetOffset() == -8);
>> > This should be
>> >
>> > EXPECT_EQ(-8, regloc.GetOffset());
>> >
>> > That way if it fails, you'll get a handy error message that says:
>> >
>> > Expected: -8
>> > Actual: -7
>> >
>> > If you use EXPECT_TRUE, it's not going to tell you the actual value.
>> The same goes for many other places in the file.  Note that you're supposed
>> to put the expected value *first*.  The test is the same either way
>> obviously, but it affects the printing of the above message.
>> >
>> > +
>> > +  // these could be set to IsSame and be valid -- meaning that the
>> > +  // register value is the same as the caller's -- but I'd rather
>> > +  // they not be mentioned at all.
>> > +  EXPECT_TRUE(row_sp->GetRegisterInfo(k_rbp, regloc) == false);
>> > +  EXPECT_TRUE(row_sp->GetRegisterInfo(k_r15, regloc) == false);
>> > +  EXPECT_TRUE(row_sp->GetRegisterInfo(k_r14, regloc) == false);
>> > +  EXPECT_TRUE(row_sp->GetRegisterInfo(k_r13, regloc) == false);
>> > +  EXPECT_TRUE(row_sp->GetRegisterInfo(k_r12, regloc) == false);
>> > +  EXPECT_TRUE(row_sp->GetRegisterInfo(k_rbx, regloc) == false);
>> > If you're using EXPECT_TRUE and EXPECT_FALSE, I think it's more
>> intuitive to not use the comparison operator.  The above is just
>> >
>> > EXPECT_FALSE(row_sp->GetRegisterInfo(k_rbx, regloc));
>>
>> ___
>> lldb-commits mailing list
>> lldb-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] r282683 - Add a unit test for an x86_64 assembly inspection of

2016-09-29 Thread Dimitar Vlahovski via lldb-commits
Hi,

Is the work that you are currently doing the reason why the lldb build on
i386 is failing?
http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake
http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/20099

Dimitar


On Thu, Sep 29, 2016 at 5:30 AM, Jason Molenda via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Good suggestions, thanks.  I'll fix those when I commit the 32-bit version
> of the same test.
>
> J
>
> > On Sep 28, 2016, at 9:28 PM, Zachary Turner  wrote:
> >
> >
> >
> > On Wed, Sep 28, 2016 at 9:10 PM Jason Molenda via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
> >
> > +  EXPECT_TRUE(regloc.GetOffset() == -8);
> > This should be
> >
> > EXPECT_EQ(-8, regloc.GetOffset());
> >
> > That way if it fails, you'll get a handy error message that says:
> >
> > Expected: -8
> > Actual: -7
> >
> > If you use EXPECT_TRUE, it's not going to tell you the actual value.
> The same goes for many other places in the file.  Note that you're supposed
> to put the expected value *first*.  The test is the same either way
> obviously, but it affects the printing of the above message.
> >
> > +
> > +  // these could be set to IsSame and be valid -- meaning that the
> > +  // register value is the same as the caller's -- but I'd rather
> > +  // they not be mentioned at all.
> > +  EXPECT_TRUE(row_sp->GetRegisterInfo(k_rbp, regloc) == false);
> > +  EXPECT_TRUE(row_sp->GetRegisterInfo(k_r15, regloc) == false);
> > +  EXPECT_TRUE(row_sp->GetRegisterInfo(k_r14, regloc) == false);
> > +  EXPECT_TRUE(row_sp->GetRegisterInfo(k_r13, regloc) == false);
> > +  EXPECT_TRUE(row_sp->GetRegisterInfo(k_r12, regloc) == false);
> > +  EXPECT_TRUE(row_sp->GetRegisterInfo(k_rbx, regloc) == false);
> > If you're using EXPECT_TRUE and EXPECT_FALSE, I think it's more
> intuitive to not use the comparison operator.  The above is just
> >
> > EXPECT_FALSE(row_sp->GetRegisterInfo(k_rbx, regloc));
>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter

2016-09-27 Thread Dimitar Vlahovski via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282529: Adding a RegisterContextMinidump_x86_64 converter 
(authored by dvlahovski).

Changed prior to commit:
  https://reviews.llvm.org/D24919?vs=72688&id=72689#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24919

Files:
  lldb/trunk/include/lldb/lldb-private-types.h
  lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
  lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Index: lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -8,16 +8,19 @@
 //===--===//
 
 // Project includes
+#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
 #include "Plugins/Process/minidump/MinidumpParser.h"
 #include "Plugins/Process/minidump/MinidumpTypes.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
 
 // Other libraries and framework includes
 #include "gtest/gtest.h"
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Host/FileSpec.h"
 
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -50,7 +53,7 @@
 MinidumpParser::Create(data_sp);
 ASSERT_TRUE(optional_parser.hasValue());
 parser.reset(new MinidumpParser(optional_parser.getValue()));
-ASSERT_GT(parser->GetByteSize(), 0UL);
+ASSERT_GT(parser->GetData().size(), 0UL);
   }
 
   llvm::SmallString<128> inputs_folder;
@@ -167,3 +170,61 @@
   ASSERT_TRUE(pid.hasValue());
   ASSERT_EQ(4440UL, pid.getValue());
 }
+
+// Register stuff
+// TODO probably split register stuff tests into different file?
+#define REG_VAL(x) *(reinterpret_cast(x))
+
+TEST_F(MinidumpParserTest, ConvertRegisterContext) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::ArrayRef thread_list = parser->GetThreads();
+  const MinidumpThread thread = thread_list[0];
+  llvm::ArrayRef registers(parser->GetData().data() +
+thread.thread_context.rva,
+thread.thread_context.data_size);
+
+  ArchSpec arch = parser->GetArchitecture();
+  RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
+  lldb::DataBufferSP buf =
+  ConvertMinidumpContextToRegIface(registers, reg_interface);
+  ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
+
+  const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
+
+  std::map reg_values;
+
+  // clang-format off
+  reg_values[lldb_rax_x86_64]=  0x;
+  reg_values[lldb_rbx_x86_64]=  0x;
+  reg_values[lldb_rcx_x86_64]=  0x0010;
+  reg_values[lldb_rdx_x86_64]=  0x;
+  reg_values[lldb_rdi_x86_64]=  0x7ffceb349cf0;
+  reg_values[lldb_rsi_x86_64]=  0x;
+  reg_values[lldb_rbp_x86_64]=  0x7ffceb34a210;
+  reg_values[lldb_rsp_x86_64]=  0x7ffceb34a210;
+  reg_values[lldb_r8_x86_64] =  0x7fe9bc1aa9c0;
+  reg_values[lldb_r9_x86_64] =  0x;
+  reg_values[lldb_r10_x86_64]=  0x7fe9bc3f16a0;
+  reg_values[lldb_r11_x86_64]=  0x0246;
+  reg_values[lldb_r12_x86_64]=  0x00401c92;
+  reg_values[lldb_r13_x86_64]=  0x7ffceb34a430;
+  reg_values[lldb_r14_x86_64]=  0x;
+  reg_values[lldb_r15_x86_64]=  0x;
+  reg_values[lldb_rip_x86_64]=  0x00401dc6;
+  reg_values[lldb_rflags_x86_64] =  0x00010206;
+  reg_values[lldb_cs_x86_64] =  0x0033;
+  reg_values[lldb_fs_x86_64] =  0x;
+  reg_values[lldb_gs_x86_64] =  0x;
+  reg_values[lldb_ss_x86_64] =  0x;
+  reg_values[lldb_ds_x86_64] =  0x;
+  reg_values[lldb_es_x86_64] =  0x;
+  // clang-format on
+
+  for (uint32_t reg_index = 0; reg_index < reg_interface->GetRegisterCount();
+   ++reg_index) {
+if (reg_values.find(reg_index) != reg_values.end()) {
+  EXPECT_EQ(reg_values[reg_index],
+REG_VAL(buf->GetBytes() + reg_info[reg_index].byte_offset));
+}
+  }
+}
Index: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
===
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpPars

[Lldb-commits] [lldb] r282529 - Adding a RegisterContextMinidump_x86_64 converter

2016-09-27 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Tue Sep 27 14:05:55 2016
New Revision: 282529

URL: http://llvm.org/viewvc/llvm-project?rev=282529&view=rev
Log:
Adding a RegisterContextMinidump_x86_64 converter

Summary:
This is a register context converter from Minidump to Linux reg context.
This knows the layout of the register context in the Minidump file
(which is the same as in Windows FYI) and as a result emits a binary data
buffer that matches the Linux register context binary layout.
This way we can reuse the existing RegisterContextLinux_x86_64 and
RegisterContextCorePOSIX_x86_64 classes.

Reviewers: labath, zturner

Subscribers: beanz, mgorny, lldb-commits, amccarth

Differential Revision: https://reviews.llvm.org/D24919

Added:

lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
Modified:
lldb/trunk/include/lldb/lldb-private-types.h
lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Modified: lldb/trunk/include/lldb/lldb-private-types.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-types.h?rev=282529&r1=282528&r2=282529&view=diff
==
--- lldb/trunk/include/lldb/lldb-private-types.h (original)
+++ lldb/trunk/include/lldb/lldb-private-types.h Tue Sep 27 14:05:55 2016
@@ -14,6 +14,8 @@
 
 #include "lldb/lldb-private.h"
 
+#include "llvm/ADT/ArrayRef.h"
+
 namespace llvm {
 namespace sys {
 class DynamicLibrary;
@@ -61,6 +63,15 @@ struct RegisterInfo {
   // the byte size of this register.
   size_t dynamic_size_dwarf_len; // The length of the DWARF expression in bytes
  // in the dynamic_size_dwarf_expr_bytes 
member.
+
+  llvm::ArrayRef data(const uint8_t *context_base) const {
+return llvm::ArrayRef(context_base + byte_offset, byte_size);
+  }
+
+  llvm::MutableArrayRef mutable_data(uint8_t *context_base) const {
+return llvm::MutableArrayRef(context_base + byte_offset,
+  byte_size);
+  }
 };
 
 //--

Modified: lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt?rev=282529&r1=282528&r2=282529&view=diff
==
--- lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt Tue Sep 27 
14:05:55 2016
@@ -3,4 +3,5 @@ include_directories(../Utility)
 add_lldb_library(lldbPluginProcessMinidump
   MinidumpTypes.cpp
   MinidumpParser.cpp
+  RegisterContextMinidump_x86_64.cpp
   )

Modified: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp?rev=282529&r1=282528&r2=282529&view=diff
==
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp Tue Sep 27 
14:05:55 2016
@@ -64,8 +64,9 @@ MinidumpParser::MinidumpParser(
 : m_data_sp(data_buf_sp), m_header(header), m_directory_map(directory_map) 
{
 }
 
-lldb::offset_t MinidumpParser::GetByteSize() {
-  return m_data_sp->GetByteSize();
+llvm::ArrayRef MinidumpParser::GetData() {
+  return llvm::ArrayRef(m_data_sp->GetBytes(),
+ m_data_sp->GetByteSize());
 }
 
 llvm::ArrayRef

Modified: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h?rev=282529&r1=282528&r2=282529&view=diff
==
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h Tue Sep 27 
14:05:55 2016
@@ -39,7 +39,7 @@ public:
   static llvm::Optional
   Create(const lldb::DataBufferSP &data_buf_sp);
 
-  lldb::offset_t GetByteSize();
+  llvm::ArrayRef GetData();
 
   llvm::ArrayRef GetStream(MinidumpStreamType stream_type);
 
@@ -71,6 +71,6 @@ private:
   llvm::DenseMap &&directory_map);
 };
 
-} // namespace minidump
-} // namespace lldb_private
+} // end namespace minidump
+} // end namespace lldb_private
 #endif // liblldb_MinidumpParser_h_

Added: 
lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x

Re: [Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter

2016-09-27 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 72688.
dvlahovski added a comment.

I like the combined approach more. So this is the implementation


https://reviews.llvm.org/D24919

Files:
  include/lldb/lldb-private-types.h
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -8,16 +8,19 @@
 //===--===//
 
 // Project includes
+#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
 #include "Plugins/Process/minidump/MinidumpParser.h"
 #include "Plugins/Process/minidump/MinidumpTypes.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
 
 // Other libraries and framework includes
 #include "gtest/gtest.h"
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Host/FileSpec.h"
 
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -50,7 +53,7 @@
 MinidumpParser::Create(data_sp);
 ASSERT_TRUE(optional_parser.hasValue());
 parser.reset(new MinidumpParser(optional_parser.getValue()));
-ASSERT_GT(parser->GetByteSize(), 0UL);
+ASSERT_GT(parser->GetData().size(), 0UL);
   }
 
   llvm::SmallString<128> inputs_folder;
@@ -167,3 +170,61 @@
   ASSERT_TRUE(pid.hasValue());
   ASSERT_EQ(4440UL, pid.getValue());
 }
+
+// Register stuff
+// TODO probably split register stuff tests into different file?
+#define REG_VAL(x) *(reinterpret_cast(x))
+
+TEST_F(MinidumpParserTest, ConvertRegisterContext) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::ArrayRef thread_list = parser->GetThreads();
+  const MinidumpThread thread = thread_list[0];
+  llvm::ArrayRef registers(parser->GetData().data() +
+thread.thread_context.rva,
+thread.thread_context.data_size);
+
+  ArchSpec arch = parser->GetArchitecture();
+  RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
+  lldb::DataBufferSP buf =
+  ConvertMinidumpContextToRegIface(registers, reg_interface);
+  ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
+
+  const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
+
+  std::map reg_values;
+
+  // clang-format off
+  reg_values[lldb_rax_x86_64]=  0x;
+  reg_values[lldb_rbx_x86_64]=  0x;
+  reg_values[lldb_rcx_x86_64]=  0x0010;
+  reg_values[lldb_rdx_x86_64]=  0x;
+  reg_values[lldb_rdi_x86_64]=  0x7ffceb349cf0;
+  reg_values[lldb_rsi_x86_64]=  0x;
+  reg_values[lldb_rbp_x86_64]=  0x7ffceb34a210;
+  reg_values[lldb_rsp_x86_64]=  0x7ffceb34a210;
+  reg_values[lldb_r8_x86_64] =  0x7fe9bc1aa9c0;
+  reg_values[lldb_r9_x86_64] =  0x;
+  reg_values[lldb_r10_x86_64]=  0x7fe9bc3f16a0;
+  reg_values[lldb_r11_x86_64]=  0x0246;
+  reg_values[lldb_r12_x86_64]=  0x00401c92;
+  reg_values[lldb_r13_x86_64]=  0x7ffceb34a430;
+  reg_values[lldb_r14_x86_64]=  0x;
+  reg_values[lldb_r15_x86_64]=  0x;
+  reg_values[lldb_rip_x86_64]=  0x00401dc6;
+  reg_values[lldb_rflags_x86_64] =  0x00010206;
+  reg_values[lldb_cs_x86_64] =  0x0033;
+  reg_values[lldb_fs_x86_64] =  0x;
+  reg_values[lldb_gs_x86_64] =  0x;
+  reg_values[lldb_ss_x86_64] =  0x;
+  reg_values[lldb_ds_x86_64] =  0x;
+  reg_values[lldb_es_x86_64] =  0x;
+  // clang-format on
+
+  for (uint32_t reg_index = 0; reg_index < reg_interface->GetRegisterCount();
+   ++reg_index) {
+if (reg_values.find(reg_index) != reg_values.end()) {
+  EXPECT_EQ(reg_values[reg_index],
+REG_VAL(buf->GetBytes() + reg_info[reg_index].byte_offset));
+}
+  }
+}
Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
@@ -0,0 +1,119 @@
+//===-- RegisterContextMinidump_x86_64.h *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//

Re: [Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter

2016-09-27 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added inline comments.


Comment at: unittests/Process/minidump/MinidumpParserTest.cpp:177
@@ +176,3 @@
+#define REG_VAL(x) *(reinterpret_cast(x))
+
+TEST_F(MinidumpParserTest, ConvertRegisterContext) {

amccarth wrote:
> `EXPECT_xxx` will check the condition and report if it's wrong.  But then the 
> test proceeds.
> 
> `ASSERT_xxx` will check the condition, and, if it's wrong, it will report 
> _and_ terminate the current test.
> 
> So my rule of thumb is:
> 
> 1.  Prefer `EXPECT_xxx` when checking that the code does what it's supposed 
> to do.
> 2.  Use `ASSERT_xxx` when the rest of the test depends on this condition.
Thanks :)


https://reviews.llvm.org/D24919



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


Re: [Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter

2016-09-27 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added a comment.

Thanks for the explanation and examples! :) Will keep this in mind in the 
future.


https://reviews.llvm.org/D24919



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


Re: [Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter

2016-09-27 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 72659.
dvlahovski added a comment.

Addressing Zachary's and Adrian's comments


https://reviews.llvm.org/D24919

Files:
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -8,16 +8,19 @@
 //===--===//
 
 // Project includes
+#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
 #include "Plugins/Process/minidump/MinidumpParser.h"
 #include "Plugins/Process/minidump/MinidumpTypes.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
 
 // Other libraries and framework includes
 #include "gtest/gtest.h"
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Host/FileSpec.h"
 
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -50,7 +53,7 @@
 MinidumpParser::Create(data_sp);
 ASSERT_TRUE(optional_parser.hasValue());
 parser.reset(new MinidumpParser(optional_parser.getValue()));
-ASSERT_GT(parser->GetByteSize(), 0UL);
+ASSERT_GT(parser->GetData().size(), 0UL);
   }
 
   llvm::SmallString<128> inputs_folder;
@@ -167,3 +170,61 @@
   ASSERT_TRUE(pid.hasValue());
   ASSERT_EQ(4440UL, pid.getValue());
 }
+
+// Register stuff
+// TODO probably split register stuff tests into different file?
+#define REG_VAL(x) *(reinterpret_cast(x))
+
+TEST_F(MinidumpParserTest, ConvertRegisterContext) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::ArrayRef thread_list = parser->GetThreads();
+  const MinidumpThread thread = thread_list[0];
+  llvm::ArrayRef registers(parser->GetData().data() +
+thread.thread_context.rva,
+thread.thread_context.data_size);
+
+  ArchSpec arch = parser->GetArchitecture();
+  RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
+  lldb::DataBufferSP buf =
+  ConvertMinidumpContextToRegIface(registers, reg_interface);
+  ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
+
+  const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
+
+  std::map reg_values;
+
+  // clang-format off
+  reg_values[lldb_rax_x86_64]=  0x;
+  reg_values[lldb_rbx_x86_64]=  0x;
+  reg_values[lldb_rcx_x86_64]=  0x0010;
+  reg_values[lldb_rdx_x86_64]=  0x;
+  reg_values[lldb_rdi_x86_64]=  0x7ffceb349cf0;
+  reg_values[lldb_rsi_x86_64]=  0x;
+  reg_values[lldb_rbp_x86_64]=  0x7ffceb34a210;
+  reg_values[lldb_rsp_x86_64]=  0x7ffceb34a210;
+  reg_values[lldb_r8_x86_64] =  0x7fe9bc1aa9c0;
+  reg_values[lldb_r9_x86_64] =  0x;
+  reg_values[lldb_r10_x86_64]=  0x7fe9bc3f16a0;
+  reg_values[lldb_r11_x86_64]=  0x0246;
+  reg_values[lldb_r12_x86_64]=  0x00401c92;
+  reg_values[lldb_r13_x86_64]=  0x7ffceb34a430;
+  reg_values[lldb_r14_x86_64]=  0x;
+  reg_values[lldb_r15_x86_64]=  0x;
+  reg_values[lldb_rip_x86_64]=  0x00401dc6;
+  reg_values[lldb_rflags_x86_64] =  0x00010206;
+  reg_values[lldb_cs_x86_64] =  0x0033;
+  reg_values[lldb_fs_x86_64] =  0x;
+  reg_values[lldb_gs_x86_64] =  0x;
+  reg_values[lldb_ss_x86_64] =  0x;
+  reg_values[lldb_ds_x86_64] =  0x;
+  reg_values[lldb_es_x86_64] =  0x;
+  // clang-format on
+
+  for (uint32_t reg_index = 0; reg_index < reg_interface->GetRegisterCount();
+   ++reg_index) {
+if (reg_values.find(reg_index) != reg_values.end()) {
+  EXPECT_EQ(reg_values[reg_index],
+REG_VAL(buf->GetBytes() + reg_info[reg_index].byte_offset));
+}
+  }
+}
Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
@@ -0,0 +1,119 @@
+//===-- RegisterContextMinidump_x86_64.h *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===

Re: [Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter

2016-09-27 Thread Dimitar Vlahovski via lldb-commits
dvlahovski marked 5 inline comments as done.


Comment at: 
source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp:49
@@ +48,3 @@
+writeRegister(source_data, result_base, ®_info[lldb_cs_x86_64], 2);
+  }
+

zturner wrote:
> dvlahovski wrote:
> > sizeof(uint16_t), sizeof(uint32_t), etc ?
> I think my comments got out of line and this is no longer at the position I 
> suggested it.  that said, I actually didn't notice all these constants being 
> passed into `writeRegister`.  I would propose changing this.  Find the 
> `RegisterInfo` class in `lldb-private-types.h` and add the following methods:
> 
> ```
> llvm::ArrayRef data(const uint8_t *context_base) const { 
>   return llvm::ArrayRef(context_base + byte_offset, byte_size);
> }
> 
> llvm::MutableArrayRef mutable_data(uint8_t *context_base) const {
>   return llvm::MutableArrayRef(context_base + byte_offset, 
> byte_size);
> }
> ```
> 
> Then you can write:
> 
> ```writeRegister(source_data, 
> reg_info[lldb_cs_x86_64].mutable_data(result_base));```
This will make the code very clean indeed, but there is a problem.

From the `RegisterInfo` I only get the `byte_offset` and I don't use the 
`byte_size` because some of the registers in the Minidump context are smaller 
(e.g. cs is 16 bit). All of the registers in the Linux context are 64 bits in 
size. So that's why I basically hard-coded the size in each of the funciton 
calls. Now with the next revision I tried to make the code clearer.


Comment at: source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h:38
@@ +37,3 @@
+// - uint64_t p4_home
+// - uint64_t p5_home
+// - uint64_t p6_home

So I had the actual struct for the register context in the previous revision, 
but now I've removed it, because I actually don't use it. So added a comment 
describing it's layout.

For the endianness part -  because this code only permutes the bytes in the 
layout the Linux register context expects them, I don't think that here is the 
place to handle that. I was hoping that the Linux register context will handle 
it, but I don't think that's the case when I look at the code in 
`RegisterContextCorePOSIX_x86_64::ReadRegister`.

Am I right - do the Linux context assume little endian? If so maybe I can also 
fix that.


Comment at: unittests/Process/minidump/MinidumpParserTest.cpp:177
@@ +176,3 @@
+static void registerEqualToVal(const uint64_t val, uint8_t *reg_val) {
+  ASSERT_EQ(val, *(reinterpret_cast(reg_val)));
+}

amccarth wrote:
> +1 to Zach's idea.
> 
> Also, consider whether `EXPECT_EQ` is more appropriate than `ASSERT_EQ` for 
> these.
Probably `EXPECT_EQ` is better because if there is a mismatch in the reg 
values, one can see all of the values.

I still don't have the sense when to use `EXPECT_EQ` and when `ASSERT_EQ`.


https://reviews.llvm.org/D24919



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


Re: [Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter

2016-09-26 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added inline comments.


Comment at: 
source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp:47-48
@@ +46,4 @@
+
+  if (*context_flags & uint32_t(MinidumpContext_x86_64_Flags::Control)) {
+writeRegister(source_data, result_base, ®_info[lldb_cs_x86_64], 2);
+  }

amccarth wrote:
> dvlahovski wrote:
> > If it is then when I do a `&` the result is an enum class of type 
> > `MinidumpContext_x86_64_Flags`. And the compiler complains that this is not 
> > convertible to bool
> I think what Zach means is that you could locally define a uint32_t const, 
> initialized with the value from the enum.  Then each if statement could use 
> that constant without a cast.
> 
> Also, is this right?  `MinidumpContext_x86_x64_Flags::Control` has two bits 
> set, so the condition will be true if either of them is set.  Is that the 
> intended behavior?  Or should you be ensuring that they're both set like this:
> 
> const utin32_t ControlFlags = MinidumpContext_x86_64::Control;
> if ((*context_flags & ControlFlags) == ControlFlags) {
>   ...
> }
> 
> ?
Now that I think about I should check the arch flag bit at the beggining of 
this.
But then this if's are OK I think - in them I only want to check if that 
specific bit is set.


https://reviews.llvm.org/D24919



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


Re: [Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter

2016-09-26 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added inline comments.


Comment at: 
source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp:49
@@ +48,3 @@
+writeRegister(source_data, result_base, ®_info[lldb_cs_x86_64], 2);
+  }
+

sizeof(uint16_t), sizeof(uint32_t), etc ?


https://reviews.llvm.org/D24919



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


Re: [Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter

2016-09-26 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added inline comments.


Comment at: 
source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp:47-48
@@ +46,4 @@
+
+  if (*context_flags & uint32_t(MinidumpContext_x86_64_Flags::Control)) {
+writeRegister(source_data, result_base, ®_info[lldb_cs_x86_64], 2);
+  }

If it is then when I do a `&` the result is an enum class of type 
`MinidumpContext_x86_64_Flags`. And the compiler complains that this is not 
convertible to bool


https://reviews.llvm.org/D24919



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


Re: [Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter

2016-09-26 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added a comment.

I will fix the comments that Zachary made in the next revision


https://reviews.llvm.org/D24919



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


Re: [Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter

2016-09-26 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 72509.
dvlahovski marked 4 inline comments as done.
dvlahovski added a comment.

Updating the CL regarding Pavel's comments


https://reviews.llvm.org/D24919

Files:
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -8,16 +8,19 @@
 //===--===//
 
 // Project includes
+#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
 #include "Plugins/Process/minidump/MinidumpParser.h"
 #include "Plugins/Process/minidump/MinidumpTypes.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
 
 // Other libraries and framework includes
 #include "gtest/gtest.h"
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Host/FileSpec.h"
 
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -50,7 +53,7 @@
 MinidumpParser::Create(data_sp);
 ASSERT_TRUE(optional_parser.hasValue());
 parser.reset(new MinidumpParser(optional_parser.getValue()));
-ASSERT_GT(parser->GetByteSize(), 0UL);
+ASSERT_GT(parser->GetData().size(), 0UL);
   }
 
   llvm::SmallString<128> inputs_folder;
@@ -167,3 +170,63 @@
   ASSERT_TRUE(pid.hasValue());
   ASSERT_EQ(4440UL, pid.getValue());
 }
+
+// Register stuff
+// TODO probably split register stuff tests into different file?
+static void registerEqualToVal(const uint64_t val, uint8_t *reg_val) {
+  ASSERT_EQ(val, *(reinterpret_cast(reg_val)));
+}
+
+TEST_F(MinidumpParserTest, ConvertRegisterContext) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::ArrayRef thread_list = parser->GetThreads();
+  const MinidumpThread thread = thread_list[0];
+  llvm::ArrayRef registers(parser->GetData().data() +
+thread.thread_context.rva,
+thread.thread_context.data_size);
+
+  ArchSpec arch = parser->GetArchitecture();
+  RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
+  lldb::DataBufferSP buf =
+  ConvertMinidumpContextToRegIface(registers, reg_interface);
+  ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
+
+  const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
+
+  std::map reg_values;
+
+  // clang-format off
+  reg_values[lldb_rax_x86_64]=  0x;
+  reg_values[lldb_rbx_x86_64]=  0x;
+  reg_values[lldb_rcx_x86_64]=  0x0010;
+  reg_values[lldb_rdx_x86_64]=  0x;
+  reg_values[lldb_rdi_x86_64]=  0x7ffceb349cf0;
+  reg_values[lldb_rsi_x86_64]=  0x;
+  reg_values[lldb_rbp_x86_64]=  0x7ffceb34a210;
+  reg_values[lldb_rsp_x86_64]=  0x7ffceb34a210;
+  reg_values[lldb_r8_x86_64] =  0x7fe9bc1aa9c0;
+  reg_values[lldb_r9_x86_64] =  0x;
+  reg_values[lldb_r10_x86_64]=  0x7fe9bc3f16a0;
+  reg_values[lldb_r11_x86_64]=  0x0246;
+  reg_values[lldb_r12_x86_64]=  0x00401c92;
+  reg_values[lldb_r13_x86_64]=  0x7ffceb34a430;
+  reg_values[lldb_r14_x86_64]=  0x;
+  reg_values[lldb_r15_x86_64]=  0x;
+  reg_values[lldb_rip_x86_64]=  0x00401dc6;
+  reg_values[lldb_rflags_x86_64] =  0x00010206;
+  reg_values[lldb_cs_x86_64] =  0x0033;
+  reg_values[lldb_fs_x86_64] =  0x;
+  reg_values[lldb_gs_x86_64] =  0x;
+  reg_values[lldb_ss_x86_64] =  0x;
+  reg_values[lldb_ds_x86_64] =  0x;
+  reg_values[lldb_es_x86_64] =  0x;
+  // clang-format on
+
+  for (uint32_t reg_index = 0; reg_index < reg_interface->GetRegisterCount();
+   ++reg_index) {
+if (reg_values.find(reg_index) != reg_values.end()) {
+  registerEqualToVal(reg_values[reg_index],
+ buf->GetBytes() + reg_info[reg_index].byte_offset);
+}
+  }
+}
Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
@@ -0,0 +1,114 @@
+//===-- Registers_x86_64.h --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the Univ

Re: [Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter

2016-09-26 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added a comment.

I tested this on the yet-to-be-submitted plugin code and it works fine on Linux 
(should work fine everywhere for that matter). I can do a backtrace, go up/down 
the stack frames and, of course, see all of the registers with `register read`


https://reviews.llvm.org/D24919



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


[Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter

2016-09-26 Thread Dimitar Vlahovski via lldb-commits
dvlahovski created this revision.
dvlahovski added reviewers: labath, zturner.
dvlahovski added subscribers: amccarth, lldb-commits.
Herald added subscribers: mgorny, beanz.

This is a register context converter from Minidump to Linux reg context.
This knows the layout of the register context in the Minidump file
(which is the same as in Windows FYI) and as a result emits a binary data
buffer that matches the Linux register context binary layout.
This way we can reuse the existing RegisterContextLinux_x86_64 and
RegisterContextCorePOSIX_x86_64 classes.

https://reviews.llvm.org/D24919

Files:
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -8,16 +8,19 @@
 //===--===//
 
 // Project includes
+#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
 #include "Plugins/Process/minidump/MinidumpParser.h"
 #include "Plugins/Process/minidump/MinidumpTypes.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
 
 // Other libraries and framework includes
 #include "gtest/gtest.h"
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Host/FileSpec.h"
 
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -167,3 +170,63 @@
   ASSERT_TRUE(pid.hasValue());
   ASSERT_EQ(4440UL, pid.getValue());
 }
+
+// Register stuff
+// TODO probably split register stuff tests into different file?
+void registerEqualToVal(const uint64_t val, uint8_t *reg_val) {
+  ASSERT_EQ(val, *(reinterpret_cast(reg_val)));
+}
+
+TEST_F(MinidumpParserTest, ConvertRegisterContext) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::ArrayRef thread_list = parser->GetThreads();
+  const MinidumpThread thread = thread_list[0];
+  llvm::ArrayRef registers(parser->GetBaseAddr() +
+thread.thread_context.rva,
+thread.thread_context.data_size);
+
+  ArchSpec arch = parser->GetArchitecture();
+  RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
+  lldb::DataBufferSP buf =
+  MinidumpContext_x86_64::Convert(registers, reg_interface);
+  ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
+
+  const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
+
+  std::map reg_values;
+
+  // clang-format off
+  reg_values[lldb_rax_x86_64]=  0x;
+  reg_values[lldb_rbx_x86_64]=  0x;
+  reg_values[lldb_rcx_x86_64]=  0x0010;
+  reg_values[lldb_rdx_x86_64]=  0x;
+  reg_values[lldb_rdi_x86_64]=  0x7ffceb349cf0;
+  reg_values[lldb_rsi_x86_64]=  0x;
+  reg_values[lldb_rbp_x86_64]=  0x7ffceb34a210;
+  reg_values[lldb_rsp_x86_64]=  0x7ffceb34a210;
+  reg_values[lldb_r8_x86_64] =  0x7fe9bc1aa9c0;
+  reg_values[lldb_r9_x86_64] =  0x;
+  reg_values[lldb_r10_x86_64]=  0x7fe9bc3f16a0;
+  reg_values[lldb_r11_x86_64]=  0x0246;
+  reg_values[lldb_r12_x86_64]=  0x00401c92;
+  reg_values[lldb_r13_x86_64]=  0x7ffceb34a430;
+  reg_values[lldb_r14_x86_64]=  0x;
+  reg_values[lldb_r15_x86_64]=  0x;
+  reg_values[lldb_rip_x86_64]=  0x00401dc6;
+  reg_values[lldb_rflags_x86_64] =  0x00010206;
+  reg_values[lldb_cs_x86_64] =  0x0033;
+  reg_values[lldb_fs_x86_64] =  0x;
+  reg_values[lldb_gs_x86_64] =  0x;
+  reg_values[lldb_ss_x86_64] =  0x;
+  reg_values[lldb_ds_x86_64] =  0x;
+  reg_values[lldb_es_x86_64] =  0x;
+  // clang-format on
+
+  for (uint32_t reg_index = 0; reg_index < reg_interface->GetRegisterCount();
+   ++reg_index) {
+if (reg_values.find(reg_index) != reg_values.end()) {
+  registerEqualToVal(reg_values[reg_index],
+ buf->GetBytes() + reg_info[reg_index].byte_offset);
+}
+  }
+}
Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
@@ -0,0 +1,189 @@
+//===-- Registers_x86_64.h --*- C++ -*-===//
+//
+// The LLVM C

[Lldb-commits] [lldb] r281606 - Reformat x86_64 register infos defines table

2016-09-15 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Thu Sep 15 07:58:27 2016
New Revision: 281606

URL: http://llvm.org/viewvc/llvm-project?rev=281606&view=rev
Log:
Reformat x86_64 register infos defines table

Fix the table format of the register defines after clang-format.
Added guards to prevent future reformatting again from clang-format.

Modified:
lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_x86_64.h

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_x86_64.h?rev=281606&r1=281605&r2=281606&view=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_x86_64.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_x86_64.h Thu Sep 15 
07:58:27 2016
@@ -196,57 +196,34 @@
 RegisterContextPOSIX_x86::g_invalidate_##reg64, NULL, 0
\
   }
 
+// clang-format off
 static RegisterInfo g_register_infos_x86_64[] = {
-// General purpose registers.   EH_Frame,   DWARF,
-// Generic,Process Plugin
-DEFINE_GPR(rax, nullptr, dwarf_rax_x86_64, dwarf_rax_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-DEFINE_GPR(rbx, nullptr, dwarf_rbx_x86_64, dwarf_rbx_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-DEFINE_GPR(rcx, "arg4", dwarf_rcx_x86_64, dwarf_rcx_x86_64,
-   LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
-DEFINE_GPR(rdx, "arg3", dwarf_rdx_x86_64, dwarf_rdx_x86_64,
-   LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
-DEFINE_GPR(rdi, "arg1", dwarf_rdi_x86_64, dwarf_rdi_x86_64,
-   LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
-DEFINE_GPR(rsi, "arg2", dwarf_rsi_x86_64, dwarf_rsi_x86_64,
-   LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
-DEFINE_GPR(rbp, "fp", dwarf_rbp_x86_64, dwarf_rbp_x86_64,
-   LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
-DEFINE_GPR(rsp, "sp", dwarf_rsp_x86_64, dwarf_rsp_x86_64,
-   LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
-DEFINE_GPR(r8, "arg5", dwarf_r8_x86_64, dwarf_r8_x86_64,
-   LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM),
-DEFINE_GPR(r9, "arg6", dwarf_r9_x86_64, dwarf_r9_x86_64,
-   LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM),
-DEFINE_GPR(r10, nullptr, dwarf_r10_x86_64, dwarf_r10_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-DEFINE_GPR(r11, nullptr, dwarf_r11_x86_64, dwarf_r11_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-DEFINE_GPR(r12, nullptr, dwarf_r12_x86_64, dwarf_r12_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-DEFINE_GPR(r13, nullptr, dwarf_r13_x86_64, dwarf_r13_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-DEFINE_GPR(r14, nullptr, dwarf_r14_x86_64, dwarf_r14_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-DEFINE_GPR(r15, nullptr, dwarf_r15_x86_64, dwarf_r15_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-DEFINE_GPR(rip, "pc", dwarf_rip_x86_64, dwarf_rip_x86_64,
-   LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
-DEFINE_GPR(rflags, "flags", dwarf_rflags_x86_64, dwarf_rflags_x86_64,
-   LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
-DEFINE_GPR(cs, nullptr, dwarf_cs_x86_64, dwarf_cs_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-DEFINE_GPR(fs, nullptr, dwarf_fs_x86_64, dwarf_fs_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-DEFINE_GPR(gs, nullptr, dwarf_gs_x86_64, dwarf_gs_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-DEFINE_GPR(ss, nullptr, dwarf_ss_x86_64, dwarf_ss_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-DEFINE_GPR(ds, nullptr, dwarf_ds_x86_64, dwarf_ds_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-DEFINE_GPR(es, nullptr, dwarf_es_x86_64, dwarf_es_x86_64,
-   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+// General purpose registers EH_Frame  DWARF 
Generic Process Plugin
+//  ===  ==  
=   
+DEFINE_GPR(rax,nullptr,  dwarf_rax_x86_64, dwarf_rax_x86_64, 
LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM),
+DEFINE_GPR(rbx,nullptr,  dwarf_rbx_x86_64, dwarf_rbx_x86_64, 
LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM),
+DEFINE_GPR(rcx,"arg4",   dwarf_rcx_x86_64, dwarf_rcx_x86_64, 
LLDB_REGNUM_GENERIC_ARG4,   LLDB_INVALID_REGNUM),
+DEFINE_GPR(rdx,"arg3",   dwarf_rdx_x86_64, dwarf_rdx_x86_64, 
LLDB_REGNUM_GENERIC_ARG3,   LLDB_INVALID_REGNUM),
+DEFINE_GPR(rdi,"arg1",

[Lldb-commits] [lldb] r281349 - Fix a merge mishap in rL281348

2016-09-13 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Tue Sep 13 11:22:15 2016
New Revision: 281349

URL: http://llvm.org/viewvc/llvm-project?rev=281349&view=rev
Log:
Fix a merge mishap in rL281348

Modified:
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp

Modified: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp?rev=281349&r1=281348&r2=281349&view=diff
==
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp Tue Sep 13 
11:22:15 2016
@@ -141,8 +141,6 @@ ArchSpec MinidumpParser::GetArchitecture
   default:
 triple.setArch(llvm::Triple::ArchType::UnknownArch);
 break;
-  default:
-break;
   }
 
   const MinidumpOSPlatform os = static_cast(


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


Re: [Lldb-commits] [PATCH] D24385: MinidumpParsing: pid, modules, exceptions

2016-09-13 Thread Dimitar Vlahovski via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281348: MinidumpParsing: pid, modules, exceptions, strings 
(authored by dvlahovski).

Changed prior to commit:
  https://reviews.llvm.org/D24385?vs=71154&id=71182#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24385

Files:
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
  lldb/trunk/unittests/Process/minidump/CMakeLists.txt
  lldb/trunk/unittests/Process/minidump/Inputs/fizzbuzz_no_heap.dmp
  lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Index: lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -59,33 +59,111 @@
 
 TEST_F(MinidumpParserTest, GetThreads) {
   SetUpData("linux-x86_64.dmp");
-  llvm::Optional> thread_list;
+  llvm::ArrayRef thread_list;
 
   thread_list = parser->GetThreads();
-  ASSERT_TRUE(thread_list.hasValue());
-  ASSERT_EQ(1UL, thread_list->size());
+  ASSERT_EQ(1UL, thread_list.size());
 
-  const MinidumpThread *thread = thread_list.getValue()[0];
-  ASSERT_EQ(16001UL, thread->thread_id);
+  const MinidumpThread thread = thread_list[0];
+  ASSERT_EQ(16001UL, thread.thread_id);
 }
 
 TEST_F(MinidumpParserTest, GetThreadsTruncatedFile) {
   SetUpData("linux-x86_64.dmp", 200);
-  llvm::Optional> thread_list;
+  llvm::ArrayRef thread_list;
 
   thread_list = parser->GetThreads();
-  ASSERT_FALSE(thread_list.hasValue());
+  ASSERT_EQ(0UL, thread_list.size());
 }
 
 TEST_F(MinidumpParserTest, GetArchitecture) {
   SetUpData("linux-x86_64.dmp");
   ASSERT_EQ(llvm::Triple::ArchType::x86_64,
-parser->GetArchitecture().GetTriple().getArch());
+parser->GetArchitecture().GetMachine());
+  ASSERT_EQ(llvm::Triple::OSType::Linux,
+parser->GetArchitecture().GetTriple().getOS());
 }
 
 TEST_F(MinidumpParserTest, GetMiscInfo) {
   SetUpData("linux-x86_64.dmp");
   const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
   ASSERT_EQ(nullptr, misc_info);
-  // linux breakpad generated minidump files don't have misc info stream
+}
+
+TEST_F(MinidumpParserTest, GetLinuxProcStatus) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional proc_status = parser->GetLinuxProcStatus();
+  ASSERT_TRUE(proc_status.hasValue());
+  lldb::pid_t pid = proc_status->GetPid();
+  ASSERT_EQ(16001UL, pid);
+}
+
+TEST_F(MinidumpParserTest, GetPid) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(16001UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetModuleList) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  ASSERT_EQ(8UL, modules.size());
+  std::string module_names[8] = {
+  "/usr/local/google/home/dvlahovski/projects/test_breakpad/a.out",
+  "/lib/x86_64-linux-gnu/libm-2.19.so",
+  "/lib/x86_64-linux-gnu/libc-2.19.so",
+  "/lib/x86_64-linux-gnu/libgcc_s.so.1",
+  "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19",
+  "/lib/x86_64-linux-gnu/libpthread-2.19.so",
+  "/lib/x86_64-linux-gnu/ld-2.19.so",
+  "linux-gate.so",
+  };
+
+  for (int i = 0; i < 8; ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(modules[i].module_name_rva);
+ASSERT_TRUE(name.hasValue());
+ASSERT_EQ(module_names[i], name.getValue());
+  }
+}
+
+TEST_F(MinidumpParserTest, GetExceptionStream) {
+  SetUpData("linux-x86_64.dmp");
+  const MinidumpExceptionStream *exception_stream =
+  parser->GetExceptionStream();
+  ASSERT_NE(nullptr, exception_stream);
+  ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
+}
+
+// Windows Minidump tests
+// fizzbuzz_no_heap.dmp is copied from the WinMiniDump tests
+TEST_F(MinidumpParserTest, GetArchitectureWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  ASSERT_EQ(llvm::Triple::ArchType::x86,
+parser->GetArchitecture().GetMachine());
+  ASSERT_EQ(llvm::Triple::OSType::Win32,
+parser->GetArchitecture().GetTriple().getOS());
+}
+
+TEST_F(MinidumpParserTest, GetLinuxProcStatusWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  llvm::Optional proc_status = parser->GetLinuxProcStatus();
+  ASSERT_FALSE(proc_status.hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetMiscInfoWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
+  ASSERT_NE(nullptr, misc_info);
+  llvm::Optional pid = misc_info->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(4440UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetPidWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  llvm::Optional pid = parser->

[Lldb-commits] [lldb] r281348 - MinidumpParsing: pid, modules, exceptions, strings

2016-09-13 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Tue Sep 13 10:54:38 2016
New Revision: 281348

URL: http://llvm.org/viewvc/llvm-project?rev=281348&view=rev
Log:
MinidumpParsing: pid, modules, exceptions, strings

Summary:
Added parsing of the MiscInfo data stream.
The main member of it that we care about is the process_id
On Linux generated Minidump (from breakpad) we don't have
the MiscInfo, we have the /proc/$pid/status from where we can get the
pid.
Also parsing the module list - the list of all of the loaded
modules/shared libraries.
Parsing the exception stream.
Parsing MinidumpStrings.

I have unit tests for all of that.
Also added some tests using a Minidump generated from Windows tools (not
from breakpad)

Reviewers: labath, zturner

Subscribers: beanz, lldb-commits

Differential Revision: https://reviews.llvm.org/D24385

Added:
lldb/trunk/unittests/Process/minidump/Inputs/fizzbuzz_no_heap.dmp
Modified:
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
lldb/trunk/unittests/Process/minidump/CMakeLists.txt
lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Modified: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp?rev=281348&r1=281347&r2=281348&view=diff
==
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp Tue Sep 13 
10:54:38 2016
@@ -1,5 +1,4 @@
-//===-- MinidumpParser.cpp ---*- C++
-//-*-===//
+//===-- MinidumpParser.cpp ---*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -56,13 +55,12 @@ MinidumpParser::Create(const lldb::DataB
 directory->location;
   }
 
-  MinidumpParser parser(data_buf_sp, header, directory_map);
-  return llvm::Optional(parser);
+  return MinidumpParser(data_buf_sp, header, std::move(directory_map));
 }
 
 MinidumpParser::MinidumpParser(
 const lldb::DataBufferSP &data_buf_sp, const MinidumpHeader *header,
-const llvm::DenseMap &directory_map)
+llvm::DenseMap &&directory_map)
 : m_data_sp(data_buf_sp), m_header(header), m_directory_map(directory_map) 
{
 }
 
@@ -70,50 +68,48 @@ lldb::offset_t MinidumpParser::GetByteSi
   return m_data_sp->GetByteSize();
 }
 
-llvm::Optional>
+llvm::ArrayRef
 MinidumpParser::GetStream(MinidumpStreamType stream_type) {
   auto iter = m_directory_map.find(static_cast(stream_type));
   if (iter == m_directory_map.end())
-return llvm::None;
+return {};
 
   // check if there is enough data
   if (iter->second.rva + iter->second.data_size > m_data_sp->GetByteSize())
-return llvm::None;
+return {};
+
+  return llvm::ArrayRef(m_data_sp->GetBytes() + iter->second.rva,
+ iter->second.data_size);
+}
 
-  llvm::ArrayRef arr_ref(m_data_sp->GetBytes() + iter->second.rva,
-  iter->second.data_size);
-  return llvm::Optional>(arr_ref);
+llvm::Optional MinidumpParser::GetMinidumpString(uint32_t rva) {
+  auto arr_ref = m_data_sp->GetData();
+  if (rva > arr_ref.size())
+return llvm::None;
+  arr_ref = arr_ref.drop_front(rva);
+  return parseMinidumpString(arr_ref);
 }
 
-llvm::Optional>
-MinidumpParser::GetThreads() {
-  llvm::Optional> data =
-  GetStream(MinidumpStreamType::ThreadList);
+llvm::ArrayRef MinidumpParser::GetThreads() {
+  llvm::ArrayRef data = GetStream(MinidumpStreamType::ThreadList);
 
-  if (!data)
+  if (data.size() == 0)
 return llvm::None;
 
-  return MinidumpThread::ParseThreadList(data.getValue());
+  return MinidumpThread::ParseThreadList(data);
 }
 
 const MinidumpSystemInfo *MinidumpParser::GetSystemInfo() {
-  llvm::Optional> data =
-  GetStream(MinidumpStreamType::SystemInfo);
+  llvm::ArrayRef data = GetStream(MinidumpStreamType::SystemInfo);
 
-  if (!data)
+  if (data.size() == 0)
 return nullptr;
 
-  return MinidumpSystemInfo::Parse(data.getValue());
+  return MinidumpSystemInfo::Parse(data);
 }
 
 ArchSpec MinidumpParser::GetArchitecture() {
   ArchSpec arch_spec;
-  arch_spec.GetTriple().setOS(llvm::Triple::OSType::UnknownOS);
-  arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::UnknownVendor);
-  arch_spec.GetTriple().setArch(llvm::Triple::ArchType::UnknownArch);
-
-  // TODO should we add the OS type here, or somewhere else ?
-
   const MinidumpSystemInfo *system_info = GetSystemInfo();
 
   if (!system_info)
@@ -122,35 +118,110 @@ ArchSpec MinidumpParser::GetArchitecture
   // TODO what to do about big endiand flavors of arm ?
   // TODO set the arm subarch stuff if the minidump has info about it
 
+

Re: [Lldb-commits] [PATCH] D24385: MinidumpParsing: pid, modules, exceptions

2016-09-13 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 71154.
dvlahovski added a comment.

Making the LinuxProcStatus a smarter class

by not parsing the pid each time when GetPid is called


https://reviews.llvm.org/D24385

Files:
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/fizzbuzz_no_heap.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -59,33 +59,111 @@
 
 TEST_F(MinidumpParserTest, GetThreads) {
   SetUpData("linux-x86_64.dmp");
-  llvm::Optional> thread_list;
+  llvm::ArrayRef thread_list;
 
   thread_list = parser->GetThreads();
-  ASSERT_TRUE(thread_list.hasValue());
-  ASSERT_EQ(1UL, thread_list->size());
+  ASSERT_EQ(1UL, thread_list.size());
 
-  const MinidumpThread *thread = thread_list.getValue()[0];
-  ASSERT_EQ(16001UL, thread->thread_id);
+  const MinidumpThread thread = thread_list[0];
+  ASSERT_EQ(16001UL, thread.thread_id);
 }
 
 TEST_F(MinidumpParserTest, GetThreadsTruncatedFile) {
   SetUpData("linux-x86_64.dmp", 200);
-  llvm::Optional> thread_list;
+  llvm::ArrayRef thread_list;
 
   thread_list = parser->GetThreads();
-  ASSERT_FALSE(thread_list.hasValue());
+  ASSERT_EQ(0UL, thread_list.size());
 }
 
 TEST_F(MinidumpParserTest, GetArchitecture) {
   SetUpData("linux-x86_64.dmp");
   ASSERT_EQ(llvm::Triple::ArchType::x86_64,
-parser->GetArchitecture().GetTriple().getArch());
+parser->GetArchitecture().GetMachine());
+  ASSERT_EQ(llvm::Triple::OSType::Linux,
+parser->GetArchitecture().GetTriple().getOS());
 }
 
 TEST_F(MinidumpParserTest, GetMiscInfo) {
   SetUpData("linux-x86_64.dmp");
   const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
   ASSERT_EQ(nullptr, misc_info);
-  // linux breakpad generated minidump files don't have misc info stream
+}
+
+TEST_F(MinidumpParserTest, GetLinuxProcStatus) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional proc_status = parser->GetLinuxProcStatus();
+  ASSERT_TRUE(proc_status.hasValue());
+  lldb::pid_t pid = proc_status->GetPid();
+  ASSERT_EQ(16001UL, pid);
+}
+
+TEST_F(MinidumpParserTest, GetPid) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(16001UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetModuleList) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  ASSERT_EQ(8UL, modules.size());
+  std::string module_names[8] = {
+  "/usr/local/google/home/dvlahovski/projects/test_breakpad/a.out",
+  "/lib/x86_64-linux-gnu/libm-2.19.so",
+  "/lib/x86_64-linux-gnu/libc-2.19.so",
+  "/lib/x86_64-linux-gnu/libgcc_s.so.1",
+  "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19",
+  "/lib/x86_64-linux-gnu/libpthread-2.19.so",
+  "/lib/x86_64-linux-gnu/ld-2.19.so",
+  "linux-gate.so",
+  };
+
+  for (int i = 0; i < 8; ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(modules[i].module_name_rva);
+ASSERT_TRUE(name.hasValue());
+ASSERT_EQ(module_names[i], name.getValue());
+  }
+}
+
+TEST_F(MinidumpParserTest, GetExceptionStream) {
+  SetUpData("linux-x86_64.dmp");
+  const MinidumpExceptionStream *exception_stream =
+  parser->GetExceptionStream();
+  ASSERT_NE(nullptr, exception_stream);
+  ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
+}
+
+// Windows Minidump tests
+// fizzbuzz_no_heap.dmp is copied from the WinMiniDump tests
+TEST_F(MinidumpParserTest, GetArchitectureWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  ASSERT_EQ(llvm::Triple::ArchType::x86,
+parser->GetArchitecture().GetMachine());
+  ASSERT_EQ(llvm::Triple::OSType::Win32,
+parser->GetArchitecture().GetTriple().getOS());
+}
+
+TEST_F(MinidumpParserTest, GetLinuxProcStatusWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  llvm::Optional proc_status = parser->GetLinuxProcStatus();
+  ASSERT_FALSE(proc_status.hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetMiscInfoWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
+  ASSERT_NE(nullptr, misc_info);
+  llvm::Optional pid = misc_info->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(4440UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetPidWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(4440UL, pid.getValue());
 }
Index: unittests/Process/minidump/CMakeLists.txt
===
--- unittests/Pro

Re: [Lldb-commits] [PATCH] D24385: MinidumpParsing: pid, modules, exceptions

2016-09-13 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 71151.
dvlahovski marked 3 inline comments as done.
dvlahovski added a comment.

Removed consumeString; Fixed comparisons in unittests; out-of-bounds check in 
MinidumpString parsing


https://reviews.llvm.org/D24385

Files:
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/fizzbuzz_no_heap.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -59,33 +59,112 @@
 
 TEST_F(MinidumpParserTest, GetThreads) {
   SetUpData("linux-x86_64.dmp");
-  llvm::Optional> thread_list;
+  llvm::ArrayRef thread_list;
 
   thread_list = parser->GetThreads();
-  ASSERT_TRUE(thread_list.hasValue());
-  ASSERT_EQ(1UL, thread_list->size());
+  ASSERT_EQ(1UL, thread_list.size());
 
-  const MinidumpThread *thread = thread_list.getValue()[0];
-  ASSERT_EQ(16001UL, thread->thread_id);
+  const MinidumpThread thread = thread_list[0];
+  ASSERT_EQ(16001UL, thread.thread_id);
 }
 
 TEST_F(MinidumpParserTest, GetThreadsTruncatedFile) {
   SetUpData("linux-x86_64.dmp", 200);
-  llvm::Optional> thread_list;
+  llvm::ArrayRef thread_list;
 
   thread_list = parser->GetThreads();
-  ASSERT_FALSE(thread_list.hasValue());
+  ASSERT_EQ(0UL, thread_list.size());
 }
 
 TEST_F(MinidumpParserTest, GetArchitecture) {
   SetUpData("linux-x86_64.dmp");
   ASSERT_EQ(llvm::Triple::ArchType::x86_64,
-parser->GetArchitecture().GetTriple().getArch());
+parser->GetArchitecture().GetMachine());
+  ASSERT_EQ(llvm::Triple::OSType::Linux,
+parser->GetArchitecture().GetTriple().getOS());
 }
 
 TEST_F(MinidumpParserTest, GetMiscInfo) {
   SetUpData("linux-x86_64.dmp");
   const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
   ASSERT_EQ(nullptr, misc_info);
-  // linux breakpad generated minidump files don't have misc info stream
+}
+
+TEST_F(MinidumpParserTest, GetLinuxProcStatus) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional proc_status = parser->GetLinuxProcStatus();
+  ASSERT_TRUE(proc_status.hasValue());
+  llvm::Optional pid = proc_status->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(16001UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetPid) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(16001UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetModuleList) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  ASSERT_EQ(8UL, modules.size());
+  std::string module_names[8] = {
+  "/usr/local/google/home/dvlahovski/projects/test_breakpad/a.out",
+  "/lib/x86_64-linux-gnu/libm-2.19.so",
+  "/lib/x86_64-linux-gnu/libc-2.19.so",
+  "/lib/x86_64-linux-gnu/libgcc_s.so.1",
+  "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19",
+  "/lib/x86_64-linux-gnu/libpthread-2.19.so",
+  "/lib/x86_64-linux-gnu/ld-2.19.so",
+  "linux-gate.so",
+  };
+
+  for (int i = 0; i < 8; ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(modules[i].module_name_rva);
+ASSERT_TRUE(name.hasValue());
+ASSERT_EQ(module_names[i], name.getValue());
+  }
+}
+
+TEST_F(MinidumpParserTest, GetExceptionStream) {
+  SetUpData("linux-x86_64.dmp");
+  const MinidumpExceptionStream *exception_stream =
+  parser->GetExceptionStream();
+  ASSERT_NE(nullptr, exception_stream);
+  ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
+}
+
+// Windows Minidump tests
+// fizzbuzz_no_heap.dmp is copied from the WinMiniDump tests
+TEST_F(MinidumpParserTest, GetArchitectureWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  ASSERT_EQ(llvm::Triple::ArchType::x86,
+parser->GetArchitecture().GetMachine());
+  ASSERT_EQ(llvm::Triple::OSType::Win32,
+parser->GetArchitecture().GetTriple().getOS());
+}
+
+TEST_F(MinidumpParserTest, GetLinuxProcStatusWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  llvm::Optional proc_status = parser->GetLinuxProcStatus();
+  ASSERT_FALSE(proc_status.hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetMiscInfoWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
+  ASSERT_NE(nullptr, misc_info);
+  llvm::Optional pid = misc_info->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(4440UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetPidWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(4440UL, pid.getValue());
 }
Index: unittests/Process/minidump/CMakeL

Re: [Lldb-commits] [PATCH] D24385: MinidumpParsing: pid, modules, exceptions

2016-09-12 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added inline comments.


Comment at: source/Plugins/Process/minidump/MinidumpParser.cpp:222
@@ -154,1 +221,2 @@
+  return MinidumpExceptionStream::Parse(data);
 }

Now that I return an ArrayRef, which is basically a reinterpret 
cast of a piece of memory to a list of modules, do you think that this is still 
something good to do?

At least for now, I'm calling this method only once in the DoLoadCore 
initializing method of the plugin (still unsubmitted code) and then creating 
the ModuleSpecs for each module.


Comment at: source/Plugins/Process/minidump/MinidumpParser.h:46
@@ -45,2 +45,3 @@
 
-  llvm::Optional> GetThreads();
+  llvm::Optional GetMinidumpString(uint32_t rva);
+

Specifically for the string - I think it's best to return 
llvm::Optional in order to distinguish between empty string and 
error. And there are some conditions that need to be met for the string to 
parsed correctly.


Comment at: source/Plugins/Process/minidump/MinidumpParser.h:60
@@ +59,3 @@
+
+  llvm::ArrayRef GetModuleList();
+

I am returning an ArrayRef. The Modules are consecutive in 
memory so this seemed like a good idea


Comment at: source/Plugins/Process/minidump/MinidumpTypes.cpp:21
@@ +20,3 @@
+llvm::StringRef
+lldb_private::minidump::consumeString(llvm::ArrayRef &Buffer) {
+  auto str = llvm::StringRef(reinterpret_cast(Buffer.data()),

So, breakpad specific string in the Minidump files are not UTF-16 string, but 
just ascii strings in the file (not null terminated).
When I get the stream "LinuxProcStatus" I know how big it is and set it in the 
ArrayRef.
So basically it is my intention here to parse the entire ArrayRef to a string


https://reviews.llvm.org/D24385



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


Re: [Lldb-commits] [PATCH] D24385: MinidumpParsing: pid, modules, exceptions

2016-09-12 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 71026.
dvlahovski marked 17 inline comments as done.
dvlahovski added a comment.
Herald added subscribers: mgorny, srhines, danalbert, tberghammer.

Changes regarding all of the comments.

Removed llvm::Optionals where it was unneeded.
Parsing also the OS from the Minidump.

Refined old and added new test cases.


https://reviews.llvm.org/D24385

Files:
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/fizzbuzz_no_heap.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -59,33 +59,112 @@
 
 TEST_F(MinidumpParserTest, GetThreads) {
   SetUpData("linux-x86_64.dmp");
-  llvm::Optional> thread_list;
+  llvm::ArrayRef thread_list;
 
   thread_list = parser->GetThreads();
-  ASSERT_TRUE(thread_list.hasValue());
-  ASSERT_EQ(1UL, thread_list->size());
+  ASSERT_EQ(1UL, thread_list.size());
 
-  const MinidumpThread *thread = thread_list.getValue()[0];
-  ASSERT_EQ(16001UL, thread->thread_id);
+  const MinidumpThread thread = thread_list[0];
+  ASSERT_EQ(16001UL, thread.thread_id);
 }
 
 TEST_F(MinidumpParserTest, GetThreadsTruncatedFile) {
   SetUpData("linux-x86_64.dmp", 200);
-  llvm::Optional> thread_list;
+  llvm::ArrayRef thread_list;
 
   thread_list = parser->GetThreads();
-  ASSERT_FALSE(thread_list.hasValue());
+  ASSERT_TRUE(thread_list.size() == 0);
 }
 
 TEST_F(MinidumpParserTest, GetArchitecture) {
   SetUpData("linux-x86_64.dmp");
   ASSERT_EQ(llvm::Triple::ArchType::x86_64,
-parser->GetArchitecture().GetTriple().getArch());
+parser->GetArchitecture().GetMachine());
+  ASSERT_EQ(llvm::Triple::OSType::Linux,
+parser->GetArchitecture().GetTriple().getOS());
 }
 
 TEST_F(MinidumpParserTest, GetMiscInfo) {
   SetUpData("linux-x86_64.dmp");
   const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
   ASSERT_EQ(nullptr, misc_info);
-  // linux breakpad generated minidump files don't have misc info stream
+}
+
+TEST_F(MinidumpParserTest, GetLinuxProcStatus) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional proc_status = parser->GetLinuxProcStatus();
+  ASSERT_TRUE(proc_status.hasValue());
+  llvm::Optional pid = proc_status->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(16001UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetPid) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(16001UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetModuleList) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::ArrayRef modules = parser->GetModuleList();
+  ASSERT_EQ(8UL, modules.size());
+  std::string module_names[8] = {
+  "/usr/local/google/home/dvlahovski/projects/test_breakpad/a.out",
+  "/lib/x86_64-linux-gnu/libm-2.19.so",
+  "/lib/x86_64-linux-gnu/libc-2.19.so",
+  "/lib/x86_64-linux-gnu/libgcc_s.so.1",
+  "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19",
+  "/lib/x86_64-linux-gnu/libpthread-2.19.so",
+  "/lib/x86_64-linux-gnu/ld-2.19.so",
+  "linux-gate.so",
+  };
+
+  for (int i = 0; i < 8; ++i) {
+llvm::Optional name =
+parser->GetMinidumpString(modules[i].module_name_rva);
+ASSERT_TRUE(name.hasValue());
+ASSERT_EQ(module_names[i], name.getValue());
+  }
+}
+
+TEST_F(MinidumpParserTest, GetExceptionStream) {
+  SetUpData("linux-x86_64.dmp");
+  const MinidumpExceptionStream *exception_stream =
+  parser->GetExceptionStream();
+  ASSERT_TRUE(exception_stream != nullptr);
+  ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
+}
+
+// Windows Minidump tests
+// fizzbuzz_no_heap.dmp is copied from the WinMiniDump tests
+TEST_F(MinidumpParserTest, GetArchitectureWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  ASSERT_EQ(llvm::Triple::ArchType::x86,
+parser->GetArchitecture().GetMachine());
+  ASSERT_EQ(llvm::Triple::OSType::Win32,
+parser->GetArchitecture().GetTriple().getOS());
+}
+
+TEST_F(MinidumpParserTest, GetLinuxProcStatusWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  llvm::Optional proc_status = parser->GetLinuxProcStatus();
+  ASSERT_FALSE(proc_status.hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetMiscInfoWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
+  ASSERT_TRUE(misc_info != nullptr);
+  llvm::Optional pid = misc_info->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(4440UL, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetPidWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  llvm::Optio

Re: [Lldb-commits] [PATCH] D24385: MinidumpParsing: pid, modules, exceptions

2016-09-09 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added a comment.

Also added parsing code for Minidump strings - the string in the file are 
UTF-16 encoded. I used the code from the WinMiniDump plugin and it can extract 
a UTF-16 string and convert it to a UTF-8 one.


https://reviews.llvm.org/D24385



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


Re: [Lldb-commits] [PATCH] D24385: MinidumpParsing: pid, modules, exceptions

2016-09-09 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 70816.
dvlahovski added a comment.

Forgot to run clang-format


https://reviews.llvm.org/D24385

Files:
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/fizzbuzz_no_heap.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -80,12 +80,67 @@
 TEST_F(MinidumpParserTest, GetArchitecture) {
   SetUpData("linux-x86_64.dmp");
   ASSERT_EQ(llvm::Triple::ArchType::x86_64,
-parser->GetArchitecture().GetTriple().getArch());
+parser->GetArchitecture().GetMachine());
 }
 
 TEST_F(MinidumpParserTest, GetMiscInfo) {
   SetUpData("linux-x86_64.dmp");
   const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
   ASSERT_EQ(nullptr, misc_info);
-  // linux breakpad generated minidump files don't have misc info stream
+}
+
+TEST_F(MinidumpParserTest, GetLinuxProcStatus) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional proc_status = parser->GetLinuxProcStatus();
+  ASSERT_TRUE(proc_status.hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetPid) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(16001, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetModuleList) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional> modules =
+  parser->GetModuleList();
+  ASSERT_TRUE(modules.hasValue());
+  ASSERT_EQ(8UL, modules->size());
+  // TODO check for specific modules here
+}
+
+TEST_F(MinidumpParserTest, GetExceptionStream) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional> data =
+  parser->GetStream(MinidumpStreamType::Exception);
+  ASSERT_TRUE(data.hasValue());
+}
+
+// Windows Minidump tests
+// fizzbuzz_no_heap.dmp is copied from the WinMiniDump tests
+TEST_F(MinidumpParserTest, GetArchitectureWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  ASSERT_EQ(llvm::Triple::ArchType::x86,
+parser->GetArchitecture().GetMachine());
+}
+
+TEST_F(MinidumpParserTest, GetLinuxProcStatusWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  llvm::Optional proc_status = parser->GetLinuxProcStatus();
+  ASSERT_FALSE(proc_status.hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetMiscInfoWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
+  ASSERT_TRUE(misc_info != nullptr);
+}
+
+TEST_F(MinidumpParserTest, GetPidWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(4440, pid.getValue());
 }
Index: unittests/Process/minidump/CMakeLists.txt
===
--- unittests/Process/minidump/CMakeLists.txt
+++ unittests/Process/minidump/CMakeLists.txt
@@ -3,6 +3,7 @@
   )
 
 set(test_inputs
-   linux-x86_64.dmp)
+   linux-x86_64.dmp
+   fizzbuzz_no_heap.dmp)
 
 add_unittest_inputs(LLDBMinidumpTests "${test_inputs}")
Index: source/Plugins/Process/minidump/MinidumpTypes.h
===
--- source/Plugins/Process/minidump/MinidumpTypes.h
+++ source/Plugins/Process/minidump/MinidumpTypes.h
@@ -18,6 +18,9 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitmaskEnum.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Endian.h"
 
 // C includes
@@ -148,6 +151,12 @@
   LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ IDIVT)
 };
 
+enum class MinidumpMiscInfoFlags : uint32_t {
+  ProcessID = (1 << 0),
+  ProcessTimes = (1 << 1),
+  LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ ProcessTimes)
+};
+
 template 
 Error consumeObject(llvm::ArrayRef &Buffer, const T *&Object) {
   Error error;
@@ -161,6 +170,8 @@
   return error;
 }
 
+llvm::StringRef consumeString(llvm::ArrayRef &Buffer);
+
 // Reference:
 // https://msdn.microsoft.com/en-us/library/windows/desktop/ms680378(v=vs.85).aspx
 struct MinidumpHeader {
@@ -206,6 +217,13 @@
 static_assert(sizeof(MinidumpDirectory) == 12,
   "sizeof MinidumpDirectory is not correct!");
 
+struct MinidumpString {
+  std::string buffer;
+
+  static llvm::Optional
+  Parse(llvm::ArrayRef &data);
+};
+
 // Reference:
 // https://msdn.microsoft.com/en-us/library/windows/desktop/ms680517(v=vs.85).aspx
 struct MinidumpThread {
@@ -272,23 +290,102 @@
 static_assert(sizeof(MinidumpSystemInfo) == 56,
   "sizeof MinidumpSystemInfo is not correct!");
 
-// TODO check flags to see what's valid
 // TODO misc2, misc3 ?
 // Re

[Lldb-commits] [PATCH] D24385: MinidumpParsing: pid, modules, exceptions

2016-09-09 Thread Dimitar Vlahovski via lldb-commits
dvlahovski created this revision.
dvlahovski added reviewers: labath, zturner.
dvlahovski added a subscriber: lldb-commits.
Herald added a subscriber: beanz.

Added parsing of the MiscInfo data stream.
The main member of it that we care about is the process_id
On Linux generated Minidump (from breakpad) we don't have
the MiscInfo, we have the /proc/$pid/status from where we can get the
pid.
Also parsing the module list - the list of all of the loaded
modules/shared libraries.
Finally - parsing the exception stream.

I have unit tests for all of that.
Also added some tests using a Minidump generated from Windows tools (not
from breakpad)

https://reviews.llvm.org/D24385

Files:
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/fizzbuzz_no_heap.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -44,10 +44,8 @@
 llvm::SmallString<128> filename = inputs_folder;
 llvm::sys::path::append(filename, minidump_filename);
 FileSpec minidump_file(filename.c_str(), false);
-lldb::DataBufferSP data_sp(
-minidump_file.MemoryMapFileContents(0, load_size));
-llvm::Optional optional_parser =
-MinidumpParser::Create(data_sp);
+lldb::DataBufferSP data_sp(minidump_file.MemoryMapFileContents(0, load_size));
+llvm::Optional optional_parser = MinidumpParser::Create(data_sp);
 ASSERT_TRUE(optional_parser.hasValue());
 parser.reset(new MinidumpParser(optional_parser.getValue()));
 ASSERT_GT(parser->GetByteSize(), 0UL);
@@ -80,12 +78,65 @@
 TEST_F(MinidumpParserTest, GetArchitecture) {
   SetUpData("linux-x86_64.dmp");
   ASSERT_EQ(llvm::Triple::ArchType::x86_64,
-parser->GetArchitecture().GetTriple().getArch());
+parser->GetArchitecture().GetMachine());
 }
 
 TEST_F(MinidumpParserTest, GetMiscInfo) {
   SetUpData("linux-x86_64.dmp");
   const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
   ASSERT_EQ(nullptr, misc_info);
-  // linux breakpad generated minidump files don't have misc info stream
+}
+
+TEST_F(MinidumpParserTest, GetLinuxProcStatus) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional proc_status = parser->GetLinuxProcStatus();
+  ASSERT_TRUE(proc_status.hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetPid) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(16001, pid.getValue());
+}
+
+TEST_F(MinidumpParserTest, GetModuleList) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional> modules = parser->GetModuleList();
+  ASSERT_TRUE(modules.hasValue());
+  ASSERT_EQ(8UL, modules->size());
+  //TODO check for specific modules here
+}
+
+TEST_F(MinidumpParserTest, GetExceptionStream) {
+  SetUpData("linux-x86_64.dmp");
+  llvm::Optional> data = parser->GetStream(MinidumpStreamType::Exception);
+  ASSERT_TRUE(data.hasValue());
+}
+
+
+// Windows Minidump tests
+// fizzbuzz_no_heap.dmp is copied from the WinMiniDump tests
+TEST_F(MinidumpParserTest, GetArchitectureWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  ASSERT_EQ(llvm::Triple::ArchType::x86, parser->GetArchitecture().GetMachine());
+}
+
+TEST_F(MinidumpParserTest, GetLinuxProcStatusWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  llvm::Optional proc_status = parser->GetLinuxProcStatus();
+  ASSERT_FALSE(proc_status.hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetMiscInfoWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
+  ASSERT_TRUE(misc_info != nullptr);
+}
+
+TEST_F(MinidumpParserTest, GetPidWindows) {
+  SetUpData("fizzbuzz_no_heap.dmp");
+  llvm::Optional pid = parser->GetPid();
+  ASSERT_TRUE(pid.hasValue());
+  ASSERT_EQ(4440, pid.getValue());
 }
Index: unittests/Process/minidump/CMakeLists.txt
===
--- unittests/Process/minidump/CMakeLists.txt
+++ unittests/Process/minidump/CMakeLists.txt
@@ -3,6 +3,7 @@
   )
 
 set(test_inputs
-   linux-x86_64.dmp)
+   linux-x86_64.dmp
+   fizzbuzz_no_heap.dmp)
 
 add_unittest_inputs(LLDBMinidumpTests "${test_inputs}")
Index: source/Plugins/Process/minidump/MinidumpTypes.h
===
--- source/Plugins/Process/minidump/MinidumpTypes.h
+++ source/Plugins/Process/minidump/MinidumpTypes.h
@@ -18,6 +18,9 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitmaskEnum.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ConvertUTF.h"
 #include

[Lldb-commits] [lldb] r281030 - Fixing a build breakage caused from a change in LLVM rL281019

2016-09-09 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Fri Sep  9 05:14:11 2016
New Revision: 281030

URL: http://llvm.org/viewvc/llvm-project?rev=281030&view=rev
Log:
Fixing a build breakage caused from a change in LLVM rL281019

Summary:
LLVM guys did some clean-up of the Attribute getters/setters
and because of that the build was failing.

Reviewers: ldrumm

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D24382

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp?rev=281030&r1=281029&r2=281030&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
 Fri Sep  9 05:14:11 2016
@@ -255,9 +255,7 @@ bool fixupRSAllocationStructByValCalls(l
   // if this argument is passed by val
   if (call_attribs.hasAttribute(i, llvm::Attribute::ByVal)) {
 // strip away the byval attribute
-call_inst->removeAttribute(
-i,
-llvm::Attribute::get(module.getContext(), llvm::Attribute::ByVal));
+call_inst->removeAttribute(i, llvm::Attribute::ByVal);
 changed = true;
   }
 }


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


[Lldb-commits] [PATCH] D24382: Fixing a build breakage caused from a change in LLVM rL281019

2016-09-09 Thread Dimitar Vlahovski via lldb-commits
dvlahovski created this revision.
dvlahovski added a reviewer: ldrumm.
dvlahovski added a subscriber: lldb-commits.

LLVM guys did some clean-up of the Attribute getters/setters
and because of that the build was failing.

https://reviews.llvm.org/D24382

Files:
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp

Index: 
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
===
--- 
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
+++ 
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
@@ -255,9 +255,7 @@
   // if this argument is passed by val
   if (call_attribs.hasAttribute(i, llvm::Attribute::ByVal)) {
 // strip away the byval attribute
-call_inst->removeAttribute(
-i,
-llvm::Attribute::get(module.getContext(), llvm::Attribute::ByVal));
+call_inst->removeAttribute(i, llvm::Attribute::ByVal);
 changed = true;
   }
 }


Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
@@ -255,9 +255,7 @@
   // if this argument is passed by val
   if (call_attribs.hasAttribute(i, llvm::Attribute::ByVal)) {
 // strip away the byval attribute
-call_inst->removeAttribute(
-i,
-llvm::Attribute::get(module.getContext(), llvm::Attribute::ByVal));
+call_inst->removeAttribute(i, llvm::Attribute::ByVal);
 changed = true;
   }
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D24382: Fixing a build breakage caused from a change in LLVM rL281019

2016-09-09 Thread Dimitar Vlahovski via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281030: Fixing a build breakage caused from a change in LLVM 
rL281019 (authored by dvlahovski).

Changed prior to commit:
  https://reviews.llvm.org/D24382?vs=70805&id=70806#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24382

Files:
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp

Index: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
===
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
@@ -255,9 +255,7 @@
   // if this argument is passed by val
   if (call_attribs.hasAttribute(i, llvm::Attribute::ByVal)) {
 // strip away the byval attribute
-call_inst->removeAttribute(
-i,
-llvm::Attribute::get(module.getContext(), llvm::Attribute::ByVal));
+call_inst->removeAttribute(i, llvm::Attribute::ByVal);
 changed = true;
   }
 }


Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
@@ -255,9 +255,7 @@
   // if this argument is passed by val
   if (call_attribs.hasAttribute(i, llvm::Attribute::ByVal)) {
 // strip away the byval attribute
-call_inst->removeAttribute(
-i,
-llvm::Attribute::get(module.getContext(), llvm::Attribute::ByVal));
+call_inst->removeAttribute(i, llvm::Attribute::ByVal);
 changed = true;
   }
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r280707 - Fixing an MSVC error from rL280692

2016-09-06 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Tue Sep  6 07:48:10 2016
New Revision: 280707

URL: http://llvm.org/viewvc/llvm-project?rev=280707&view=rev
Log:
Fixing an MSVC error from rL280692

MSVC emits an error when one uses a const variable in a lambda without
capturing it.

gcc and clang don't emit an error in this scenario.

Modified:
lldb/trunk/source/Commands/CommandObjectFrame.cpp

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=280707&r1=280706&r2=280707&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Tue Sep  6 07:48:10 2016
@@ -218,7 +218,7 @@ protected:
 
 const bool qualify_cxx_base_classes = false;
 
-DumpValueObjectOptions::DeclPrintingHelper helper = 
[&valobj_sp](ConstString type,
+DumpValueObjectOptions::DeclPrintingHelper helper = [&valobj_sp, 
qualify_cxx_base_classes](ConstString type,
  
ConstString var,
  const 
DumpValueObjectOptions &opts,
  
Stream &stream) -> bool {


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


[Lldb-commits] [lldb] r280703 - Revert "Intel(R) Memory Protection Extensions (Intel(R) MPX) support."

2016-09-06 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Tue Sep  6 06:00:37 2016
New Revision: 280703

URL: http://llvm.org/viewvc/llvm-project?rev=280703&view=rev
Log:
Revert "Intel(R) Memory Protection Extensions (Intel(R) MPX) support."

This reverts commit rL280668 because the register tests fail on i386
Linux.

I investigated a little bit what causes the failure - there are missing
registers when running 'register read -a'.
This is the output I got at the bottom:
"""
...
Memory Protection Extensions:
  bnd0 = {0x 0x}
  bnd1 = {0x 0x}
  bnd2 = {0x 0x}
  bnd3 = {0x 0x}

unknown:
2 registers were unavailable.
"""

Also looking at the packets exchanged between the client and server:
"""
...
history[308] tid=0x7338 <  19> send packet: $qRegisterInfo4a#d7
history[309] tid=0x7338 < 130> read packet:
$name:bnd0;bitsize:128;offset:1032;encoding:vector;format:vector-uint64;set:Memory
Protection Extensions;ehframe:101;dwarf:101;#48
history[310] tid=0x7338 <  19> send packet: $qRegisterInfo4b#d8
history[311] tid=0x7338 < 130> read packet:
$name:bnd1;bitsize:128;offset:1048;encoding:vector;format:vector-uint64;set:Memory
Protection Extensions;ehframe:102;dwarf:102;#52
history[312] tid=0x7338 <  19> send packet: $qRegisterInfo4c#d9
history[313] tid=0x7338 < 130> read packet:
$name:bnd2;bitsize:128;offset:1064;encoding:vector;format:vector-uint64;set:Memory
Protection Extensions;ehframe:103;dwarf:103;#53
history[314] tid=0x7338 <  19> send packet: $qRegisterInfo4d#da
history[315] tid=0x7338 < 130> read packet:
$name:bnd3;bitsize:128;offset:1080;encoding:vector;format:vector-uint64;set:Memory
Protection Extensions;ehframe:104;dwarf:104;#54
history[316] tid=0x7338 <  19> send packet: $qRegisterInfo4e#db
history[317] tid=0x7338 <  76> read packet:
$name:bndcfgu;bitsize:64;offset:1096;encoding:vector;format:vector-uint8;#99
history[318] tid=0x7338 <  19> send packet: $qRegisterInfo4f#dc
history[319] tid=0x7338 <  78> read packet:
$name:bndstatus;bitsize:64;offset:1104;encoding:vector;format:vector-uint8;#8e
...
"""

The bndcfgu and bndstatus registers don't have the 'Memory Protections
Extension' set. I looked at the code and it seems that that is set
correctly.

So I'm not sure what's the problem or where does it come from.

Also there is a second failure related to something like this in the
tests:
"""
registerSet.GetName().lower()
"""

For some reason the registerSet.GetName() returns None.

Added:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/Makefile
  - copied, changed from r280697, 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py
  - copied, changed from r280697, 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/a.cpp
  - copied, changed from r280697, 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/a.cpp
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/main.cpp
  - copied, changed from r280697, 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/main.cpp
Removed:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/a.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/main.cpp
Modified:
lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp

lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContext_x86.h
lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_i386.h
lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
lldb/trunk/source/Plugins/Process/Utility/lldb-x86-register-enums.h

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Copied: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/Makefile 
(from r280697, 
lldb/trunk/packages/Python/ll

Re: [Lldb-commits] [PATCH] D23545: Minidump parsing

2016-09-02 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added inline comments.


Comment at: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp:146
@@ +145,3 @@
+break;
+}
+

labath wrote:
> You have a "enumeration not handled in a switch" warning here. Could you do 
> something about that?
Yes, I fixed it locally. Will submit it with the next CL. :)


Repository:
  rL LLVM

https://reviews.llvm.org/D23545



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


Re: [Lldb-commits] [PATCH] D23545: Minidump parsing

2016-09-01 Thread Dimitar Vlahovski via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280356: Minidump parsing (authored by dvlahovski).

Changed prior to commit:
  https://reviews.llvm.org/D23545?vs=69340&id=69988#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23545

Files:
  lldb/trunk/cmake/LLDBDependencies.cmake
  lldb/trunk/source/Plugins/Process/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
  lldb/trunk/unittests/Process/CMakeLists.txt
  lldb/trunk/unittests/Process/minidump/CMakeLists.txt
  lldb/trunk/unittests/Process/minidump/Inputs/linux-x86_64.cpp
  lldb/trunk/unittests/Process/minidump/Inputs/linux-x86_64.dmp
  lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Index: lldb/trunk/cmake/LLDBDependencies.cmake
===
--- lldb/trunk/cmake/LLDBDependencies.cmake
+++ lldb/trunk/cmake/LLDBDependencies.cmake
@@ -81,6 +81,7 @@
   lldbPluginInstrumentationRuntimeThreadSanitizer
   lldbPluginSystemRuntimeMacOSX
   lldbPluginProcessElfCore
+  lldbPluginProcessMinidump
   lldbPluginJITLoaderGDB
   lldbPluginExpressionParserClang
   lldbPluginExpressionParserGo
Index: lldb/trunk/unittests/Process/minidump/Inputs/linux-x86_64.cpp
===
--- lldb/trunk/unittests/Process/minidump/Inputs/linux-x86_64.cpp
+++ lldb/trunk/unittests/Process/minidump/Inputs/linux-x86_64.cpp
@@ -0,0 +1,25 @@
+// Example source from breakpad's linux tutorial
+// https://chromium.googlesource.com/breakpad/breakpad/+/master/docs/linux_starter_guide.md
+
+#include 
+#include 
+#include 
+
+#include "client/linux/handler/exception_handler.h"
+
+
+static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
+void* context, bool succeeded) {
+printf("Dump path: %s\n", descriptor.path());
+return succeeded;
+}
+
+void crash() { volatile int* a = (int*)(NULL); *a = 1; }
+
+int main(int argc, char* argv[]) {
+google_breakpad::MinidumpDescriptor descriptor("/tmp");
+google_breakpad::ExceptionHandler eh(descriptor, NULL, dumpCallback, NULL, true, -1);
+printf("pid: %d\n", getpid());
+crash();
+return 0;
+}
Index: lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -0,0 +1,97 @@
+//===-- MinidumpTypesTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Project includes
+#include "Plugins/Process/minidump/MinidumpParser.h"
+#include "Plugins/Process/minidump/MinidumpTypes.h"
+
+// Other libraries and framework includes
+#include "gtest/gtest.h"
+
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Host/FileSpec.h"
+
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+// C includes
+
+// C++ includes
+#include 
+
+extern const char *TestMainArgv0;
+
+using namespace lldb_private;
+using namespace minidump;
+
+class MinidumpParserTest : public testing::Test
+{
+public:
+void
+SetUp() override
+{
+llvm::StringRef dmp_folder = llvm::sys::path::parent_path(TestMainArgv0);
+inputs_folder = dmp_folder;
+llvm::sys::path::append(inputs_folder, "Inputs");
+}
+
+void
+SetUpData(const char *minidump_filename, size_t load_size = SIZE_MAX)
+{
+llvm::SmallString<128> filename = inputs_folder;
+llvm::sys::path::append(filename, minidump_filename);
+FileSpec minidump_file(filename.c_str(), false);
+lldb::DataBufferSP data_sp(minidump_file.MemoryMapFileContents(0, load_size));
+llvm::Optional optional_parser = MinidumpParser::Create(data_sp);
+ASSERT_TRUE(optional_parser.hasValue());
+parser.reset(new MinidumpParser(optional_parser.getValue()));
+ASSERT_GT(parser->GetByteSize(), 0UL);
+}
+
+llvm::SmallString<128> inputs_folder;
+std::unique_ptr parser;
+};
+
+TEST_F(MinidumpParserTest, GetThreads)
+{
+SetUpData("linux-x86_64.dmp");
+llvm::Optional> thread_list;
+
+thread_list = parser->GetThreads();
+ASSERT_TRUE(thread_list.hasValue());
+ASSERT_EQ(1UL, thread_list->size());
+
+const MinidumpThread *thread = thread_list.getValue()[0];
+ASSERT_EQ(16001UL, thread->thread_id);
+}
+
+TES

[Lldb-commits] [lldb] r280356 - Minidump parsing

2016-09-01 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Thu Sep  1 06:29:53 2016
New Revision: 280356

URL: http://llvm.org/viewvc/llvm-project?rev=280356&view=rev
Log:
Minidump parsing

Summary:
This is a Minidump parsing code.
There are still some more structures/data streams that need to be added.
The aim ot this is to be used in the implementation of
a minidump debugging plugin that works on all platforms/architectures.
Currently we have a windows-only plugin that uses the WinAPI to parse
the dump files.
Also added unittests for the current functionality.

Reviewers: labath, amccarth

Subscribers: tberghammer, danalbert, srhines, lldb-commits, dschuff

Differential Revision: https://reviews.llvm.org/D23545

Added:
lldb/trunk/source/Plugins/Process/minidump/
lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
lldb/trunk/unittests/Process/minidump/
lldb/trunk/unittests/Process/minidump/CMakeLists.txt
lldb/trunk/unittests/Process/minidump/Inputs/
lldb/trunk/unittests/Process/minidump/Inputs/linux-x86_64.cpp
lldb/trunk/unittests/Process/minidump/Inputs/linux-x86_64.dmp
lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
Modified:
lldb/trunk/cmake/LLDBDependencies.cmake
lldb/trunk/source/Plugins/Process/CMakeLists.txt
lldb/trunk/unittests/Process/CMakeLists.txt

Modified: lldb/trunk/cmake/LLDBDependencies.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/LLDBDependencies.cmake?rev=280356&r1=280355&r2=280356&view=diff
==
--- lldb/trunk/cmake/LLDBDependencies.cmake (original)
+++ lldb/trunk/cmake/LLDBDependencies.cmake Thu Sep  1 06:29:53 2016
@@ -81,6 +81,7 @@ set( LLDB_USED_LIBS
   lldbPluginInstrumentationRuntimeThreadSanitizer
   lldbPluginSystemRuntimeMacOSX
   lldbPluginProcessElfCore
+  lldbPluginProcessMinidump
   lldbPluginJITLoaderGDB
   lldbPluginExpressionParserClang
   lldbPluginExpressionParserGo

Modified: lldb/trunk/source/Plugins/Process/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/CMakeLists.txt?rev=280356&r1=280355&r2=280356&view=diff
==
--- lldb/trunk/source/Plugins/Process/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/Process/CMakeLists.txt Thu Sep  1 06:29:53 2016
@@ -17,3 +17,4 @@ add_subdirectory(gdb-remote)
 add_subdirectory(Utility)
 add_subdirectory(mach-core)
 add_subdirectory(elf-core)
+add_subdirectory(minidump)

Added: lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt?rev=280356&view=auto
==
--- lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt (added)
+++ lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt Thu Sep  1 
06:29:53 2016
@@ -0,0 +1,6 @@
+include_directories(../Utility)
+
+add_lldb_library(lldbPluginProcessMinidump
+  MinidumpTypes.cpp
+  MinidumpParser.cpp
+  )

Added: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp?rev=280356&view=auto
==
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp (added)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp Thu Sep  1 
06:29:53 2016
@@ -0,0 +1,160 @@
+//===-- MinidumpParser.cpp ---*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Project includes
+#include "MinidumpParser.h"
+
+// Other libraries and framework includes
+// C includes
+// C++ includes
+
+using namespace lldb_private;
+using namespace minidump;
+
+llvm::Optional
+MinidumpParser::Create(const lldb::DataBufferSP &data_buf_sp)
+{
+if (data_buf_sp->GetByteSize() < sizeof(MinidumpHeader))
+{
+return llvm::None;
+}
+
+llvm::ArrayRef header_data(data_buf_sp->GetBytes(), 
sizeof(MinidumpHeader));
+const MinidumpHeader *header = MinidumpHeader::Parse(header_data);
+
+if (header == nullptr)
+{
+return llvm::None;
+}
+
+lldb::offset_t directory_list_offset = header->stream_directory_rva;
+// check if there is enough data for the parsing of the directory list
+if ((directory_list_offset + sizeof(MinidumpDirectory) * 
header->stream

Re: [Lldb-commits] [PATCH] D23545: Minidump parsing

2016-08-26 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 69340.
dvlahovski added a comment.

Making MinidumpParser constuctor private


https://reviews.llvm.org/D23545

Files:
  cmake/LLDBDependencies.cmake
  source/Plugins/Process/CMakeLists.txt
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/CMakeLists.txt
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/linux-x86_64.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- /dev/null
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -0,0 +1,97 @@
+//===-- MinidumpTypesTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Project includes
+#include "Plugins/Process/minidump/MinidumpParser.h"
+#include "Plugins/Process/minidump/MinidumpTypes.h"
+
+// Other libraries and framework includes
+#include "gtest/gtest.h"
+
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Host/FileSpec.h"
+
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+// C includes
+
+// C++ includes
+#include 
+
+extern const char *TestMainArgv0;
+
+using namespace lldb_private;
+using namespace minidump;
+
+class MinidumpParserTest : public testing::Test
+{
+public:
+void
+SetUp() override
+{
+llvm::StringRef dmp_folder = llvm::sys::path::parent_path(TestMainArgv0);
+inputs_folder = dmp_folder;
+llvm::sys::path::append(inputs_folder, "Inputs");
+}
+
+void
+SetUpData(const char *minidump_filename, size_t load_size = SIZE_MAX)
+{
+llvm::SmallString<128> filename = inputs_folder;
+llvm::sys::path::append(filename, minidump_filename);
+FileSpec minidump_file(filename.c_str(), false);
+lldb::DataBufferSP data_sp(minidump_file.MemoryMapFileContents(0, load_size));
+llvm::Optional optional_parser = MinidumpParser::Create(data_sp);
+ASSERT_TRUE(optional_parser.hasValue());
+parser.reset(new MinidumpParser(optional_parser.getValue()));
+ASSERT_GT(parser->GetByteSize(), 0UL);
+}
+
+llvm::SmallString<128> inputs_folder;
+std::unique_ptr parser;
+};
+
+TEST_F(MinidumpParserTest, GetThreads)
+{
+SetUpData("linux-x86_64.dmp");
+llvm::Optional> thread_list;
+
+thread_list = parser->GetThreads();
+ASSERT_TRUE(thread_list.hasValue());
+ASSERT_EQ(1UL, thread_list->size());
+
+const MinidumpThread *thread = thread_list.getValue()[0];
+ASSERT_EQ(16001UL, thread->thread_id);
+}
+
+TEST_F(MinidumpParserTest, GetThreadsTruncatedFile)
+{
+SetUpData("linux-x86_64.dmp", 200);
+llvm::Optional> thread_list;
+
+thread_list = parser->GetThreads();
+ASSERT_FALSE(thread_list.hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetArchitecture)
+{
+SetUpData("linux-x86_64.dmp");
+ASSERT_EQ(llvm::Triple::ArchType::x86_64, parser->GetArchitecture().GetTriple().getArch());
+}
+
+TEST_F(MinidumpParserTest, GetMiscInfo)
+{
+SetUpData("linux-x86_64.dmp");
+const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
+ASSERT_EQ(nullptr, misc_info);
+// linux breakpad generated minidump files don't have misc info stream
+}
Index: unittests/Process/minidump/CMakeLists.txt
===
--- /dev/null
+++ unittests/Process/minidump/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_lldb_unittest(LLDBMinidumpTests
+  MinidumpParserTest.cpp
+  )
+
+set(test_inputs
+   linux-x86_64.dmp)
+
+add_unittest_inputs(LLDBMinidumpTests "${test_inputs}")
Index: unittests/Process/CMakeLists.txt
===
--- unittests/Process/CMakeLists.txt
+++ unittests/Process/CMakeLists.txt
@@ -1 +1,2 @@
 add_subdirectory(gdb-remote)
+add_subdirectory(minidump)
Index: source/Plugins/Process/minidump/MinidumpTypes.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/MinidumpTypes.h
@@ -0,0 +1,298 @@
+//===-- MinidumpTypes.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_MinidumpTypes_h_
+#defi

Re: [Lldb-commits] [PATCH] D23545: Minidump parsing

2016-08-25 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added a comment.

I changed all of the `llvm::Optional` returning functions to 
return only `const type *`
and signalize for 'failure' by returning a `nullptr`. In the cases where I 
return objects (e.g. vector of threads)
I'm still using the `llvm::Optional` pattern.
I also think that using `llvm::Error` is a good idea, but I think that it'll be 
difficult, because of 
collisions with the `lldb::Error`, and also at some point I have to convert 
objects from one type to the other.

So that's why I stick to the `llvm::Optional`.
I also used it on the creation of `MinidumpParser` (following somewhat the 
pattern that you proposed)


https://reviews.llvm.org/D23545



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


Re: [Lldb-commits] [PATCH] D23545: Minidump parsing

2016-08-25 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 69254.
dvlahovski added a comment.

Changed the constructing pattern of MinidumpParser

Now there is a static Create method that returns
and llvm::Optional MinidumpParser.


https://reviews.llvm.org/D23545

Files:
  cmake/LLDBDependencies.cmake
  source/Plugins/Process/CMakeLists.txt
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/CMakeLists.txt
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/linux-x86_64.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- /dev/null
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -0,0 +1,97 @@
+//===-- MinidumpTypesTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Project includes
+#include "Plugins/Process/minidump/MinidumpParser.h"
+#include "Plugins/Process/minidump/MinidumpTypes.h"
+
+// Other libraries and framework includes
+#include "gtest/gtest.h"
+
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Host/FileSpec.h"
+
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+// C includes
+
+// C++ includes
+#include 
+
+extern const char *TestMainArgv0;
+
+using namespace lldb_private;
+using namespace minidump;
+
+class MinidumpParserTest : public testing::Test
+{
+public:
+void
+SetUp() override
+{
+llvm::StringRef dmp_folder = llvm::sys::path::parent_path(TestMainArgv0);
+inputs_folder = dmp_folder;
+llvm::sys::path::append(inputs_folder, "Inputs");
+}
+
+void
+SetUpData(const char *minidump_filename, size_t load_size = SIZE_MAX)
+{
+llvm::SmallString<128> filename = inputs_folder;
+llvm::sys::path::append(filename, minidump_filename);
+FileSpec minidump_file(filename.c_str(), false);
+lldb::DataBufferSP data_sp(minidump_file.MemoryMapFileContents(0, load_size));
+llvm::Optional optional_parser = MinidumpParser::Create(data_sp);
+ASSERT_TRUE(optional_parser.hasValue());
+parser.reset(new MinidumpParser(optional_parser.getValue()));
+ASSERT_GT(parser->GetByteSize(), 0UL);
+}
+
+llvm::SmallString<128> inputs_folder;
+std::unique_ptr parser;
+};
+
+TEST_F(MinidumpParserTest, GetThreads)
+{
+SetUpData("linux-x86_64.dmp");
+llvm::Optional> thread_list;
+
+thread_list = parser->GetThreads();
+ASSERT_TRUE(thread_list.hasValue());
+ASSERT_EQ(1UL, thread_list->size());
+
+const MinidumpThread *thread = thread_list.getValue()[0];
+ASSERT_EQ(16001UL, thread->thread_id);
+}
+
+TEST_F(MinidumpParserTest, GetThreadsTruncatedFile)
+{
+SetUpData("linux-x86_64.dmp", 200);
+llvm::Optional> thread_list;
+
+thread_list = parser->GetThreads();
+ASSERT_FALSE(thread_list.hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetArchitecture)
+{
+SetUpData("linux-x86_64.dmp");
+ASSERT_EQ(llvm::Triple::ArchType::x86_64, parser->GetArchitecture().GetTriple().getArch());
+}
+
+TEST_F(MinidumpParserTest, GetMiscInfo)
+{
+SetUpData("linux-x86_64.dmp");
+const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
+ASSERT_EQ(nullptr, misc_info);
+// linux breakpad generated minidump files don't have misc info stream
+}
Index: unittests/Process/minidump/CMakeLists.txt
===
--- /dev/null
+++ unittests/Process/minidump/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_lldb_unittest(LLDBMinidumpTests
+  MinidumpParserTest.cpp
+  )
+
+set(test_inputs
+   linux-x86_64.dmp)
+
+add_unittest_inputs(LLDBMinidumpTests "${test_inputs}")
Index: unittests/Process/CMakeLists.txt
===
--- unittests/Process/CMakeLists.txt
+++ unittests/Process/CMakeLists.txt
@@ -1 +1,2 @@
 add_subdirectory(gdb-remote)
+add_subdirectory(minidump)
Index: source/Plugins/Process/minidump/MinidumpTypes.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/MinidumpTypes.h
@@ -0,0 +1,298 @@
+//===-- MinidumpTypes.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===---

Re: [Lldb-commits] [PATCH] D23545: Minidump parsing

2016-08-19 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 68690.
dvlahovski added a comment.

Move creation of ArrayRef after sanity check

Add a test that checks that the thread list is not present in a
truncated minidump file


https://reviews.llvm.org/D23545

Files:
  cmake/LLDBDependencies.cmake
  source/Plugins/Process/CMakeLists.txt
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/CMakeLists.txt
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/linux-x86_64.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- /dev/null
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -0,0 +1,96 @@
+//===-- MinidumpTypesTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Project includes
+#include "Plugins/Process/minidump/MinidumpParser.h"
+#include "Plugins/Process/minidump/MinidumpTypes.h"
+
+// Other libraries and framework includes
+#include "gtest/gtest.h"
+
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Host/FileSpec.h"
+
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+// C includes
+
+// C++ includes
+#include 
+
+extern const char *TestMainArgv0;
+
+using namespace lldb_private;
+using namespace minidump;
+
+class MinidumpParserTest : public testing::Test
+{
+public:
+void
+SetUp() override
+{
+llvm::StringRef dmp_folder = llvm::sys::path::parent_path(TestMainArgv0);
+inputs_folder = dmp_folder;
+llvm::sys::path::append(inputs_folder, "Inputs");
+}
+
+void
+SetUpData(const char *minidump_filename, size_t load_size = SIZE_MAX)
+{
+llvm::SmallString<128> filename = inputs_folder;
+llvm::sys::path::append(filename, minidump_filename);
+FileSpec minidump_file(filename.c_str(), false);
+lldb::DataBufferSP data_sp(minidump_file.MemoryMapFileContents(0, load_size));
+parser.reset(new MinidumpParser(data_sp));
+ASSERT_GT(parser->GetByteSize(), 0UL);
+ASSERT_TRUE(static_cast(parser));
+}
+
+llvm::SmallString<128> inputs_folder;
+std::unique_ptr parser;
+};
+
+TEST_F(MinidumpParserTest, GetThreads)
+{
+SetUpData("linux-x86_64.dmp");
+llvm::Optional> thread_list;
+
+thread_list = parser->GetThreads();
+ASSERT_TRUE(thread_list.hasValue());
+ASSERT_EQ(1UL, thread_list->size());
+
+const MinidumpThread *thread = thread_list.getValue()[0];
+ASSERT_EQ(16001UL, thread->thread_id);
+}
+
+TEST_F(MinidumpParserTest, GetThreadsTruncatedFile)
+{
+SetUpData("linux-x86_64.dmp", 128);
+llvm::Optional> thread_list;
+
+thread_list = parser->GetThreads();
+ASSERT_FALSE(thread_list.hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetArchitecture)
+{
+SetUpData("linux-x86_64.dmp");
+ASSERT_EQ(llvm::Triple::ArchType::x86_64, parser->GetArchitecture().GetTriple().getArch());
+}
+
+TEST_F(MinidumpParserTest, GetMiscInfo)
+{
+SetUpData("linux-x86_64.dmp");
+const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
+ASSERT_EQ(nullptr, misc_info);
+// linux breakpad generated minidump files don't have misc info stream
+}
Index: unittests/Process/minidump/CMakeLists.txt
===
--- /dev/null
+++ unittests/Process/minidump/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_lldb_unittest(LLDBMinidumpTests
+  MinidumpParserTest.cpp
+  )
+
+set(test_inputs
+   linux-x86_64.dmp)
+
+add_unittest_inputs(LLDBMinidumpTests "${test_inputs}")
Index: unittests/Process/CMakeLists.txt
===
--- unittests/Process/CMakeLists.txt
+++ unittests/Process/CMakeLists.txt
@@ -1 +1,2 @@
 add_subdirectory(gdb-remote)
+add_subdirectory(minidump)
Index: source/Plugins/Process/minidump/MinidumpTypes.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/MinidumpTypes.h
@@ -0,0 +1,298 @@
+//===-- MinidumpTypes.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_MinidumpTypes_h_
+#define libll

[Lldb-commits] [lldb] r279234 - Fixing a Darwing test thats failing on windows

2016-08-19 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Fri Aug 19 07:44:53 2016
New Revision: 279234

URL: http://llvm.org/viewvc/llvm-project?rev=279234&view=rev
Log:
Fixing a Darwing test thats failing on windows

The pexpect import should be make after the skip-if-not-darwin part
because pexpect is not available on Windows

Modified:
lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py?rev=279234&r1=279233&r2=279234&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py Fri Aug 19 07:44:53 
2016
@@ -7,7 +7,6 @@ from __future__ import print_function
 
 import json
 import os
-import pexpect
 import platform
 import re
 import sys
@@ -59,6 +58,7 @@ class DarwinLogTestBase(lldbtest.TestBas
 def run_lldb_to_breakpoint(self, exe, source_file, line,
enable_command=None, settings_commands=None):
 
+import pexpect
 # Set self.child_prompt, which is "(lldb) ".
 prompt = self.child_prompt
 


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


  1   2   >