[Lldb-commits] [PATCH] D50336: Add support for ARM and ARM64 breakpad generated minidump files (version 2).

2018-08-06 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

More offsetof issues:

$ svn commit
Sendingsource/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
Transmitting file data .done
Committing transaction...
Committed revision 339034.


Repository:
  rL LLVM

https://reviews.llvm.org/D50336



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


[Lldb-commits] [PATCH] D50336: Add support for ARM and ARM64 breakpad generated minidump files (version 2).

2018-08-06 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Passing patches between linux and mac the offsetof fixes got lost. When binary 
files are involved, patches are trickier to pass between to machines.


Repository:
  rL LLVM

https://reviews.llvm.org/D50336



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


[Lldb-commits] [PATCH] D50336: Add support for ARM and ARM64 breakpad generated minidump files (version 2).

2018-08-06 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Fixed offsetof issues with:

$ svn commit
Sendingsource/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
Sendingsource/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
Transmitting file data ..done
Committing transaction...
Committed revision 339033.


Repository:
  rL LLVM

https://reviews.llvm.org/D50336



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


[Lldb-commits] [PATCH] D50336: Add support for ARM and ARM64 breakpad generated minidump files (version 2).

2018-08-06 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339032: Add support for ARM and ARM64 breakpad generated 
minidump files (version 2). (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50336?vs=159324=159326#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50336

Files:
  lldb/trunk/include/lldb/Target/Target.h
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp
  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/ProcessMinidump.cpp
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
  lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp
  lldb/trunk/source/Target/Target.cpp

Index: lldb/trunk/include/lldb/Target/Target.h
===
--- lldb/trunk/include/lldb/Target/Target.h
+++ lldb/trunk/include/lldb/Target/Target.h
@@ -913,28 +913,30 @@
   /// Set the architecture for this target.
   ///
   /// If the current target has no Images read in, then this just sets the
-  /// architecture, which will
-  /// be used to select the architecture of the ExecutableModule when that is
-  /// set.
-  /// If the current target has an ExecutableModule, then calling
-  /// SetArchitecture with a different
+  /// architecture, which will be used to select the architecture of the
+  /// ExecutableModule when that is set. If the current target has an
+  /// ExecutableModule, then calling SetArchitecture with a different
   /// architecture from the currently selected one will reset the
-  /// ExecutableModule to that slice
-  /// of the file backing the ExecutableModule.  If the file backing the
-  /// ExecutableModule does not
-  /// contain a fork of this architecture, then this code will return false, and
-  /// the architecture
-  /// won't be changed.
-  /// If the input arch_spec is the same as the already set architecture, this
-  /// is a no-op.
+  /// ExecutableModule to that slice of the file backing the ExecutableModule.
+  /// If the file backing the ExecutableModule does not contain a fork of this
+  /// architecture, then this code will return false, and the architecture
+  /// won't be changed. If the input arch_spec is the same as the already set
+  /// architecture, this is a no-op.
   ///
   /// @param[in] arch_spec
   /// The new architecture.
   ///
+  /// @param[in] set_platform
+  /// If \b true, then the platform will be adjusted if the currently
+  /// selected platform is not compatible with the archicture being set.
+  /// If \b false, then just the architecture will be set even if the
+  /// currently selected platform isn't compatible (in case it might be
+  /// manually set following this function call).
+  ///
   /// @return
   /// \b true if the architecture was successfully set, \bfalse otherwise.
   //--
-  bool SetArchitecture(const ArchSpec _spec);
+  bool SetArchitecture(const ArchSpec _spec, bool set_platform = false);
 
   bool MergeArchitecture(const ArchSpec _spec);
 
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
@@ -189,6 +189,161 @@
 stop_description = thread.GetStopDescription(256)
 self.assertEqual(stop_description, "")
 
+def check_register_unsigned(self, set, name, expected):
+reg_value = set.GetChildMemberWithName(name)
+self.assertTrue(reg_value.IsValid(),
+'Verify we have a register named "%s"' % (name))
+self.assertEqual(reg_value.GetValueAsUnsigned(), expected,
+ 'Verify "%s" == %i' % (name, expected))
+
+def check_register_string_value(self, set, name, expected, format):
+reg_value = set.GetChildMemberWithName(name)
+

[Lldb-commits] [PATCH] D50336: Add support for ARM and ARM64 breakpad generated minidump files (version 2).

2018-08-06 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB339032: Add support for ARM and ARM64 breakpad generated 
minidump files (version 2). (authored by gclayton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50336?vs=159324=159325#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50336

Files:
  include/lldb/Target/Target.h
  lldb.xcodeproj/project.pbxproj
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
  source/Plugins/Process/minidump/ThreadMinidump.cpp
  source/Target/Target.cpp

Index: include/lldb/Target/Target.h
===
--- include/lldb/Target/Target.h
+++ include/lldb/Target/Target.h
@@ -913,28 +913,30 @@
   /// Set the architecture for this target.
   ///
   /// If the current target has no Images read in, then this just sets the
-  /// architecture, which will
-  /// be used to select the architecture of the ExecutableModule when that is
-  /// set.
-  /// If the current target has an ExecutableModule, then calling
-  /// SetArchitecture with a different
+  /// architecture, which will be used to select the architecture of the
+  /// ExecutableModule when that is set. If the current target has an
+  /// ExecutableModule, then calling SetArchitecture with a different
   /// architecture from the currently selected one will reset the
-  /// ExecutableModule to that slice
-  /// of the file backing the ExecutableModule.  If the file backing the
-  /// ExecutableModule does not
-  /// contain a fork of this architecture, then this code will return false, and
-  /// the architecture
-  /// won't be changed.
-  /// If the input arch_spec is the same as the already set architecture, this
-  /// is a no-op.
+  /// ExecutableModule to that slice of the file backing the ExecutableModule.
+  /// If the file backing the ExecutableModule does not contain a fork of this
+  /// architecture, then this code will return false, and the architecture
+  /// won't be changed. If the input arch_spec is the same as the already set
+  /// architecture, this is a no-op.
   ///
   /// @param[in] arch_spec
   /// The new architecture.
   ///
+  /// @param[in] set_platform
+  /// If \b true, then the platform will be adjusted if the currently
+  /// selected platform is not compatible with the archicture being set.
+  /// If \b false, then just the architecture will be set even if the
+  /// currently selected platform isn't compatible (in case it might be
+  /// manually set following this function call).
+  ///
   /// @return
   /// \b true if the architecture was successfully set, \bfalse otherwise.
   //--
-  bool SetArchitecture(const ArchSpec _spec);
+  bool SetArchitecture(const ArchSpec _spec, bool set_platform = false);
 
   bool MergeArchitecture(const ArchSpec _spec);
 
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
@@ -189,6 +189,161 @@
 stop_description = thread.GetStopDescription(256)
 self.assertEqual(stop_description, "")
 
+def check_register_unsigned(self, set, name, expected):
+reg_value = set.GetChildMemberWithName(name)
+self.assertTrue(reg_value.IsValid(),
+'Verify we have a register named "%s"' % (name))
+self.assertEqual(reg_value.GetValueAsUnsigned(), expected,
+ 'Verify "%s" == %i' % (name, expected))
+
+def check_register_string_value(self, set, name, expected, format):
+reg_value = set.GetChildMemberWithName(name)
+self.assertTrue(reg_value.IsValid(),
+'Verify we have a register named "%s"' % (name))
+if format is not None:
+reg_value.SetFormat(format)
+self.assertEqual(reg_value.GetValue(), expected,
+ 'Verify "%s" has 

[Lldb-commits] [PATCH] D50336: Add support for ARM and ARM64 breakpad generated minidump files (version 2).

2018-08-06 Thread Greg Clayton via Phabricator via lldb-commits
clayborg updated this revision to Diff 159324.
clayborg added a comment.
Herald added a subscriber: mgorny.

Added CMakeList.txt changes, tested on linux, and removed unused "log" variable.


https://reviews.llvm.org/D50336

Files:
  include/lldb/Target/Target.h
  lldb.xcodeproj/project.pbxproj
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
  source/Plugins/Process/minidump/ThreadMinidump.cpp
  source/Target/Target.cpp

Index: source/Target/Target.cpp
===
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -1426,13 +1426,33 @@
   }
 }
 
-bool Target::SetArchitecture(const ArchSpec _spec) {
+bool Target::SetArchitecture(const ArchSpec _spec, bool set_platform) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET));
   bool missing_local_arch = !m_arch.GetSpec().IsValid();
   bool replace_local_arch = true;
   bool compatible_local_arch = false;
   ArchSpec other(arch_spec);
 
