<div dir="ltr"><div>This change seems to have introduced a linker failure while building the gtest suite:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Ld build/Release/lldb-gtest normal x86_64</font></div><div><font face="monospace, monospace">    cd "/Users/buildslave/jenkins/sharedspace/lldb@2/lldb"</font></div><div><font face="monospace, monospace">    export MACOSX_DEPLOYMENT_TARGET=10.9</font></div><div><font face="monospace, monospace">    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -L/Users/buildslave/jenkins/sharedspace/lldb@2/lldb/build/Release -F/Users/buildslave/jenkins/sharedspace/lldb@2/lldb/build/Release -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/PrivateFrameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks -filelist /Users/buildslave/jenkins/sharedspace/lldb@2/lldb/build/lldb.build/Release/lldb-gtest-build.build/Objects-normal/x86_64/lldb-gtest.LinkFileList -mmacosx-version-min=10.9 -weak-lcompression -lz -filelist /Users/buildslave/jenkins/sharedspace/lldb@2/lldb/llvm-build/Release+Asserts/archives.txt -framework Foundation -framework DebugSymbols -framework Security -framework CoreServices -framework ApplicationServices /Users/buildslave/jenkins/sharedspace/lldb@2/lldb/llvm-build/Release+Asserts/x86_64/lib/libgtest.a -L /System/Library/Frameworks/Python.framework/Versions/2.7/lib -l python2.7 -stdlib=libc++ -lxml2.2 -lpanel -ledit -lz -lncurses /Users/buildslave/jenkins/sharedspace/lldb@2/lldb/build/Release/liblldb-core.a -Xlinker -dependency_info -Xlinker /Users/buildslave/jenkins/sharedspace/lldb@2/lldb/build/lldb.build/Release/lldb-gtest-build.build/Objects-normal/x86_64/lldb-gtest_dependency_info.dat -o /Users/buildslave/jenkins/sharedspace/lldb@2/lldb/build/Release/lldb-gtest</font></div><div><font face="monospace, monospace">Undefined symbols for architecture x86_64:</font></div><div><font face="monospace, monospace">  "lldb_private::minidump::ConvertMinidumpContextToRegIface(llvm::ArrayRef<unsigned char>, lldb_private::RegisterInfoInterface*)", referenced from:</font></div><div><font face="monospace, monospace">      MinidumpParserTest_ConvertRegisterContext_Test::TestBody() in MinidumpParserTest.o</font></div><div><font face="monospace, monospace">ld: symbol(s) not found for architecture x86_64</font></div></blockquote><div><br></div><div>It first struck yesterday afternoon:</div><div><br></div><div><a href="http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/20745/console">http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/20745/console</a></div><div><br></div><div>and recurring through today:</div><div><br></div><div><a href="http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/20770/console">http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/20770/console</a></div><div><br></div><div>Is there a change that needs to be made to the test suite to address this?</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 27, 2016 at 12:05 PM, Dimitar Vlahovski via lldb-commits <span dir="ltr"><<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dvlahovski<br>
Date: Tue Sep 27 14:05:55 2016<br>
New Revision: 282529<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=282529&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=282529&view=rev</a><br>
Log:<br>
Adding a RegisterContextMinidump_x86_64 converter<br>
<br>
Summary:<br>
This is a register context converter from Minidump to Linux reg context.<br>
This knows the layout of the register context in the Minidump file<br>
(which is the same as in Windows FYI) and as a result emits a binary data<br>
buffer that matches the Linux register context binary layout.<br>
This way we can reuse the existing RegisterContextLinux_x86_64 and<br>
RegisterContextCorePOSIX_x86_<wbr>64 classes.<br>
<br>
Reviewers: labath, zturner<br>
<br>
Subscribers: beanz, mgorny, lldb-commits, amccarth<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D24919" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D24919</a><br>
<br>
Added:<br>
    lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>RegisterContextMinidump_x86_<wbr>64.cpp<br>
    lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>RegisterContextMinidump_x86_<wbr>64.h<br>
