[Lldb-commits] [lldb] r332702 - Make ObjectFileMachO work on non-darwin platforms
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Fri May 18 04:35:46 PDT 2018
Author: labath
Date: Fri May 18 04:35:46 2018
New Revision: 332702
URL: http://llvm.org/viewvc/llvm-project?rev=332702&view=rev
Log:
Make ObjectFileMachO work on non-darwin platforms
Summary:
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). For the time
being I have created OS-independent definitions of these constants and
made the register context classes use those. Long term, the error
handling in these classes should be probably changed to use more
standard mechanisms such as Status or Error classes.
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.
Reviewers: jasonmolenda, aprantl, clayborg, javed.absar
Subscribers: mgorny, lldb-commits, kristof.beyls
Differential Revision: https://reviews.llvm.org/D46934
Added:
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
Modified:
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/RegisterContextDarwin_arm.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
Modified: lldb/trunk/lit/Modules/lc_version_min.yaml
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/lc_version_min.yaml?rev=332702&r1=332701&r2=332702&view=diff
==============================================================================
--- lldb/trunk/lit/Modules/lc_version_min.yaml (original)
+++ lldb/trunk/lit/Modules/lc_version_min.yaml Fri May 18 04:35:46 2018
@@ -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
Modified: lldb/trunk/source/Initialization/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/CMakeLists.txt?rev=332702&r1=332701&r2=332702&view=diff
==============================================================================
--- lldb/trunk/source/Initialization/CMakeLists.txt (original)
+++ lldb/trunk/source/Initialization/CMakeLists.txt Fri May 18 04:35:46 2018
@@ -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 @@ add_lldb_library(lldbInitialization
lldbPluginObjectContainerBSDArchive
lldbPluginObjectContainerMachOArchive
lldbPluginObjectFileELF
+ lldbPluginObjectFileMachO
lldbPluginObjectFilePECOFF
lldbPluginProcessGDBRemote
${EXTRA_PLUGINS}
Modified: lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/SystemInitializerCommon.cpp?rev=332702&r1=332701&r2=332702&view=diff
==============================================================================
--- lldb/trunk/source/Initialization/SystemInitializerCommon.cpp (original)
+++ lldb/trunk/source/Initialization/SystemInitializerCommon.cpp Fri May 18 04:35:46 2018
@@ -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 @@ void SystemInitializerCommon::Initialize
// Initialize plug-ins
ObjectContainerBSDArchive::Initialize();
ObjectFileELF::Initialize();
+ ObjectFileMachO::Initialize();
ObjectFilePECOFF::Initialize();
EmulateInstructionARM::Initialize();
@@ -93,9 +91,6 @@ void SystemInitializerCommon::Initialize
//----------------------------------------------------------------------
ObjectContainerUniversalMachO::Initialize();
-#if defined(__APPLE__)
- ObjectFileMachO::Initialize();
-#endif
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
ProcessPOSIXLog::Initialize();
#endif
@@ -109,6 +104,7 @@ void SystemInitializerCommon::Terminate(
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
ObjectContainerBSDArchive::Terminate();
ObjectFileELF::Terminate();
+ ObjectFileMachO::Terminate();
ObjectFilePECOFF::Terminate();
EmulateInstructionARM::Terminate();
@@ -116,9 +112,6 @@ void SystemInitializerCommon::Terminate(
EmulateInstructionMIPS64::Terminate();
ObjectContainerUniversalMachO::Terminate();
-#if defined(__APPLE__)
- ObjectFileMachO::Terminate();
-#endif
#if defined(_MSC_VER)
ProcessWindowsLog::Terminate();
Added: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h?rev=332702&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h (added)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h Fri May 18 04:35:46 2018
@@ -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
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp?rev=332702&r1=332701&r2=332702&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp Fri May 18 04:35:46 2018
@@ -7,13 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#if defined(__APPLE__)
-
#include "RegisterContextDarwin_arm.h"
-
-// C Includes
-#include <mach/mach_types.h>
-#include <mach/thread_act.h>
+#include "RegisterContextDarwinConstants.h"
// C++ Includes
// Other libraries and framework includes
@@ -1766,5 +1761,3 @@ bool RegisterContextDarwin_arm::ClearHar
}
return false;
}
-
-#endif
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp?rev=332702&r1=332701&r2=332702&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp Fri May 18 04:35:46 2018
@@ -8,14 +8,8 @@
//
//===----------------------------------------------------------------------===//
-#if defined(__APPLE__)
-
#include "RegisterContextDarwin_arm64.h"
-
-// C Includes
-#include <mach/mach_types.h>
-#include <mach/thread_act.h>
-#include <sys/sysctl.h>
+#include "RegisterContextDarwinConstants.h"
// C++ Includes
// Other libraries and framework includes
@@ -1043,5 +1037,3 @@ bool RegisterContextDarwin_arm64::ClearH
}
return false;
}
-
-#endif
More information about the lldb-commits
mailing list