[Lldb-commits] [PATCH] D46934: Make ObjectFileMachO work on non-darwin platforms

2018-05-18 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332702: Make ObjectFileMachO work on non-darwin platforms 
(authored by labath, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D46934

Files:
  lldb/trunk/lit/Modules/lc_version_min.yaml
  lldb/trunk/source/Initialization/CMakeLists.txt
  lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp

Index: lldb/trunk/lit/Modules/lc_version_min.yaml
===
--- lldb/trunk/lit/Modules/lc_version_min.yaml
+++ lldb/trunk/lit/Modules/lc_version_min.yaml
@@ -1,6 +1,6 @@
 # RUN: yaml2obj %s > %t.out
 # RUN: lldb-test symbols %t.out | FileCheck %s
-# REQUIRES: darwin
+
 # Test that the deployment target is parsed from the load commands.
 # CHECK: x86_64-apple-macosx10.9.0
 --- !mach-o
Index: lldb/trunk/source/Initialization/CMakeLists.txt
===
--- lldb/trunk/source/Initialization/CMakeLists.txt
+++ lldb/trunk/source/Initialization/CMakeLists.txt
@@ -1,7 +1,3 @@
-if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
-  list(APPEND EXTRA_PLUGINS lldbPluginObjectFileMachO)
-endif()
-
 if ( CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD|NetBSD" )
   list(APPEND EXTRA_PLUGINS lldbPluginProcessPOSIX)
 endif()
@@ -24,6 +20,7 @@
 lldbPluginObjectContainerBSDArchive
 lldbPluginObjectContainerMachOArchive
 lldbPluginObjectFileELF
+lldbPluginObjectFileMachO
 lldbPluginObjectFilePECOFF
 lldbPluginProcessGDBRemote
 ${EXTRA_PLUGINS}
Index: lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
===
--- lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
+++ lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
@@ -21,10 +21,7 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Timer.h"
-
-#if defined(__APPLE__)
 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
-#endif
 
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
@@ -82,6 +79,7 @@
   // Initialize plug-ins
   ObjectContainerBSDArchive::Initialize();
   ObjectFileELF::Initialize();
+  ObjectFileMachO::Initialize();
   ObjectFilePECOFF::Initialize();
 
   EmulateInstructionARM::Initialize();
@@ -93,9 +91,6 @@
   //--
   ObjectContainerUniversalMachO::Initialize();
 
-#if defined(__APPLE__)
-  ObjectFileMachO::Initialize();
-#endif
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
   ProcessPOSIXLog::Initialize();
 #endif
@@ -109,16 +104,14 @@
   Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
   ObjectContainerBSDArchive::Terminate();
   ObjectFileELF::Terminate();
+  ObjectFileMachO::Terminate();
   ObjectFilePECOFF::Terminate();
 
   EmulateInstructionARM::Terminate();
   EmulateInstructionMIPS::Terminate();
   EmulateInstructionMIPS64::Terminate();
 
   ObjectContainerUniversalMachO::Terminate();
-#if defined(__APPLE__)
-  ObjectFileMachO::Terminate();
-#endif
 
 #if defined(_MSC_VER)
   ProcessWindowsLog::Terminate();
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
@@ -7,13 +7,8 @@
 //
 //===--===//
 
-#if defined(__APPLE__)
-
 #include "RegisterContextDarwin_arm.h"
-
-// C Includes
-#include 
-#include 
+#include "RegisterContextDarwinConstants.h"
 
 // C++ Includes
 // Other libraries and framework includes
@@ -1766,5 +1761,3 @@
   }
   return false;
 }
-
-#endif
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
@@ -8,14 +8,8 @@
 //
 //===--===//
 
-#if defined(__APPLE__)
-
 #include "RegisterContextDarwin_arm64.h"
-
-// C Includes
-#include 
-#include 
-#include 
+#include "RegisterContextDarwinConstants.h"
 
 // C++ Includes
 // Other libraries and framework includes