Modified:<br>
    lldb/trunk/include/lldb/lldb-<wbr>private-types.h<br>
    lldb/trunk/source/Plugins/<wbr>Process/minidump/CMakeLists.<wbr>txt<br>
    lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>MinidumpParser.cpp<br>
    lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>MinidumpParser.h<br>
    lldb/trunk/unittests/Process/<wbr>minidump/MinidumpParserTest.<wbr>cpp<br>
<br>
Modified: lldb/trunk/include/lldb/lldb-<wbr>private-types.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-types.h?rev=282529&r1=282528&r2=282529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lldb/trunk/include/<wbr>lldb/lldb-private-types.h?rev=<wbr>282529&r1=282528&r2=282529&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lldb/trunk/include/lldb/lldb-<wbr>private-types.h (original)<br>
+++ lldb/trunk/include/lldb/lldb-<wbr>private-types.h Tue Sep 27 14:05:55 2016<br>
@@ -14,6 +14,8 @@<br>
<br>
 #include "lldb/lldb-private.h"<br>
<br>
+#include "llvm/ADT/ArrayRef.h"<br>
+<br>
 namespace llvm {<br>
 namespace sys {<br>
 class DynamicLibrary;<br>
@@ -61,6 +63,15 @@ struct RegisterInfo {<br>
   // the byte size of this register.<br>
   size_t dynamic_size_dwarf_len; // The length of the DWARF expression in bytes<br>
                                  // in the dynamic_size_dwarf_expr_bytes member.<br>
+<br>
+  llvm::ArrayRef<uint8_t> data(const uint8_t *context_base) const {<br>
+    return llvm::ArrayRef<uint8_t>(<wbr>context_base + byte_offset, byte_size);<br>
+  }<br>
+<br>
+  llvm::MutableArrayRef<uint8_t> mutable_data(uint8_t *context_base) const {<br>
+    return llvm::MutableArrayRef<uint8_t><wbr>(context_base + byte_offset,<br>
+                                          byte_size);<br>
+  }<br>
 };<br>
<br>
 //----------------------------<wbr>------------------------------<wbr>------------<br>
<br>
Modified: lldb/trunk/source/Plugins/<wbr>Process/minidump/CMakeLists.<wbr>txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt?rev=282529&r1=282528&r2=282529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lldb/trunk/source/<wbr>Plugins/Process/minidump/<wbr>CMakeLists.txt?rev=282529&r1=<wbr>282528&r2=282529&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lldb/trunk/source/Plugins/<wbr>Process/minidump/CMakeLists.<wbr>txt (original)<br>
+++ lldb/trunk/source/Plugins/<wbr>Process/minidump/CMakeLists.<wbr>txt Tue Sep 27 14:05:55 2016<br>
@@ -3,4 +3,5 @@ include_directories(../<wbr>Utility)<br>
 add_lldb_library(<wbr>lldbPluginProcessMinidump<br>
   MinidumpTypes.cpp<br>
   MinidumpParser.cpp<br>
+  RegisterContextMinidump_x86_<wbr>64.cpp<br>
   )<br>
<br>
Modified: lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>MinidumpParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp?rev=282529&r1=282528&r2=282529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lldb/trunk/source/<wbr>Plugins/Process/minidump/<wbr>MinidumpParser.cpp?rev=282529&<wbr>r1=282528&r2=282529&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>MinidumpParser.cpp (original)<br>
+++ lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>MinidumpParser.cpp Tue Sep 27 14:05:55 2016<br>
@@ -64,8 +64,9 @@ MinidumpParser::<wbr>MinidumpParser(<br>
     : m_data_sp(data_buf_sp), m_header(header), m_directory_map(directory_map) {<br>
 }<br>
<br>
-lldb::offset_t MinidumpParser::GetByteSize() {<br>
-  return m_data_sp->GetByteSize();<br>
+llvm::ArrayRef<uint8_t> MinidumpParser::GetData() {<br>
+  return llvm::ArrayRef<uint8_t>(m_<wbr>data_sp->GetBytes(),<br>
+                                 m_data_sp->GetByteSize());<br>
 }<br>
<br>
 llvm::ArrayRef<uint8_t><br>
<br>
Modified: lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>MinidumpParser.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h?rev=282529&r1=282528&r2=282529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lldb/trunk/source/<wbr>Plugins/Process/minidump/<wbr>MinidumpParser.h?rev=282529&<wbr>r1=282528&r2=282529&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>MinidumpParser.h (original)<br>
+++ lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>MinidumpParser.h Tue Sep 27 14:05:55 2016<br>
@@ -39,7 +39,7 @@ public:<br>
   static llvm::Optional<MinidumpParser><br>
   Create(const lldb::DataBufferSP &data_buf_sp);<br>
<br>
-  lldb::offset_t GetByteSize();<br>
+  llvm::ArrayRef<uint8_t> GetData();<br>
<br>
   llvm::ArrayRef<uint8_t> GetStream(MinidumpStreamType stream_type);<br>
<br>
@@ -71,6 +71,6 @@ private:<br>
       llvm::DenseMap<uint32_t, MinidumpLocationDescriptor> &&directory_map);<br>
 };<br>
<br>
-} // namespace minidump<br>
-} // namespace lldb_private<br>
+} // end namespace minidump<br>
+} // end namespace lldb_private<br>
 #endif // liblldb_MinidumpParser_h_<br>