+  // Changing the architecture might mean that the currently selected platform
+  // isn't compatible. Set the platform correctly if we are asked to do so,
+  // otherwise assume the user will set the platform manually.
+  if (set_platform) {
+if (other.IsValid()) {
+  auto platform_sp = GetPlatform();
+  if (!platform_sp ||
+  !platform_sp->IsCompatibleArchitecture(other, false, nullptr)) {
+ArchSpec platform_arch;
+auto arch_platform_sp =
+Platform::GetPlatformForArchitecture(other, _arch);
+if (arch_platform_sp) {
+  SetPlatform(arch_platform_sp);
+  if (platform_arch.IsValid())
+other = platform_arch;
+}
+  }
+}
+  }
+
   if (!missing_local_arch) {
 if (m_arch.GetSpec().IsCompatibleMatch(arch_spec)) {
   other.MergeFrom(m_arch.GetSpec());
Index: source/Plugins/Process/minidump/ThreadMinidump.cpp
===
--- source/Plugins/Process/minidump/ThreadMinidump.cpp
+++ source/Plugins/Process/minidump/ThreadMinidump.cpp
@@ -11,6 +11,8 @@
 #include "ThreadMinidump.h"
 #include "ProcessMinidump.h"
 
+#include "RegisterContextMinidump_ARM.h"
+#include "RegisterContextMinidump_ARM64.h"
 #include "RegisterContextMinidump_x86_32.h"
 #include "RegisterContextMinidump_x86_64.h"
 
@@ -54,7 +56,6 @@
 ThreadMinidump::CreateRegisterContextForFrame(StackFrame *frame) {
   RegisterContextSP reg_ctx_sp;
   uint32_t concrete_frame_idx = 0;
-  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
 
   if (frame)
 concrete_frame_idx = frame->GetConcreteFrameIndex();
@@ -88,17 +89,24 @@
   *this, reg_interface, gpregset, {}));
   break;
 }