@@ -1043,5 +1037,3 @@
   }
   return false;
 }
-
-#endif
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h

[Lldb-commits] [PATCH] D46934: Make ObjectFileMachO work on non-darwin platforms

2018-05-17 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 147341.
labath added a comment.

- Use #ifndef approach for handling the constants.


https://reviews.llvm.org/D46934

Files:
  lit/Modules/lc_version_min.yaml
  source/Initialization/CMakeLists.txt
  source/Initialization/SystemInitializerCommon.cpp
  source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
  source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
  source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp

Index: source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
===
--- source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
+++ source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
@@ -8,14 +8,8 @@
 //
 //===--===//
 
-#if defined(__APPLE__)
-
 #include "RegisterContextDarwin_arm64.h"
-
-// C Includes
-#include 
-#include 
-#include 
+#include "RegisterContextDarwinConstants.h"
 
 // C++ Includes
 // Other libraries and framework includes
@@ -1043,5 +1037,3 @@
   }
   return false;
 }
-
-#endif
Index: source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
===
--- source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
+++ source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
@@ -7,13 +7,8 @@
 //
 //===--===//
 
-#if defined(__APPLE__)
-
 #include "RegisterContextDarwin_arm.h"
-
-// C Includes
-#include 
-#include 
+#include "RegisterContextDarwinConstants.h"
 
 // C++ Includes
 // Other libraries and framework includes
@@ -1766,5 +1761,3 @@
   }
   return false;
 }
-
-#endif
Index: source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
===
--- /dev/null
+++ source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
@@ -0,0 +1,26 @@
+//===-- RegisterContextDarwinConstants.h *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLDB_REGISTERCONTEXTDARWINCONSTANTS_H
+#define LLDB_REGISTERCONTEXTDARWINCONSTANTS_H
+
+namespace lldb_private {
+
+/// Constants returned by various RegisterContextDarwin_*** functions.
+#ifndef KERN_SUCCESS
+#define KERN_SUCCESS 0
+#endif
+
+#ifndef KERN_INVALID_ARGUMENT
+#define KERN_INVALID_ARGUMENT 4
+#endif
+
+} // namespace lldb_private
+
+#endif // LLDB_REGISTERCONTEXTDARWINCONSTANTS_H
Index: source/Initialization/SystemInitializerCommon.cpp
===
--- source/Initialization/SystemInitializerCommon.cpp
+++ source/Initialization/SystemInitializerCommon.cpp
@@ -21,10 +21,7 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Timer.h"
-
-#if defined(__APPLE__)
 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
-#endif
 
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
@@ -82,6 +79,7 @@
   // Initialize plug-ins
   ObjectContainerBSDArchive::Initialize();
   ObjectFileELF::Initialize();
+  ObjectFileMachO::Initialize();
   ObjectFilePECOFF::Initialize();
 
   EmulateInstructionARM::Initialize();
@@ -93,9 +91,6 @@
   //--
   ObjectContainerUniversalMachO::Initialize();
 
-#if defined(__APPLE__)
-  ObjectFileMachO::Initialize();
-#endif
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
   ProcessPOSIXLog::Initialize();
 #endif
@@ -109,16 +104,14 @@
   Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
   ObjectContainerBSDArchive::Terminate();
   ObjectFileELF::Terminate();
+  ObjectFileMachO::Terminate();
   ObjectFilePECOFF::Terminate();
 
   EmulateInstructionARM::Terminate();
   EmulateInstructionMIPS::Terminate();
   EmulateInstructionMIPS64::Terminate();
 
   ObjectContainerUniversalMachO::Terminate();
-#if defined(__APPLE__)
-  ObjectFileMachO::Terminate();
-#endif
 
 #if defined(_MSC_VER)
   ProcessWindowsLog::Terminate();
