From 57f1e08d204dc9af74e3e56375c79e23cf476703 Mon Sep 17 00:00:00 2001 From: Eugene Zemtsov Date: Tue, 7 Apr 2015 04:15:19 -0700 Subject: [PATCH] Improve comments and fix Realloc in executable debugger heap --- src/debug/daccess/dacdbiimpl.cpp | 4 ++-- src/debug/di/module.cpp | 2 +- src/debug/ee/debugger.cpp | 15 ++++++++++++++- src/utilcode/clrhost_nodependencies.cpp | 4 ++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/debug/daccess/dacdbiimpl.cpp b/src/debug/daccess/dacdbiimpl.cpp index 755b4a0..908c31b 100644 --- a/src/debug/daccess/dacdbiimpl.cpp +++ b/src/debug/daccess/dacdbiimpl.cpp @@ -480,7 +480,7 @@ BOOL DacDbiInterfaceImpl::IsTransitionStub(CORDB_ADDRESS address) // Currently IsIPInModule() is not implemented in the PAL. Rather than skipping the check, we should // either E_NOTIMPL this API or implement IsIPInModule() in the PAL. Since ICDProcess::IsTransitionStub() // is only called by VS in mixed-mode debugging scenarios, and mixed-mode debugging is not supported on - // Mac, there is really no incentive to implement this API on Mac at this point. + // POSIX systems, there is really no incentive to implement this API at this point. ThrowHR(E_NOTIMPL); #else // !FEATURE_PAL @@ -5621,7 +5621,7 @@ void DacDbiInterfaceImpl::GetContext(VMPTR_Thread vmThread, DT_CONTEXT * pContex // thread handle. The function to do the conversion is OpenThread(), which is not implemented in PAL. // Instead, we just zero out the seed CONTEXT for the stackwalk. This tells the stackwalker to // start the stackwalk with the first explicit frame. This won't work when we do native debugging, - // but that won't happen on the Linux/Mac since they don't support native debugging. + // but that won't happen on the POSIX systems since they don't support native debugging. ZeroMemory(pContextBuffer, sizeof(*pContextBuffer)); #else // FEATURE_PAL pContextBuffer->ContextFlags = CONTEXT_ALL; diff --git a/src/debug/di/module.cpp b/src/debug/di/module.cpp index d88b789..f9ecf43 100644 --- a/src/debug/di/module.cpp +++ b/src/debug/di/module.cpp @@ -882,7 +882,7 @@ HRESULT CordbModule::InitPublicMetaDataFromFile(const WCHAR * pszFullPathName, bool validateFileInfo) { #ifdef FEATURE_PAL - // TODO: Some intricate details of file mapping don't work on Linux as on Windows. + // UNIXTODO: Some intricate details of file mapping don't work on Linux as on Windows. // We have to revisit this and try to fix it for POSIX system. return E_FAIL; #else diff --git a/src/debug/ee/debugger.cpp b/src/debug/ee/debugger.cpp index f091b3c..bf6b6bd 100644 --- a/src/debug/ee/debugger.cpp +++ b/src/debug/ee/debugger.cpp @@ -16736,7 +16736,7 @@ void *DebuggerHeap::Alloc(DWORD size) // We don't have executable heap in PAL, but we still need to allocate // executable memory, that's why have change protection level for // each allocation. - // TODO: We need to look how JIT solves this problem. + // UNIXTODO: We need to look how JIT solves this problem. DWORD unusedFlags; if (!VirtualProtect(ret, size, PAGE_EXECUTE_READWRITE, &unusedFlags)) { @@ -16786,6 +16786,19 @@ void *DebuggerHeap::Realloc(void *pMem, DWORD newSize, DWORD oldSize) this->Free(pMem); #endif + +#ifdef FEATURE_PAL + // We don't have executable heap in PAL, but we still need to allocate + // executable memory, that's why have change protection level for + // each allocation. + // UNIXTODO: We need to look how JIT solves this problem. + DWORD unusedFlags; + if (!VirtualProtect(ret, newSize, PAGE_EXECUTE_READWRITE, &unusedFlags)) + { + _ASSERTE(!"VirtualProtect failed to make this memory executable"); + } +#endif // FEATURE_PAL + return ret; } diff --git a/src/utilcode/clrhost_nodependencies.cpp b/src/utilcode/clrhost_nodependencies.cpp index d95ac8f..fc670d8 100644 --- a/src/utilcode/clrhost_nodependencies.cpp +++ b/src/utilcode/clrhost_nodependencies.cpp @@ -584,7 +584,7 @@ BOOL DbgIsExecutable(LPVOID lpMem, SIZE_T length) #if defined(CROSSGEN_COMPILE) || defined(FEATURE_PAL) // No NX support on PAL or for crossgen compilations. return TRUE; -#else // !defined(CROSSGEN_COMPILE) +#else // !(CROSSGEN_COMPILE || FEATURE_PAL) BYTE *regionStart = (BYTE*) ALIGN_DOWN((BYTE*)lpMem, OS_PAGE_SIZE); BYTE *regionEnd = (BYTE*) ALIGN_UP((BYTE*)lpMem+length, OS_PAGE_SIZE); _ASSERTE(length > 0); @@ -606,7 +606,7 @@ BOOL DbgIsExecutable(LPVOID lpMem, SIZE_T length) } return TRUE; -#endif // defined(CROSSGEN_COMPILE) +#endif // CROSSGEN_COMPILE || FEATURE_PAL } #endif //_DEBUG -- 2.7.4