Improve comments and fix Realloc in executable debugger heap
authorEugene Zemtsov <e.zemtsov@gmail.com>
Tue, 7 Apr 2015 11:15:19 +0000 (04:15 -0700)
committerEugene Zemtsov <e.zemtsov@gmail.com>
Tue, 7 Apr 2015 11:15:19 +0000 (04:15 -0700)
src/debug/daccess/dacdbiimpl.cpp
src/debug/di/module.cpp
src/debug/ee/debugger.cpp
src/utilcode/clrhost_nodependencies.cpp

index 755b4a0..908c31b 100644 (file)
@@ -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;
index d88b789..f9ecf43 100644 (file)
@@ -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    
index f091b3c..bf6b6bd 100644 (file)
@@ -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;
 }
 
index d95ac8f..fc670d8 100644 (file)
@@ -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