Index: source/Initialization/CMakeLists.txt
===
--- source/Initialization/CMakeLists.txt
+++ source/Initialization/CMakeLists.txt
@@ -1,7 +1,3 @@
-if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
-  list(APPEND EXTRA_PLUGINS lldbPluginObjectFileMachO)
-endif()
-
 if ( CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD|NetBSD" )
   list(APPEND EXTRA_PLUGINS lldbPluginProcessPOSIX)
 endif()
@@ -24,6 +20,7 @@
 lldbPluginObjectContainerBSDArchive
 lldbPluginObjectContainerMachOArchive
 lldbPluginObjectFileELF
+

[Lldb-commits] [PATCH] D46934: Make ObjectFileMachO work on non-darwin platforms

2018-05-17 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

In https://reviews.llvm.org/D46934#1102867, @labath wrote:

> In https://reviews.llvm.org/D46934#1101963, @aprantl wrote:
>
> > Does that mean we can now also remove the #ifdef __APPLE__ from the 
> > objectfile unit tests?
>
>
> Which ones do you mean? I wasn't aware we had any. The thing I know of,  
> which would be interesting to enable is the MachO core file tests. This can't 
> be done yet because the respective process plugin is apple-only, but I 
> haven't looked at what it would take to enable it everywhere.


Sorry, I was confused. I was thinking about the HostInfoMacOSX class unit test 
which I added at the same time and somehow the two got conflated in my memory.


https://reviews.llvm.org/D46934



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


[Lldb-commits] [PATCH] D46934: Make ObjectFileMachO work on non-darwin platforms

2018-05-17 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: source/Plugins/Process/Utility/RegisterContextDarwinConstants.h:18
+  KERNEL_SUCCESS = 0,
+  KERNEL_INVALID_ARGUMENT = 4,
+};

I think I would prefer

#ifndef KERN_INVALID_ARGUMENT
#define KERN_INVALID_ARGUMENT 4
#endif

over renaming the constant. I think that that is less confusing to read and we 
use that pattern in other places in LLDB, too.


https://reviews.llvm.org/D46934



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


[Lldb-commits] [PATCH] D46934: Make ObjectFileMachO work on non-darwin platforms

2018-05-17 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 147286.
labath added a comment.

This is the version with new symbolic constants. I put them in a new file, as I
couldn't think of a better place for them.

I didn't want to put them in a too generic place as I don't think we should
encourage their use (we should convert error to one of our standard errors types
as soon as possible). On the other hand, they are used in two files, so they
can't be internal to a compilation unit. There wasn't anything reasonable in the
overlap of the existing includes of the two files, so I created a new file
instead.


https://reviews.llvm.org/D46934

Files:
  lit/Modules/lc_version_min.yaml
  source/Initialization/CMakeLists.txt
  source/Initialization/SystemInitializerCommon.cpp
  source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
  source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
  source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp

Index: source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
===
--- source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
+++ source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
@@ -8,14 +8,8 @@
 //
 //===--===//
 
-#if defined(__APPLE__)
-
 #include "RegisterContextDarwin_arm64.h"
-
-// C Includes
-#include 
-#include 
-#include 
+#include "RegisterContextDarwinConstants.h"
 
 // C++ Includes
 // Other libraries and framework includes
@@ -221,7 +215,7 @@
   int set = GPRRegSet;
   if (!RegisterSetIsCached(set)) {
 SetError(set, Write, -1);
-return KERN_INVALID_ARGUMENT;
+return KERNEL_INVALID_ARGUMENT;
   }
   SetError(set, Write, DoWriteGPR(GetThreadID(), set, gpr));
   SetError(set, Read, -1);
@@ -232,7 +226,7 @@
   int set = FPURegSet;
   if (!RegisterSetIsCached(set)) {
 SetError(set, Write, -1);
-return KERN_INVALID_ARGUMENT;
+return KERNEL_INVALID_ARGUMENT;
   }
   SetError(set, Write, DoWriteFPU(GetThreadID(), set, fpu));
   SetError(set, Read, -1);