+case llvm::Triple::aarch64: {
+  DataExtractor data(m_gpregset_data.data(), m_gpregset_data.size(),
+ lldb::eByteOrderLittle, 8);
+  m_thread_reg_ctx_sp.reset(new RegisterContextMinidump_ARM64(*this, data));
+  break;
+}
+case llvm::Triple::arm: {
+  DataExtractor data(m_gpregset_data.data(), m_gpregset_data.size(),
+ lldb::eByteOrderLittle, 8);
+  const bool apple = arch.GetTriple().getVendor() == llvm::Triple::Apple;
+  m_thread_reg_ctx_sp.reset(
+  new RegisterContextMinidump_ARM(*this, data, apple));
+  break;
+}
 default:
   break;
 }
 
-if (!reg_interface) {
-  if (log)
-log->Printf("elf-core::%s:: Architecture(%d) not supported",
-__FUNCTION__, arch.GetMachine());
-  assert(false && "Architecture not supported");
-}
-
 reg_ctx_sp = m_thread_reg_ctx_sp;
   } else if (m_unwinder_ap) {
 reg_ctx_sp = m_unwinder_ap->CreateRegisterContextForFrame(frame);
Index: source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
===
--- source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
+++ source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
@@ -0,0 +1,85 @@
+//===-- RegisterContextMinidump_ARM64.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed 

[Lldb-commits] [PATCH] D50336: Add support for ARM and ARM64 breakpad generated minidump files (version 2).

2018-08-06 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

This should be fine once the cmake thing is addressed.


https://reviews.llvm.org/D50336



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


Re: [Lldb-commits] [PATCH] D50336: Add support for ARM and ARM64 breakpad generated minidump files (version 2).

2018-08-06 Thread Greg Clayton via lldb-commits
I was in the process of testing on linux. I will fix this.


> On Aug 6, 2018, at 8:19 AM, Zachary Turner  wrote:
> 
> Did you see my comments on the first round about how the CMake build didn’t 
> work? Because I don’t see any changes to CMakeLists.txt here, which means it 
> still won’t work.
> 
> The easiest way to make sure you get all the fixes that may have gone in 
> after your initial commit is to revert the revert and build your 
> modifications on top of that. Then, for example, the fixes to CMakeLists.txt 
> would already be here.
> On Mon, Aug 6, 2018 at 11:14 AM Greg Clayton via Phabricator 
> mailto:revi...@reviews.llvm.org>> wrote:
> clayborg created this revision.
> clayborg added reviewers: labath, zturner, markmentovai, javed.absar.
> Herald added subscribers: chrib, kristof.beyls.
> 
> In this patch I add support for ARM and ARM64 break pad files. There are two 
> flavors of ARM: Apple where FP is https://reviews.llvm.org/source/openmp/ 
> , and non Apple where FP is 
> https://reviews.llvm.org/source/libunwind/ 
> . Added minimal tests that load 
> up ARM64 and the two flavors or ARM core files with a single thread and known 
> register values in each register. Each register is checked for the exact 
> value.
> 
> This is a fixed version of: https://reviews.llvm.org/D49750 
> 
> 
> The changes from https://reviews.llvm.org/D49750 
>  are:
> 
> - Don't init the m_arch in the Initialize call as a system info isn't 
> required. This keeps the thread list, module list and other tests from failing
> - Added -Wextended-offsetof to Xcode project so we catch use extended usages 
> of offsetof before submission
> - Fixed any extended offset of warnings
> 
> 
> https://reviews.llvm.org/D50336 
> 
> Files:
>   include/lldb/Target/Target.h
>   lldb.xcodeproj/project.pbxproj
>   
> packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
>   
> packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp
>   
> packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp
>   
> packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp
>   source/Plugins/Process/minidump/MinidumpParser.cpp
>   source/Plugins/Process/minidump/MinidumpParser.h
>   source/Plugins/Process/minidump/ProcessMinidump.cpp
>   source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
>   source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
>   source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
>   source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
>   source/Plugins/Process/minidump/ThreadMinidump.cpp
>   source/Target/Target.cpp
> 

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


[Lldb-commits] [PATCH] D50336: Add support for ARM and ARM64 breakpad generated minidump files (version 2).

2018-08-06 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a subscriber: clayborg.
zturner added a comment.

Did you see my comments on the first round about how the CMake build didn’t
work? Because I don’t see any changes to CMakeLists.txt here, which means
it still won’t work.

The easiest way to make sure you get all the fixes that may have gone in
after your initial commit is to revert the revert and build your
modifications on top of that. Then, for example, the fixes to
CMakeLists.txt would already be here.


https://reviews.llvm.org/D50336



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


Re: [Lldb-commits] [PATCH] D50336: Add support for ARM and ARM64 breakpad generated minidump files (version 2).

2018-08-06 Thread Zachary Turner via lldb-commits
Did you see my comments on the first round about how the CMake build didn’t
work? Because I don’t see any changes to CMakeLists.txt here, which means
it still won’t work.

The easiest way to make sure you get all the fixes that may have gone in
after your initial commit is to revert the revert and build your
modifications on top of that. Then, for example, the fixes to
CMakeLists.txt would already be here.
On Mon, Aug 6, 2018 at 11:14 AM Greg Clayton via Phabricator <
revi...@reviews.llvm.org> wrote:

> clayborg created this revision.
> clayborg added reviewers: labath, zturner, markmentovai, javed.absar.
> Herald added subscribers: chrib, kristof.beyls.
>
> In this patch I add support for ARM and ARM64 break pad files. There are
> two flavors of ARM: Apple where FP is
> https://reviews.llvm.org/source/openmp/, and non Apple where FP is
> https://reviews.llvm.org/source/libunwind/. Added minimal tests that load
> up ARM64 and the two flavors or ARM core files with a single thread and
> known register values in each register. Each register is checked for the
> exact value.
>
> This is a fixed version of: https://reviews.llvm.org/D49750
>
> The changes from https://reviews.llvm.org/D49750 are:
>
> - Don't init the m_arch in the Initialize call as a system info isn't
> required. This keeps the thread list, module list and other tests from
> failing
> - Added -Wextended-offsetof to Xcode project so we catch use extended
> usages of offsetof before submission
> - Fixed any extended offset of warnings
>
>
> https://reviews.llvm.org/D50336
>
> Files:
>   include/lldb/Target/Target.h
>   lldb.xcodeproj/project.pbxproj
>
> packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
>
> packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp
>
> packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp
>
> packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp
>   source/Plugins/Process/minidump/MinidumpParser.cpp
>   source/Plugins/Process/minidump/MinidumpParser.h
>   source/Plugins/Process/minidump/ProcessMinidump.cpp
>   source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
>   source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
>   source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
>   source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
>   source/Plugins/Process/minidump/ThreadMinidump.cpp
>   source/Target/Target.cpp
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50336: Add support for ARM and ARM64 breakpad generated minidump files (version 2).

2018-08-06 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added reviewers: labath, zturner, markmentovai, javed.absar.
Herald added subscribers: chrib, kristof.beyls.

In this patch I add support for ARM and ARM64 break pad files. There are two 
flavors of ARM: Apple where FP is https://reviews.llvm.org/source/openmp/, and 
non Apple where FP is https://reviews.llvm.org/source/libunwind/. Added minimal 
tests that load up ARM64 and the two flavors or ARM core files with a single 
thread and known register values in each register. Each register is checked for 
the exact value.

This is a fixed version of: https://reviews.llvm.org/D49750

The changes from https://reviews.llvm.org/D49750 are:

- Don't init the m_arch in the Initialize call as a system info isn't required. 
This keeps the thread list, module list and other tests from failing
- Added -Wextended-offsetof to Xcode project so we catch use extended usages of 
offsetof before submission
- Fixed any extended offset of warnings


https://reviews.llvm.org/D50336

Files:
  include/lldb/Target/Target.h
  lldb.xcodeproj/project.pbxproj
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
  source/Plugins/Process/minidump/ThreadMinidump.cpp
  source/Target/Target.cpp

Index: source/Target/Target.cpp
===
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -1426,13 +1426,33 @@
   }
 }
 
