mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-24 22:30:13 +00:00
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 llvm-svn: 332702
This commit is contained in:
parent
90d308ef4b
commit
981a34c428
@ -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
|
||||
|
@ -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}
|
||||
|
@ -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();
|
||||
|
@ -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
|
@ -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::ClearHardwareWatchpoint(uint32_t hw_index) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -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::ClearHardwareWatchpoint(uint32_t hw_index) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user