@@ -243,7 +237,7 @@
   int set = EXCRegSet;
   if (!RegisterSetIsCached(set)) {
 SetError(set, Write, -1);
-return KERN_INVALID_ARGUMENT;
+return KERNEL_INVALID_ARGUMENT;
   }
   SetError(set, Write, DoWriteEXC(GetThreadID(), set, exc));
   SetError(set, Read, -1);
@@ -254,7 +248,7 @@
   int set = DBGRegSet;
   if (!RegisterSetIsCached(set)) {
 SetError(set, Write, -1);
-return KERN_INVALID_ARGUMENT;
+return KERNEL_INVALID_ARGUMENT;
   }
   SetError(set, Write, DoWriteDBG(GetThreadID(), set, dbg));
   SetError(set, Read, -1);
@@ -274,7 +268,7 @@
   default:
 break;
   }
-  return KERN_INVALID_ARGUMENT;
+  return KERNEL_INVALID_ARGUMENT;
 }
 
 int RegisterContextDarwin_arm64::WriteRegisterSet(uint32_t set) {
@@ -293,7 +287,7 @@
   break;
 }
   }
-  return KERN_INVALID_ARGUMENT;
+  return KERNEL_INVALID_ARGUMENT;
 }
 
 void RegisterContextDarwin_arm64::LogDBGRegisters(Log *log, const DBG ) {
@@ -313,7 +307,7 @@
   if (set == -1)
 return false;
 
-  if (ReadRegisterSet(set, false) != KERN_SUCCESS)
+  if (ReadRegisterSet(set, false) != KERNEL_SUCCESS)
 return false;
 
   switch (reg) {
@@ -545,7 +539,7 @@
   if (set == -1)
 return false;
 
-  if (ReadRegisterSet(set, false) != KERN_SUCCESS)
+  if (ReadRegisterSet(set, false) != KERNEL_SUCCESS)
 return false;
 
   switch (reg) {
@@ -642,14 +636,14 @@
   default:
 return false;
   }
-  return WriteRegisterSet(set) == KERN_SUCCESS;
+  return WriteRegisterSet(set) == KERNEL_SUCCESS;
 }
 
 bool RegisterContextDarwin_arm64::ReadAllRegisterValues(
 lldb::DataBufferSP _sp) {
   data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
-  if (data_sp && ReadGPR(false) == KERN_SUCCESS &&
-  ReadFPU(false) == KERN_SUCCESS && ReadEXC(false) == KERN_SUCCESS) {
+  if (data_sp && ReadGPR(false) == KERNEL_SUCCESS &&
+  ReadFPU(false) == KERNEL_SUCCESS && ReadEXC(false) == KERNEL_SUCCESS) {
 uint8_t *dst = data_sp->GetBytes();
 ::memcpy(dst, , sizeof(gpr));
 dst += sizeof(gpr);
@@ -675,11 +669,11 @@
 
 ::memcpy(, src, sizeof(exc));
 uint32_t success_count = 0;
-if (WriteGPR() == KERN_SUCCESS)
+if (WriteGPR() == KERNEL_SUCCESS)
   ++success_count;
-if (WriteFPU() == KERN_SUCCESS)
+if (WriteFPU() == KERNEL_SUCCESS)
   ++success_count;
-if (WriteEXC() == KERN_SUCCESS)
+if (WriteEXC() == KERNEL_SUCCESS)
   ++success_count;
 return success_count == 3;
   }
@@ -980,7 +974,7 @@
   // Read the debug state
   int kret = ReadDBG(false);
 
-  if (kret == KERN_SUCCESS) {
+  if (kret == KERNEL_SUCCESS) {
 // Check to make sure we have the needed hardware support
 uint32_t i = 0;
 
@@ -1007,7 +1001,7 @@
   //("RegisterContextDarwin_arm64::EnableHardwareWatchpoint()
   //WriteDBG() => 0x%8.8x.", kret);
 
-  if (kret == KERN_SUCCESS)
+  if (kret == 

[Lldb-commits] [PATCH] D46934: Make ObjectFileMachO work on non-darwin platforms

2018-05-17 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D46934#1101963, @aprantl wrote:

> Does that mean we can now also remove the #ifdef __APPLE__ from the 
> objectfile unit tests?


Which ones do you mean? I wasn't aware we had any. The thing I know of,  which 
would be interesting to enable is the MachO core file tests. This can't be done 
yet because the respective process plugin is apple-only, but I haven't looked 
at what it would take to enable it everywhere.


https://reviews.llvm.org/D46934



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


[Lldb-commits] [PATCH] D46934: Make ObjectFileMachO work on non-darwin platforms

2018-05-16 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Does that mean we can now also remove the #ifdef __APPLE__ from the objectfile 
unit tests?


https://reviews.llvm.org/D46934



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


[Lldb-commits] [PATCH] D46934: Make ObjectFileMachO work on non-darwin platforms

2018-05-16 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.

Thanks for untangling this Pavel, I hadn't noticed we weren't building this 
plugin for non-darwin systems.  I'd agree with Adrian's comment that we should 
have a constants like LLDB_KERNEL_SUCCESS / LLDB_KERNEL_INVALID_ARGUMENT, I 
think the place where -1 was being returned currently would be considered 
incorrect (it's probably my fault for all I know ;)


https://reviews.llvm.org/D46934



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


[Lldb-commits] [PATCH] D46934: Make ObjectFileMachO work on non-darwin platforms

2018-05-16 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp:1037
 SetError(set, Write, -1);
-return KERN_INVALID_ARGUMENT;
+return -1;
   }

aprantl wrote:
> Could we keep this as a local constant?
> perhaps with an #ifndef KERN_INVALID_ARGUMENT clause?
We could. I didn't do that originally, as 
`RegisterContextDarwin_x86_64::WriteGPR()` looks exactly like this function, 
and it uses `-1` already, but that works for me as well.


https://reviews.llvm.org/D46934



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


[Lldb-commits] [PATCH] D46934: Make ObjectFileMachO work on non-darwin platforms

2018-05-16 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp:1037
 SetError(set, Write, -1);
-return KERN_INVALID_ARGUMENT;
+return -1;
   }

Could we keep this as a local constant?
perhaps with an #ifndef KERN_INVALID_ARGUMENT clause?


https://reviews.llvm.org/D46934



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


[Lldb-commits] [PATCH] D46934: Make ObjectFileMachO work on non-darwin platforms

2018-05-16 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: jasonmolenda, aprantl, clayborg.
Herald added subscribers: kristof.beyls, mgorny.
Herald added a reviewer: javed.absar.

Before this patch we were unable to write cross-platform MachO tests
because the parsing code did not compile on other platforms. The reason
for that was that ObjectFileMachO depended on
RegisterContextDarwin_arm(64)? (presumably for core file parsing) and
the two Register Context classes uses constants from the system headers
(KERN_SUCCESS, KERN_INVALID_ARGUMENT).

As far as I can tell, these two files don't actually interact with the
darwin kernel -- they are used only in ObjectFileMachO and MacOSX-Kernel
process plugin (even though it has "kernel" in the name, this one
communicates with it via network packets and not syscalls). So there is
no good reason to use os-specific error codes here. In fact, the
RegisterContextDarwin_i386/x86_64 classes and the code which uses them
already use 0/-1 constants for these purposes, so changing the arm
context to do the same makes the code more consistent.

This is the only change necessary (apart from build system glue) to make
ObjectFileMachO work on other platforms. To demonstrate that, I remove
REQUIRES:darwin from our (only) cross-platform mach-o test.


https://reviews.llvm.org/D46934

Files:
  lit/Modules/lc_version_min.yaml
  source/Initialization/CMakeLists.txt
  source/Initialization/SystemInitializerCommon.cpp
  source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
  source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp

Index: source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
===
--- source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
+++ source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
@@ -8,15 +8,8 @@
 //
 //===--===//
 
-#if defined(__APPLE__)
-
 #include "RegisterContextDarwin_arm64.h"
 
-// C Includes
-#include 
-#include 
-#include 
-
 // C++ Includes
 // Other libraries and framework includes
 #include "lldb/Core/RegisterValue.h"
@@ -221,7 +214,7 @@
   int set = GPRRegSet;
   if (!RegisterSetIsCached(set)) {
 SetError(set, Write, -1);
-return KERN_INVALID_ARGUMENT;
+return -1;
   }
   SetError(set, Write, DoWriteGPR(GetThreadID(), set, gpr));
   SetError(set, Read, -1);
@@ -232,7 +225,7 @@
   int set = FPURegSet;
   if (!RegisterSetIsCached(set)) {
 SetError(set, Write, -1);
-return KERN_INVALID_ARGUMENT;
+return -1;
   }
   SetError(set, Write, DoWriteFPU(GetThreadID(), set, fpu));
   SetError(set, Read, -1);
@@ -243,7 +236,7 @@
   int set = EXCRegSet;
   if (!RegisterSetIsCached(set)) {
 SetError(set, Write, -1);
-return KERN_INVALID_ARGUMENT;
+return -1;
   }
   SetError(set, Write, DoWriteEXC(GetThreadID(), set, exc));
   SetError(set, Read, -1);
@@ -254,7 +247,7 @@
   int set = DBGRegSet;
   if (!RegisterSetIsCached(set)) {
 SetError(set, Write, -1);
-return KERN_INVALID_ARGUMENT;
+return -1;
   }
   SetError(set, Write, DoWriteDBG(GetThreadID(), set, dbg));
   SetError(set, Read, -1);
@@ -274,7 +267,7 @@
   default:
 break;
   }
-  return KERN_INVALID_ARGUMENT;
+  return -1;
 }
 
 int RegisterContextDarwin_arm64::WriteRegisterSet(uint32_t set) {
@@ -293,7 +286,7 @@
   break;
 }
   }
-  return KERN_INVALID_ARGUMENT;
+  return -1;
 }
 
 void RegisterContextDarwin_arm64::LogDBGRegisters(Log *log, const DBG ) {
@@ -313,7 +306,7 @@
   if (set == -1)
 return false;
 
-  if (ReadRegisterSet(set, false) != KERN_SUCCESS)
+  if (ReadRegisterSet(set, false) != 0)
 return false;
 
   switch (reg) {
@@ -545,7 +538,7 @@
   if (set == -1)
 return false;
 
-  if (ReadRegisterSet(set, false) != KERN_SUCCESS)
+  if (ReadRegisterSet(set, false) != 0)
 return false;
 
   switch (reg) {
@@ -642,14 +635,14 @@
   default:
 return false;
   }
-  return WriteRegisterSet(set) == KERN_SUCCESS;
+  return WriteRegisterSet(set) == 0;
 }
 
 bool RegisterContextDarwin_arm64::ReadAllRegisterValues(
 lldb::DataBufferSP _sp) {
   data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
-  if (data_sp && ReadGPR(false) == KERN_SUCCESS &&
-  ReadFPU(false) == KERN_SUCCESS && ReadEXC(false) == KERN_SUCCESS) {
+  if (data_sp && ReadGPR(false) == 0 && ReadFPU(false) == 0 &&
+  ReadEXC(false) == 0) {
 uint8_t *dst = data_sp->GetBytes();
 ::memcpy(dst, , sizeof(gpr));
 dst += sizeof(gpr);
@@ -675,11 +668,11 @@
 
 ::memcpy(, src, sizeof(exc));
 uint32_t success_count = 0;
-if (WriteGPR() == KERN_SUCCESS)
+if (WriteGPR() == 0)
   ++success_count;
-if (WriteFPU() == KERN_SUCCESS)
+if (WriteFPU() == 0)
   ++success_count;
-if (WriteEXC() == KERN_SUCCESS)
+if (WriteEXC() == 0)
   ++success_count;
 return success_count == 3;
   }
@@ -980,7 +973,7 @@
   // Read the debug state
   int