-bool Target::SetArchitecture(const ArchSpec _spec) {
+bool Target::SetArchitecture(const ArchSpec _spec, bool set_platform) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET));
   bool missing_local_arch = !m_arch.GetSpec().IsValid();
   bool replace_local_arch = true;
   bool compatible_local_arch = false;
   ArchSpec other(arch_spec);
 
+  // Changing the architecture might mean that the currently selected platform
+  // isn't compatible. Set the platform correctly if we are asked to do so,
+  // otherwise assume the user will set the platform manually.
+  if (set_platform) {
+if (other.IsValid()) {
+  auto platform_sp = GetPlatform();
+  if (!platform_sp ||
+  !platform_sp->IsCompatibleArchitecture(other, false, nullptr)) {
+ArchSpec platform_arch;
+auto arch_platform_sp =
+Platform::GetPlatformForArchitecture(other, _arch);
+if (arch_platform_sp) {
+  SetPlatform(arch_platform_sp);
+  if (platform_arch.IsValid())
+other = platform_arch;
+}
+  }
+}
+  }
+
   if (!missing_local_arch) {
 if (m_arch.GetSpec().IsCompatibleMatch(arch_spec)) {
   other.MergeFrom(m_arch.GetSpec());
Index: source/Plugins/Process/minidump/ThreadMinidump.cpp
===
--- source/Plugins/Process/minidump/ThreadMinidump.cpp
+++ source/Plugins/Process/minidump/ThreadMinidump.cpp
@@ -11,6 +11,8 @@
 #include "ThreadMinidump.h"
 #include "ProcessMinidump.h"
 
+#include "RegisterContextMinidump_ARM.h"
+#include "RegisterContextMinidump_ARM64.h"
 #include "RegisterContextMinidump_x86_32.h"
 #include "RegisterContextMinidump_x86_64.h"
 
@@ -88,17 +90,24 @@
   *this, reg_interface, gpregset, {}));
   break;
 }
+case llvm::Triple::aarch64: {
+  DataExtractor data(m_gpregset_data.data(), m_gpregset_data.size(),
+ lldb::eByteOrderLittle, 8);
+  m_thread_reg_ctx_sp.reset(new RegisterContextMinidump_ARM64(*this, data));
+  break;
+}
+case llvm::Triple::arm: {
+  DataExtractor data(m_gpregset_data.data(), m_gpregset_data.size(),
+ lldb::eByteOrderLittle, 8);
+  const bool apple = arch.GetTriple().getVendor() == llvm::Triple::Apple;
+  m_thread_reg_ctx_sp.reset(
+  new RegisterContextMinidump_ARM(*this, data, apple));
+  break;
+}
 default:
   break;
 }
 
-if (!reg_interface) {
-  if (log)
-log->Printf("elf-core::%s:: Architecture(%d) not supported",
-__FUNCTION__, arch.GetMachine());
-  assert(false && "Architecture not supported");
-}
-
 reg_ctx_sp = m_thread_reg_ctx_sp;
   } else if (m_unwinder_ap) {
 reg_ctx_sp = m_unwinder_ap->CreateRegisterContextForFrame(frame);
Index: