diff --git a/src/coreclr/debug/di/CMakeLists.txt b/src/coreclr/debug/di/CMakeLists.txt index 55f34bd1ce3e273aa61cd73ff3f9303c0b6a063c..b0272c4d2518d8e915d1125006b2f08c67c5f05b 100644 --- a/src/coreclr/debug/di/CMakeLists.txt +++ b/src/coreclr/debug/di/CMakeLists.txt @@ -1,4 +1,5 @@ add_definitions( + -DDBI_COMPILE -DFEATURE_METADATA_CUSTOM_DATA_SOURCE -DFEATURE_METADATA_DEBUGGEE_DATA_SOURCE -DFEATURE_NO_HOST diff --git a/src/coreclr/debug/inc/amd64/primitives.h b/src/coreclr/debug/inc/amd64/primitives.h index d42dc666fc858036d882cf9f3a0c5c3583c53c64..d8d14b24b5425a82717f7c9b7925f9b879ce9090 100644 --- a/src/coreclr/debug/inc/amd64/primitives.h +++ b/src/coreclr/debug/inc/amd64/primitives.h @@ -12,7 +12,9 @@ #ifndef PRIMITIVES_H_ #define PRIMITIVES_H_ +#if !defined(DBI_COMPILE) && !defined(DACCESS_COMPILE) #include "executableallocator.h" +#endif #ifndef CORDB_ADDRESS_TYPE typedef const BYTE CORDB_ADDRESS_TYPE; @@ -189,9 +191,14 @@ inline void CORDbgInsertBreakpoint(UNALIGNED CORDB_ADDRESS_TYPE *address) { LIMITED_METHOD_CONTRACT; - ExecutableWriterHolder breakpointWriterHolder((LPVOID)address, CORDbg_BREAK_INSTRUCTION_SIZE); +#if !defined(DBI_COMPILE) && !defined(DACCESS_COMPILE) + ExecutableWriterHolder breakpointWriterHolder(address, CORDbg_BREAK_INSTRUCTION_SIZE); + UNALIGNED CORDB_ADDRESS_TYPE* addressRW = breakpointWriterHolder.GetRW(); +#else // !DBI_COMPILE && !DACCESS_COMPILE + UNALIGNED CORDB_ADDRESS_TYPE* addressRW = address; +#endif // !DBI_COMPILE && !DACCESS_COMPILE - *((unsigned char*)breakpointWriterHolder.GetRW()) = 0xCC; // int 3 (single byte patch) + *((unsigned char*)addressRW) = 0xCC; // int 3 (single byte patch) FlushInstructionCache(GetCurrentProcess(), address, 1); } @@ -202,9 +209,14 @@ inline void CORDbgSetInstruction(UNALIGNED CORDB_ADDRESS_TYPE* address, // In a DAC build, this function assumes the input is an host address. LIMITED_METHOD_DAC_CONTRACT; - ExecutableWriterHolder instructionWriterHolder((LPVOID)address, sizeof(unsigned char)); +#if !defined(DBI_COMPILE) && !defined(DACCESS_COMPILE) + ExecutableWriterHolder instructionWriterHolder(address, sizeof(unsigned char)); + UNALIGNED CORDB_ADDRESS_TYPE* addressRW = instructionWriterHolder.GetRW(); +#else // !DBI_COMPILE && !DACCESS_COMPILE + UNALIGNED CORDB_ADDRESS_TYPE* addressRW = address; +#endif // !DBI_COMPILE && !DACCESS_COMPILE - *((unsigned char*)instructionWriterHolder.GetRW()) = + *((unsigned char*)addressRW) = (unsigned char) instruction; // setting one byte is important FlushInstructionCache(GetCurrentProcess(), address, 1); diff --git a/src/coreclr/debug/inc/arm/primitives.h b/src/coreclr/debug/inc/arm/primitives.h index eb29d83bc622eb59e1d6bdf03e88eba98dc6b6a8..c4e2d28602e5658c53cd92f40c36dff3bf442398 100644 --- a/src/coreclr/debug/inc/arm/primitives.h +++ b/src/coreclr/debug/inc/arm/primitives.h @@ -12,7 +12,9 @@ #ifndef PRIMITIVES_H_ #define PRIMITIVES_H_ +#if !defined(DBI_COMPILE) && !defined(DACCESS_COMPILE) #include "executableallocator.h" +#endif #ifndef THUMB_CODE #define THUMB_CODE 1 @@ -161,9 +163,14 @@ inline void CORDbgSetInstruction(CORDB_ADDRESS_TYPE* address, // In a DAC build, this function assumes the input is an host address. LIMITED_METHOD_DAC_CONTRACT; - ExecutableWriterHolder instructionWriterHolder((LPVOID)address, sizeof(PRD_TYPE)); +#if !defined(DBI_COMPILE) && !defined(DACCESS_COMPILE) + ExecutableWriterHolder instructionWriterHolder(address, sizeof(PRD_TYPE)); + CORDB_ADDRESS_TYPE* addressRW = instructionWriterHolder.GetRW(); +#else // !DBI_COMPILE && !DACCESS_COMPILE + CORDB_ADDRESS_TYPE* addressRW = address; +#endif // !DBI_COMPILE && !DACCESS_COMPILE - CORDB_ADDRESS ptraddr = (CORDB_ADDRESS)instructionWriterHolder.GetRW(); + CORDB_ADDRESS ptraddr = (CORDB_ADDRESS)addressRW; _ASSERTE(ptraddr & THUMB_CODE); ptraddr &= ~THUMB_CODE; diff --git a/src/coreclr/debug/inc/arm64/primitives.h b/src/coreclr/debug/inc/arm64/primitives.h index 1fb1b9ce3e8b234d663e70ac5118679b30ffbb5f..4f4c3f7bcd8f218aa3dbcb55fb67397a813d8eab 100644 --- a/src/coreclr/debug/inc/arm64/primitives.h +++ b/src/coreclr/debug/inc/arm64/primitives.h @@ -12,7 +12,9 @@ #ifndef PRIMITIVES_H_ #define PRIMITIVES_H_ +#if !defined(DBI_COMPILE) && !defined(DACCESS_COMPILE) #include "executableallocator.h" +#endif typedef NEON128 FPRegister64; typedef const BYTE CORDB_ADDRESS_TYPE; @@ -148,9 +150,13 @@ inline void CORDbgSetInstruction(CORDB_ADDRESS_TYPE* address, // In a DAC build, this function assumes the input is an host address. LIMITED_METHOD_DAC_CONTRACT; +#if !defined(DBI_COMPILE) && !defined(DACCESS_COMPILE) ExecutableWriterHolder instructionWriterHolder((LPVOID)address, sizeof(PRD_TYPE)); ULONGLONG ptraddr = dac_cast(instructionWriterHolder.GetRW()); +#else // !DBI_COMPILE && !DACCESS_COMPILE + ULONGLONG ptraddr = dac_cast(address); +#endif // !DBI_COMPILE && !DACCESS_COMPILE *(PRD_TYPE *)ptraddr = instruction; FlushInstructionCache(GetCurrentProcess(), address, diff --git a/src/coreclr/debug/inc/i386/primitives.h b/src/coreclr/debug/inc/i386/primitives.h index 0c1d4bcea92834bf7e86864ed84ca2b0b45a634c..313b42c5a1970d9908f9c09079d2de55d5d35df3 100644 --- a/src/coreclr/debug/inc/i386/primitives.h +++ b/src/coreclr/debug/inc/i386/primitives.h @@ -12,7 +12,9 @@ #ifndef PRIMITIVES_H_ #define PRIMITIVES_H_ +#if !defined(DBI_COMPILE) && !defined(DACCESS_COMPILE) #include "executableallocator.h" +#endif typedef const BYTE CORDB_ADDRESS_TYPE; typedef DPTR(CORDB_ADDRESS_TYPE) PTR_CORDB_ADDRESS_TYPE; @@ -149,9 +151,14 @@ inline void CORDbgInsertBreakpoint(UNALIGNED CORDB_ADDRESS_TYPE *address) { LIMITED_METHOD_CONTRACT; - ExecutableWriterHolder breakpointWriterHolder((LPVOID)address, CORDbg_BREAK_INSTRUCTION_SIZE); +#if !defined(DBI_COMPILE) && !defined(DACCESS_COMPILE) + ExecutableWriterHolder breakpointWriterHolder(address, CORDbg_BREAK_INSTRUCTION_SIZE); + UNALIGNED CORDB_ADDRESS_TYPE* addressRW = breakpointWriterHolder.GetRW(); +#else // !DBI_COMPILE && !DACCESS_COMPILE + UNALIGNED CORDB_ADDRESS_TYPE* addressRW = address; +#endif // !DBI_COMPILE && !DACCESS_COMPILE - *((unsigned char*)breakpointWriterHolder.GetRW()) = 0xCC; // int 3 (single byte patch) + *((unsigned char*)addressRW) = 0xCC; // int 3 (single byte patch) FlushInstructionCache(GetCurrentProcess(), address, 1); } diff --git a/src/coreclr/dlls/mscordac/mscordac_unixexports.src b/src/coreclr/dlls/mscordac/mscordac_unixexports.src index aa7352b207927db65177afc9e30b6fcea5aa2161..4fc0af3d682340b361bd259867d2fa98397f1b93 100644 --- a/src/coreclr/dlls/mscordac/mscordac_unixexports.src +++ b/src/coreclr/dlls/mscordac/mscordac_unixexports.src @@ -70,7 +70,6 @@ nativeStringResourceTable_mscorrc #PAL__open #PAL__pread #PAL__close -#PAL_JitWriteProtect #_wcsicmp #_stricmp diff --git a/src/coreclr/inc/executableallocator.h b/src/coreclr/inc/executableallocator.h index c71f613dbe5e27a2137c0457f60a16eda1bb50bb..ce0c6c22f890e6b618aa883dbc18604fb67f2c80 100644 --- a/src/coreclr/inc/executableallocator.h +++ b/src/coreclr/inc/executableallocator.h @@ -33,7 +33,7 @@ class ExecutableWriterHolder if (m_addressRX != NULL) { // TODO: mapping / unmapping for targets using double memory mapping will be added with the double mapped allocator addition -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if defined(HOST_OSX) && defined(HOST_ARM64) && !defined(DACCESS_COMPILE) PAL_JitWriteProtect(false); #endif } @@ -63,7 +63,7 @@ public: { m_addressRX = addressRX; m_addressRW = addressRX; -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if defined(HOST_OSX) && defined(HOST_ARM64) && !defined(DACCESS_COMPILE) PAL_JitWriteProtect(true); #endif } diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 69d90522a0d66ffc83ab991d2f234a1ab79439a7..8e0553e02e88892402cead1948cb28db6918ef09 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -2760,14 +2760,16 @@ VirtualFree( IN SIZE_T dwSize, IN DWORD dwFreeType); -#if defined(HOST_OSX) + +#if defined(HOST_OSX) && defined(HOST_ARM64) PALIMPORT VOID PALAPI PAL_JitWriteProtect(bool writeEnable); -#endif // defined(HOST_OSX) +#endif // defined(HOST_OSX) && defined(HOST_ARM64) + PALIMPORT BOOL diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index 9267f4fdf1c707e78567a2ed93895e820e593001..645cf10aec8d6ab4500426612fcd41f226bfcfa9 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -1760,10 +1760,9 @@ ExitVirtualProtect: return bRetVal; } -#if defined(HOST_OSX) +#if defined(HOST_OSX) && defined(HOST_ARM64) PALAPI VOID PAL_JitWriteProtect(bool writeEnable) { -#if defined(HOST_ARM64) thread_local int enabledCount = 0; if (writeEnable) { @@ -1780,9 +1779,8 @@ PALAPI VOID PAL_JitWriteProtect(bool writeEnable) } _ASSERTE(enabledCount >= 0); } -#endif // HOST_ARM64 } -#endif // HOST_OSX +#endif // HOST_OSX && HOST_ARM64 #if HAVE_VM_ALLOCATE //---------------------------------------------------------------------------------------