<br>
Added: lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>RegisterContextMinidump_x86_<wbr>64.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp?rev=282529&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lldb/trunk/source/<wbr>Plugins/Process/minidump/<wbr>RegisterContextMinidump_x86_<wbr>64.cpp?rev=282529&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>RegisterContextMinidump_x86_<wbr>64.cpp (added)<br>
+++ lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>RegisterContextMinidump_x86_<wbr>64.cpp Tue Sep 27 14:05:55 2016<br>
@@ -0,0 +1,158 @@<br>
+//===-- RegisterContextMinidump_x86_<wbr>64.cpp ----------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+// Project includes<br>
+#include "RegisterContextMinidump_x86_<wbr>64.h"<br>
+<br>
+// Other libraries and framework includes<br>
+#include "lldb/Core/DataBufferHeap.h"<br>
+<br>
+// C includes<br>
+// C++ includes<br>
+<br>
+using namespace lldb_private;<br>
+using namespace minidump;<br>
+<br>
+void writeRegister(llvm::ArrayRef<<wbr>uint8_t> &reg_src,<br>
+                   llvm::MutableArrayRef<uint8_t> reg_dest) {<br>
+  memcpy(reg_dest.data(), reg_src.data(), reg_dest.size());<br>
+  reg_src = reg_src.drop_front(reg_dest.<wbr>size());<br>
+}<br>
+<br>
+llvm::MutableArrayRef<uint8_<wbr>t> getDestRegister(uint8_t *context,<br>
+                                               uint32_t lldb_reg_num,<br>
+                                               const RegisterInfo &reg) {<br>
+  auto bytes = reg.mutable_data(context);<br>
+<br>
+  switch (lldb_reg_num) {<br>
+  case lldb_cs_x86_64:<br>
+  case lldb_ds_x86_64:<br>
+  case lldb_es_x86_64:<br>
+  case lldb_fs_x86_64:<br>
+  case lldb_gs_x86_64:<br>
+  case lldb_ss_x86_64:<br>
+    return bytes.take_front(2);<br>
+    break;<br>
+  case lldb_rflags_x86_64:<br>
+    return bytes.take_front(4);<br>
+    break;<br>
+  default:<br>
+    return bytes.take_front(8);<br>
+    break;<br>
+  }<br>
+}<br>
+<br>
+lldb::DataBufferSP lldb_private::minidump::<wbr>ConvertMinidumpContextToRegIfa<wbr>ce(<br>
+    llvm::ArrayRef<uint8_t> source_data,<br>
+    RegisterInfoInterface *target_reg_interface) {<br>
+<br>
+  const RegisterInfo *reg_info = target_reg_interface-><wbr>GetRegisterInfo();<br>
+<br>
+  lldb::DataBufferSP result_context_buf(<br>
+      new DataBufferHeap(target_reg_<wbr>interface->GetGPRSize(), 0));<br>
+  uint8_t *result_base = result_context_buf->GetBytes()<wbr>;<br>
+<br>
+  source_data = source_data.drop_front(6 * 8); // p[1-6] home registers<br>
+  const uint32_t *context_flags;<br>
+  consumeObject(source_data, context_flags);<br>
+  const uint32_t x86_64_Flag =<br>
+      static_cast<uint32_t>(<wbr>MinidumpContext_x86_64_Flags::<wbr>x86_64_Flag);<br>
+  const uint32_t ControlFlag =<br>
+      static_cast<uint32_t>(<wbr>MinidumpContext_x86_64_Flags::<wbr>Control);<br>
+  const uint32_t IntegerFlag =<br>
+      static_cast<uint32_t>(<wbr>MinidumpContext_x86_64_Flags::<wbr>Integer);<br>
+  const uint32_t SegmentsFlag =<br>
+      static_cast<uint32_t>(<wbr>MinidumpContext_x86_64_Flags::<wbr>Segments);<br>
+  const uint32_t DebugRegistersFlag =<br>
+      static_cast<uint32_t>(<wbr>MinidumpContext_x86_64_Flags::<wbr>DebugRegisters);<br>
+<br>
+  if (!(*context_flags & x86_64_Flag)) {<br>
+    return result_context_buf; // error<br>
+  }<br>
+<br>
+  source_data = source_data.drop_front(4); // mx_csr<br>
+<br>
+  if (*context_flags & ControlFlag) {<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_cs_x86_64,<br>
+                                               reg_info[lldb_cs_x86_64]));<br>
+  }<br>
+<br>
+  if (*context_flags & SegmentsFlag) {<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_ds_x86_64,<br>
+                                               reg_info[lldb_ds_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_es_x86_64,<br>
+                                               reg_info[lldb_es_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_fs_x86_64,<br>
+                                               reg_info[lldb_fs_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_gs_x86_64,<br>
+                                               reg_info[lldb_gs_x86_64]));<br>
+  }<br>
+<br>
+  if (*context_flags & ControlFlag) {<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_ss_x86_64,<br>
+                                               reg_info[lldb_ss_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_rflags_x86_64,<br>
+                                               reg_info[lldb_rflags_x86_64]))<wbr>;<br>
+  }<br>
+<br>
+  if (*context_flags & DebugRegistersFlag) {<br>
+    source_data =<br>
+        source_data.drop_front(6 * 8); // 6 debug registers 64 bit each<br>
+  }<br>
+<br>
+  if (*context_flags & IntegerFlag) {<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_rax_x86_64,<br>
+                                               reg_info[lldb_rax_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_rcx_x86_64,<br>
+                                               reg_info[lldb_rcx_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_rdx_x86_64,<br>
+                                               reg_info[lldb_rdx_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_rbx_x86_64,<br>
+                                               reg_info[lldb_rbx_x86_64]));<br>
+  }<br>
+<br>
+  if (*context_flags & ControlFlag) {<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_rsp_x86_64,<br>
+                                               reg_info[lldb_rsp_x86_64]));<br>
+  }<br>
+<br>
+  if (*context_flags & IntegerFlag) {<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_rbp_x86_64,<br>
+                                               reg_info[lldb_rbp_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_rsi_x86_64,<br>
+                                               reg_info[lldb_rsi_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_rdi_x86_64,<br>
+                                               reg_info[lldb_rdi_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_r8_x86_64,<br>
+                                               reg_info[lldb_r8_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_r9_x86_64,<br>
+                                               reg_info[lldb_r9_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_r10_x86_64,<br>
+                                               reg_info[lldb_r10_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_r11_x86_64,<br>
+                                               reg_info[lldb_r11_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_r12_x86_64,<br>
+                                               reg_info[lldb_r12_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_r13_x86_64,<br>
+                                               reg_info[lldb_r13_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_r14_x86_64,<br>
+                                               reg_info[lldb_r14_x86_64]));<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_r15_x86_64,<br>
+                                               reg_info[lldb_r15_x86_64]));<br>
+  }<br>
+<br>
+  if (*context_flags & ControlFlag) {<br>
+    writeRegister(source_data, getDestRegister(result_base, lldb_rip_x86_64,<br>
+                                               reg_info[lldb_rip_x86_64]));<br>
+  }<br>
+<br>
+  // TODO parse the floating point registers<br>
+<br>
+  return result_context_buf;<br>
+}<br>
<br>
Added: lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>RegisterContextMinidump_x86_<wbr>64.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h?rev=282529&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lldb/trunk/source/<wbr>Plugins/Process/minidump/<wbr>RegisterContextMinidump_x86_<wbr>64.h?rev=282529&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>RegisterContextMinidump_x86_<wbr>64.h (added)<br>
+++ lldb/trunk/source/Plugins/<wbr>Process/minidump/<wbr>RegisterContextMinidump_x86_<wbr>64.h Tue Sep 27 14:05:55 2016<br>
@@ -0,0 +1,119 @@<br>
+//===-- RegisterContextMinidump_x86_<wbr>64.h ------------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#ifndef liblldb_<wbr>RegisterContextMinidump_h_<br>
+#define liblldb_<wbr>RegisterContextMinidump_h_<br>
+<br>
+// Project includes<br>
+#include "MinidumpTypes.h"<br>
+<br>
+// Other libraries and framework includes<br>
+#include "Plugins/Process/Utility/<wbr>RegisterInfoInterface.h"<br>
+#include "Plugins/Process/Utility/lldb-<wbr>x86-register-enums.h"<br>
+<br>
+#include "lldb/Target/RegisterContext.<wbr>h"<br>
+<br>
+#include "llvm/ADT/ArrayRef.h"<br>
+#include "llvm/ADT/BitmaskEnum.h"<br>
+<br>
+// C includes<br>
+// C++ includes<br>
+<br>
+namespace lldb_private {<br>
+<br>
+namespace minidump {<br>
+<br>
+// The content of the Minidump register context is as follows:<br>
+// (for reference see breakpad's source or WinNT.h)<br>
+// Register parameter home addresses: (p1_home .. p6_home)<br>
+// - uint64_t p1_home<br>
+// - uint64_t p2_home<br>
+// - uint64_t p3_home<br>
+// - uint64_t p4_home<br>
+// - uint64_t p5_home<br>
+// - uint64_t p6_home<br>
+//<br>
+// - uint32_t context_flags - field that determines the layout of the structure<br>
+//     and which parts of it are populated<br>
+// - uint32_t mx_csr<br>
+//<br>
+// - uint16_t cs - included if MinidumpContext_x86_64_Flags::<wbr>Control<br>
+//<br>
+// - uint16_t ds - included if MinidumpContext_x86_64_Flags::<wbr>Segments<br>
+// - uint16_t es - included if MinidumpContext_x86_64_Flags::<wbr>Segments<br>
+// - uint16_t fs - included if MinidumpContext_x86_64_Flags::<wbr>Segments<br>
+// - uint16_t gs - included if MinidumpContext_x86_64_Flags::<wbr>Segments<br>
+//<br>
+// - uint16_t ss     - included if MinidumpContext_x86_64_Flags::<wbr>Control<br>
+// - uint32_t rflags - included if MinidumpContext_x86_64_Flags::<wbr>Control<br>
+//<br>
+// Debug registers: (included if MinidumpContext_x86_64_Flags::<wbr>DebugRegisters)<br>
+// - uint64_t dr0<br>
+// - uint64_t dr1<br>
+// - uint64_t dr2<br>
+// - uint64_t dr3<br>
+// - uint64_t dr6<br>
+// - uint64_t dr7<br>
+//<br>
+// The next 4 registers are included if MinidumpContext_x86_64_Flags::<wbr>Integer<br>
+// - uint64_t rax<br>
+// - uint64_t rcx<br>
+// - uint64_t rdx<br>
+// - uint64_t rbx<br>
+//<br>
+// - uint64_t rsp - included if MinidumpContext_x86_64_Flags::<wbr>Control<br>
+//<br>
+// The next 11 registers are included if MinidumpContext_x86_64_Flags::<wbr>Integer<br>
+// - uint64_t rbp<br>
+// - uint64_t rsi<br>
+// - uint64_t rdi<br>
+// - uint64_t r8<br>
+// - uint64_t r9<br>
+// - uint64_t r10<br>
+// - uint64_t r11<br>
+// - uint64_t r12<br>
+// - uint64_t r13<br>
+// - uint64_t r14<br>
+// - uint64_t r15<br>
+//<br>
+// - uint64_t rip - included if MinidumpContext_x86_64_Flags::<wbr>Control<br>
+//<br>
+// TODO: add floating point registers here<br>
+<br>
+// This function receives an ArrayRef pointing to the bytes of the Minidump<br>
+// register context and returns a DataBuffer that's ordered by the offsets<br>
+// specified in the RegisterInfoInterface argument<br>
+// This way we can reuse the already existing register contexts<br>
+lldb::DataBufferSP<br>
+<wbr>ConvertMinidumpContextToRegIfa<wbr>ce(llvm::ArrayRef<uint8_t> source_data,<br>
+                                 RegisterInfoInterface *target_reg_interface);<br>
+<br>
+// For context_flags. These values indicate the type of<br>
+// context stored in the structure.  The high 24 bits identify the CPU, the<br>
+// low 8 bits identify the type of context saved.<br>
+LLVM_ENABLE_BITMASK_ENUMS_IN_<wbr>NAMESPACE();<br>
+<br>
+enum class MinidumpContext_x86_64_Flags : uint32_t {<br>
+  x86_64_Flag = 0x00100000,<br>
+  Control = x86_64_Flag | 0x00000001,<br>
+  Integer = x86_64_Flag | 0x00000002,<br>
+  Segments = x86_64_Flag | 0x00000004,<br>
+  FloatingPoint = x86_64_Flag | 0x00000008,<br>
+  DebugRegisters = x86_64_Flag | 0x00000010,<br>
+  XState = x86_64_Flag | 0x00000040,<br>
+<br>
+  Full = Control | Integer | FloatingPoint,<br>
+  All = Full | Segments | DebugRegisters,<br>
+<br>
+  LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ All)<br>
+};<br>
+<br>
+} // end namespace minidump<br>
+} // end namespace lldb_private<br>
+#endif // liblldb_<wbr>RegisterContextMinidump_h_<br>
<br>
Modified: lldb/trunk/unittests/Process/<wbr>minidump/MinidumpParserTest.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp?rev=282529&r1=282528&r2=282529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lldb/trunk/unittests/<wbr>Process/minidump/<wbr>MinidumpParserTest.cpp?rev=<wbr>282529&r1=282528&r2=282529&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lldb/trunk/unittests/Process/<wbr>minidump/MinidumpParserTest.<wbr>cpp (original)<br>
+++ lldb/trunk/unittests/Process/<wbr>minidump/MinidumpParserTest.<wbr>cpp Tue Sep 27 14:05:55 2016<br>
@@ -8,8 +8,10 @@<br>
 //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
<br>
 // Project includes<br>
+#include "Plugins/Process/Utility/<wbr>RegisterContextLinux_x86_64.h"<br>
 #include "Plugins/Process/minidump/<wbr>MinidumpParser.h"<br>
 #include "Plugins/Process/minidump/<wbr>MinidumpTypes.h"<br>
+#include "Plugins/Process/minidump/<wbr>RegisterContextMinidump_x86_<wbr>64.h"<br>
<br>
 // Other libraries and framework includes<br>
 #include "gtest/gtest.h"<br>
@@ -18,6 +20,7 @@<br>
 #include "lldb/Core/DataExtractor.h"<br>
 #include "lldb/Host/FileSpec.h"<br>
<br>
+#include "llvm/ADT/ArrayRef.h"<br>
 #include "llvm/ADT/Optional.h"<br>
 #include "llvm/Support/FileSystem.h"<br>
 #include "llvm/Support/Path.h"<br>
@@ -50,7 +53,7 @@ public:<br>
         MinidumpParser::Create(data_<wbr>sp);<br>
     ASSERT_TRUE(optional_parser.<wbr>hasValue());<br>
     parser.reset(new MinidumpParser(optional_<wbr>parser.getValue()));<br>
-    ASSERT_GT(parser->GetByteSize(<wbr>), 0UL);<br>
+    ASSERT_GT(parser->GetData().<wbr>size(), 0UL);<br>
   }<br>
<br>
   llvm::SmallString<128> inputs_folder;<br>
@@ -167,3 +170,61 @@ TEST_F(MinidumpParserTest, GetPidWindows<br>
   ASSERT_TRUE(pid.hasValue());<br>
   ASSERT_EQ(4440UL, pid.getValue());<br>
 }<br>
+<br>
+// Register stuff<br>
+// TODO probably split register stuff tests into different file?<br>
+#define REG_VAL(x) *(reinterpret_cast<uint64_t *>(x))<br>
+<br>
+TEST_F(MinidumpParserTest, ConvertRegisterContext) {<br>
+  SetUpData("linux-x86_64.dmp");<br>
+  llvm::ArrayRef<MinidumpThread> thread_list = parser->GetThreads();<br>
+  const MinidumpThread thread = thread_list[0];<br>
+  llvm::ArrayRef<uint8_t> registers(parser->GetData().<wbr>data() +<br>
+                                        thread.thread_context.rva,<br>
+                                    thread.thread_context.data_<wbr>size);<br>
+<br>
+  ArchSpec arch = parser->GetArchitecture();<br>
+  RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(<wbr>arch);<br>
+  lldb::DataBufferSP buf =<br>
+      ConvertMinidumpContextToRegIfa<wbr>ce(registers, reg_interface);<br>
+  ASSERT_EQ(reg_interface-><wbr>GetGPRSize(), buf->GetByteSize());<br>
+<br>
+  const RegisterInfo *reg_info = reg_interface-><wbr>GetRegisterInfo();<br>
+<br>
+  std::map<uint64_t, uint64_t> reg_values;<br>
+<br>
+  // clang-format off<br>
+  reg_values[lldb_rax_x86_64]    =  0x0000000000000000;<br>
+  reg_values[lldb_rbx_x86_64]    =  0x0000000000000000;<br>
+  reg_values[lldb_rcx_x86_64]    =  0x0000000000000010;<br>
+  reg_values[lldb_rdx_x86_64]    =  0x0000000000000000;<br>
+  reg_values[lldb_rdi_x86_64]    =  0x00007ffceb349cf0;<br>
+  reg_values[lldb_rsi_x86_64]    =  0x0000000000000000;<br>
+  reg_values[lldb_rbp_x86_64]    =  0x00007ffceb34a210;<br>
+  reg_values[lldb_rsp_x86_64]    =  0x00007ffceb34a210;<br>
+  reg_values[lldb_r8_x86_64]     =  0x00007fe9bc1aa9c0;<br>
+  reg_values[lldb_r9_x86_64]     =  0x0000000000000000;<br>
+  reg_values[lldb_r10_x86_64]    =  0x00007fe9bc3f16a0;<br>
+  reg_values[lldb_r11_x86_64]    =  0x0000000000000246;<br>
+  reg_values[lldb_r12_x86_64]    =  0x0000000000401c92;<br>
+  reg_values[lldb_r13_x86_64]    =  0x00007ffceb34a430;<br>
+  reg_values[lldb_r14_x86_64]    =  0x0000000000000000;<br>
+  reg_values[lldb_r15_x86_64]    =  0x0000000000000000;<br>
+  reg_values[lldb_rip_x86_64]    =  0x0000000000401dc6;<br>
+  reg_values[lldb_rflags_x86_64] =  0x0000000000010206;<br>
+  reg_values[lldb_cs_x86_64]     =  0x0000000000000033;<br>
+  reg_values[lldb_fs_x86_64]     =  0x0000000000000000;<br>
+  reg_values[lldb_gs_x86_64]     =  0x0000000000000000;<br>
+  reg_values[lldb_ss_x86_64]     =  0x0000000000000000;<br>
+  reg_values[lldb_ds_x86_64]     =  0x0000000000000000;<br>
+  reg_values[lldb_es_x86_64]     =  0x0000000000000000;<br>
+  // clang-format on<br>
+<br>
+  for (uint32_t reg_index = 0; reg_index < reg_interface-><wbr>GetRegisterCount();<br>
+       ++reg_index) {<br>
+    if (reg_values.find(reg_index) != reg_values.end()) {<br>
+      EXPECT_EQ(reg_values[reg_<wbr>index],<br>
+                REG_VAL(buf->GetBytes() + reg_info[reg_index].byte_<wbr>offset));<br>
+    }<br>
+  }<br>
+}<br>
<br>
<br>
______________________________<wbr>_________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/lldb-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Tim <<a href="mailto:penryu@gmail.com" target="_blank">penryu@gmail.com</a>></div>
</div>