Index: lit/Modules/lc_version_min.yaml =================================================================== --- lit/Modules/lc_version_min.yaml +++ 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: 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 + lldbPluginObjectFileMachO lldbPluginObjectFilePECOFF lldbPluginProcessGDBRemote ${EXTRA_PLUGINS} 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,6 +104,7 @@ Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION); ObjectContainerBSDArchive::Terminate(); ObjectFileELF::Terminate(); + ObjectFileMachO::Terminate(); ObjectFilePECOFF::Terminate(); EmulateInstructionARM::Terminate(); @@ -116,9 +112,6 @@ EmulateInstructionMIPS64::Terminate(); ObjectContainerUniversalMachO::Terminate(); -#if defined(__APPLE__) - ObjectFileMachO::Terminate(); -#endif #if defined(_MSC_VER) ProcessWindowsLog::Terminate(); Index: source/Plugins/Process/Utility/RegisterContextDarwinConstants.h =================================================================== --- /dev/null +++ source/Plugins/Process/Utility/RegisterContextDarwinConstants.h @@ -0,0 +1,22 @@ +//===-- 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. +enum { + KERNEL_SUCCESS = 0, + KERNEL_INVALID_ARGUMENT = 4, +}; +} + +#endif // LLDB_REGISTERCONTEXTDARWINCONSTANTS_H 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 @@ -1040,7 +1035,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); @@ -1051,7 +1046,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); @@ -1062,7 +1057,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); @@ -1073,7 +1068,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); @@ -1095,7 +1090,7 @@ default: break; } - return KERN_INVALID_ARGUMENT; + return KERNEL_INVALID_ARGUMENT; } int RegisterContextDarwin_arm::WriteRegisterSet(uint32_t set) { @@ -1116,7 +1111,7 @@ break; } } - return KERN_INVALID_ARGUMENT; + return KERNEL_INVALID_ARGUMENT; } void RegisterContextDarwin_arm::LogDBGRegisters(Log *log, const DBG &dbg) { @@ -1136,7 +1131,7 @@ if (set == -1) return false; - if (ReadRegisterSet(set, false) != KERN_SUCCESS) + if (ReadRegisterSet(set, false) != KERNEL_SUCCESS) return false; switch (reg) { @@ -1224,7 +1219,7 @@ if (set == -1) return false; - if (ReadRegisterSet(set, false) != KERN_SUCCESS) + if (ReadRegisterSet(set, false) != KERNEL_SUCCESS) return false; switch (reg) { @@ -1300,14 +1295,14 @@ default: return false; } - return WriteRegisterSet(set) == KERN_SUCCESS; + return WriteRegisterSet(set) == KERNEL_SUCCESS; } bool RegisterContextDarwin_arm::ReadAllRegisterValues( lldb::DataBufferSP &data_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, &gpr, sizeof(gpr)); dst += sizeof(gpr); @@ -1333,11 +1328,11 @@ ::memcpy(&exc, 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; } @@ -1543,7 +1538,7 @@ int kret = ReadDBG(false); - if (kret == KERN_SUCCESS) { + if (kret == KERNEL_SUCCESS) { const uint32_t num_hw_breakpoints = NumSupportedHardwareBreakpoints(); uint32_t i; for (i = 0; i < num_hw_breakpoints; ++i) { @@ -1601,7 +1596,7 @@ // ("RegisterContextDarwin_arm::EnableHardwareBreakpoint() // WriteDBG() => 0x%8.8x.", kret); - if (kret == KERN_SUCCESS) + if (kret == KERNEL_SUCCESS) return i; } // else @@ -1620,7 +1615,7 @@ int kret = ReadDBG(false); const uint32_t num_hw_points = NumSupportedHardwareBreakpoints(); - if (kret == KERN_SUCCESS) { + if (kret == KERNEL_SUCCESS) { if (hw_index < num_hw_points) { dbg.bcr[hw_index] = 0; // if (log) log->Printf @@ -1634,7 +1629,7 @@ kret = WriteDBG(); - if (kret == KERN_SUCCESS) + if (kret == KERNEL_SUCCESS) return true; } } @@ -1704,7 +1699,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; @@ -1731,7 +1726,7 @@ // ("RegisterContextDarwin_arm::EnableHardwareWatchpoint() // WriteDBG() => 0x%8.8x.", kret); - if (kret == KERN_SUCCESS) + if (kret == KERNEL_SUCCESS) return i; } else { // if (log) log->Printf @@ -1746,7 +1741,7 @@ int kret = ReadDBG(false); const uint32_t num_hw_points = NumSupportedHardwareWatchpoints(); - if (kret == KERN_SUCCESS) { + if (kret == KERNEL_SUCCESS) { if (hw_index < num_hw_points) { dbg.wcr[hw_index] = 0; // if (log) log->Printf @@ -1760,11 +1755,9 @@ kret = WriteDBG(); - if (kret == KERN_SUCCESS) + if (kret == KERNEL_SUCCESS) return true; } } return false; } - -#endif 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 &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 &data_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, &gpr, sizeof(gpr)); dst += sizeof(gpr); @@ -675,11 +669,11 @@ ::memcpy(&exc, 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 == KERNEL_SUCCESS) return i; } else { // if (log) log->Printf @@ -1023,7 +1017,7 @@ int kret = ReadDBG(false); const uint32_t num_hw_points = NumSupportedHardwareWatchpoints(); - if (kret == KERN_SUCCESS) { + if (kret == KERNEL_SUCCESS) { if (hw_index < num_hw_points) { dbg.wcr[hw_index] = 0; // if (log) log->Printf @@ -1037,11 +1031,9 @@ kret = WriteDBG(); - if (kret == KERN_SUCCESS) + if (kret == KERNEL_SUCCESS) return true; } } return false; } - -#endif