diff --git a/src/coreclr/debug/dbgutil/dbgutil.cpp b/src/coreclr/debug/dbgutil/dbgutil.cpp index cecc783cc18cb7..8366d7a6065901 100644 --- a/src/coreclr/debug/dbgutil/dbgutil.cpp +++ b/src/coreclr/debug/dbgutil/dbgutil.cpp @@ -1,15 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -//***************************************************************************** -// dbgutil.cpp -// - -// -//***************************************************************************** -// // Various common helpers for PE resource reading used by multiple debug components. -// #include #include "corerror.h" @@ -136,275 +128,6 @@ HRESULT GetMachineAndResourceSectionRVA(ICorDebugDataTarget* pDataTarget, return GetMachineAndDirectoryAddress(pDataTarget, moduleBaseAddress, IMAGE_DIRECTORY_ENTRY_RESOURCE, pwImageFileMachine, pdwResourceSectionRVA); } -HRESULT GetResourceRvaFromResourceSectionRva(ICorDebugDataTarget* pDataTarget, - ULONG64 moduleBaseAddress, - DWORD resourceSectionRva, - DWORD type, - DWORD name, - DWORD language, - DWORD* pResourceRva, - DWORD* pResourceSize) -{ - HRESULT hr = S_OK; - DWORD nameTableRva = 0; - DWORD langTableRva = 0; - DWORD resourceDataEntryRva = 0; - *pResourceRva = 0; - *pResourceSize = 0; - - // The resource section begins with a resource directory that indexes all the resources by type. - // Each entry it points to is another resource directory that indexes all the same type - // resources by name. And each entry in that table points to another resource directory that indexes - // all the same type/name resources by language. Entries in the final table give the RVA of the actual - // resource. - // Note all RVAs in this section are relative to the beginning of the resource section, - // not the beginning of the image. - - hr = GetNextLevelResourceEntryRVA(pDataTarget, type, moduleBaseAddress, resourceSectionRva, &nameTableRva); - - - if (SUCCEEDED(hr)) - { - nameTableRva += resourceSectionRva; - hr = GetNextLevelResourceEntryRVA(pDataTarget, name, moduleBaseAddress, nameTableRva, &langTableRva); - - } - if (SUCCEEDED(hr)) - { - langTableRva += resourceSectionRva; - hr = GetNextLevelResourceEntryRVA(pDataTarget, language, moduleBaseAddress, langTableRva, &resourceDataEntryRva); - } - - // The resource data entry has the first 4 bytes indicating the RVA of the resource - // The next 4 bytes indicate the size of the resource - if (SUCCEEDED(hr)) - { - resourceDataEntryRva += resourceSectionRva; - IMAGE_RESOURCE_DATA_ENTRY dataEntry; - hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDataEntryRva, - (BYTE*)&dataEntry, sizeof(dataEntry)); - *pResourceRva = dataEntry.OffsetToData; - *pResourceSize = dataEntry.Size; - } - - return hr; -} - -HRESULT GetResourceRvaFromResourceSectionRvaByName(ICorDebugDataTarget* pDataTarget, - ULONG64 moduleBaseAddress, - DWORD resourceSectionRva, - DWORD type, - LPCWSTR pwszName, - DWORD language, - DWORD* pResourceRva, - DWORD* pResourceSize) -{ - HRESULT hr = S_OK; - DWORD nameTableRva = 0; - DWORD langTableRva = 0; - DWORD resourceDataEntryRva = 0; - *pResourceRva = 0; - *pResourceSize = 0; - - // The resource section begins with a resource directory that indexes all the resources by type. - // Each entry it points to is another resource directory that indexes all the same type - // resources by name. And each entry in that table points to another resource directory that indexes - // all the same type/name resources by language. Entries in the final table give the RVA of the actual - // resource. - // Note all RVAs in this section are relative to the beginning of the resource section, - // not the beginning of the image. - hr = GetNextLevelResourceEntryRVA(pDataTarget, type, moduleBaseAddress, resourceSectionRva, &nameTableRva); - - - if (SUCCEEDED(hr)) - { - nameTableRva += resourceSectionRva; - hr = GetNextLevelResourceEntryRVAByName(pDataTarget, pwszName, moduleBaseAddress, nameTableRva, resourceSectionRva, &langTableRva); - } - if (SUCCEEDED(hr)) - { - langTableRva += resourceSectionRva; - hr = GetNextLevelResourceEntryRVA(pDataTarget, language, moduleBaseAddress, langTableRva, &resourceDataEntryRva); - } - - // The resource data entry has the first 4 bytes indicating the RVA of the resource - // The next 4 bytes indicate the size of the resource - if (SUCCEEDED(hr)) - { - resourceDataEntryRva += resourceSectionRva; - IMAGE_RESOURCE_DATA_ENTRY dataEntry; - hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDataEntryRva, - (BYTE*)&dataEntry, sizeof(dataEntry)); - *pResourceRva = dataEntry.OffsetToData; - *pResourceSize = dataEntry.Size; - } - - return hr; -} - -// Traverses down one level in the PE resource tree structure -// -// Arguments: -// pDataTarget - the data target for inspecting this process -// id - the id of the next node in the resource tree you want -// moduleBaseAddress - the base address of the module being inspected -// resourceDirectoryRVA - the base address of the beginning of the resource directory for this -// level of the tree -// pNextLevelRVA - out - The RVA for the next level tree directory or the RVA of the resource entry -// -// Returns: -// S_OK if successful or an appropriate failing HRESULT -HRESULT GetNextLevelResourceEntryRVA(ICorDebugDataTarget* pDataTarget, - DWORD id, - ULONG64 moduleBaseAddress, - DWORD resourceDirectoryRVA, - DWORD* pNextLevelRVA) -{ - *pNextLevelRVA = 0; - HRESULT hr = S_OK; - - // A resource directory which consists of - // a header followed by a number of entries. In the header at offset 12 is - // the number entries identified by name, followed by the number of entries - // identified by ID at offset 14. Both are 2 bytes. - // This method only supports locating entries by ID, not by name - IMAGE_RESOURCE_DIRECTORY resourceDirectory; - hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDirectoryRVA, (BYTE*)&resourceDirectory, sizeof(resourceDirectory)); - - - - // The ith resource directory entry is at offset 16 + 8i from the beginning of the resource - // directory table - WORD numNameEntries; - WORD numIDEntries; - if (SUCCEEDED(hr)) - { - numNameEntries = resourceDirectory.NumberOfNamedEntries; - numIDEntries = resourceDirectory.NumberOfIdEntries; - - for (WORD i = numNameEntries; i < numNameEntries + numIDEntries; i++) - { - IMAGE_RESOURCE_DIRECTORY_ENTRY entry; - hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDirectoryRVA + sizeof(resourceDirectory) + sizeof(entry)*i, - (BYTE*)&entry, sizeof(entry)); - if (FAILED(hr)) - { - break; - } - if (entry.Id == id) - { - *pNextLevelRVA = entry.OffsetToDirectory; - break; - } - } - } - - // If we didn't find the entry - if (SUCCEEDED(hr) && *pNextLevelRVA == 0) - { - hr = E_FAIL; - } - - return hr; // resource not found -} - -// Traverses down one level in the PE resource tree structure -// -// Arguments: -// pDataTarget - the data target for inspecting this process -// name - the name of the next node in the resource tree you want -// moduleBaseAddress - the base address of the module being inspected -// resourceDirectoryRVA - the base address of the beginning of the resource directory for this -// level of the tree -// resourceSectionRVA - the rva of the beginning of the resource section of the PE file -// pNextLevelRVA - out - The RVA for the next level tree directory or the RVA of the resource entry -// -// Returns: -// S_OK if successful or an appropriate failing HRESULT -HRESULT GetNextLevelResourceEntryRVAByName(ICorDebugDataTarget* pDataTarget, - LPCWSTR pwzName, - ULONG64 moduleBaseAddress, - DWORD resourceDirectoryRva, - DWORD resourceSectionRva, - DWORD* pNextLevelRva) -{ - HRESULT hr = S_OK; - DWORD nameLength = (DWORD)u16_strlen(pwzName); - WCHAR entryName[50]; - assert(nameLength < 50); // this implementation won't support matching a name longer - // than 50 characters. We only look up the hard coded name - // of the debug resource in clr.dll though, so it shouldn't be - // an issue. Increase this count if we ever want to look up - // larger names - if (nameLength >= 50) - { - hr = E_FAIL; // invalid name length - } - - // A resource directory which consists of - // a header followed by a number of entries. In the header at offset 12 is - // the number entries identified by name, followed by the number of entries - // identified by ID at offset 14. Both are 2 bytes. - // This method only supports locating entries by ID, not by name - IMAGE_RESOURCE_DIRECTORY resourceDirectory = { 0 }; - if (SUCCEEDED(hr)) - { - hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDirectoryRva, (BYTE*)&resourceDirectory, sizeof(resourceDirectory)); - } - - // The ith resource directory entry is at offset 16 + 8i from the beginning of the resource - // directory table - if (SUCCEEDED(hr)) - { - WORD numNameEntries = resourceDirectory.NumberOfNamedEntries; - for (WORD i = 0; i < numNameEntries; i++) - { - IMAGE_RESOURCE_DIRECTORY_ENTRY entry; - hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDirectoryRva + sizeof(resourceDirectory) + sizeof(entry)*i, - (BYTE*)&entry, sizeof(entry)); - if (FAILED(hr)) - { - break; - } - - // the NameRVAOrID field points to a UTF16 string with a 2 byte length in front of it - // read the 2 byte length first. The doc of course doesn't mention this, but the RVA is - // relative to the base of the resource section and needs the leading bit stripped. - WORD entryNameLength = 0; - hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceSectionRva + - entry.NameOffset, (BYTE*)&entryNameLength, sizeof(entryNameLength)); - if (FAILED(hr)) - { - break; - } - if (entryNameLength != nameLength) - { - continue; // names aren't the same length, not a match - } - - // read the rest of the string data and check for a match - hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceSectionRva + - entry.NameOffset + 2, (BYTE*)entryName, entryNameLength*sizeof(WCHAR)); - if (FAILED(hr)) - { - break; - } - if (memcmp(entryName, pwzName, entryNameLength*sizeof(WCHAR)) == 0) - { - *pNextLevelRva = entry.OffsetToDirectory; - break; - } - } - } - - if (SUCCEEDED(hr) && *pNextLevelRva == 0) - { - hr = E_FAIL; // resource not found - } - - return hr; -} - #endif // HOST_WINDOWS // A small wrapper that reads from the data target and throws on error diff --git a/src/coreclr/debug/di/CMakeLists.txt b/src/coreclr/debug/di/CMakeLists.txt index 53f41b9320f760..53ebbd37015249 100644 --- a/src/coreclr/debug/di/CMakeLists.txt +++ b/src/coreclr/debug/di/CMakeLists.txt @@ -26,7 +26,6 @@ set(CORDBDI_SOURCES rsthread.cpp rstype.cpp shared.cpp - symbolinfo.cpp valuehome.cpp ) @@ -40,8 +39,7 @@ set(CORDBDI_HEADERS nativepipeline.h rsenumerator.hpp rspriv.h - rspriv.inl - symbolinfo.h) + rspriv.inl) if(CLR_CMAKE_HOST_WIN32) diff --git a/src/coreclr/debug/di/process.cpp b/src/coreclr/debug/di/process.cpp index 5dac14989899bb..f5359a8873f6d0 100644 --- a/src/coreclr/debug/di/process.cpp +++ b/src/coreclr/debug/di/process.cpp @@ -1,11 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -//***************************************************************************** -// File: process.cpp -// -//***************************************************************************** - #include "stdafx.h" #include "CLREventBase.h" #include @@ -6900,33 +6895,6 @@ CordbUnmanagedThread *CordbProcess::HandleUnmanagedCreateThread(DWORD dwThreadId } #endif // FEATURE_INTEROP_DEBUGGING - -//----------------------------------------------------------------------------- -// Initializes the DAC -// Arguments: none--initializes the DAC for this CordbProcess instance -// Note: Throws on error -//----------------------------------------------------------------------------- -void CordbProcess::InitDac() -{ - // Go-Go DAC power!! - HRESULT hr = S_OK; - EX_TRY - { - InitializeDac(); - } - EX_CATCH_HRESULT(hr); - - // We Need DAC to debug for both Managed & Interop. - if (FAILED(hr)) - { - // We assert here b/c we're trying to be friendly. Most likely, the cause is either: - // - a bad installation - // - a CLR dev built mscorwks but didn't build DAC. - SIMPLIFYING_ASSUMPTION_MSGF(false, ("Failed to load DAC while for debugging. hr=0x%08x", hr)); - ThrowHR(hr); - } -} //CordbProcess::InitDac - // Update the entire RS copy of the debugger control block by reading the LS copy. The RS copy is treated as // a throw-away temporary buffer, rather than a true cache. That is, we make no assumptions about the // validity of the information over time. Thus, before using any of the values, we need to update it. We @@ -7928,26 +7896,6 @@ HRESULT CordbProcess::StartSyncFromWin32Stop(BOOL * pfAsyncBreakSent) return hr; } -// Check if the left side has exited. If so, get the right-side -// into shutdown mode. Only use this to avert us from going into -// an unrecoverable error. -bool CordbProcess::CheckIfLSExited() -{ -// Check by waiting on the handle with no timeout. - if (WaitHandle::Wait(*m_handle, 0) == 0) - { - Lock(); - m_terminated = true; - m_exiting = true; - Unlock(); - } - - LOG((LF_CORDB, LL_INFO10, "CP::IsLSExited() returning '%s'\n", - m_exiting ? "true" : "false")); - - return m_exiting; -} - // Call this if something really bad happened and we can't do // anything meaningful with the CordbProcess. void CordbProcess::UnrecoverableError(HRESULT errorHR, @@ -8908,99 +8856,6 @@ void CordbProcess::FinishInitializeIPCChannelWorker() ThrowHR(hr); } - -//--------------------------------------------------------------------------------------- -// Marshals over a string buffer in a managed event -// -// Arguments: -// pTarget - data-target for read the buffer from the LeftSide. -// -// Throws on error -void Ls_Rs_BaseBuffer::CopyLSDataToRSWorker(ICorDebugDataTarget * pTarget) -{ - // - const DWORD cbCacheSize = m_cbSize; - - // SHOULD not happen for more than once in well-behaved case. - if (m_pbRS != NULL) - { - SIMPLIFYING_ASSUMPTION(!"m_pbRS is non-null; is this a corrupted event?"); - ThrowHR(E_INVALIDARG); - } - - NewArrayHolder pData(new BYTE[cbCacheSize]); - - ULONG32 cbRead; - HRESULT hrRead = pTarget->ReadVirtual(PTR_TO_CORDB_ADDRESS(m_pbLS), pData, cbCacheSize , &cbRead); - - if(FAILED(hrRead)) - { - hrRead = CORDBG_E_READVIRTUAL_FAILURE; - } - - if (SUCCEEDED(hrRead) && (cbCacheSize != cbRead)) - { - hrRead = HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY); - } - IfFailThrow(hrRead); - - // Now do Transfer - m_pbRS = pData; - pData.SuppressRelease(); -} - -//--------------------------------------------------------------------------------------- -// Marshals over a Byte buffer in a managed event -// -// Arguments: -// pTarget - data-target for read the buffer from the LeftSide. -// -// Throws on error -void Ls_Rs_ByteBuffer::CopyLSDataToRS(ICorDebugDataTarget * pTarget) -{ - CopyLSDataToRSWorker(pTarget); -} - -//--------------------------------------------------------------------------------------- -// Marshals over a string buffer in a managed event -// -// Arguments: -// pTarget - data-target for read the buffer from the LeftSide. -// -// Throws on error -void Ls_Rs_StringBuffer::CopyLSDataToRS(ICorDebugDataTarget * pTarget) -{ - CopyLSDataToRSWorker(pTarget); - - // Ensure we're a valid, well-formed string. - // @dbgtodo - this should only happen in corrupted scenarios. Perhaps a better HR here? - // - null terminated. - // - no embedded nulls. - - const WCHAR * pString = GetString(); - SIZE_T dwExpectedLenWithNull = m_cbSize / sizeof(WCHAR); - - // Should at least have 1 character for the null-terminator. - if (dwExpectedLenWithNull == 0) - { - ThrowHR(CORDBG_E_TARGET_INCONSISTENT); - } - - // Ensure that there's a null where we expect it to be. - if (pString[dwExpectedLenWithNull-1] != 0) - { - ThrowHR(CORDBG_E_TARGET_INCONSISTENT); - } - - // Now we know it's safe to call u16_strlen. The buffer is local, so we know the pages are there. - // And we know there's a null capping the max length of the string. - SIZE_T dwActualLenWithNull = u16_strlen(pString) + 1; - if (dwActualLenWithNull != dwExpectedLenWithNull) - { - ThrowHR(CORDBG_E_TARGET_INCONSISTENT); - } -} - //--------------------------------------------------------------------------------------- // Copy a managed debug event from the target process into this local process // @@ -11988,16 +11843,6 @@ Reaction CordbProcess::TriageExcep1stChanceAndInit(CordbUnmanagedThread * pUnman } #endif - // If we were stepping for exception retrigger and got the single step and it should be hidden then just ignore it. - // Anything that isn't cInbandExceptionRetrigger will cause the debug event to be dequeued, stepping turned off, and - // it will count as not retriggering - // TODO: I don't think the IsSSFlagNeeded() check is needed here though it doesn't break anything - if (pUnmanagedThread->IsSSFlagNeeded() && pUnmanagedThread->IsSSFlagHidden() && (dwExCode == STATUS_SINGLE_STEP)) - { - LOG((LF_CORDB, LL_INFO10000, "CP::TE1stCAI: ignoring hidden single step\n")); - return REACTION(cIgnore); - } - // Is this a breakpoint indicating that the Left Side is now synchronized? if ((dwExCode == STATUS_BREAKPOINT) && (pExAddress == pIPCRuntimeOffsets->m_notifyRSOfSyncCompleteBPAddr)) @@ -12592,22 +12437,6 @@ void CordbProcess::HandleDebugEventForInteropDebugging(const DEBUG_EVENT * pEven CordbWin32EventThread * pW32EventThread = this->m_pShim->GetWin32EventThread(); _ASSERTE(pW32EventThread != NULL); - // if we were waiting for a retriggered exception but received any other event then turn - // off the single stepping and dequeue the IB event. Right now we only use the SS flag internally - // for stepping during possible retrigger. - if(reaction.GetType() != Reaction::cInbandExceptionRetrigger && pUnmanagedThread->IsSSFlagNeeded()) - { - _ASSERTE(pUnmanagedThread->HasIBEvent()); - CordbUnmanagedEvent* pUnmanagedEvent = pUnmanagedThread->IBEvent(); - _ASSERTE(pUnmanagedEvent->IsIBEvent()); - _ASSERTE(pUnmanagedEvent->IsEventContinuedUnhijacked()); - _ASSERTE(pUnmanagedEvent->IsDispatched()); - LOG((LF_CORDB, LL_INFO100000, "CP::HDEFID: IB event did not retrigger ue=0x%p\n", pUnmanagedEvent)); - - DequeueUnmanagedEvent(pUnmanagedThread); - pUnmanagedThread->EndStepping(); - } - switch(reaction.GetType()) { // Common for flares. @@ -12756,10 +12585,6 @@ void CordbProcess::HandleDebugEventForInteropDebugging(const DEBUG_EVENT * pEven // so can't assert this //_ASSERTE(pUnmanagedThread->IsFirstChanceHijacked()); - // we should not be stepping at the end of hijacks - _ASSERTE(!pUnmanagedThread->IsSSFlagHidden()); - _ASSERTE(!pUnmanagedThread->IsSSFlagNeeded()); - // if we were hijacked then clean up if(pUnmanagedThread->IsFirstChanceHijacked()) { @@ -12905,16 +12730,6 @@ void CordbProcess::HandleDebugEventForInteropDebugging(const DEBUG_EVENT * pEven LOG((LF_CORDB, LL_INFO100000, "W32ET::W32EL: IB event completing, continuing ue=0x%p\n", pUnmanagedEvent)); DequeueUnmanagedEvent(pUnmanagedThread); - // If this event came from RaiseException then flush the context to ensure we won't use it until we re-enter - if(pUnmanagedEvent->m_owner->IsRaiseExceptionHijacked()) - { - pUnmanagedEvent->m_owner->RestoreFromRaiseExceptionHijack(); - pUnmanagedEvent->m_owner->ClearRaiseExceptionEntryContext(); - } - else // otherwise we should have been stepping - { - pUnmanagedThread->EndStepping(); - } pW32EventThread->ForceDbgContinue(this, pUnmanagedThread, pUnmanagedEvent->IsExceptionCleared() ? DBG_CONTINUE : DBG_EXCEPTION_NOT_HANDLED, false); diff --git a/src/coreclr/debug/di/rsmain.cpp b/src/coreclr/debug/di/rsmain.cpp index e2f25163737021..b0199c36356183 100644 --- a/src/coreclr/debug/di/rsmain.cpp +++ b/src/coreclr/debug/di/rsmain.cpp @@ -5,7 +5,6 @@ // File: RsMain.cpp // // Random RS utility stuff, plus root ICorDebug implementation -// //***************************************************************************** #include "stdafx.h" @@ -39,33 +38,6 @@ RSDebuggingInfo * g_pRSDebuggingInfo = &g_RSDebuggingInfo_OutOfProc; // The following instances are used for invoking overloaded new/delete forDbiWorker forDbi; -#ifdef _DEBUG -// For logs, we can print the string name for the debug codes. -const char * GetDebugCodeName(DWORD dwCode) -{ - if (dwCode < 1 || dwCode > 9) - { - return "!Invalid Debug Event Code!"; - } - - static const char * const szNames[] = { - "(1) EXCEPTION_DEBUG_EVENT", - "(2) CREATE_THREAD_DEBUG_EVENT", - "(3) CREATE_PROCESS_DEBUG_EVENT", - "(4) EXIT_THREAD_DEBUG_EVENT", - "(5) EXIT_PROCESS_DEBUG_EVENT", - "(6) LOAD_DLL_DEBUG_EVENT", - "(7) UNLOAD_DLL_DEBUG_EVENT", - "(8) OUTPUT_DEBUG_STRING_EVENT", - "(9) RIP_EVENT",// <-- only on Win9X - }; - - return szNames[dwCode - 1]; -} - -#endif - - //----------------------------------------------------------------------------- // Per-thread state for Debug builds... //----------------------------------------------------------------------------- diff --git a/src/coreclr/debug/di/rspriv.h b/src/coreclr/debug/di/rspriv.h index 2bc1cf52884470..9e68d3c1abd5ea 100644 --- a/src/coreclr/debug/di/rspriv.h +++ b/src/coreclr/debug/di/rspriv.h @@ -3341,8 +3341,6 @@ class CordbProcess : void MarkAllThreadsDirty(); - bool CheckIfLSExited(); - void Lock() { // Lock Hierarchy - shouldn't have List lock when taking/release the process lock. @@ -3982,9 +3980,6 @@ class CordbProcess : // Index into m_pPatchTable of the first patch (first used entry). ULONG m_iFirstPatch; - // Initializes the DAC - void InitDac(); - // copy new data from LS DCB to RS buffer void UpdateRightSideDCB(); @@ -10384,17 +10379,13 @@ enum CordbUnmanagedThreadState CUTS_None = 0x0000, CUTS_Deleted = 0x0001, CUTS_FirstChanceHijacked = 0x0002, - // Set when interop debugging needs the SS flag to be enabled - // regardless of what the user wants it to be - CUTS_IsSSFlagNeeded = 0x0004, + // unused = 0x0004, CUTS_GenericHijacked = 0x0008, - // when the m_raiseExceptionEntryContext is valid - CUTS_HasRaiseExceptionEntryCtx = 0x0010, + // unused = 0x0010, CUTS_BlockingForSync = 0x0020, CUTS_Suspended = 0x0040, CUTS_IsSpecialDebuggerThread = 0x0080, - // when the thread is re-executing RaiseException to retrigger an exception - CUTS_IsRaiseExceptionHijacked = 0x0100, + // unused = 0x0100, CUTS_HasIBEvent = 0x0200, CUTS_HasOOBEvent = 0x0400, CUTS_HasSpecialStackOverflowCase = 0x0800, @@ -10403,9 +10394,7 @@ enum CordbUnmanagedThreadState #endif CUTS_SkippingNativePatch = 0x2000, CUTS_HasContextSet = 0x4000, - // Set when interop debugging is making use of the single step flag - // but the user has not set it - CUTS_IsSSFlagHidden = 0x8000 + // unused = 0x8000, }; @@ -10456,10 +10445,6 @@ class CordbUnmanagedThread : public CordbBase HRESULT GetThreadContext(DT_CONTEXT * pContext); HRESULT SetThreadContext(DT_CONTEXT * pContext); - // Turns on and off the internal usage of the SS flag - VOID BeginStepping(); - VOID EndStepping(); - // An accessor for &m_context, this value generally stores // a context we may need to restore after a hijack completes DT_CONTEXT * GetHijackCtx(); @@ -10485,10 +10470,6 @@ class CordbUnmanagedThread : public CordbBase #endif BOOL IsSkippingNativePatch() { LIMITED_METHOD_CONTRACT; return m_state & CUTS_SkippingNativePatch; } BOOL IsContextSet() { LIMITED_METHOD_CONTRACT; return m_state & CUTS_HasContextSet; } - BOOL IsSSFlagNeeded() { LIMITED_METHOD_CONTRACT; return m_state & CUTS_IsSSFlagNeeded; } - BOOL IsSSFlagHidden() { LIMITED_METHOD_CONTRACT; return m_state & CUTS_IsSSFlagHidden; } - BOOL HasRaiseExceptionEntryCtx() { LIMITED_METHOD_CONTRACT; return m_state & CUTS_HasRaiseExceptionEntryCtx; } - BOOL IsRaiseExceptionHijacked() { LIMITED_METHOD_CONTRACT; return m_state & CUTS_IsRaiseExceptionHijacked; } void SetState(CordbUnmanagedThreadState state) { @@ -10499,12 +10480,6 @@ class CordbUnmanagedThread : public CordbBase } void ClearState(CordbUnmanagedThreadState state) {LIMITED_METHOD_CONTRACT; m_state = (CordbUnmanagedThreadState)(m_state & ~state); } - void HijackToRaiseException(); - void RestoreFromRaiseExceptionHijack(); - void SaveRaiseExceptionEntryContext(); - void ClearRaiseExceptionEntryContext(); - BOOL IsExceptionFromLastRaiseException(const EXCEPTION_RECORD* pExceptionRecord); - CordbUnmanagedEvent *IBEvent() {LIMITED_METHOD_CONTRACT; return &m_IBEvent; } CordbUnmanagedEvent *IBEvent2() {LIMITED_METHOD_CONTRACT; return &m_IBEvent2; } CordbUnmanagedEvent *OOBEvent() { return &m_OOBEvent; } @@ -10553,15 +10528,6 @@ class CordbUnmanagedThread : public CordbBase // See CordbUnmanagedThread::GetThreadContext for details DT_CONTEXT m_context; - // The context of the thread the last time it called into kernel32!RaiseException - DT_CONTEXT m_raiseExceptionEntryContext; - - DWORD m_raiseExceptionExceptionCode; - DWORD m_raiseExceptionExceptionFlags; - DWORD m_raiseExceptionNumberParameters; - ULONG_PTR m_raiseExceptionExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; - - #ifdef TARGET_X86 // the SEH handler which was the leaf when SaveCurrentSeh was called (prior to hijack) REMOTE_PTR m_pSavedLeafSeh; @@ -10587,7 +10553,6 @@ class CordbUnmanagedThread : public CordbBase bool GetEEPGCDisabled(); void GetEEState(bool *threadStepping, bool *specialManagedException); - bool GetEEFrame(); }; #endif // FEATURE_INTEROP_DEBUGGING diff --git a/src/coreclr/debug/di/rsthread.cpp b/src/coreclr/debug/di/rsthread.cpp index 99ae8fe1ae0850..a2f45a8199db2d 100644 --- a/src/coreclr/debug/di/rsthread.cpp +++ b/src/coreclr/debug/di/rsthread.cpp @@ -1,10 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: rsthread.cpp -// - #include "stdafx.h" #include "primitives.h" #include @@ -3249,11 +3245,6 @@ bool CordbUnmanagedThread::IsCantStop() } _ASSERTE(GetProcess()->ThreadHoldsProcessLock()); - if (IsRaiseExceptionHijacked()) - { - return true; - } - REMOTE_PTR pEEThread; HRESULT hr = this->GetEEThreadPtr(&pEEThread); if (FAILED(hr)) @@ -3382,40 +3373,6 @@ bool CordbUnmanagedThread::GetEEPGCDisabled() return false; } -bool CordbUnmanagedThread::GetEEFrame() -{ - REMOTE_PTR pEEThread; - - HRESULT hr = GetEEThreadPtr(&pEEThread); - - _ASSERTE(SUCCEEDED(hr)); - _ASSERTE(pEEThread != NULL); - - // Compute the address of the thread's frame ptr - DebuggerIPCRuntimeOffsets *pRO = &(GetProcess()->m_runtimeOffsets); - void *pEEThreadFrame = (BYTE*) pEEThread + pRO->m_EEThreadFrameOffset; - - // Grab the thread's frame out of the EE Thread. - DWORD EEThreadFrame; - hr = GetProcess()->SafeReadStruct(PTR_TO_CORDB_ADDRESS(pEEThreadFrame), &EEThreadFrame); - - if (FAILED(hr)) - { - LOG((LF_CORDB, LL_INFO1000, "CUT::GEETF: failed to read thread frame: 0x%p + 0x%x = 0x%p, err=%d\n", - pEEThread, pRO->m_EEThreadFrameOffset, pEEThreadFrame, GetLastError())); - - return false; - } - - LOG((LF_CORDB, LL_INFO1000000, "CUT::GEETF: EE Thread's frame is 0x%08x\n", EEThreadFrame)); - - // Looks like we've got the frame of the thread. - if (EEThreadFrame != pRO->m_EEMaxFrameValue) - return true; - else - return false; -} - // Gets the thread context as if the thread were unhijacked, regardless // of whether it really is HRESULT CordbUnmanagedThread::GetThreadContext(DT_CONTEXT* pContext) @@ -3428,11 +3385,11 @@ HRESULT CordbUnmanagedThread::GetThreadContext(DT_CONTEXT* pContext) // Both #1 and #3 are stored in the GetHijackCtx() space so of course you can't // have them both. You have #1 if IsContextSet() is true, otherwise it holds #3. // - // GenericHijack, FirstChanceHijackForSync, and RaiseExceptionHijack use #1 if available + // GenericHijack and FirstChanceHijackForSync use #1 if available // and fallback to #3 if not. In other words they use GetHijackCtx() regardless of which thing it holds // M2UHandoff uses #1 if available and then falls back to #2. // - // The reasoning here is that the first three hijacks are intended to be transparent. Since + // The reasoning here is that the first two hijacks are intended to be transparent. Since // the debugger shouldn't know they are occurring then it shouldn't see changes potentially // made on the LS. The M2UHandoff is not transparent, it has to update the context in order // to get clear of a bp. @@ -3443,13 +3400,12 @@ HRESULT CordbUnmanagedThread::GetThreadContext(DT_CONTEXT* pContext) LOG((LF_CORDB, LL_INFO10000, "CUT::GTC: thread=0x%p, flags=0x%x.\n", this, pContext->ContextFlags)); - if(IsContextSet() || IsGenericHijacked() || (IsFirstChanceHijacked() && IsBlockingForSync()) - || IsRaiseExceptionHijacked()) + if(IsContextSet() || IsGenericHijacked() || (IsFirstChanceHijacked() && IsBlockingForSync())) { - _ASSERTE(IsFirstChanceHijacked() || IsGenericHijacked() || IsRaiseExceptionHijacked()); + _ASSERTE(IsFirstChanceHijacked() || IsGenericHijacked()); LOG((LF_CORDB, LL_INFO10000, "CUT::GTC: hijackCtx case IsContextSet=%d IsGenericHijacked=%d" - "HijackedForSync=%d RaiseExceptionHijacked=%d.\n", - IsContextSet(), IsGenericHijacked(), IsBlockingForSync(), IsRaiseExceptionHijacked())); + "HijackedForSync=%d.\n", + IsContextSet(), IsGenericHijacked(), IsBlockingForSync())); LOG((LF_CORDB, LL_INFO10000, "CUT::GTC: hijackCtx is:\n")); LogContext(GetHijackCtx()); CORDbgCopyThreadContext(pContext, GetHijackCtx()); @@ -3479,10 +3435,6 @@ HRESULT CordbUnmanagedThread::GetThreadContext(DT_CONTEXT* pContext) hr = HRESULT_FROM_GetLastError(); } - if(IsSSFlagHidden()) - { - UnsetSSFlag(pContext); - } LogContext(pContext); return hr; @@ -3503,19 +3455,15 @@ HRESULT CordbUnmanagedThread::SetThreadContext(DT_CONTEXT* pContext) // If the thread is first chance hijacked, then write the context into the remote process. If the thread is generic // hijacked, then update the copy of the context that we already have. Otherwise call the normal Win32 function. - if (IsGenericHijacked() || IsFirstChanceHijacked() || IsRaiseExceptionHijacked()) + if (IsGenericHijacked() || IsFirstChanceHijacked()) { if(IsGenericHijacked()) { LOG((LF_CORDB, LL_INFO10000, "CUT::STC: setting context from generic/2nd chance hijack.\n")); } - else if(IsFirstChanceHijacked()) - { - LOG((LF_CORDB, LL_INFO10000, "CUT::STC: setting context from 1st chance hijack.\n")); - } else { - LOG((LF_CORDB, LL_INFO10000, "CUT::STC: setting context from RaiseException hijack.\n")); + LOG((LF_CORDB, LL_INFO10000, "CUT::STC: setting context from 1st chance hijack.\n")); } SetState(CUTS_HasContextSet); CORDbgCopyThreadContext(GetHijackCtx(), pContext); @@ -3524,19 +3472,6 @@ HRESULT CordbUnmanagedThread::SetThreadContext(DT_CONTEXT* pContext) { LOG((LF_CORDB, LL_INFO10000, "CUT::STC: setting context from win32.\n")); - // If the user is also setting the SS flag then we no longer have to hide it - if(IsSSFlagEnabled(pContext)) - { - ClearState(CUTS_IsSSFlagHidden); - } - // if the user is turning off the SS flag but we still want it on then leave it on - // but hidden - if(!IsSSFlagEnabled(pContext) && IsSSFlagNeeded()) - { - SetState(CUTS_IsSSFlagHidden); - SetSSFlag(pContext); - } - BOOL succ = DbiSetThreadContext(m_handle, pContext); if (!succ) @@ -3548,54 +3483,6 @@ HRESULT CordbUnmanagedThread::SetThreadContext(DT_CONTEXT* pContext) return hr; } -// Turns on the stepping flag internally and tracks whether or not the flag -// should also be seen by the user -VOID CordbUnmanagedThread::BeginStepping() -{ - _ASSERTE(!IsGenericHijacked() && !IsFirstChanceHijacked()); - _ASSERTE(!IsSSFlagNeeded()); - _ASSERTE(!IsSSFlagHidden()); - - DT_CONTEXT tempContext; - tempContext.ContextFlags = DT_CONTEXT_FULL; - BOOL succ = DbiGetThreadContext(m_handle, &tempContext); - _ASSERTE(succ); - - if(!IsSSFlagEnabled(&tempContext)) - { - SetSSFlag(&tempContext); - SetState(CUTS_IsSSFlagHidden); - } - SetState(CUTS_IsSSFlagNeeded); - - succ = DbiSetThreadContext(m_handle, &tempContext); - _ASSERTE(succ); -} - -// Turns off the stepping flag internally. If the user was also not using it then -// the flag is turned off on the context -VOID CordbUnmanagedThread::EndStepping() -{ - _ASSERTE(!IsGenericHijacked() && !IsFirstChanceHijacked()); - _ASSERTE(IsSSFlagNeeded()); - - DT_CONTEXT tempContext; - tempContext.ContextFlags = DT_CONTEXT_FULL; - BOOL succ = DbiGetThreadContext(m_handle, &tempContext); - _ASSERTE(succ); - - if(IsSSFlagHidden()) - { - UnsetSSFlag(&tempContext); - ClearState(CUTS_IsSSFlagHidden); - } - ClearState(CUTS_IsSSFlagNeeded); - - succ = DbiSetThreadContext(m_handle, &tempContext); - _ASSERTE(succ); -} - - // Writes some details of the given context into the debugger log VOID CordbUnmanagedThread::LogContext(DT_CONTEXT* pContext) { @@ -3644,9 +3531,6 @@ HRESULT CordbUnmanagedThread::SetupFirstChanceHijackForSync() // This also means we can't hijack in coopeative (since that's a can't-stop) _ASSERTE(!IsCantStop()); - // we should not be stepping into hijacks - _ASSERTE(!IsSSFlagHidden()); - _ASSERTE(!IsSSFlagNeeded()); _ASSERTE(!IsContextSet()); // snapshot the current context so we can start spoofing it @@ -3731,10 +3615,6 @@ HRESULT CordbUnmanagedThread::SetupFirstChanceHijack(EHijackReason::EHijackReaso // This also means we can't hijack in coopeative (since that's a can't-stop) _ASSERTE(!IsCantStop()); - // we should not be stepping into hijacks - _ASSERTE(!IsSSFlagHidden()); - _ASSERTE(!IsSSFlagNeeded()); - // There's a bizarre race where the thread was suspended right as the thread was about to dispatch a // debug event. We still get the debug event, and then may try to hijack. Resume the thread so that // it can run to the hijack. @@ -4164,192 +4044,6 @@ BOOL CordbUnmanagedThread::GetStackRange(CORDB_ADDRESS *pBase, CORDB_ADDRESS *pL #endif // FEATURE_DBGIPC_TRANSPORT } -//----------------------------------------------------------------------------- -// Returns the thread context to the state it was in when it last entered RaiseException -// This allows the thread to retrigger an exception caused by RaiseException -//----------------------------------------------------------------------------- -void CordbUnmanagedThread::HijackToRaiseException() -{ - LOG((LF_CORDB, LL_INFO1000, "CP::HTRE: hijacking to RaiseException\n")); - _ASSERTE(HasRaiseExceptionEntryCtx()); - _ASSERTE(!IsRaiseExceptionHijacked()); - _ASSERTE(!IsGenericHijacked()); - _ASSERTE(!IsFirstChanceHijacked()); - _ASSERTE(!IsContextSet()); - - BOOL succ = DbiGetThreadContext(m_handle, GetHijackCtx()); - _ASSERTE(succ); - succ = DbiSetThreadContext(m_handle, &m_raiseExceptionEntryContext); - _ASSERTE(succ); - SetState(CUTS_IsRaiseExceptionHijacked); -} - -//---------------------------------------------------------------------------- -// Returns the context to its unhijacked state. -//---------------------------------------------------------------------------- -void CordbUnmanagedThread::RestoreFromRaiseExceptionHijack() -{ - LOG((LF_CORDB, LL_INFO1000, "CP::RFREH: ending RaiseException hijack\n")); - _ASSERTE(IsRaiseExceptionHijacked()); - - DT_CONTEXT restoreContext; - restoreContext.ContextFlags = DT_CONTEXT_FULL; - HRESULT hr = GetThreadContext(&restoreContext); - _ASSERTE(SUCCEEDED(hr)); - - ClearState(CUTS_IsRaiseExceptionHijacked); - hr = SetThreadContext(&restoreContext); - _ASSERTE(SUCCEEDED(hr)); -} - -//----------------------------------------------------------------------------- -// Attempts to store the state of a thread currently entering RaiseException -// This grabs both a full context and enough state to determine what exception -// RaiseException should be raising. If any of the state can not be retrieved -// then this entrance to RaiseException is silently ignored -//----------------------------------------------------------------------------- -void CordbUnmanagedThread::SaveRaiseExceptionEntryContext() -{ - _ASSERTE(FALSE); // should be unused now - LOG((LF_CORDB, LL_INFO1000, "CP::SREEC: saving raise exception context.\n")); - _ASSERTE(!HasRaiseExceptionEntryCtx()); - _ASSERTE(!IsRaiseExceptionHijacked()); - HRESULT hr = S_OK; - DT_CONTEXT context; - context.ContextFlags = DT_CONTEXT_FULL; - DbiGetThreadContext(m_handle, &context); - // if the flag is set, unset it - // we don't want to be single stepping through RaiseException the second time - // sending out OOB SS events. Ultimately we will rethrow the exception which would - // cleared the SS flag anyways. - UnsetSSFlag(&context); - memcpy(&m_raiseExceptionEntryContext, &context, sizeof(DT_CONTEXT)); - - // calculate the exception that we would expect to come from this invocation of RaiseException - REMOTE_PTR pExceptionInformation = NULL; -#if defined(TARGET_AMD64) - m_raiseExceptionExceptionCode = (DWORD)m_raiseExceptionEntryContext.Rcx; - m_raiseExceptionExceptionFlags = (DWORD)m_raiseExceptionEntryContext.Rdx; - m_raiseExceptionNumberParameters = (DWORD)m_raiseExceptionEntryContext.R8; - pExceptionInformation = (REMOTE_PTR)m_raiseExceptionEntryContext.R9; -#elif defined(TARGET_ARM64) - m_raiseExceptionExceptionCode = (DWORD)m_raiseExceptionEntryContext.X0; - m_raiseExceptionExceptionFlags = (DWORD)m_raiseExceptionEntryContext.X1; - m_raiseExceptionNumberParameters = (DWORD)m_raiseExceptionEntryContext.X2; - pExceptionInformation = (REMOTE_PTR)m_raiseExceptionEntryContext.X3; -#elif defined(TARGET_X86) - hr = m_pProcess->SafeReadStruct(PTR_TO_CORDB_ADDRESS((BYTE*)m_raiseExceptionEntryContext.Esp+4), &m_raiseExceptionExceptionCode); - if(FAILED(hr)) - { - LOG((LF_CORDB, LL_INFO1000, "CP::SREEC: failed to read exception code.\n")); - return; - } - hr = m_pProcess->SafeReadStruct(PTR_TO_CORDB_ADDRESS((BYTE*)m_raiseExceptionEntryContext.Esp+8), &m_raiseExceptionExceptionFlags); - if(FAILED(hr)) - { - LOG((LF_CORDB, LL_INFO1000, "CP::SREEC: failed to read exception flags.\n")); - return; - } - hr = m_pProcess->SafeReadStruct(PTR_TO_CORDB_ADDRESS((BYTE*)m_raiseExceptionEntryContext.Esp+12), &m_raiseExceptionNumberParameters); - if(FAILED(hr)) - { - LOG((LF_CORDB, LL_INFO1000, "CP::SREEC: failed to read number of parameters.\n")); - return; - } - hr = m_pProcess->SafeReadStruct(PTR_TO_CORDB_ADDRESS((BYTE*)m_raiseExceptionEntryContext.Esp+16), &pExceptionInformation); - if(FAILED(hr)) - { - LOG((LF_CORDB, LL_INFO1000, "CP::SREEC: failed to read exception information pointer.\n")); - return; - } -#else - _ASSERTE(!"Implement this for your platform"); - return; -#endif - LOG((LF_CORDB, LL_INFO1000, "CP::SREEC: RaiseException parameters are 0x%x 0x%x 0x%x 0x%p.\n", - m_raiseExceptionExceptionCode, m_raiseExceptionExceptionFlags, - m_raiseExceptionNumberParameters, pExceptionInformation)); - TargetBuffer exceptionInfoTargetBuffer(pExceptionInformation, sizeof(REMOTE_PTR)*m_raiseExceptionNumberParameters); - EX_TRY - { - m_pProcess->SafeReadBuffer(exceptionInfoTargetBuffer, (BYTE*)m_raiseExceptionExceptionInformation); - } - EX_CATCH_HRESULT(hr); - if(FAILED(hr)) - { - LOG((LF_CORDB, LL_INFO1000, "CP::SREEC: failed to read exception information.\n")); - return; - } - - // If everything was successful then set this flag, otherwise none of the above data is considered valid - SetState(CUTS_HasRaiseExceptionEntryCtx); - return; -} - -//----------------------------------------------------------------------------- -// Clears all the state saved in SaveRaiseExceptionContext and returns the thread -// to the state as if RaiseException has yet to be called. This is typically called -// after an exception retriggers or after determining that the exception never will -// retrigger. -//----------------------------------------------------------------------------- -void CordbUnmanagedThread::ClearRaiseExceptionEntryContext() -{ - _ASSERTE(FALSE); // should be unused now - LOG((LF_CORDB, LL_INFO1000, "CP::CREEC: clearing raise exception context.\n")); - _ASSERTE(HasRaiseExceptionEntryCtx()); - ClearState(CUTS_HasRaiseExceptionEntryCtx); -} - -//----------------------------------------------------------------------------- -// Uses a heuristic to determine if the given exception record is likely to be the exception -// raised by the last invocation of RaiseException on this thread. The current heuristic compares -// ExceptionCode, ExceptionFlags, and all ExceptionInformation. -//----------------------------------------------------------------------------- -BOOL CordbUnmanagedThread::IsExceptionFromLastRaiseException(const EXCEPTION_RECORD* pExceptionRecord) -{ - _ASSERTE(FALSE); // should be unused now - if(!HasRaiseExceptionEntryCtx()) - { - LOG((LF_CORDB, LL_INFO1000, "CP::IEFLRE: not a match - no previous raise context\n")); - return FALSE; - } - - if (pExceptionRecord->ExceptionCode != m_raiseExceptionExceptionCode) - { - LOG((LF_CORDB, LL_INFO1000, "CP::IEFLRE: not a match - exception codes differ 0x%x 0x%x\n", - pExceptionRecord->ExceptionCode, m_raiseExceptionExceptionCode)); - return FALSE; - } - - if (pExceptionRecord->ExceptionFlags != m_raiseExceptionExceptionFlags) - { - LOG((LF_CORDB, LL_INFO1000, "CP::IEFLRE: not a match - exception flags differ 0x%x 0x%x\n", - pExceptionRecord->ExceptionFlags, m_raiseExceptionExceptionFlags)); - return FALSE; - } - - if (pExceptionRecord->NumberParameters != m_raiseExceptionNumberParameters) - { - LOG((LF_CORDB, LL_INFO1000, "CP::IEFLRE: not a match - number parameters differ 0x%x 0x%x\n", - pExceptionRecord->NumberParameters, m_raiseExceptionNumberParameters)); - return FALSE; - } - - for(DWORD i = 0; i < pExceptionRecord->NumberParameters; i++) - { - if(m_raiseExceptionExceptionInformation[i] != pExceptionRecord->ExceptionInformation[i]) - { - LOG((LF_CORDB, LL_INFO1000, "CP::IEFLRE: not a match - param %d differs 0x%x 0x%x\n", - i, pExceptionRecord->ExceptionInformation[i], m_raiseExceptionExceptionInformation[i])); - return FALSE; - } - } - - LOG((LF_CORDB, LL_INFO1000, "CP::IEFLRE: match\n")); - return TRUE; -} - - //----------------------------------------------------------------------------- // Inject an int3 at the given remote address //----------------------------------------------------------------------------- diff --git a/src/coreclr/debug/di/symbolinfo.cpp b/src/coreclr/debug/di/symbolinfo.cpp deleted file mode 100644 index 9bdb38da5797a0..00000000000000 --- a/src/coreclr/debug/di/symbolinfo.cpp +++ /dev/null @@ -1,1500 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - - -// callbacks for diasymreader when using SymConverter - - -#include "stdafx.h" -#include "symbolinfo.h" -#include "ex.h" - - -SymbolInfo::SymbolInfo() -{ - m_cRef=1; -} - -SymbolInfo::~SymbolInfo() -{ - for (COUNT_T i = 0;i < m_Documents.GetCount();i++) - { - if (m_Documents.Get(i) != NULL) - ((ISymUnmanagedDocumentWriter*)m_Documents.Get(i))->Release(); - } -} - -HRESULT SymbolInfo::AddDocument(DWORD id, ISymUnmanagedDocumentWriter* pDocument) -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - HRESULT hr=S_OK; - EX_TRY - { - while(m_Documents.GetCount()<=id) - m_Documents.Append(NULL); - _ASSERTE(m_Documents.Get(id) == NULL); - m_Documents.Set(id,pDocument); - pDocument->AddRef(); - } - EX_CATCH_HRESULT(hr); - return hr; -} - -HRESULT SymbolInfo::MapDocument(DWORD id, ISymUnmanagedDocumentWriter** pDocument) -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - HRESULT hr=E_FAIL; - if(m_Documents.GetCount()>id) - { - *pDocument=(ISymUnmanagedDocumentWriter*)m_Documents.Get(id); - if (*pDocument == NULL) - return E_FAIL; - (*pDocument)->AddRef(); - hr=S_OK; - } - return hr; -} - -HRESULT SymbolInfo::SetClassProps(mdToken cls, DWORD flags, LPCWSTR wszName, mdToken parent) -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - HRESULT hr=S_OK; - EX_TRY - { - if(m_Classes.Lookup(cls) == NULL) - { - NewHolder classProps (new ClassProps(cls,flags,wszName,parent)); - m_Classes.Add(classProps); - classProps.SuppressRelease(); - } - } - EX_CATCH_HRESULT(hr); - return hr; -} - -HRESULT SymbolInfo::AddSignature(SBuffer& sig, mdSignature token) -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - HRESULT hr=S_OK; - EX_TRY - { - if ( m_Signatures.Lookup(sig) == NULL) - { - NewHolder sigProps (new SignatureProps(sig,token)); - m_Signatures.Add(sigProps); - sigProps.SuppressRelease(); - } - } - EX_CATCH_HRESULT(hr); - return hr; -} - - -SymbolInfo::ClassProps* SymbolInfo::FindClass(mdToken cls) -{ - WRAPPER_NO_CONTRACT; - return m_Classes.Lookup(cls); -} - -SymbolInfo::SignatureProps* SymbolInfo::FindSignature(SBuffer& sig) -{ - WRAPPER_NO_CONTRACT; - return m_Signatures.Lookup(sig); -} - -HRESULT SymbolInfo::AddScope(ULONG32 left, ULONG32 right) -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - HRESULT hr=S_OK; - EX_TRY - { - if (m_Scopes.Lookup(left) == NULL) - { - NewHolder map (new ScopeMap(left,right)); - m_Scopes.Add(map); - map.SuppressRelease(); - } - } - EX_CATCH_HRESULT(hr); - return hr; - -} - -HRESULT SymbolInfo::MapScope(ULONG32 left, ULONG32* pRight) -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - ScopeMap* props = m_Scopes.Lookup(left); - if(props == NULL) - { - _ASSERTE(FALSE); - return E_FAIL; - } - *pRight=props->right; - return S_OK; -} - - - -HRESULT SymbolInfo::SetMethodProps(mdToken method, mdToken cls, LPCWSTR wszName) -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - HRESULT hr=S_OK; - EX_TRY - { - m_LastMethod.method=method; - m_LastMethod.cls=cls; - m_LastMethod.wszName.Set(wszName); - m_LastMethod.wszName.Normalize(); - } - EX_CATCH_HRESULT(hr) - return hr; -} - - -// IUnknown methods -STDMETHODIMP SymbolInfo::QueryInterface (REFIID riid, LPVOID * ppvObj) -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - if(ppvObj==NULL) - return E_POINTER; - - if (riid == IID_IMetaDataEmit) - *ppvObj=static_cast(this); - else - if (riid == IID_IMetaDataImport) - *ppvObj=static_cast(this); - else - if (riid == IID_IUnknown) - *ppvObj=static_cast(this); - else - return E_NOTIMPL; - - AddRef(); - return S_OK; -} - -STDMETHODIMP_(ULONG) SymbolInfo::AddRef () -{ - LIMITED_METHOD_CONTRACT; - return InterlockedIncrement(&m_cRef); -} - -STDMETHODIMP_(ULONG) SymbolInfo::Release () -{ - LIMITED_METHOD_CONTRACT; - ULONG retval=InterlockedDecrement(&m_cRef); - if(retval==0) - delete this; - - return retval; -} - -STDMETHODIMP SymbolInfo::GetTypeDefProps ( // S_OK or error. - mdTypeDef td, // [IN] TypeDef token for inquiry. - _Out_writes_to_opt_(cchTypeDef, pchTypeDef) - LPWSTR szTypeDef, // [OUT] Put name here. - ULONG cchTypeDef, // [IN] size of name buffer in wide chars. - ULONG *pchTypeDef, // [OUT] put size of name (wide chars) here. - DWORD *pdwTypeDefFlags, // [OUT] Put flags here. - mdToken *ptkExtends) // [OUT] Put base class TypeDef/TypeRef here. -{ - CONTRACTL - { - NOTHROW; - PRECONDITION(ptkExtends==NULL); - PRECONDITION(CheckPointer(szTypeDef)); - } - CONTRACTL_END; - - if (szTypeDef == NULL) - return E_POINTER; - - ClassProps* classInfo=FindClass(td); - _ASSERTE(classInfo); - if(classInfo == NULL) - return E_UNEXPECTED; - - if(pdwTypeDefFlags) - *pdwTypeDefFlags=classInfo->flags; - - - SIZE_T cch=u16_strlen(classInfo->wszName)+1; - if (cch > UINT32_MAX) - return E_UNEXPECTED; - *pchTypeDef=(ULONG)cch; - - if (cchTypeDef < cch) - return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - - wcscpy_s(szTypeDef,cchTypeDef,classInfo->wszName); - - if(pdwTypeDefFlags) - *pdwTypeDefFlags=classInfo->flags; - - - return S_OK; -} - -STDMETHODIMP SymbolInfo::GetMethodProps ( - mdMethodDef mb, // The method for which to get props. - mdTypeDef *pClass, // Put method's class here. - _Out_writes_to_opt_(cchMethod, *pchMethod) - LPWSTR szMethod, // Put method's name here. - ULONG cchMethod, // Size of szMethod buffer in wide chars. - ULONG *pchMethod, // Put actual size here - DWORD *pdwAttr, // Put flags here. - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob, // [OUT] actual size of signature blob - ULONG *pulCodeRVA, // [OUT] codeRVA - DWORD *pdwImplFlags) // [OUT] Impl. Flags -{ - CONTRACTL - { - NOTHROW; - PRECONDITION(m_LastMethod.method==mb); - PRECONDITION(pClass!=NULL); - PRECONDITION(pchMethod!=NULL); - - PRECONDITION(pdwAttr == NULL); - PRECONDITION(ppvSigBlob == NULL); - PRECONDITION(pcbSigBlob == NULL); - PRECONDITION(pulCodeRVA == NULL); - PRECONDITION(pdwImplFlags == NULL); - PRECONDITION(CheckPointer(szMethod)); - } - CONTRACTL_END; - - if (szMethod == NULL) - return E_POINTER; - - - *pClass=m_LastMethod.cls; - SIZE_T cch=u16_strlen(m_LastMethod.wszName)+1; - if(cch > UINT32_MAX) - return E_UNEXPECTED; - *pchMethod=(ULONG)cch; - - if (cchMethod < cch) - return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - - wcscpy_s(szMethod,cchMethod,m_LastMethod.wszName); - - return S_OK; -} - - -STDMETHODIMP SymbolInfo::GetNestedClassProps ( // S_OK or error. - mdTypeDef tdNestedClass, // [IN] NestedClass token. - mdTypeDef *ptdEnclosingClass) // [OUT] EnclosingClass token. -{ - CONTRACTL - { - NOTHROW; - PRECONDITION(CheckPointer(ptdEnclosingClass)); - } - CONTRACTL_END; - - if(ptdEnclosingClass == NULL) - return E_POINTER; - - ClassProps* classInfo=FindClass(tdNestedClass); - _ASSERTE(classInfo); - if(classInfo == NULL) - return E_UNEXPECTED; - - *ptdEnclosingClass=classInfo->tkEnclosing; - - - return S_OK; - -} - - -STDMETHODIMP SymbolInfo::GetTokenFromSig ( // S_OK or error. - PCCOR_SIGNATURE pvSig, // [IN] Signature to define. - ULONG cbSig, // [IN] Size of signature data. - mdSignature *pmsig) // [OUT] returned signature token. -{ - SBuffer sig; - sig.SetImmutable(pvSig,cbSig); - SignatureProps* sigProps=FindSignature(sig); - _ASSERTE(sigProps); - if(sigProps == NULL) - return E_UNEXPECTED; - - *pmsig=sigProps->tkSig; - return S_OK; -} - - -////////////////////////////////////////////// -// All the functions below are just stubs - -STDMETHODIMP_(void) SymbolInfo::CloseEnum (HCORENUM hEnum) -{ - _ASSERTE(!"NYI"); -} - -STDMETHODIMP SymbolInfo::CountEnum (HCORENUM hEnum, ULONG *pulCount) -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::ResetEnum (HCORENUM hEnum, ULONG ulPos) -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumTypeDefs (HCORENUM *phEnum, mdTypeDef rTypeDefs[], - ULONG cMax, ULONG *pcTypeDefs) -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumInterfaceImpls (HCORENUM *phEnum, mdTypeDef td, - mdInterfaceImpl rImpls[], ULONG cMax, - ULONG* pcImpls) -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumTypeRefs (HCORENUM *phEnum, mdTypeRef rTypeRefs[], - ULONG cMax, ULONG* pcTypeRefs) -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::FindTypeDefByName ( // S_OK or error. - LPCWSTR szTypeDef, // [IN] Name of the Type. - mdToken tkEnclosingClass, // [IN] TypeDef/TypeRef for Enclosing class. - mdTypeDef *ptd) // [OUT] Put the TypeDef token here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetScopeProps ( // S_OK or error. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] Put the name here. - ULONG cchName, // [IN] Size of name buffer in wide chars. - ULONG *pchName, // [OUT] Put size of name (wide chars) here. - GUID *pmvid) // [OUT, OPTIONAL] Put MVID here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetModuleFromScope ( // S_OK. - mdModule *pmd) // [OUT] Put mdModule token here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - - -STDMETHODIMP SymbolInfo::GetInterfaceImplProps ( // S_OK or error. - mdInterfaceImpl iiImpl, // [IN] InterfaceImpl token. - mdTypeDef *pClass, // [OUT] Put implementing class token here. - mdToken *ptkIface) // [OUT] Put implemented interface token here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetTypeRefProps ( // S_OK or error. - mdTypeRef tr, // [IN] TypeRef token. - mdToken *ptkResolutionScope, // [OUT] Resolution scope, ModuleRef or AssemblyRef. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] Name of the TypeRef. - ULONG cchName, // [IN] Size of buffer. - ULONG *pchName) // [OUT] Size of Name. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::ResolveTypeRef (mdTypeRef tr, REFIID riid, IUnknown **ppIScope, mdTypeDef *ptd) -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - - -STDMETHODIMP SymbolInfo::EnumMembers ( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - mdToken rMembers[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumMembersWithName ( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdToken rMembers[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumMethods ( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - mdMethodDef rMethods[], // [OUT] Put MethodDefs here. - ULONG cMax, // [IN] Max MethodDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumMethodsWithName ( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdMethodDef rMethods[], // [OU] Put MethodDefs here. - ULONG cMax, // [IN] Max MethodDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumFields ( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - mdFieldDef rFields[], // [OUT] Put FieldDefs here. - ULONG cMax, // [IN] Max FieldDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumFieldsWithName ( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdFieldDef rFields[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - - -STDMETHODIMP SymbolInfo::EnumParams ( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdMethodDef mb, // [IN] MethodDef to scope the enumeration. - mdParamDef rParams[], // [OUT] Put ParamDefs here. - ULONG cMax, // [IN] Max ParamDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumMemberRefs ( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken tkParent, // [IN] Parent token to scope the enumeration. - mdMemberRef rMemberRefs[], // [OUT] Put MemberRefs here. - ULONG cMax, // [IN] Max MemberRefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumMethodImpls ( // S_OK, S_FALSE, or error - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdToken rMethodBody[], // [OUT] Put Method Body tokens here. - mdToken rMethodDecl[], // [OUT] Put Method Declaration tokens here. - ULONG cMax, // [IN] Max tokens to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumPermissionSets ( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken tk, // [IN] if !NIL, token to scope the enumeration. - DWORD dwActions, // [IN] if !0, return only these actions. - mdPermission rPermission[], // [OUT] Put Permissions here. - ULONG cMax, // [IN] Max Permissions to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::FindMember ( - mdTypeDef td, // [IN] given typedef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdToken *pmb) // [OUT] matching memberdef -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::FindMethod ( - mdTypeDef td, // [IN] given typedef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdMethodDef *pmb) // [OUT] matching memberdef -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::FindField ( - mdTypeDef td, // [IN] given typedef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdFieldDef *pmb) // [OUT] matching memberdef -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::FindMemberRef ( - mdTypeRef td, // [IN] given typeRef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdMemberRef *pmr) // [OUT] matching memberref -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - - -STDMETHODIMP SymbolInfo::GetMemberRefProps ( // S_OK or error. - mdMemberRef mr, // [IN] given memberref - mdToken *ptk, // [OUT] Put classref or classdef here. - _Out_writes_to_opt_(cchMember, *pchMember) - LPWSTR szMember, // [OUT] buffer to fill for member's name - ULONG cchMember, // [IN] the count of char of szMember - ULONG *pchMember, // [OUT] actual count of char in member name - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to meta data blob value - ULONG *pbSig) // [OUT] actual size of signature blob -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumProperties ( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdProperty rProperties[], // [OUT] Put Properties here. - ULONG cMax, // [IN] Max properties to put. - ULONG *pcProperties) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumEvents ( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdEvent rEvents[], // [OUT] Put events here. - ULONG cMax, // [IN] Max events to put. - ULONG *pcEvents) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetEventProps ( // S_OK, S_FALSE, or error. - mdEvent ev, // [IN] event token - mdTypeDef *pClass, // [OUT] typedef containing the event declarion. - LPCWSTR szEvent, // [OUT] Event name - ULONG cchEvent, // [IN] the count of wchar of szEvent - ULONG *pchEvent, // [OUT] actual count of wchar for event's name - DWORD *pdwEventFlags, // [OUT] Event flags. - mdToken *ptkEventType, // [OUT] EventType class - mdMethodDef *pmdAddOn, // [OUT] AddOn method of the event - mdMethodDef *pmdRemoveOn, // [OUT] RemoveOn method of the event - mdMethodDef *pmdFire, // [OUT] Fire method of the event - mdMethodDef rmdOtherMethod[], // [OUT] other method of the event - ULONG cMax, // [IN] size of rmdOtherMethod - ULONG *pcOtherMethod) // [OUT] total number of other method of this event -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumMethodSemantics ( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdMethodDef mb, // [IN] MethodDef to scope the enumeration. - mdToken rEventProp[], // [OUT] Put Event/Property here. - ULONG cMax, // [IN] Max properties to put. - ULONG *pcEventProp) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetMethodSemantics ( // S_OK, S_FALSE, or error. - mdMethodDef mb, // [IN] method token - mdToken tkEventProp, // [IN] event/property token. - DWORD *pdwSemanticsFlags) // [OUT] the role flags for the method/propevent pair -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetClassLayout ( - mdTypeDef td, // [IN] give typedef - DWORD *pdwPackSize, // [OUT] 1, 2, 4, 8, or 16 - COR_FIELD_OFFSET rFieldOffset[], // [OUT] field offset array - ULONG cMax, // [IN] size of the array - ULONG *pcFieldOffset, // [OUT] needed array size - ULONG *pulClassSize) // [OUT] the size of the class -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetFieldMarshal ( - mdToken tk, // [IN] given a field's memberdef - PCCOR_SIGNATURE *ppvNativeType, // [OUT] native type of this field - ULONG *pcbNativeType) // [OUT] the count of bytes of *ppvNativeType -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetRVA ( // S_OK or error. - mdToken tk, // Member for which to set offset - ULONG *pulCodeRVA, // The offset - DWORD *pdwImplFlags) // the implementation flags -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetPermissionSetProps ( - mdPermission pm, // [IN] the permission token. - DWORD *pdwAction, // [OUT] CorDeclSecurity. - void const **ppvPermission, // [OUT] permission blob. - ULONG *pcbPermission) // [OUT] count of bytes of pvPermission. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetSigFromToken ( // S_OK or error. - mdSignature mdSig, // [IN] Signature token. - PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to token. - ULONG *pcbSig) // [OUT] return size of signature. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetModuleRefProps ( // S_OK or error. - mdModuleRef mur, // [IN] moduleref token. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] buffer to fill with the moduleref name. - ULONG cchName, // [IN] size of szName in wide characters. - ULONG *pchName) // [OUT] actual count of characters in the name. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumModuleRefs ( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdModuleRef rModuleRefs[], // [OUT] put modulerefs here. - ULONG cmax, // [IN] max memberrefs to put. - ULONG *pcModuleRefs) // [OUT] put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetTypeSpecFromToken ( // S_OK or error. - mdTypeSpec typespec, // [IN] TypeSpec token. - PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to TypeSpec signature - ULONG *pcbSig) // [OUT] return size of signature. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetNameFromToken ( // Not Recommended! May be removed! - mdToken tk, // [IN] Token to get name from. Must have a name. - MDUTF8CSTR *pszUtf8NamePtr) // [OUT] Return pointer to UTF8 name in heap. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumUnresolvedMethods ( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken rMethods[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetUserString ( // S_OK or error. - mdString stk, // [IN] String token. - _Out_writes_to_opt_(cchString, *pchString) - LPWSTR szString, // [OUT] Copy of string. - ULONG cchString, // [IN] Max chars of room in szString. - ULONG *pchString) // [OUT] How many chars in actual string. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetPinvokeMap ( // S_OK or error. - mdToken tk, // [IN] FieldDef or MethodDef. - DWORD *pdwMappingFlags, // [OUT] Flags used for mapping. - _Out_writes_to_opt_(cchImportName, *pchImportName) - LPWSTR szImportName, // [OUT] Import name. - ULONG cchImportName, // [IN] Size of the name buffer. - ULONG *pchImportName, // [OUT] Actual number of characters stored. - mdModuleRef *pmrImportDLL) // [OUT] ModuleRef token for the target DLL. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumSignatures ( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdSignature rSignatures[], // [OUT] put signatures here. - ULONG cmax, // [IN] max signatures to put. - ULONG *pcSignatures) // [OUT] put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumTypeSpecs ( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdTypeSpec rTypeSpecs[], // [OUT] put TypeSpecs here. - ULONG cmax, // [IN] max TypeSpecs to put. - ULONG *pcTypeSpecs) // [OUT] put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumUserStrings ( // S_OK or error. - HCORENUM *phEnum, // [IN/OUT] pointer to the enum. - mdString rStrings[], // [OUT] put Strings here. - ULONG cmax, // [IN] max Strings to put. - ULONG *pcStrings) // [OUT] put # put here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetParamForMethodIndex ( // S_OK or error. - mdMethodDef md, // [IN] Method token. - ULONG ulParamSeq, // [IN] Parameter sequence. - mdParamDef *ppd) // [IN] Put Param token here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::EnumCustomAttributes ( // S_OK or error. - HCORENUM *phEnum, // [IN, OUT] COR enumerator. - mdToken tk, // [IN] Token to scope the enumeration, 0 for all. - mdToken tkType, // [IN] Type of interest, 0 for all. - mdCustomAttribute rCustomAttributes[], // [OUT] Put custom attribute tokens here. - ULONG cMax, // [IN] Size of rCustomAttributes. - ULONG *pcCustomAttributes) // [OUT, OPTIONAL] Put count of token values here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetCustomAttributeProps ( // S_OK or error. - mdCustomAttribute cv, // [IN] CustomAttribute token. - mdToken *ptkObj, // [OUT, OPTIONAL] Put object token here. - mdToken *ptkType, // [OUT, OPTIONAL] Put AttrType token here. - void const **ppBlob, // [OUT, OPTIONAL] Put pointer to data here. - ULONG *pcbSize) // [OUT, OPTIONAL] Put size of date here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::FindTypeRef ( - mdToken tkResolutionScope, // [IN] ModuleRef, AssemblyRef or TypeRef. - LPCWSTR szName, // [IN] TypeRef Name. - mdTypeRef *ptr) // [OUT] matching TypeRef. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetMemberProps ( - mdToken mb, // The member for which to get props. - mdTypeDef *pClass, // Put member's class here. - _Out_writes_to_opt_(cchMember, *pchMember) - LPWSTR szMember, // Put member's name here. - ULONG cchMember, // Size of szMember buffer in wide chars. - ULONG *pchMember, // Put actual size here - DWORD *pdwAttr, // Put flags here. - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob, // [OUT] actual size of signature blob - ULONG *pulCodeRVA, // [OUT] codeRVA - DWORD *pdwImplFlags, // [OUT] Impl. Flags - DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_* - UVCP_CONSTANT *ppValue, // [OUT] constant value - ULONG *pcchValue) // [OUT] size of constant string in chars, 0 for non-strings. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetFieldProps ( - mdFieldDef mb, // The field for which to get props. - mdTypeDef *pClass, // Put field's class here. - _Out_writes_to_opt_(cchField, *pchField) - LPWSTR szField, // Put field's name here. - ULONG cchField, // Size of szField buffer in wide chars. - ULONG *pchField, // Put actual size here - DWORD *pdwAttr, // Put flags here. - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob, // [OUT] actual size of signature blob - DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_* - UVCP_CONSTANT *ppValue, // [OUT] constant value - ULONG *pcchValue) // [OUT] size of constant string in chars, 0 for non-strings. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetPropertyProps ( // S_OK, S_FALSE, or error. - mdProperty prop, // [IN] property token - mdTypeDef *pClass, // [OUT] typedef containing the property declarion. - LPCWSTR szProperty, // [OUT] Property name - ULONG cchProperty, // [IN] the count of wchar of szProperty - ULONG *pchProperty, // [OUT] actual count of wchar for property name - DWORD *pdwPropFlags, // [OUT] property flags. - PCCOR_SIGNATURE *ppvSig, // [OUT] property type. pointing to meta data internal blob - ULONG *pbSig, // [OUT] count of bytes in *ppvSig - DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_* - UVCP_CONSTANT *ppDefaultValue, // [OUT] constant value - ULONG *pcchDefaultValue, // [OUT] size of constant string in chars, 0 for non-strings. - mdMethodDef *pmdSetter, // [OUT] setter method of the property - mdMethodDef *pmdGetter, // [OUT] getter method of the property - mdMethodDef rmdOtherMethod[], // [OUT] other method of the property - ULONG cMax, // [IN] size of rmdOtherMethod - ULONG *pcOtherMethod) // [OUT] total number of other method of this property -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetParamProps ( // S_OK or error. - mdParamDef tk, // [IN]The Parameter. - mdMethodDef *pmd, // [OUT] Parent Method token. - ULONG *pulSequence, // [OUT] Parameter sequence. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] Put name here. - ULONG cchName, // [OUT] Size of name buffer. - ULONG *pchName, // [OUT] Put actual size of name here. - DWORD *pdwAttr, // [OUT] Put flags here. - DWORD *pdwCPlusTypeFlag, // [OUT] Flag for value type. selected ELEMENT_TYPE_*. - UVCP_CONSTANT *ppValue, // [OUT] Constant value. - ULONG *pcchValue) // [OUT] size of constant string in chars, 0 for non-strings. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetCustomAttributeByName ( // S_OK or error. - mdToken tkObj, // [IN] Object with Custom Attribute. - LPCWSTR szName, // [IN] Name of desired Custom Attribute. - const void **ppData, // [OUT] Put pointer to data here. - ULONG *pcbData) // [OUT] Put size of data here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP_(BOOL) SymbolInfo::IsValidToken ( // True or False. - mdToken tk) // [IN] Given token. -{ - _ASSERTE(!"NYI"); - return FALSE; -} - - -STDMETHODIMP SymbolInfo::GetNativeCallConvFromSig ( // S_OK or error. - void const *pvSig, // [IN] Pointer to signature. - ULONG cbSig, // [IN] Count of signature bytes. - ULONG *pCallConv) // [OUT] Put calling conv here (see CorPinvokemap). -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::IsGlobal ( // S_OK or error. - mdToken pd, // [IN] Type, Field, or Method token. - int *pbGlobal) // [OUT] Put 1 if global, 0 otherwise. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - - -// IMetaDataEmit functions - -STDMETHODIMP SymbolInfo::SetModuleProps ( // S_OK or error. - LPCWSTR szName) // [IN] If not NULL, the name of the module to set. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::Save ( // S_OK or error. - LPCWSTR szFile, // [IN] The filename to save to. - DWORD dwSaveFlags) // [IN] Flags for the save. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SaveToStream ( // S_OK or error. - IStream *pIStream, // [IN] A writable stream to save to. - DWORD dwSaveFlags) // [IN] Flags for the save. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetSaveSize ( // S_OK or error. - CorSaveSize fSave, // [IN] cssAccurate or cssQuick. - DWORD *pdwSaveSize) // [OUT] Put the size here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineTypeDef ( // S_OK or error. - LPCWSTR szTypeDef, // [IN] Name of TypeDef - DWORD dwTypeDefFlags, // [IN] CustomAttribute flags - mdToken tkExtends, // [IN] extends this TypeDef or typeref - mdToken rtkImplements[], // [IN] Implements interfaces - mdTypeDef *ptd) // [OUT] Put TypeDef token here -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineNestedType ( // S_OK or error. - LPCWSTR szTypeDef, // [IN] Name of TypeDef - DWORD dwTypeDefFlags, // [IN] CustomAttribute flags - mdToken tkExtends, // [IN] extends this TypeDef or typeref - mdToken rtkImplements[], // [IN] Implements interfaces - mdTypeDef tdEncloser, // [IN] TypeDef token of the enclosing type. - mdTypeDef *ptd) // [OUT] Put TypeDef token here -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetHandler ( // S_OK. - IUnknown *pUnk) // [IN] The new error handler. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineMethod ( // S_OK or error. - mdTypeDef td, // Parent TypeDef - LPCWSTR szName, // Name of member - DWORD dwMethodFlags, // Member attributes - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - ULONG ulCodeRVA, - DWORD dwImplFlags, - mdMethodDef *pmd) // Put member token here -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineMethodImpl ( // S_OK or error. - mdTypeDef td, // [IN] The class implementing the method - mdToken tkBody, // [IN] Method body - MethodDef or MethodRef - mdToken tkDecl) // [IN] Method declaration - MethodDef or MethodRef -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineTypeRefByName ( // S_OK or error. - mdToken tkResolutionScope, // [IN] ModuleRef, AssemblyRef or TypeRef. - LPCWSTR szName, // [IN] Name of the TypeRef. - mdTypeRef *ptr) // [OUT] Put TypeRef token here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineImportType ( // S_OK or error. - IMetaDataAssemblyImport *pAssemImport, // [IN] Assembly containing the TypeDef. - const void *pbHashValue, // [IN] Hash Blob for Assembly. - ULONG cbHashValue, // [IN] Count of bytes. - IMetaDataImport *pImport, // [IN] Scope containing the TypeDef. - mdTypeDef tdImport, // [IN] The imported TypeDef. - IMetaDataAssemblyEmit *pAssemEmit, // [IN] Assembly into which the TypeDef is imported. - mdTypeRef *ptr) // [OUT] Put TypeRef token here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineMemberRef ( // S_OK or error - mdToken tkImport, // [IN] ClassRef or ClassDef importing a member. - LPCWSTR szName, // [IN] member's name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdMemberRef *pmr) // [OUT] memberref token -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineImportMember ( // S_OK or error. - IMetaDataAssemblyImport *pAssemImport, // [IN] Assembly containing the Member. - const void *pbHashValue, // [IN] Hash Blob for Assembly. - ULONG cbHashValue, // [IN] Count of bytes. - IMetaDataImport *pImport, // [IN] Import scope, with member. - mdToken mbMember, // [IN] Member in import scope. - IMetaDataAssemblyEmit *pAssemEmit, // [IN] Assembly into which the Member is imported. - mdToken tkParent, // [IN] Classref or classdef in emit scope. - mdMemberRef *pmr) // [OUT] Put member ref here. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineEvent( - mdTypeDef td, // [IN] the class/interface on which the event is being defined - LPCWSTR szEvent, // [IN] Name of the event - DWORD dwEventFlags, // [IN] CorEventAttr - mdToken tkEventType, // [IN] a reference (mdTypeRef or mdTypeRef) to the Event class - mdMethodDef mdAddOn, // [IN] required add method - mdMethodDef mdRemoveOn, // [IN] required remove method - mdMethodDef mdFire, // [IN] optional fire method - mdMethodDef rmdOtherMethods[], // [IN] optional array of other methods associate with the event - mdEvent *pmdEvent) // [OUT] output event token -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetClassLayout( - mdTypeDef td, // [IN] typedef - DWORD dwPackSize, // [IN] packing size specified as 1, 2, 4, 8, or 16 - COR_FIELD_OFFSET rFieldOffsets[], // [IN] array of layout specification - ULONG ulClassSize) // [IN] size of the class -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DeleteClassLayout( - mdTypeDef td) // [IN] typedef whose layout is to be deleted. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetFieldMarshal( - mdToken tk, // [IN] given a fieldDef or paramDef token - PCCOR_SIGNATURE pvNativeType, // [IN] native type specification - ULONG cbNativeType) // [IN] count of bytes of pvNativeType -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DeleteFieldMarshal( - mdToken tk) // [IN] given a fieldDef or paramDef token -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefinePermissionSet( - mdToken tk, // [IN] the object to be decorated. - DWORD dwAction, // [IN] CorDeclSecurity. - void const *pvPermission, // [IN] permission blob. - ULONG cbPermission, // [IN] count of bytes of pvPermission. - mdPermission *ppm) // [OUT] returned permission token. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetRVA ( // S_OK or error. - mdMethodDef md, // [IN] Method for which to set offset - ULONG ulRVA) // [IN] The offset -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineModuleRef ( // S_OK or error. - LPCWSTR szName, // [IN] DLL name - mdModuleRef *pmur) // [OUT] returned -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetParent ( // S_OK or error. - mdMemberRef mr, // [IN] Token for the ref to be fixed up. - mdToken tk) // [IN] The ref parent. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::GetTokenFromTypeSpec ( // S_OK or error. - PCCOR_SIGNATURE pvSig, // [IN] TypeSpec Signature to define. - ULONG cbSig, // [IN] Size of signature data. - mdTypeSpec *ptypespec) // [OUT] returned TypeSpec token. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SaveToMemory ( // S_OK or error. - void *pbData, // [OUT] Location to write data. - ULONG cbData) // [IN] Max size of data buffer. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineUserString ( // Return code. - LPCWSTR szString, // [IN] User literal string. - ULONG cchString, // [IN] Length of string. - mdString *pstk) // [OUT] String token. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DeleteToken ( // Return code. - mdToken tkObj) // [IN] The token to be deleted -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetMethodProps ( // S_OK or error. - mdMethodDef md, // [IN] The MethodDef. - DWORD dwMethodFlags, // [IN] Method attributes. - ULONG ulCodeRVA, // [IN] Code RVA. - DWORD dwImplFlags) // [IN] Impl flags. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetTypeDefProps ( // S_OK or error. - mdTypeDef td, // [IN] The TypeDef. - DWORD dwTypeDefFlags, // [IN] TypeDef flags. - mdToken tkExtends, // [IN] Base TypeDef or TypeRef. - mdToken rtkImplements[]) // [IN] Implemented interfaces. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetEventProps ( // S_OK or error. - mdEvent ev, // [IN] The event token. - DWORD dwEventFlags, // [IN] CorEventAttr. - mdToken tkEventType, // [IN] A reference (mdTypeRef or mdTypeRef) to the Event class. - mdMethodDef mdAddOn, // [IN] Add method. - mdMethodDef mdRemoveOn, // [IN] Remove method. - mdMethodDef mdFire, // [IN] Fire method. - mdMethodDef rmdOtherMethods[])// [IN] Array of other methods associate with the event. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetPermissionSetProps ( // S_OK or error. - mdToken tk, // [IN] The object to be decorated. - DWORD dwAction, // [IN] CorDeclSecurity. - void const *pvPermission, // [IN] Permission blob. - ULONG cbPermission, // [IN] Count of bytes of pvPermission. - mdPermission *ppm) // [OUT] Permission token. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefinePinvokeMap ( // Return code. - mdToken tk, // [IN] FieldDef or MethodDef. - DWORD dwMappingFlags, // [IN] Flags used for mapping. - LPCWSTR szImportName, // [IN] Import name. - mdModuleRef mrImportDLL) // [IN] ModuleRef token for the target DLL. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetPinvokeMap ( // Return code. - mdToken tk, // [IN] FieldDef or MethodDef. - DWORD dwMappingFlags, // [IN] Flags used for mapping. - LPCWSTR szImportName, // [IN] Import name. - mdModuleRef mrImportDLL) // [IN] ModuleRef token for the target DLL. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DeletePinvokeMap ( // Return code. - mdToken tk) // [IN] FieldDef or MethodDef. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -// New CustomAttribute functions. -STDMETHODIMP SymbolInfo::DefineCustomAttribute ( // Return code. - mdToken tkObj, // [IN] The object to put the value on. - mdToken tkType, // [IN] Type of the CustomAttribute (TypeRef/TypeDef). - void const *pCustomAttribute, // [IN] The custom value data. - ULONG cbCustomAttribute, // [IN] The custom value data length. - mdCustomAttribute *pcv) // [OUT] The custom value token value on return. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetCustomAttributeValue ( // Return code. - mdCustomAttribute pcv, // [IN] The custom value token whose value to replace. - void const *pCustomAttribute, // [IN] The custom value data. - ULONG cbCustomAttribute)// [IN] The custom value data length. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineField ( // S_OK or error. - mdTypeDef td, // Parent TypeDef - LPCWSTR szName, // Name of member - DWORD dwFieldFlags, // Member attributes - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - DWORD dwCPlusTypeFlag, // [IN] flag for value type. selected ELEMENT_TYPE_* - void const *pValue, // [IN] constant value - ULONG cchValue, // [IN] size of constant value (string, in wide chars). - mdFieldDef *pmd) // [OUT] Put member token here -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineProperty ( - mdTypeDef td, // [IN] the class/interface on which the property is being defined - LPCWSTR szProperty, // [IN] Name of the property - DWORD dwPropFlags, // [IN] CorPropertyAttr - PCCOR_SIGNATURE pvSig, // [IN] the required type signature - ULONG cbSig, // [IN] the size of the type signature blob - DWORD dwCPlusTypeFlag, // [IN] flag for value type. selected ELEMENT_TYPE_* - void const *pValue, // [IN] constant value - ULONG cchValue, // [IN] size of constant value (string, in wide chars). - mdMethodDef mdSetter, // [IN] optional setter of the property - mdMethodDef mdGetter, // [IN] optional getter of the property - mdMethodDef rmdOtherMethods[], // [IN] an optional array of other methods - mdProperty *pmdProp) // [OUT] output property token -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::DefineParam ( - mdMethodDef md, // [IN] Owning method - ULONG ulParamSeq, // [IN] Which param - LPCWSTR szName, // [IN] Optional param name - DWORD dwParamFlags, // [IN] Optional param flags - DWORD dwCPlusTypeFlag, // [IN] flag for value type. selected ELEMENT_TYPE_* - void const *pValue, // [IN] constant value - ULONG cchValue, // [IN] size of constant value (string, in wide chars). - mdParamDef *ppd) // [OUT] Put param token here -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetFieldProps ( // S_OK or error. - mdFieldDef fd, // [IN] The FieldDef. - DWORD dwFieldFlags, // [IN] Field attributes. - DWORD dwCPlusTypeFlag, // [IN] Flag for the value type, selected ELEMENT_TYPE_* - void const *pValue, // [IN] Constant value. - ULONG cchValue) // [IN] size of constant value (string, in wide chars). -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetPropertyProps ( // S_OK or error. - mdProperty pr, // [IN] Property token. - DWORD dwPropFlags, // [IN] CorPropertyAttr. - DWORD dwCPlusTypeFlag, // [IN] Flag for value type, selected ELEMENT_TYPE_* - void const *pValue, // [IN] Constant value. - ULONG cchValue, // [IN] size of constant value (string, in wide chars). - mdMethodDef mdSetter, // [IN] Setter of the property. - mdMethodDef mdGetter, // [IN] Getter of the property. - mdMethodDef rmdOtherMethods[])// [IN] Array of other methods. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetParamProps ( // Return code. - mdParamDef pd, // [IN] Param token. - LPCWSTR szName, // [IN] Param name. - DWORD dwParamFlags, // [IN] Param flags. - DWORD dwCPlusTypeFlag, // [IN] Flag for value type. selected ELEMENT_TYPE_*. - void const *pValue, // [OUT] Constant value. - ULONG cchValue) // [IN] size of constant value (string, in wide chars). -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -// Specialized Custom Attributes for security. -STDMETHODIMP SymbolInfo::DefineSecurityAttributeSet ( // Return code. - mdToken tkObj, // [IN] Class or method requiring security attributes. - COR_SECATTR rSecAttrs[], // [IN] Array of security attribute descriptions. - ULONG cSecAttrs, // [IN] Count of elements in above array. - ULONG *pulErrorAttr) // [OUT] On error, index of attribute causing problem. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::ApplyEditAndContinue ( // S_OK or error. - IUnknown *pImport) // [IN] Metadata from the delta PE. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::TranslateSigWithScope ( - IMetaDataAssemblyImport *pAssemImport, // [IN] importing assembly interface - const void *pbHashValue, // [IN] Hash Blob for Assembly. - ULONG cbHashValue, // [IN] Count of bytes. - IMetaDataImport *import, // [IN] importing interface - PCCOR_SIGNATURE pbSigBlob, // [IN] signature in the importing scope - ULONG cbSigBlob, // [IN] count of bytes of signature - IMetaDataAssemblyEmit *pAssemEmit, // [IN] emit assembly interface - IMetaDataEmit *emit, // [IN] emit interface - PCOR_SIGNATURE pvTranslatedSig, // [OUT] buffer to hold translated signature - ULONG cbTranslatedSigMax, - ULONG *pcbTranslatedSig)// [OUT] count of bytes in the translated signature -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetMethodImplFlags ( // [IN] S_OK or error. - mdMethodDef md, // [IN] Method for which to set ImplFlags - DWORD dwImplFlags) -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::SetFieldRVA ( // [IN] S_OK or error. - mdFieldDef fd, // [IN] Field for which to set offset - ULONG ulRVA) // [IN] The offset -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::Merge ( // S_OK or error. - IMetaDataImport *pImport, // [IN] The scope to be merged. - IMapToken *pHostMapToken, // [IN] Host IMapToken interface to receive token remap notification - IUnknown *pHandler) // [IN] An object to receive to receive error notification. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - -STDMETHODIMP SymbolInfo::MergeEnd () // S_OK or error. -{ - _ASSERTE(!"NYI"); - return E_NOTIMPL; -} - - diff --git a/src/coreclr/debug/di/symbolinfo.h b/src/coreclr/debug/di/symbolinfo.h deleted file mode 100644 index f5551acac319ff..00000000000000 --- a/src/coreclr/debug/di/symbolinfo.h +++ /dev/null @@ -1,815 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - - -// callbacks for diasymreader when using SymConverter - - -#ifndef SYMBOLINFO_H -#define SYMBOLINFO_H -#include "arraylist.h" -#include "shash.h" -#include "corsym.h" -#include "sstring.h" - -class SymbolInfo: IMetaDataEmit, IMetaDataImport -{ - - struct ScopeMap - { - ULONG32 left; - ULONG32 right; - ScopeMap(ULONG32 l, ULONG32 r):left(l), right(r){}; - ULONG32 GetKey() {return left;}; - static COUNT_T Hash(ULONG32 key) {return key;}; - }; - - struct MethodProps - { - mdMethodDef method; - mdTypeDef cls; - SString wszName; - MethodProps() : method(mdTokenNil) {}; - }; - - struct ClassProps - { - mdTypeDef cls; - DWORD flags; - SString wszName; - mdTypeDef tkEnclosing; - ClassProps(mdToken c, DWORD f, LPCWSTR name, mdToken tkE): - cls(c),flags(f),wszName(name),tkEnclosing(tkE) {wszName.Normalize();}; - - mdTypeDef GetKey() {return cls;}; - static COUNT_T Hash(mdTypeDef key) {return key;}; - }; - - struct SignatureProps - { - SBuffer sig; - DWORD tkSig; - SignatureProps(SBuffer& signature, DWORD token): - tkSig(token) {sig.Set(signature);}; - SBuffer& GetKey() {return sig;}; - static COUNT_T Hash(SBuffer& key) {return HashBytes(key,key.GetSize());}; - }; - - Volatile m_cRef; - ArrayList m_Documents; - PtrSHashWithCleanup m_Scopes; - PtrSHashWithCleanup m_Signatures; - PtrSHashWithCleanup m_Classes; - - MethodProps m_LastMethod; // diasymreader supports only one open method at a time - - ClassProps* FindClass(mdToken cls); - SignatureProps* FindSignature(SBuffer& sig); - - virtual ~SymbolInfo(); // protected, b/c the lifetime is controlled by refcount - -public: - SymbolInfo(); - - HRESULT AddDocument(DWORD id, ISymUnmanagedDocumentWriter* Document); - HRESULT MapDocument(DWORD id, ISymUnmanagedDocumentWriter** Document); - HRESULT AddScope(ULONG32 left, ULONG32 right); - HRESULT MapScope(ULONG32 left, ULONG32* pRight); - HRESULT SetMethodProps(mdToken method, mdTypeDef cls, LPCWSTR wszName); - HRESULT SetClassProps(mdTypeDef cls, DWORD flags, LPCWSTR wszName, mdTypeDef enclosingCls); - HRESULT AddSignature(SBuffer& sig, mdSignature token); - - // IUnknown methods - STDMETHOD(QueryInterface) (REFIID riid, LPVOID * ppvObj); - STDMETHOD_(ULONG,AddRef) (); - STDMETHOD_(ULONG,Release) (); - - - // IMetaDataImport functions - - STDMETHOD_(void, CloseEnum)(HCORENUM hEnum); - STDMETHOD(CountEnum)(HCORENUM hEnum, ULONG *pulCount); - STDMETHOD(ResetEnum)(HCORENUM hEnum, ULONG ulPos); - STDMETHOD(EnumTypeDefs)(HCORENUM *phEnum, mdTypeDef rTypeDefs[], - ULONG cMax, ULONG *pcTypeDefs); - STDMETHOD(EnumInterfaceImpls)(HCORENUM *phEnum, mdTypeDef td, - mdInterfaceImpl rImpls[], ULONG cMax, - ULONG* pcImpls); - STDMETHOD(EnumTypeRefs)(HCORENUM *phEnum, mdTypeRef rTypeRefs[], - ULONG cMax, ULONG* pcTypeRefs); - - STDMETHOD(FindTypeDefByName)( // S_OK or error. - LPCWSTR szTypeDef, // [IN] Name of the Type. - mdToken tkEnclosingClass, // [IN] TypeDef/TypeRef for Enclosing class. - mdTypeDef *ptd); // [OUT] Put the TypeDef token here. - - STDMETHOD(GetScopeProps)( // S_OK or error. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] Put the name here. - ULONG cchName, // [IN] Size of name buffer in wide chars. - ULONG *pchName, // [OUT] Put size of name (wide chars) here. - GUID *pmvid); // [OUT, OPTIONAL] Put MVID here. - - STDMETHOD(GetModuleFromScope)( // S_OK. - mdModule *pmd); // [OUT] Put mdModule token here. - - STDMETHOD(GetTypeDefProps)( // S_OK or error. - mdTypeDef td, // [IN] TypeDef token for inquiry. - _Out_writes_to_opt_(cchTypeDef, *pchTypeDef) - LPWSTR szTypeDef, // [OUT] Put name here. - ULONG cchTypeDef, // [IN] size of name buffer in wide chars. - ULONG *pchTypeDef, // [OUT] put size of name (wide chars) here. - DWORD *pdwTypeDefFlags, // [OUT] Put flags here. - mdToken *ptkExtends); // [OUT] Put base class TypeDef/TypeRef here. - - STDMETHOD(GetInterfaceImplProps)( // S_OK or error. - mdInterfaceImpl iiImpl, // [IN] InterfaceImpl token. - mdTypeDef *pClass, // [OUT] Put implementing class token here. - mdToken *ptkIface); // [OUT] Put implemented interface token here. - - STDMETHOD(GetTypeRefProps)( // S_OK or error. - mdTypeRef tr, // [IN] TypeRef token. - mdToken *ptkResolutionScope, // [OUT] Resolution scope, ModuleRef or AssemblyRef. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] Name of the TypeRef. - ULONG cchName, // [IN] Size of buffer. - ULONG *pchName); // [OUT] Size of Name. - - STDMETHOD(ResolveTypeRef)(mdTypeRef tr, REFIID riid, IUnknown **ppIScope, mdTypeDef *ptd); - - STDMETHOD(EnumMembers)( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - mdToken rMembers[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(EnumMembersWithName)( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdToken rMembers[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(EnumMethods)( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - mdMethodDef rMethods[], // [OUT] Put MethodDefs here. - ULONG cMax, // [IN] Max MethodDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(EnumMethodsWithName)( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdMethodDef rMethods[], // [OU] Put MethodDefs here. - ULONG cMax, // [IN] Max MethodDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(EnumFields)( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - mdFieldDef rFields[], // [OUT] Put FieldDefs here. - ULONG cMax, // [IN] Max FieldDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(EnumFieldsWithName)( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdFieldDef rFields[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - - STDMETHOD(EnumParams)( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdMethodDef mb, // [IN] MethodDef to scope the enumeration. - mdParamDef rParams[], // [OUT] Put ParamDefs here. - ULONG cMax, // [IN] Max ParamDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(EnumMemberRefs)( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken tkParent, // [IN] Parent token to scope the enumeration. - mdMemberRef rMemberRefs[], // [OUT] Put MemberRefs here. - ULONG cMax, // [IN] Max MemberRefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(EnumMethodImpls)( // S_OK, S_FALSE, or error - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdToken rMethodBody[], // [OUT] Put Method Body tokens here. - mdToken rMethodDecl[], // [OUT] Put Method Declaration tokens here. - ULONG cMax, // [IN] Max tokens to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(EnumPermissionSets)( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken tk, // [IN] if !NIL, token to scope the enumeration. - DWORD dwActions, // [IN] if !0, return only these actions. - mdPermission rPermission[], // [OUT] Put Permissions here. - ULONG cMax, // [IN] Max Permissions to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(FindMember)( - mdTypeDef td, // [IN] given typedef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdToken *pmb); // [OUT] matching memberdef - - STDMETHOD(FindMethod)( - mdTypeDef td, // [IN] given typedef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdMethodDef *pmb); // [OUT] matching memberdef - - STDMETHOD(FindField)( - mdTypeDef td, // [IN] given typedef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdFieldDef *pmb); // [OUT] matching memberdef - - STDMETHOD(FindMemberRef)( - mdTypeRef td, // [IN] given typeRef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdMemberRef *pmr); // [OUT] matching memberref - - STDMETHOD (GetMethodProps)( - mdMethodDef mb, // The method for which to get props. - mdTypeDef *pClass, // Put method's class here. - _Out_writes_to_opt_(cchMethod, *pchMethod) - LPWSTR szMethod, // Put method's name here. - ULONG cchMethod, // Size of szMethod buffer in wide chars. - ULONG *pchMethod, // Put actual size here - DWORD *pdwAttr, // Put flags here. - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob, // [OUT] actual size of signature blob - ULONG *pulCodeRVA, // [OUT] codeRVA - DWORD *pdwImplFlags); // [OUT] Impl. Flags - - STDMETHOD(GetMemberRefProps)( // S_OK or error. - mdMemberRef mr, // [IN] given memberref - mdToken *ptk, // [OUT] Put classref or classdef here. - _Out_writes_to_opt_(cchMember, *pchMember) - LPWSTR szMember, // [OUT] buffer to fill for member's name - ULONG cchMember, // [IN] the count of char of szMember - ULONG *pchMember, // [OUT] actual count of char in member name - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to meta data blob value - ULONG *pbSig); // [OUT] actual size of signature blob - - STDMETHOD(EnumProperties)( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdProperty rProperties[], // [OUT] Put Properties here. - ULONG cMax, // [IN] Max properties to put. - ULONG *pcProperties); // [OUT] Put # put here. - - STDMETHOD(EnumEvents)( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdEvent rEvents[], // [OUT] Put events here. - ULONG cMax, // [IN] Max events to put. - ULONG *pcEvents); // [OUT] Put # put here. - - STDMETHOD(GetEventProps)( // S_OK, S_FALSE, or error. - mdEvent ev, // [IN] event token - mdTypeDef *pClass, // [OUT] typedef containing the event declarion. - LPCWSTR szEvent, // [OUT] Event name - ULONG cchEvent, // [IN] the count of wchar of szEvent - ULONG *pchEvent, // [OUT] actual count of wchar for event's name - DWORD *pdwEventFlags, // [OUT] Event flags. - mdToken *ptkEventType, // [OUT] EventType class - mdMethodDef *pmdAddOn, // [OUT] AddOn method of the event - mdMethodDef *pmdRemoveOn, // [OUT] RemoveOn method of the event - mdMethodDef *pmdFire, // [OUT] Fire method of the event - mdMethodDef rmdOtherMethod[], // [OUT] other method of the event - ULONG cMax, // [IN] size of rmdOtherMethod - ULONG *pcOtherMethod); // [OUT] total number of other method of this event - - STDMETHOD(EnumMethodSemantics)( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdMethodDef mb, // [IN] MethodDef to scope the enumeration. - mdToken rEventProp[], // [OUT] Put Event/Property here. - ULONG cMax, // [IN] Max properties to put. - ULONG *pcEventProp); // [OUT] Put # put here. - - STDMETHOD(GetMethodSemantics)( // S_OK, S_FALSE, or error. - mdMethodDef mb, // [IN] method token - mdToken tkEventProp, // [IN] event/property token. - DWORD *pdwSemanticsFlags); // [OUT] the role flags for the method/propevent pair - - STDMETHOD(GetClassLayout) ( - mdTypeDef td, // [IN] give typedef - DWORD *pdwPackSize, // [OUT] 1, 2, 4, 8, or 16 - COR_FIELD_OFFSET rFieldOffset[], // [OUT] field offset array - ULONG cMax, // [IN] size of the array - ULONG *pcFieldOffset, // [OUT] needed array size - ULONG *pulClassSize); // [OUT] the size of the class - - STDMETHOD(GetFieldMarshal) ( - mdToken tk, // [IN] given a field's memberdef - PCCOR_SIGNATURE *ppvNativeType, // [OUT] native type of this field - ULONG *pcbNativeType); // [OUT] the count of bytes of *ppvNativeType - - STDMETHOD(GetRVA)( // S_OK or error. - mdToken tk, // Member for which to set offset - ULONG *pulCodeRVA, // The offset - DWORD *pdwImplFlags); // the implementation flags - - STDMETHOD(GetPermissionSetProps) ( - mdPermission pm, // [IN] the permission token. - DWORD *pdwAction, // [OUT] CorDeclSecurity. - void const **ppvPermission, // [OUT] permission blob. - ULONG *pcbPermission); // [OUT] count of bytes of pvPermission. - - STDMETHOD(GetSigFromToken)( // S_OK or error. - mdSignature mdSig, // [IN] Signature token. - PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to token. - ULONG *pcbSig); // [OUT] return size of signature. - - STDMETHOD(GetModuleRefProps)( // S_OK or error. - mdModuleRef mur, // [IN] moduleref token. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] buffer to fill with the moduleref name. - ULONG cchName, // [IN] size of szName in wide characters. - ULONG *pchName); // [OUT] actual count of characters in the name. - - STDMETHOD(EnumModuleRefs)( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdModuleRef rModuleRefs[], // [OUT] put modulerefs here. - ULONG cmax, // [IN] max memberrefs to put. - ULONG *pcModuleRefs); // [OUT] put # put here. - - STDMETHOD(GetTypeSpecFromToken)( // S_OK or error. - mdTypeSpec typespec, // [IN] TypeSpec token. - PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to TypeSpec signature - ULONG *pcbSig); // [OUT] return size of signature. - - STDMETHOD(GetNameFromToken)( // Not Recommended! May be removed! - mdToken tk, // [IN] Token to get name from. Must have a name. - MDUTF8CSTR *pszUtf8NamePtr); // [OUT] Return pointer to UTF8 name in heap. - - STDMETHOD(EnumUnresolvedMethods)( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken rMethods[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(GetUserString)( // S_OK or error. - mdString stk, // [IN] String token. - _Out_writes_to_opt_(cchString, *pchString) - LPWSTR szString, // [OUT] Copy of string. - ULONG cchString, // [IN] Max chars of room in szString. - ULONG *pchString); // [OUT] How many chars in actual string. - - STDMETHOD(GetPinvokeMap)( // S_OK or error. - mdToken tk, // [IN] FieldDef or MethodDef. - DWORD *pdwMappingFlags, // [OUT] Flags used for mapping. - _Out_writes_to_opt_(cchImportName, *pchImportName) - LPWSTR szImportName, // [OUT] Import name. - ULONG cchImportName, // [IN] Size of the name buffer. - ULONG *pchImportName, // [OUT] Actual number of characters stored. - mdModuleRef *pmrImportDLL); // [OUT] ModuleRef token for the target DLL. - - STDMETHOD(EnumSignatures)( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdSignature rSignatures[], // [OUT] put signatures here. - ULONG cmax, // [IN] max signatures to put. - ULONG *pcSignatures); // [OUT] put # put here. - - STDMETHOD(EnumTypeSpecs)( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdTypeSpec rTypeSpecs[], // [OUT] put TypeSpecs here. - ULONG cmax, // [IN] max TypeSpecs to put. - ULONG *pcTypeSpecs); // [OUT] put # put here. - - STDMETHOD(EnumUserStrings)( // S_OK or error. - HCORENUM *phEnum, // [IN/OUT] pointer to the enum. - mdString rStrings[], // [OUT] put Strings here. - ULONG cmax, // [IN] max Strings to put. - ULONG *pcStrings); // [OUT] put # put here. - - STDMETHOD(GetParamForMethodIndex)( // S_OK or error. - mdMethodDef md, // [IN] Method token. - ULONG ulParamSeq, // [IN] Parameter sequence. - mdParamDef *ppd); // [IN] Put Param token here. - - STDMETHOD(EnumCustomAttributes)( // S_OK or error. - HCORENUM *phEnum, // [IN, OUT] COR enumerator. - mdToken tk, // [IN] Token to scope the enumeration, 0 for all. - mdToken tkType, // [IN] Type of interest, 0 for all. - mdCustomAttribute rCustomAttributes[], // [OUT] Put custom attribute tokens here. - ULONG cMax, // [IN] Size of rCustomAttributes. - ULONG *pcCustomAttributes); // [OUT, OPTIONAL] Put count of token values here. - - STDMETHOD(GetCustomAttributeProps)( // S_OK or error. - mdCustomAttribute cv, // [IN] CustomAttribute token. - mdToken *ptkObj, // [OUT, OPTIONAL] Put object token here. - mdToken *ptkType, // [OUT, OPTIONAL] Put AttrType token here. - void const **ppBlob, // [OUT, OPTIONAL] Put pointer to data here. - ULONG *pcbSize); // [OUT, OPTIONAL] Put size of date here. - - STDMETHOD(FindTypeRef)( - mdToken tkResolutionScope, // [IN] ModuleRef, AssemblyRef or TypeRef. - LPCWSTR szName, // [IN] TypeRef Name. - mdTypeRef *ptr); // [OUT] matching TypeRef. - - STDMETHOD(GetMemberProps)( - mdToken mb, // The member for which to get props. - mdTypeDef *pClass, // Put member's class here. - _Out_writes_to_opt_(cchMember, *pchMember) - LPWSTR szMember, // Put member's name here. - ULONG cchMember, // Size of szMember buffer in wide chars. - ULONG *pchMember, // Put actual size here - DWORD *pdwAttr, // Put flags here. - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob, // [OUT] actual size of signature blob - ULONG *pulCodeRVA, // [OUT] codeRVA - DWORD *pdwImplFlags, // [OUT] Impl. Flags - DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_* - UVCP_CONSTANT *ppValue, // [OUT] constant value - ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for non-strings. - - STDMETHOD(GetFieldProps)( - mdFieldDef mb, // The field for which to get props. - mdTypeDef *pClass, // Put field's class here. - _Out_writes_to_opt_(cchField, *pchField) - LPWSTR szField, // Put field's name here. - ULONG cchField, // Size of szField buffer in wide chars. - ULONG *pchField, // Put actual size here - DWORD *pdwAttr, // Put flags here. - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob, // [OUT] actual size of signature blob - DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_* - UVCP_CONSTANT *ppValue, // [OUT] constant value - ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for non-strings. - - STDMETHOD(GetPropertyProps)( // S_OK, S_FALSE, or error. - mdProperty prop, // [IN] property token - mdTypeDef *pClass, // [OUT] typedef containing the property declarion. - LPCWSTR szProperty, // [OUT] Property name - ULONG cchProperty, // [IN] the count of wchar of szProperty - ULONG *pchProperty, // [OUT] actual count of wchar for property name - DWORD *pdwPropFlags, // [OUT] property flags. - PCCOR_SIGNATURE *ppvSig, // [OUT] property type. pointing to meta data internal blob - ULONG *pbSig, // [OUT] count of bytes in *ppvSig - DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_* - UVCP_CONSTANT *ppDefaultValue, // [OUT] constant value - ULONG *pcchDefaultValue, // [OUT] size of constant string in chars, 0 for non-strings. - mdMethodDef *pmdSetter, // [OUT] setter method of the property - mdMethodDef *pmdGetter, // [OUT] getter method of the property - mdMethodDef rmdOtherMethod[], // [OUT] other method of the property - ULONG cMax, // [IN] size of rmdOtherMethod - ULONG *pcOtherMethod); // [OUT] total number of other method of this property - - STDMETHOD(GetParamProps)( // S_OK or error. - mdParamDef tk, // [IN]The Parameter. - mdMethodDef *pmd, // [OUT] Parent Method token. - ULONG *pulSequence, // [OUT] Parameter sequence. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] Put name here. - ULONG cchName, // [OUT] Size of name buffer. - ULONG *pchName, // [OUT] Put actual size of name here. - DWORD *pdwAttr, // [OUT] Put flags here. - DWORD *pdwCPlusTypeFlag, // [OUT] Flag for value type. selected ELEMENT_TYPE_*. - UVCP_CONSTANT *ppValue, // [OUT] Constant value. - ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for non-strings. - - STDMETHOD(GetCustomAttributeByName)( // S_OK or error. - mdToken tkObj, // [IN] Object with Custom Attribute. - LPCWSTR szName, // [IN] Name of desired Custom Attribute. - const void **ppData, // [OUT] Put pointer to data here. - ULONG *pcbData); // [OUT] Put size of data here. - - STDMETHOD_(BOOL, IsValidToken)( // True or False. - mdToken tk); // [IN] Given token. - - STDMETHOD(GetNestedClassProps)( // S_OK or error. - mdTypeDef tdNestedClass, // [IN] NestedClass token. - mdTypeDef *ptdEnclosingClass); // [OUT] EnclosingClass token. - - STDMETHOD(GetNativeCallConvFromSig)( // S_OK or error. - void const *pvSig, // [IN] Pointer to signature. - ULONG cbSig, // [IN] Count of signature bytes. - ULONG *pCallConv); // [OUT] Put calling conv here (see CorPinvokemap). - - STDMETHOD(IsGlobal)( // S_OK or error. - mdToken pd, // [IN] Type, Field, or Method token. - int *pbGlobal); // [OUT] Put 1 if global, 0 otherwise. - - - // IMetaDataEmit functions - - STDMETHOD(SetModuleProps)( // S_OK or error. - LPCWSTR szName); // [IN] If not NULL, the name of the module to set. - - STDMETHOD(Save)( // S_OK or error. - LPCWSTR szFile, // [IN] The filename to save to. - DWORD dwSaveFlags); // [IN] Flags for the save. - - STDMETHOD(SaveToStream)( // S_OK or error. - IStream *pIStream, // [IN] A writable stream to save to. - DWORD dwSaveFlags); // [IN] Flags for the save. - - STDMETHOD(GetSaveSize)( // S_OK or error. - CorSaveSize fSave, // [IN] cssAccurate or cssQuick. - DWORD *pdwSaveSize); // [OUT] Put the size here. - - STDMETHOD(DefineTypeDef)( // S_OK or error. - LPCWSTR szTypeDef, // [IN] Name of TypeDef - DWORD dwTypeDefFlags, // [IN] CustomAttribute flags - mdToken tkExtends, // [IN] extends this TypeDef or typeref - mdToken rtkImplements[], // [IN] Implements interfaces - mdTypeDef *ptd); // [OUT] Put TypeDef token here - - STDMETHOD(DefineNestedType)( // S_OK or error. - LPCWSTR szTypeDef, // [IN] Name of TypeDef - DWORD dwTypeDefFlags, // [IN] CustomAttribute flags - mdToken tkExtends, // [IN] extends this TypeDef or typeref - mdToken rtkImplements[], // [IN] Implements interfaces - mdTypeDef tdEncloser, // [IN] TypeDef token of the enclosing type. - mdTypeDef *ptd); // [OUT] Put TypeDef token here - - STDMETHOD(SetHandler)( // S_OK. - IUnknown *pUnk); // [IN] The new error handler. - - STDMETHOD(DefineMethod)( // S_OK or error. - mdTypeDef td, // Parent TypeDef - LPCWSTR szName, // Name of member - DWORD dwMethodFlags, // Member attributes - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - ULONG ulCodeRVA, - DWORD dwImplFlags, - mdMethodDef *pmd); // Put member token here - - STDMETHOD(DefineMethodImpl)( // S_OK or error. - mdTypeDef td, // [IN] The class implementing the method - mdToken tkBody, // [IN] Method body - MethodDef or MethodRef - mdToken tkDecl); // [IN] Method declaration - MethodDef or MethodRef - - STDMETHOD(DefineTypeRefByName)( // S_OK or error. - mdToken tkResolutionScope, // [IN] ModuleRef, AssemblyRef or TypeRef. - LPCWSTR szName, // [IN] Name of the TypeRef. - mdTypeRef *ptr); // [OUT] Put TypeRef token here. - - STDMETHOD(DefineImportType)( // S_OK or error. - IMetaDataAssemblyImport *pAssemImport, // [IN] Assembly containing the TypeDef. - const void *pbHashValue, // [IN] Hash Blob for Assembly. - ULONG cbHashValue, // [IN] Count of bytes. - IMetaDataImport *pImport, // [IN] Scope containing the TypeDef. - mdTypeDef tdImport, // [IN] The imported TypeDef. - IMetaDataAssemblyEmit *pAssemEmit, // [IN] Assembly into which the TypeDef is imported. - mdTypeRef *ptr); // [OUT] Put TypeRef token here. - - STDMETHOD(DefineMemberRef)( // S_OK or error - mdToken tkImport, // [IN] ClassRef or ClassDef importing a member. - LPCWSTR szName, // [IN] member's name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdMemberRef *pmr); // [OUT] memberref token - - STDMETHOD(DefineImportMember)( // S_OK or error. - IMetaDataAssemblyImport *pAssemImport, // [IN] Assembly containing the Member. - const void *pbHashValue, // [IN] Hash Blob for Assembly. - ULONG cbHashValue, // [IN] Count of bytes. - IMetaDataImport *pImport, // [IN] Import scope, with member. - mdToken mbMember, // [IN] Member in import scope. - IMetaDataAssemblyEmit *pAssemEmit, // [IN] Assembly into which the Member is imported. - mdToken tkParent, // [IN] Classref or classdef in emit scope. - mdMemberRef *pmr); // [OUT] Put member ref here. - - STDMETHOD(DefineEvent) ( - mdTypeDef td, // [IN] the class/interface on which the event is being defined - LPCWSTR szEvent, // [IN] Name of the event - DWORD dwEventFlags, // [IN] CorEventAttr - mdToken tkEventType, // [IN] a reference (mdTypeRef or mdTypeRef) to the Event class - mdMethodDef mdAddOn, // [IN] required add method - mdMethodDef mdRemoveOn, // [IN] required remove method - mdMethodDef mdFire, // [IN] optional fire method - mdMethodDef rmdOtherMethods[], // [IN] optional array of other methods associate with the event - mdEvent *pmdEvent); // [OUT] output event token - - STDMETHOD(SetClassLayout) ( - mdTypeDef td, // [IN] typedef - DWORD dwPackSize, // [IN] packing size specified as 1, 2, 4, 8, or 16 - COR_FIELD_OFFSET rFieldOffsets[], // [IN] array of layout specification - ULONG ulClassSize); // [IN] size of the class - - STDMETHOD(DeleteClassLayout) ( - mdTypeDef td); // [IN] typedef whose layout is to be deleted. - - STDMETHOD(SetFieldMarshal) ( - mdToken tk, // [IN] given a fieldDef or paramDef token - PCCOR_SIGNATURE pvNativeType, // [IN] native type specification - ULONG cbNativeType); // [IN] count of bytes of pvNativeType - - STDMETHOD(DeleteFieldMarshal) ( - mdToken tk); // [IN] given a fieldDef or paramDef token - - STDMETHOD(DefinePermissionSet) ( - mdToken tk, // [IN] the object to be decorated. - DWORD dwAction, // [IN] CorDeclSecurity. - void const *pvPermission, // [IN] permission blob. - ULONG cbPermission, // [IN] count of bytes of pvPermission. - mdPermission *ppm); // [OUT] returned permission token. - - STDMETHOD(SetRVA)( // S_OK or error. - mdMethodDef md, // [IN] Method for which to set offset - ULONG ulRVA); // [IN] The offset - - STDMETHOD(GetTokenFromSig)( // S_OK or error. - PCCOR_SIGNATURE pvSig, // [IN] Signature to define. - ULONG cbSig, // [IN] Size of signature data. - mdSignature *pmsig); // [OUT] returned signature token. - - STDMETHOD(DefineModuleRef)( // S_OK or error. - LPCWSTR szName, // [IN] DLL name - mdModuleRef *pmur); // [OUT] returned - - // This should go away once everyone starts using SetMemberRefProps. - STDMETHOD(SetParent)( // S_OK or error. - mdMemberRef mr, // [IN] Token for the ref to be fixed up. - mdToken tk); // [IN] The ref parent. - - STDMETHOD(GetTokenFromTypeSpec)( // S_OK or error. - PCCOR_SIGNATURE pvSig, // [IN] TypeSpec Signature to define. - ULONG cbSig, // [IN] Size of signature data. - mdTypeSpec *ptypespec); // [OUT] returned TypeSpec token. - - STDMETHOD(SaveToMemory)( // S_OK or error. - void *pbData, // [OUT] Location to write data. - ULONG cbData); // [IN] Max size of data buffer. - - STDMETHOD(DefineUserString)( // Return code. - LPCWSTR szString, // [IN] User literal string. - ULONG cchString, // [IN] Length of string. - mdString *pstk); // [OUT] String token. - - STDMETHOD(DeleteToken)( // Return code. - mdToken tkObj); // [IN] The token to be deleted - - STDMETHOD(SetMethodProps)( // S_OK or error. - mdMethodDef md, // [IN] The MethodDef. - DWORD dwMethodFlags, // [IN] Method attributes. - ULONG ulCodeRVA, // [IN] Code RVA. - DWORD dwImplFlags); // [IN] Impl flags. - - STDMETHOD(SetTypeDefProps)( // S_OK or error. - mdTypeDef td, // [IN] The TypeDef. - DWORD dwTypeDefFlags, // [IN] TypeDef flags. - mdToken tkExtends, // [IN] Base TypeDef or TypeRef. - mdToken rtkImplements[]); // [IN] Implemented interfaces. - - STDMETHOD(SetEventProps)( // S_OK or error. - mdEvent ev, // [IN] The event token. - DWORD dwEventFlags, // [IN] CorEventAttr. - mdToken tkEventType, // [IN] A reference (mdTypeRef or mdTypeRef) to the Event class. - mdMethodDef mdAddOn, // [IN] Add method. - mdMethodDef mdRemoveOn, // [IN] Remove method. - mdMethodDef mdFire, // [IN] Fire method. - mdMethodDef rmdOtherMethods[]);// [IN] Array of other methods associate with the event. - - STDMETHOD(SetPermissionSetProps)( // S_OK or error. - mdToken tk, // [IN] The object to be decorated. - DWORD dwAction, // [IN] CorDeclSecurity. - void const *pvPermission, // [IN] Permission blob. - ULONG cbPermission, // [IN] Count of bytes of pvPermission. - mdPermission *ppm); // [OUT] Permission token. - - STDMETHOD(DefinePinvokeMap)( // Return code. - mdToken tk, // [IN] FieldDef or MethodDef. - DWORD dwMappingFlags, // [IN] Flags used for mapping. - LPCWSTR szImportName, // [IN] Import name. - mdModuleRef mrImportDLL); // [IN] ModuleRef token for the target DLL. - - STDMETHOD(SetPinvokeMap)( // Return code. - mdToken tk, // [IN] FieldDef or MethodDef. - DWORD dwMappingFlags, // [IN] Flags used for mapping. - LPCWSTR szImportName, // [IN] Import name. - mdModuleRef mrImportDLL); // [IN] ModuleRef token for the target DLL. - - STDMETHOD(DeletePinvokeMap)( // Return code. - mdToken tk); // [IN] FieldDef or MethodDef. - - // New CustomAttribute functions. - STDMETHOD(DefineCustomAttribute)( // Return code. - mdToken tkObj, // [IN] The object to put the value on. - mdToken tkType, // [IN] Type of the CustomAttribute (TypeRef/TypeDef). - void const *pCustomAttribute, // [IN] The custom value data. - ULONG cbCustomAttribute, // [IN] The custom value data length. - mdCustomAttribute *pcv); // [OUT] The custom value token value on return. - - STDMETHOD(SetCustomAttributeValue)( // Return code. - mdCustomAttribute pcv, // [IN] The custom value token whose value to replace. - void const *pCustomAttribute, // [IN] The custom value data. - ULONG cbCustomAttribute);// [IN] The custom value data length. - - STDMETHOD(DefineField)( // S_OK or error. - mdTypeDef td, // Parent TypeDef - LPCWSTR szName, // Name of member - DWORD dwFieldFlags, // Member attributes - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - DWORD dwCPlusTypeFlag, // [IN] flag for value type. selected ELEMENT_TYPE_* - void const *pValue, // [IN] constant value - ULONG cchValue, // [IN] size of constant value (string, in wide chars). - mdFieldDef *pmd); // [OUT] Put member token here - - STDMETHOD(DefineProperty)( - mdTypeDef td, // [IN] the class/interface on which the property is being defined - LPCWSTR szProperty, // [IN] Name of the property - DWORD dwPropFlags, // [IN] CorPropertyAttr - PCCOR_SIGNATURE pvSig, // [IN] the required type signature - ULONG cbSig, // [IN] the size of the type signature blob - DWORD dwCPlusTypeFlag, // [IN] flag for value type. selected ELEMENT_TYPE_* - void const *pValue, // [IN] constant value - ULONG cchValue, // [IN] size of constant value (string, in wide chars). - mdMethodDef mdSetter, // [IN] optional setter of the property - mdMethodDef mdGetter, // [IN] optional getter of the property - mdMethodDef rmdOtherMethods[], // [IN] an optional array of other methods - mdProperty *pmdProp); // [OUT] output property token - - STDMETHOD(DefineParam)( - mdMethodDef md, // [IN] Owning method - ULONG ulParamSeq, // [IN] Which param - LPCWSTR szName, // [IN] Optional param name - DWORD dwParamFlags, // [IN] Optional param flags - DWORD dwCPlusTypeFlag, // [IN] flag for value type. selected ELEMENT_TYPE_* - void const *pValue, // [IN] constant value - ULONG cchValue, // [IN] size of constant value (string, in wide chars). - mdParamDef *ppd); // [OUT] Put param token here - - STDMETHOD(SetFieldProps)( // S_OK or error. - mdFieldDef fd, // [IN] The FieldDef. - DWORD dwFieldFlags, // [IN] Field attributes. - DWORD dwCPlusTypeFlag, // [IN] Flag for the value type, selected ELEMENT_TYPE_* - void const *pValue, // [IN] Constant value. - ULONG cchValue); // [IN] size of constant value (string, in wide chars). - - STDMETHOD(SetPropertyProps)( // S_OK or error. - mdProperty pr, // [IN] Property token. - DWORD dwPropFlags, // [IN] CorPropertyAttr. - DWORD dwCPlusTypeFlag, // [IN] Flag for value type, selected ELEMENT_TYPE_* - void const *pValue, // [IN] Constant value. - ULONG cchValue, // [IN] size of constant value (string, in wide chars). - mdMethodDef mdSetter, // [IN] Setter of the property. - mdMethodDef mdGetter, // [IN] Getter of the property. - mdMethodDef rmdOtherMethods[]);// [IN] Array of other methods. - - STDMETHOD(SetParamProps)( // Return code. - mdParamDef pd, // [IN] Param token. - LPCWSTR szName, // [IN] Param name. - DWORD dwParamFlags, // [IN] Param flags. - DWORD dwCPlusTypeFlag, // [IN] Flag for value type. selected ELEMENT_TYPE_*. - void const *pValue, // [OUT] Constant value. - ULONG cchValue); // [IN] size of constant value (string, in wide chars). - - // Specialized Custom Attributes for security. - STDMETHOD(DefineSecurityAttributeSet)( // Return code. - mdToken tkObj, // [IN] Class or method requiring security attributes. - COR_SECATTR rSecAttrs[], // [IN] Array of security attribute descriptions. - ULONG cSecAttrs, // [IN] Count of elements in above array. - ULONG *pulErrorAttr); // [OUT] On error, index of attribute causing problem. - - STDMETHOD(ApplyEditAndContinue)( // S_OK or error. - IUnknown *pImport); // [IN] Metadata from the delta PE. - - STDMETHOD(TranslateSigWithScope)( - IMetaDataAssemblyImport *pAssemImport, // [IN] importing assembly interface - const void *pbHashValue, // [IN] Hash Blob for Assembly. - ULONG cbHashValue, // [IN] Count of bytes. - IMetaDataImport *import, // [IN] importing interface - PCCOR_SIGNATURE pbSigBlob, // [IN] signature in the importing scope - ULONG cbSigBlob, // [IN] count of bytes of signature - IMetaDataAssemblyEmit *pAssemEmit, // [IN] emit assembly interface - IMetaDataEmit *emit, // [IN] emit interface - PCOR_SIGNATURE pvTranslatedSig, // [OUT] buffer to hold translated signature - ULONG cbTranslatedSigMax, - ULONG *pcbTranslatedSig);// [OUT] count of bytes in the translated signature - - STDMETHOD(SetMethodImplFlags)( // [IN] S_OK or error. - mdMethodDef md, // [IN] Method for which to set ImplFlags - DWORD dwImplFlags); - - STDMETHOD(SetFieldRVA)( // [IN] S_OK or error. - mdFieldDef fd, // [IN] Field for which to set offset - ULONG ulRVA); // [IN] The offset - - STDMETHOD(Merge)( // S_OK or error. - IMetaDataImport *pImport, // [IN] The scope to be merged. - IMapToken *pHostMapToken, // [IN] Host IMapToken interface to receive token remap notification - IUnknown *pHandler); // [IN] An object to receive to receive error notification. - - STDMETHOD(MergeEnd)(); // S_OK or error. - -}; - -#endif // SYMBOLINFO_H diff --git a/src/coreclr/debug/ee/controller.cpp b/src/coreclr/debug/ee/controller.cpp index a4663f52ac0fba..589b513883a2c6 100644 --- a/src/coreclr/debug/ee/controller.cpp +++ b/src/coreclr/debug/ee/controller.cpp @@ -9,7 +9,6 @@ // Putting code & #includes, #defines, etc, before the stdafx.h will // cause the code,etc, to be silently ignored -// #include "stdafx.h" #include "openum.h" @@ -925,26 +924,6 @@ DebuggerControllerPatch *DebuggerPatchTable::GetNextPatch(DebuggerControllerPatc return NULL; } -#ifdef _DEBUG -void DebuggerPatchTable::CheckPatchTable() -{ - if ((TADDR)NULL != m_pcEntries) - { - LOG((LF_CORDB,LL_INFO1000, "DPT:CPT: %u\n", m_iEntries)); - DebuggerControllerPatch *dcp; - ULONG i = 0; - while (i++ < m_iEntries) - { - dcp = (DebuggerControllerPatch*)&(((DebuggerControllerPatch *)m_pcEntries)[i]); - if (dcp->opcode != 0 ) - { - dcp->LogInstance(); - } - } - } -} -#endif // _DEBUG - // Count how many patches are in the table. // Use for asserts int DebuggerPatchTable::GetNumberOfPatches() @@ -3894,32 +3873,6 @@ struct PatchTargetVisitorData FramePointer maxFrame; }; -VOID DebuggerController::PatchTargetVisitor(TADDR pVirtualTraceCallTarget, VOID* pUserData) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - DebuggerController* controller = ((PatchTargetVisitorData*) pUserData)->controller; - FramePointer maxFrame = ((PatchTargetVisitorData*) pUserData)->maxFrame; - - EX_TRY - { - CONTRACT_VIOLATION(GCViolation); // PatchTrace throws, which implies GC-triggers - TraceDestination trace; - trace.InitForUnmanagedStub(pVirtualTraceCallTarget); - controller->PatchTrace(&trace, maxFrame, true); - } - EX_CATCH - { - // not much we can do here - } - EX_END_CATCH -} - // // DisableTraceCall disables call events on the controller // diff --git a/src/coreclr/debug/ee/controller.h b/src/coreclr/debug/ee/controller.h index 4be2bbe7cfdbfe..b0f510cf9de162 100644 --- a/src/coreclr/debug/ee/controller.h +++ b/src/coreclr/debug/ee/controller.h @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // File: controller.h -// - // // Debugger control flow object -// //***************************************************************************** #ifndef CONTROLLER_H_ @@ -911,14 +909,6 @@ class DebuggerPatchTable : private CHashTableAndData return ItemIndex(p); } -#ifdef _DEBUG -public: - // DEBUG An internal debugging routine, it iterates - // through the hashtable, stopping at every - // single entry, no matter what it's state. - void CheckPatchTable(); -#endif // _DEBUG - // Count how many patches are in the table. // Use for asserts int GetNumberOfPatches(); @@ -1376,9 +1366,6 @@ class DebuggerController void Dequeue(); protected: - // Helper function that is called on each virtual trace call target to set a trace patch - static void PatchTargetVisitor(TADDR pVirtualTraceCallTarget, VOID* pUserData); - DebuggerControllerPatch *AddILPrimaryPatch(Module *module, mdMethodDef md, MethodDesc *pMethodDescFilter, diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index f20c8c7f1f97b6..31d3377a0393bd 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -719,54 +719,6 @@ CONTEXT * GetManagedLiveCtx(Thread * pThread) return pCtx; } -// Attempt to validate a GC handle. -HRESULT ValidateGCHandle(OBJECTHANDLE oh) -{ - // The only real way to do this is to Enumerate all GC handles in the handle table. - // That's too expensive. So we'll use a similar workaround that we use in ValidateObject. - // This will err on the side off returning True for invalid handles. - - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - HRESULT hr = S_OK; - - EX_TRY - { - // Use AVInRuntimeImplOkHolder. - AVInRuntimeImplOkayHolder AVOkay; - - // This may throw if the Object Handle is invalid. - Object * objPtr = *((Object**) oh); - - // NULL is certinally valid... - if (objPtr != NULL) - { - if (!objPtr->ValidateObjectWithPossibleAV()) - { - LOG((LF_CORDB, LL_INFO10000, "GAV: object methodtable-class invariant doesn't hold.\n")); - hr = E_INVALIDARG; - goto LExit; - } - } - - LExit: ; - } - EX_CATCH - { - LOG((LF_CORDB, LL_INFO10000, "GAV: exception indicated ref is bad.\n")); - hr = E_INVALIDARG; - } - EX_END_CATCH - - return hr; -} - - // Validate an object. Returns E_INVALIDARG or S_OK. HRESULT ValidateObject(Object *objPtr) { @@ -8340,31 +8292,6 @@ void Debugger::ExceptionHandle(MethodDesc *fd, TADDR pMethodAddr, SIZE_T offset, fd, pDJI, offset, handlerFP, STEP_EXCEPTION_HANDLER); } -BOOL Debugger::ShouldAutoAttach() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - _ASSERTE(!CORDebuggerAttached()); - - // We're relying on the caller to determine the - - LOG((LF_CORDB, LL_INFO1000000, "D::SAD\n")); - - // Check if the user has specified a setting in the registry about what he - // wants done when an unhandled exception occurs. - DebuggerLaunchSetting dls = GetDbgJITDebugLaunchSetting(); - - return dls == DLS_ATTACH_DEBUGGER; - - // @TODO cache the debugger launch setting. - -} - BOOL Debugger::FallbackJITAttachPrompt() { _ASSERTE(!CORDebuggerAttached()); @@ -12173,35 +12100,6 @@ HRESULT Debugger::DeoptimizeMethod(Module* pModule, mdMethodDef methodDef) } #endif //FEATURE_CODE_VERSIONING && !DACCESS_COMPILE -HRESULT Debugger::IsMethodDeoptimized(Module *pModule, mdMethodDef methodDef, BOOL *pResult) -{ - CONTRACTL - { - NOTHROW; - CAN_TAKE_LOCK; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (pModule == NULL || pResult == NULL || TypeFromToken(methodDef) != mdtMethodDef) - { - return E_INVALIDARG; - } - -#ifdef FEATURE_CODE_VERSIONING - { - CodeVersionManager::LockHolder codeVersioningLockHolder; - CodeVersionManager *pCodeVersionManager = pModule->GetCodeVersionManager(); - ILCodeVersion activeILVersion = pCodeVersionManager->GetActiveILCodeVersion(pModule, methodDef); - *pResult = activeILVersion.IsDeoptimized(); - } -#else - *pResult = FALSE; -#endif // FEATURE_CODE_VERSIONING - - return S_OK; -} - HRESULT Debugger::UpdateCustomNotificationTable(Module *pModule, mdTypeDef classToken, BOOL enabled) { CONTRACTL @@ -12441,37 +12339,6 @@ bool Debugger::IsThreadAtSafePlace(Thread *thread) } } -//----------------------------------------------------------------------------- -// Get the complete user state flags. -// This will collect flags both from the EE and from the LS. -// This is the real implementation of the RS's ICorDebugThread::GetUserState(). -// -// Parameters: -// pThread - non-null thread to get state for. -// -// Returns: a CorDebugUserState flags enum describing state. -//----------------------------------------------------------------------------- -CorDebugUserState Debugger::GetFullUserState(Thread *pThread) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(CheckPointer(pThread)); - } - CONTRACTL_END; - - CorDebugUserState state = g_pEEInterface->GetPartialUserState(pThread); - - bool fSafe = IsThreadAtSafePlace(pThread); - if (!fSafe) - { - state = (CorDebugUserState) (state | USER_UNSAFE_POINT); - } - - return state; -} - /****************************************************************************** * * Helper for debugger to get an unique thread id @@ -14750,40 +14617,6 @@ void Debugger::LockDebuggerForShutdown(void) #endif } - -/* - * DisableDebugger - * - * This routine is used by the EE to inform the debugger that it should block all - * threads from executing as soon as it can. Any thread entering the debugger can - * block infinitely, as well. - * - * This is accomplished by transitioning the debugger lock into a mode where it will - * block all threads infinitely rather than taking the lock. - * - */ -void Debugger::DisableDebugger(void) -{ -#ifndef DACCESS_COMPILE - - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(ThisMaybeHelperThread()); - } - CONTRACTL_END; - - m_fDisabled = true; - - CORDBDebuggerSetUnrecoverableError(this, CORDBG_E_DEBUGGING_DISABLED, false); - -#else - DacNotImpl(); -#endif -} - - /**************************************************************************** * This will perform the duties of the helper thread if none already exists. * This is called in the case that the loader lock is held and so no new @@ -15000,29 +14833,6 @@ BOOL Debugger::SendCtrlCToDebugger(DWORD dwCtrlType) return GetDebuggerHandlingCtrlC(); } -// Allows the debugger to keep an up to date list of special threads -HRESULT Debugger::UpdateSpecialThreadList(DWORD cThreadArrayLength, - DWORD *rgdwThreadIDArray) -{ - LIMITED_METHOD_CONTRACT; - - _ASSERTE(g_pRCThread != NULL); - - DebuggerIPCControlBlock *pIPC = g_pRCThread->GetDCB(); - _ASSERTE(pIPC); - - if (!pIPC) - return E_FAIL; - - // Save the thread list information, and mark the dirty bit so - // the right side knows. - pIPC->m_specialThreadList = rgdwThreadIDArray; - pIPC->m_specialThreadListLength = cThreadArrayLength; - pIPC->m_specialThreadListDirty = true; - - return S_OK; -} - // // If a thread is Win32 suspended right after hitting a breakpoint instruction, but before the OS has transitioned the // thread over to the user-level exception dispatching logic, then we may see the IP pointing after the breakpoint diff --git a/src/coreclr/debug/ee/debugger.h b/src/coreclr/debug/ee/debugger.h index d2ef8867fd5b40..9df20d2486344b 100644 --- a/src/coreclr/debug/ee/debugger.h +++ b/src/coreclr/debug/ee/debugger.h @@ -2083,9 +2083,6 @@ class Debugger : public DebugInterface bool IsThreadAtSafePlaceWorker(Thread *thread); bool IsThreadAtSafePlace(Thread *thread); - CorDebugUserState GetFullUserState(Thread *pThread); - - void Terminate(); void Continue(); @@ -2235,7 +2232,6 @@ class Debugger : public DebugInterface #endif // FEATURE_CODE_VERSIONING HRESULT DeoptimizeMethod(Module* pModule, mdMethodDef methodDef); #endif //DACCESS_COMPILE - HRESULT IsMethodDeoptimized(Module *pModule, mdMethodDef methodDef, BOOL *pResult); HRESULT UpdateForceCatchHandlerFoundTable(BOOL enableEvents, OBJECTREF exObj, AppDomain *pAppDomain); HRESULT UpdateCustomNotificationTable(Module *pModule, mdTypeDef classToken, BOOL enabled); @@ -2518,7 +2514,6 @@ class Debugger : public DebugInterface virtual void EnumMemoryRegionsIfFuncEvalFrame(CLRDataEnumMemoryFlags flags, Frame * pFrame); #endif - BOOL ShouldAutoAttach(); BOOL FallbackJITAttachPrompt(); void AppDomainCreated(AppDomain * pAppDomain); @@ -2545,8 +2540,6 @@ class Debugger : public DebugInterface void LockDebuggerForShutdown(void); - void DisableDebugger(void); - // Pid of the left side process that this Debugger instance is in. DWORD GetPid(void) { return m_processId; } @@ -2555,9 +2548,6 @@ class Debugger : public DebugInterface // send an event to the RS indicating that there's a Ctrl-C or Ctrl-Break BOOL SendCtrlCToDebugger(DWORD dwCtrlType); - // Allows the debugger to keep an up to date list of special threads - HRESULT UpdateSpecialThreadList(DWORD cThreadArrayLength, DWORD *rgdwThreadIDArray); - #ifndef DACCESS_COMPILE static void AcquireDebuggerDataLock(Debugger *pDebugger); diff --git a/src/coreclr/debug/inc/dacdbiinterface.h b/src/coreclr/debug/inc/dacdbiinterface.h index 23b19097f614c7..836978f9626ed6 100644 --- a/src/coreclr/debug/inc/dacdbiinterface.h +++ b/src/coreclr/debug/inc/dacdbiinterface.h @@ -1972,63 +1972,7 @@ IDacDbiInterface : public IUnknown // virtual HRESULT STDMETHODCALLTYPE HasReadWriteMetadata(VMPTR_PEAssembly vmPEAssembly, OUT BOOL* pHasReadWriteMetadata) = 0; - // DEPRECATED - use GetActiveRejitILCodeVersionNode - // Retrieves the active ReJitInfo for a given module/methodDef, if it exists. - // Active is defined as after GetReJitParameters returns from the profiler dll and - // no call to Revert has completed yet. - // - // - // Arguments: - // vmModule - The module to search in - // methodTk - The methodDef token indicates the method within the module to check - // pReJitInfo - [out] The RejitInfo request, if any, that is active on this method. If no request - // is active this will be pReJitInfo->IsNull() == TRUE. - // - // Returns: - // S_OK regardless of whether a rejit request is active or not, as long as the answer is certain - // error HRESULTs such as CORDBG_READ_VIRTUAL_FAILURE are possible - // - // DEPRECATED - use GetNativeCodeVersionNode - // Retrieves the ReJitInfo for a given MethodDesc/code address, if it exists. - // - // - // Arguments: - // vmMethod - The method to look for - // codeStartAddress - The code start address disambiguates between multiple rejitted instances - // of the method. - // pReJitInfo - [out] The RejitInfo request that corresponds to this MethodDesc/code address, if it exists. - // NULL otherwise. - // - // Returns: - // S_OK regardless of whether a rejit request is active or not, as long as the answer is certain - // error HRESULTs such as CORDBG_READ_VIRTUAL_FAILURE are possible - // - // DEPRECATED - use GetILCodeVersion - // Retrieves the SharedReJitInfo for a given ReJitInfo. - // - // - // Arguments: - // vmReJitInfo - The ReJitInfo to inspect - // pSharedReJitInfo - [out] The SharedReJitInfo that is pointed to by vmReJitInfo. - // - // Returns: - // S_OK if no error - // error HRESULTs such as CORDBG_READ_VIRTUAL_FAILURE are possible - // - // DEPRECATED - use GetILCodeVersionData - // Retrieves useful data from a SharedReJitInfo such as IL code and IL mapping. - // - // - // Arguments: - // sharedReJitInfo - The SharedReJitInfo to inspect - // pData - [out] Various properties of the SharedReJitInfo such as IL code and IL mapping. - // - // Returns: - // S_OK if no error - // error HRESULTs such as CORDBG_READ_VIRTUAL_FAILURE are possible - // // Retrieves a bool indicating whether or not a method's optimizations have been disabled - // defined in Debugger::IsMethodDeoptimized // // // diff --git a/src/coreclr/debug/inc/dbgipcevents.h b/src/coreclr/debug/inc/dbgipcevents.h index 36eac9df480b73..9dfbee8d336965 100644 --- a/src/coreclr/debug/inc/dbgipcevents.h +++ b/src/coreclr/debug/inc/dbgipcevents.h @@ -1326,11 +1326,6 @@ struct MSLAYOUT Ls_Rs_BaseBuffer { #ifdef RIGHT_SIDE_COMPILE protected: - // copy data can happen on both LS and RS. In LS case, - // ReadProcessMemory is really reading from its own process memory. - // - void CopyLSDataToRSWorker(ICorDebugDataTarget * pTargethProcess); - // retrieve the RS data and own it BYTE *TransferRSDataWorker() { @@ -1390,7 +1385,6 @@ struct MSLAYOUT Ls_Rs_ByteBuffer : public Ls_Rs_BaseBuffer return m_pbRS; } - void CopyLSDataToRS(ICorDebugDataTarget * pTarget); BYTE *TransferRSData() { return TransferRSDataWorker(); @@ -1410,9 +1404,6 @@ struct MSLAYOUT Ls_Rs_StringBuffer : public Ls_Rs_BaseBuffer return reinterpret_cast (m_pbRS); } - // Copy over the string. - void CopyLSDataToRS(ICorDebugDataTarget * pTarget); - // Caller will pick up ownership. // Since caller will delete this data, we can't give back a constant pointer. WCHAR * TransferStringData() diff --git a/src/coreclr/debug/inc/dbgtargetcontext.h b/src/coreclr/debug/inc/dbgtargetcontext.h index 606e4954b35272..1cdffb95fee13c 100644 --- a/src/coreclr/debug/inc/dbgtargetcontext.h +++ b/src/coreclr/debug/inc/dbgtargetcontext.h @@ -16,15 +16,6 @@ // platform we'll provide a hand-rolled version. // -// -// For cross platform cases we also need to provide a helper function for byte-swapping a context structure -// should the endian-ness of the debugger and debuggee platforms differ. This is called ByteSwapContext and is -// obviously a no-op for those cases where the left and right sides agree on storage format. -// -// NOTE: Any changes to the field layout of DT_CONTEXT must be tracked in the associated definition of -// ByteSwapContext. -// - // **** // **** NOTE: T_CONTEXT (in pal/inc/pal.h) can now be larger than DT_CONTEXT (currently T_CONTEXT on Linux/MacOS // **** x64 includes the XSTATE registers). This means the following: @@ -130,51 +121,6 @@ typedef struct { static_assert(sizeof(DT_CONTEXT) == sizeof(T_CONTEXT), "DT_CONTEXT size must equal the T_CONTEXT size on X86"); -// Since the target is little endian in this case we only have to provide a real implementation of -// ByteSwapContext if the platform we're building on is big-endian. -#ifdef BIGENDIAN -inline void ByteSwapContext(DT_CONTEXT *pContext) -{ - // Our job is simplified since the context has large contiguous ranges with fields of the same size. Keep - // the following logic in sync with the definition of DT_CONTEXT above. - BYTE *pbContext = (BYTE*)pContext; - - // The first span consists of 4 byte fields. - DWORD cbFields = (offsetof(DT_CONTEXT, FloatSave) + offsetof(DT_FLOATING_SAVE_AREA, RegisterArea)) / 4; - for (DWORD i = 0; i < cbFields; i++) - { - ByteSwapPrimitive(pbContext, pbContext, 4); - pbContext += 4; - } - - // Then there's a float save area containing 8 byte fields. - cbFields = sizeof(pContext->FloatSave.RegisterArea); - for (DWORD i = 0; i < cbFields; i++) - { - ByteSwapPrimitive(pbContext, pbContext, 8); - pbContext += 8; - } - - // Back to 4 byte fields. - cbFields = (offsetof(DT_CONTEXT, ExtendedRegisters) - offsetof(DT_CONTEXT, SegGs)) / 4; - for (DWORD i = 0; i < cbFields; i++) - { - ByteSwapPrimitive(pbContext, pbContext, 4); - pbContext += 4; - } - - // We don't know the formatting of the extended register area, but the debugger doesn't access this data - // on the left side, so just leave it in left-side format for now. - - // Validate that we converted up to where we think we did as a hedge against DT_CONTEXT layout changes. - _PASSERT((pbContext - ((BYTE*)pContext)) == (sizeof(DT_CONTEXT) - sizeof(pContext->ExtendedRegisters))); -} -#else // BIGENDIAN -inline void ByteSwapContext(DT_CONTEXT *pContext) -{ -} -#endif // BIGENDIAN - #elif defined(DTCONTEXT_IS_AMD64) #define DT_CONTEXT_AMD64 0x00100000L @@ -491,9 +437,6 @@ static_assert(sizeof(DT_CONTEXT) == sizeof(T_CONTEXT), "DT_CONTEXT size must equ #define DT_CONTEXT_FULL (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_FLOATING_POINT) #define DT_CONTEXT_ALL (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_FLOATING_POINT | DT_CONTEXT_DEBUG_REGISTERS) -#define DT_LOONGARCH64_MAX_BREAKPOINTS 8 -#define DT_LOONGARCH64_MAX_WATCHPOINTS 2 - typedef struct DECLSPEC_ALIGN(16) { // // Control flags. @@ -560,9 +503,6 @@ static_assert(sizeof(DT_CONTEXT) == sizeof(T_CONTEXT), "DT_CONTEXT size must equ #define DT_CONTEXT_FULL (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_FLOATING_POINT) #define DT_CONTEXT_ALL (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_FLOATING_POINT | DT_CONTEXT_DEBUG_REGISTERS) -#define DT_RISCV64_MAX_BREAKPOINTS 8 -#define DT_RISCV64_MAX_WATCHPOINTS 2 - typedef struct DECLSPEC_ALIGN(16) { // // Control flags. diff --git a/src/coreclr/debug/inc/dbgutil.h b/src/coreclr/debug/inc/dbgutil.h index ed34de6d35519f..506d2b86f0294a 100644 --- a/src/coreclr/debug/inc/dbgutil.h +++ b/src/coreclr/debug/inc/dbgutil.h @@ -1,11 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -//***************************************************************************** -// dbgutil.h -// - -// -//***************************************************************************** #pragma once #include @@ -29,62 +23,6 @@ HRESULT GetMachineAndResourceSectionRVA(ICorDebugDataTarget* pDataTarget, WORD* pwImageFileMachine, DWORD* pdwResourceSectionRVA); -HRESULT GetResourceRvaFromResourceSectionRva(ICorDebugDataTarget* pDataTarget, - ULONG64 moduleBaseAddress, - DWORD resourceSectionRva, - DWORD type, - DWORD name, - DWORD language, - DWORD* pResourceRva, - DWORD* pResourceSize); - -HRESULT GetResourceRvaFromResourceSectionRvaByName(ICorDebugDataTarget* pDataTarget, - ULONG64 moduleBaseAddress, - DWORD resourceSectionRva, - DWORD type, - LPCWSTR pwszName, - DWORD language, - DWORD* pResourceRva, - DWORD* pResourceSize); - -// Traverses down one level in the PE resource tree structure -// -// Arguments: -// pDataTarget - the data target for inspecting this process -// id - the id of the next node in the resource tree you want -// moduleBaseAddress - the base address of the module being inspected -// resourceDirectoryRVA - the base address of the beginning of the resource directory for this -// level of the tree -// pNextLevelRVA - out - The RVA for the next level tree directory or the RVA of the resource entry -// -// Returns: -// S_OK if successful or an appropriate failing HRESULT -HRESULT GetNextLevelResourceEntryRVA(ICorDebugDataTarget* pDataTarget, - DWORD id, - ULONG64 moduleBaseAddress, - DWORD resourceDirectoryRVA, - DWORD* pNextLevelRVA); - -// Traverses down one level in the PE resource tree structure -// -// Arguments: -// pDataTarget - the data target for inspecting this process -// name - the name of the next node in the resource tree you want -// moduleBaseAddress - the base address of the module being inspected -// resourceDirectoryRVA - the base address of the beginning of the resource directory for this -// level of the tree -// resourceSectionRVA - the rva of the beginning of the resource section of the PE file -// pNextLevelRVA - out - The RVA for the next level tree directory or the RVA of the resource entry -// -// Returns: -// S_OK if successful or an appropriate failing HRESULT -HRESULT GetNextLevelResourceEntryRVAByName(ICorDebugDataTarget* pDataTarget, - LPCWSTR pwzName, - ULONG64 moduleBaseAddress, - DWORD resourceDirectoryRva, - DWORD resourceSectionRva, - DWORD* pNextLevelRva); - // A small wrapper that reads from the data target and throws on error HRESULT ReadFromDataTarget(ICorDebugDataTarget* pDataTarget, ULONG64 addr, diff --git a/src/coreclr/dlls/mscordac/mscordac_unixexports.src b/src/coreclr/dlls/mscordac/mscordac_unixexports.src index d726161e7d0e9b..654547e293776a 100644 --- a/src/coreclr/dlls/mscordac/mscordac_unixexports.src +++ b/src/coreclr/dlls/mscordac/mscordac_unixexports.src @@ -83,7 +83,6 @@ nativeStringResourceTable_mscorrc #GetStdHandle #GetSystemInfo #GetTempPathA -#GetTempPathW #LoadLibraryExA #LoadLibraryExW #MapViewOfFile diff --git a/src/coreclr/gc/background.cpp b/src/coreclr/gc/background.cpp index 267ff4adfd94f6..709b3790b76d18 100644 --- a/src/coreclr/gc/background.cpp +++ b/src/coreclr/gc/background.cpp @@ -71,29 +71,6 @@ void gc_heap::switch_one_quantum() disable_preemptive (true); } -void gc_heap::reset_ww_by_chunk (uint8_t* start_address, size_t total_reset_size) -{ - size_t reset_size = 0; - size_t remaining_reset_size = 0; - size_t next_reset_size = 0; - - while (reset_size != total_reset_size) - { - remaining_reset_size = total_reset_size - reset_size; - next_reset_size = ((remaining_reset_size >= ww_reset_quantum) ? - ww_reset_quantum : remaining_reset_size); - if (next_reset_size) - { - reset_write_watch_for_gc_heap(start_address, next_reset_size); - reset_size += next_reset_size; - - switch_one_quantum(); - } - } - - assert (reset_size == total_reset_size); -} - // This does a Sleep(1) for every reset ww_reset_quantum bytes of reset // we do concurrently. void gc_heap::switch_on_reset (BOOL concurrent_p, size_t* current_total_reset_size, size_t last_reset_size) diff --git a/src/coreclr/gc/diagnostics.cpp b/src/coreclr/gc/diagnostics.cpp index 370afcb96b40c5..eb820992d91baf 100644 --- a/src/coreclr/gc/diagnostics.cpp +++ b/src/coreclr/gc/diagnostics.cpp @@ -1769,29 +1769,4 @@ void gc_heap::walk_heap (walk_fn fn, void* context, int gen_number, BOOL walk_la #endif //MULTIPLE_HEAPS } -void gc_heap::walk_read_only_segment(heap_segment *seg, void *pvContext, object_callback_func pfnMethodTable, object_callback_func pfnObjRef) -{ - uint8_t *o = heap_segment_mem(seg); - - int alignment = get_alignment_constant(TRUE); - - while (o < heap_segment_allocated(seg)) - { - pfnMethodTable(pvContext, o); - - if (contain_pointers (o)) - { - go_through_object_nostart (method_table (o), o, size(o), oo, - { - if (*oo) - pfnObjRef(pvContext, oo); - } - ); - } - - o += Align(size(o), alignment); - } -} - - } // namespace WKS/SVR diff --git a/src/coreclr/gc/gcimpl.h b/src/coreclr/gc/gcimpl.h index 4fb14a446a2e64..0eb561a3d57958 100644 --- a/src/coreclr/gc/gcimpl.h +++ b/src/coreclr/gc/gcimpl.h @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - #ifndef GCIMPL_H_ #define GCIMPL_H_ @@ -67,9 +66,6 @@ class GCHeap : public IGCHeapInternal public: GCHeap(){}; - /* BaseGCHeap Methods*/ - PER_HEAP_ISOLATED HRESULT StaticShutdown (); - size_t GetTotalBytesInUse (); // Gets the amount of bytes objects currently occupy on the GC heap. size_t GetCurrentObjSize(); diff --git a/src/coreclr/gc/gcpriv.h b/src/coreclr/gc/gcpriv.h index e8ce0a41caa700..e72efe82ab3823 100644 --- a/src/coreclr/gc/gcpriv.h +++ b/src/coreclr/gc/gcpriv.h @@ -1664,8 +1664,6 @@ class gc_heap PER_HEAP_ISOLATED_METHOD void fire_committed_usage_event(); - PER_HEAP_ISOLATED_METHOD void walk_read_only_segment(heap_segment *seg, void *pvContext, object_callback_func pfnMethodTable, object_callback_func pfnObjRef); - PER_HEAP_ISOLATED_METHOD int get_plan_gen_num (int gen_number); // region is only needed for regions and gen is only needed otherwise for these @@ -1795,8 +1793,6 @@ class gc_heap #endif //MULTIPLE_HEAPS ); - PER_HEAP_ISOLATED_METHOD void shutdown_gc(); - PER_HEAP_ISOLATED_METHOD void suspend_EE (); PER_HEAP_ISOLATED_METHOD void restart_EE (); @@ -2251,12 +2247,8 @@ class gc_heap uint64_t loh_size, BOOL disallow_full_blocking); - PER_HEAP_METHOD BOOL loh_allocated_for_no_gc(); - PER_HEAP_ISOLATED_METHOD void release_no_gc_loh_segments(); - PER_HEAP_ISOLATED_METHOD void thread_no_gc_loh_segments(); - PER_HEAP_METHOD void check_and_set_no_gc_oom(); PER_HEAP_METHOD void allocate_for_no_gc_after_gc(); @@ -2511,7 +2503,6 @@ class gc_heap PER_HEAP_ISOLATED_METHOD void reset_write_watch_for_gc_heap(void* base_address, size_t region_size); PER_HEAP_ISOLATED_METHOD void get_write_watch_for_gc_heap(bool reset, void *base_address, size_t region_size, void** dirty_pages, uintptr_t* dirty_page_count_ref, bool is_runtime_suspended); PER_HEAP_METHOD void switch_one_quantum(); - PER_HEAP_METHOD void reset_ww_by_chunk (uint8_t* start_address, size_t total_reset_size); PER_HEAP_METHOD void switch_on_reset (BOOL concurrent_p, size_t* current_total_reset_size, size_t last_reset_size); PER_HEAP_METHOD void reset_write_watch (BOOL concurrent_p); #endif //BACKGROUND_GC diff --git a/src/coreclr/gc/handletable.cpp b/src/coreclr/gc/handletable.cpp index 206a844bb0c2c6..7f6cdd4483a3d9 100644 --- a/src/coreclr/gc/handletable.cpp +++ b/src/coreclr/gc/handletable.cpp @@ -5,9 +5,6 @@ * Generational GC handle manager. Main Entrypoint Layer. * * Implements generic support for external roots into a GC heap. - * - - * */ #include "common.h" @@ -768,37 +765,6 @@ void HndVerifyTable(HHANDLETABLE hTable, const uint32_t *types, uint32_t typeCou } } - -/* - * HndNotifyGcCycleComplete - * - * Informs the handle table that a GC has completed. - * - */ -void HndNotifyGcCycleComplete(HHANDLETABLE hTable, uint32_t condemned, uint32_t maxgen) -{ -#ifdef _DEBUG - WRAPPER_NO_CONTRACT; - - // fetch the handle table pointer - HandleTable *pTable = Table(hTable); - - { - // lock the table down - CrstHolder ch(&pTable->Lock); - - // if this was a full GC then dump a cumulative log of scanning stats - if (condemned >= maxgen) - DEBUG_LogScanningStatistics(pTable, LL_INFO10); - } -#else - LIMITED_METHOD_CONTRACT; - UNREFERENCED_PARAMETER(hTable); - UNREFERENCED_PARAMETER(condemned); - UNREFERENCED_PARAMETER(maxgen); -#endif -} - /* * HndCountHandles * diff --git a/src/coreclr/gc/handletable.h b/src/coreclr/gc/handletable.h index 2df719aa400be7..96b2e979a64fa5 100644 --- a/src/coreclr/gc/handletable.h +++ b/src/coreclr/gc/handletable.h @@ -5,9 +5,6 @@ * Generational GC handle manager. Entrypoint Header. * * Implements generic support for external handles into a GC heap. - * - - * */ #ifndef _HANDLETABLE_H @@ -120,8 +117,6 @@ void HndScanHandlesForGC(HHANDLETABLE hTable, void HndResetAgeMap(HHANDLETABLE hTable, const uint32_t *types, uint32_t typeCount, uint32_t condemned, uint32_t maxgen, uint32_t flags); void HndVerifyTable(HHANDLETABLE hTable, const uint32_t *types, uint32_t typeCount, uint32_t condemned, uint32_t maxgen, uint32_t flags); -void HndNotifyGcCycleComplete(HHANDLETABLE hTable, uint32_t condemned, uint32_t maxgen); - /* * Handle counting */ diff --git a/src/coreclr/gc/handletablecore.cpp b/src/coreclr/gc/handletablecore.cpp index f0194af2d84367..ab82281c9e9a87 100644 --- a/src/coreclr/gc/handletablecore.cpp +++ b/src/coreclr/gc/handletablecore.cpp @@ -5,9 +5,6 @@ * Generational GC handle manager. Core Table Implementation. * * Implementation of core table management routines. - * - - * */ #include "common.h" @@ -529,29 +526,6 @@ TableSegment *SegmentAlloc(HandleTable *pTable) return pSegment; } -/* - * Check if a handle is part of a HandleTable - */ -BOOL TableContainHandle(HandleTable *pTable, OBJECTHANDLE handle) -{ - _ASSERTE (handle); - - // get the segment for this handle - TableSegment *pSegment = (TableSegment *)HandleFetchSegmentPointer(handle); - - CrstHolder ch(&pTable->Lock); - TableSegment *pWorkerSegment = pTable->pSegmentList; - while (pWorkerSegment) - { - if (pWorkerSegment == pSegment) - { - return TRUE; - } - pWorkerSegment = pWorkerSegment->pNextSegment; - } - return FALSE; -} - /* * SegmentRemoveFreeBlocks * diff --git a/src/coreclr/gc/handletablepriv.h b/src/coreclr/gc/handletablepriv.h index f8196ec735fdff..82b39fe4bf1322 100644 --- a/src/coreclr/gc/handletablepriv.h +++ b/src/coreclr/gc/handletablepriv.h @@ -5,9 +5,6 @@ * Generational GC handle manager. Internal Implementation Header. * * Shared defines and declarations for handle table implementation. - * - - * */ #include "common.h" @@ -658,11 +655,6 @@ TableSegment *SegmentAlloc(HandleTable *pTable); */ void SegmentFree(TableSegment *pSegment); -/* - * Check if a handle is part of a HandleTable - */ -BOOL TableContainHandle(HandleTable *pTable, OBJECTHANDLE handle); - /* * SegmentRemoveFreeBlocks * diff --git a/src/coreclr/gc/init.cpp b/src/coreclr/gc/init.cpp index 081b3fd94d889b..1b2215cba6f85d 100644 --- a/src/coreclr/gc/init.cpp +++ b/src/coreclr/gc/init.cpp @@ -1113,25 +1113,6 @@ gc_heap* gc_heap::make_gc_heap ( #endif //MULTIPLE_HEAPS } -// Destroys resources owned by gc. It is assumed that a last GC has been performed and that -// the finalizer queue has been drained. -void gc_heap::shutdown_gc() -{ - destroy_semi_shared(); - -#ifdef MULTIPLE_HEAPS - //delete the heaps array - delete[] g_heaps; - destroy_thread_support(); - n_heaps = 0; -#endif //MULTIPLE_HEAPS - //destroy seg_manager - - destroy_initial_memory(); - - GCToOSInterface::Shutdown(); -} - void gc_heap::init_records() { // An option is to move this to be after we figure out which gen to condemn so we don't diff --git a/src/coreclr/gc/interface.cpp b/src/coreclr/gc/interface.cpp index 93d44a96ca8b36..d64331a4ab4aaf 100644 --- a/src/coreclr/gc/interface.cpp +++ b/src/coreclr/gc/interface.cpp @@ -113,76 +113,6 @@ void GCHeap::ValidateObjectMember (Object* obj) #endif // VERIFY_HEAP } -HRESULT GCHeap::StaticShutdown() -{ - deleteGCShadow(); - - GCScan::GcRuntimeStructuresValid (FALSE); - - // Cannot assert this, since we use SuspendEE as the mechanism to quiesce all - // threads except the one performing the shutdown. - // ASSERT( !GcInProgress ); - - // Guard against any more GC occurring and against any threads blocking - // for GC to complete when the GC heap is gone. This fixes a race condition - // where a thread in GC is destroyed as part of process destruction and - // the remaining threads block for GC complete. - - //GCTODO - //EnterAllocLock(); - //Enter(); - //EnterFinalizeLock(); - //SetGCDone(); - - // during shutdown lot of threads are suspended - // on this even, we don't want to wake them up just yet - //CloseHandle (WaitForGCEvent); - - //find out if the global card table hasn't been used yet - uint32_t* ct = &g_gc_card_table[card_word (gcard_of (g_gc_lowest_address))]; - if (card_table_refcount (ct) == 0) - { - destroy_card_table (ct); - g_gc_card_table = nullptr; - -#ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES - g_gc_card_bundle_table = nullptr; -#endif -#ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP - SoftwareWriteWatch::StaticClose(); -#endif // FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP - } - -#ifndef USE_REGIONS - //destroy all segments on the standby list - while(gc_heap::segment_standby_list != 0) - { - heap_segment* next_seg = heap_segment_next (gc_heap::segment_standby_list); -#ifdef MULTIPLE_HEAPS - (gc_heap::g_heaps[0])->delete_heap_segment (gc_heap::segment_standby_list, FALSE); -#else //MULTIPLE_HEAPS - pGenGCHeap->delete_heap_segment (gc_heap::segment_standby_list, FALSE); -#endif //MULTIPLE_HEAPS - gc_heap::segment_standby_list = next_seg; - } -#endif // USE_REGIONS - -#ifdef MULTIPLE_HEAPS - - for (int i = 0; i < gc_heap::n_heaps; i ++) - { - //destroy pure GC stuff - gc_heap::destroy_gc_heap (gc_heap::g_heaps[i]); - } -#else - gc_heap::destroy_gc_heap (pGenGCHeap); - -#endif //MULTIPLE_HEAPS - gc_heap::shutdown_gc(); - - return S_OK; -} - // init the instance heap HRESULT GCHeap::Init(size_t hn) { diff --git a/src/coreclr/gc/no_gc.cpp b/src/coreclr/gc/no_gc.cpp index 17c2f381d47f87..098c10d17c9d6e 100644 --- a/src/coreclr/gc/no_gc.cpp +++ b/src/coreclr/gc/no_gc.cpp @@ -292,24 +292,6 @@ BOOL gc_heap::find_loh_space_for_no_gc() return (saved_loh_segment_no_gc != 0); } -BOOL gc_heap::loh_allocated_for_no_gc() -{ - if (!saved_loh_segment_no_gc) - return FALSE; - - heap_segment* seg = generation_allocation_segment (generation_of (loh_generation)); - do - { - if (seg == saved_loh_segment_no_gc) - { - return FALSE; - } - seg = heap_segment_next (seg); - } while (seg); - - return TRUE; -} - BOOL gc_heap::commit_loh_for_no_gc (heap_segment* seg) { uint8_t* end_committed = heap_segment_allocated (seg) + loh_allocation_no_gc; @@ -317,27 +299,6 @@ BOOL gc_heap::commit_loh_for_no_gc (heap_segment* seg) return (grow_heap_segment (seg, end_committed)); } -void gc_heap::thread_no_gc_loh_segments() -{ -#ifdef MULTIPLE_HEAPS - for (int i = 0; i < n_heaps; i++) - { - gc_heap* hp = g_heaps[i]; - if (hp->loh_allocated_for_no_gc()) - { - hp->thread_uoh_segment (loh_generation, hp->saved_loh_segment_no_gc); - hp->saved_loh_segment_no_gc = 0; - } - } -#else //MULTIPLE_HEAPS - if (loh_allocated_for_no_gc()) - { - thread_uoh_segment (loh_generation, saved_loh_segment_no_gc); - saved_loh_segment_no_gc = 0; - } -#endif //MULTIPLE_HEAPS -} - void gc_heap::set_loh_allocations_for_no_gc() { if (current_no_gc_region_info.loh_allocation_size != 0) diff --git a/src/coreclr/gc/objecthandle.cpp b/src/coreclr/gc/objecthandle.cpp index f948cd1f00fe0e..93138b8cf08afe 100644 --- a/src/coreclr/gc/objecthandle.cpp +++ b/src/coreclr/gc/objecthandle.cpp @@ -3,9 +3,6 @@ /* * Wraps handle table to implement various handle types (Strong, Weak, etc.) - * - - * */ #include "common.h" @@ -841,38 +838,6 @@ uint32_t GetVariableHandleType(OBJECTHANDLE handle) return (uint32_t)HndGetHandleExtraInfo(handle); } -/* - * UpdateVariableHandleType. - * - * Changes the dynamic type of a variable-strength handle. - * - * N.B. This routine is not a macro since we do validation in RETAIL. - * We always validate the type here because it can come from external callers. - */ -void UpdateVariableHandleType(OBJECTHANDLE handle, uint32_t type) -{ - WRAPPER_NO_CONTRACT; - - // verify that we are being asked to set a valid type - if (!IS_VALID_VHT_VALUE(type)) - { - // bogus value passed in - _ASSERTE(FALSE); - return; - } - - // (francish) CONCURRENT GC NOTE - // - // If/when concurrent GC is implemented, we need to make sure variable handles - // DON'T change type during an asynchronous scan, OR that we properly recover - // from the change. Some changes are benign, but for example changing to or - // from a pinning handle in the middle of a scan would not be fun. - // - - // store the type in the handle's extra info - HndSetHandleExtraInfo(handle, HNDTYPE_VARIABLE, (uintptr_t)type); -} - /* * CompareExchangeVariableHandleType. * diff --git a/src/coreclr/gc/objecthandle.h b/src/coreclr/gc/objecthandle.h index 414b24ebd3272d..15138e7add0342 100644 --- a/src/coreclr/gc/objecthandle.h +++ b/src/coreclr/gc/objecthandle.h @@ -3,9 +3,6 @@ /* * Wraps handle table to implement various handle types (Strong, Weak, etc.) - * - - * */ #ifndef _OBJECTHANDLE_H @@ -63,7 +60,6 @@ void SetDependentHandleSecondary(OBJECTHANDLE handle, OBJECTREF secondary); #ifndef DACCESS_COMPILE uint32_t GetVariableHandleType(OBJECTHANDLE handle); -void UpdateVariableHandleType(OBJECTHANDLE handle, uint32_t type); uint32_t CompareExchangeVariableHandleType(OBJECTHANDLE handle, uint32_t oldType, uint32_t newType); /* diff --git a/src/coreclr/gc/softwarewritewatch.h b/src/coreclr/gc/softwarewritewatch.h index f259e878463b0c..1dd92db677e9c6 100644 --- a/src/coreclr/gc/softwarewritewatch.h +++ b/src/coreclr/gc/softwarewritewatch.h @@ -71,7 +71,6 @@ class SoftwareWriteWatch public: static void ClearDirty(void *baseAddress, size_t regionByteSize); - static void SetDirty(void *address, size_t writeByteSize); static void SetDirtyRegion(void *baseAddress, size_t regionByteSize); private: static bool GetDirtyFromBlock(uint8_t *block, uint8_t *firstPageAddressInBlock, size_t startByteIndex, size_t endByteIndex, void **dirtyPages, size_t *dirtyPageIndexRef, size_t dirtyPageCount, bool clearDirty); @@ -304,23 +303,6 @@ inline void SoftwareWriteWatch::ClearDirty(void *baseAddress, size_t regionByteS memset(tableBaseAddress, 0, tableRegionByteSize); } -inline void SoftwareWriteWatch::SetDirty(void *address, size_t writeByteSize) -{ - VerifyCreated(); - VerifyMemoryRegion(address, writeByteSize); - assert(address != nullptr); - assert(writeByteSize <= sizeof(void *)); - - size_t tableByteIndex = GetTableByteIndex(address); - assert(GetTableByteIndex(reinterpret_cast(address) + (writeByteSize - 1)) == tableByteIndex); - - uint8_t *tableByteAddress = &GetTable()[tableByteIndex]; - if (*tableByteAddress == 0) - { - *tableByteAddress = 0xff; - } -} - inline void SoftwareWriteWatch::SetDirtyRegion(void *baseAddress, size_t regionByteSize) { VerifyCreated(); diff --git a/src/coreclr/ilasm/assembler.h b/src/coreclr/ilasm/assembler.h index 3d5326a41f878d..1fb116e92f6b3b 100644 --- a/src/coreclr/ilasm/assembler.h +++ b/src/coreclr/ilasm/assembler.h @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -/************************************************************************/ -/* Assembler.h */ -/************************************************************************/ #ifndef Assember_h #define Assember_h @@ -1244,8 +1241,6 @@ class Assembler { //return m_TypeDefDList.FIND(szName); }; unsigned NumTypeDefs() {return m_TypeDefDList.COUNT();}; -private: - HRESULT GetCAName(mdToken tkCA, _Out_ LPWSTR *ppszName); public: void RecordTypeConstraints(GenericParamConstraintList* pGPCList, int numTyPars, TyParDescr* tyPars); @@ -1264,5 +1259,3 @@ class Assembler { #ifdef _MSC_VER #pragma warning(default : 4640) #endif - - diff --git a/src/coreclr/ilasm/writer.cpp b/src/coreclr/ilasm/writer.cpp index a985d2ec196c63..1fe27fb53e6cd9 100644 --- a/src/coreclr/ilasm/writer.cpp +++ b/src/coreclr/ilasm/writer.cpp @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// writer.cpp -// #include "ilasmpch.h" @@ -725,54 +722,6 @@ DWORD Assembler::EmitExportStub(DWORD dwVTFSlotRVA) } //#endif -HRESULT Assembler::GetCAName(mdToken tkCA, _Out_ LPWSTR *ppszName) -{ - HRESULT hr = S_OK; - DWORD cchName; - LPWSTR name; - - *ppszName = NULL; - - if (TypeFromToken(tkCA) == mdtMemberRef) - { - mdToken parent; - if (FAILED(hr = m_pImporter->GetMemberRefProps( tkCA, &parent, NULL, 0, NULL, NULL, NULL))) - return hr; - tkCA = parent; - } - else if (TypeFromToken(tkCA) == mdtMethodDef) - { - mdToken parent; - if (FAILED(hr = m_pImporter->GetMemberProps( tkCA, &parent, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL))) - return hr; - tkCA = parent; - } - - if (TypeFromToken(tkCA) == mdtTypeRef) - { - // A TypeRef - if (FAILED(hr = m_pImporter->GetTypeRefProps(tkCA, NULL, NULL, 0, &cchName))) - return hr; - if ((name = new WCHAR[cchName + 1]) == NULL) - return E_OUTOFMEMORY; - hr = m_pImporter->GetTypeRefProps(tkCA, NULL, name, cchName, &cchName); - } - else - { - hr = m_pImporter->GetTypeDefProps(tkCA, NULL, 0, &cchName, NULL, NULL); - if (hr != S_OK) - return hr; - if ((name = new WCHAR[cchName + 1]) == NULL) - return E_OUTOFMEMORY; - hr = m_pImporter->GetTypeDefProps(tkCA, name, cchName, &cchName, NULL, NULL); - } - if (SUCCEEDED(hr)) - *ppszName = name; - else - delete [] name; - return hr; -} - BYTE HexToByte (CHAR wc) { if (!iswxdigit(wc)) return (BYTE) 0xff; diff --git a/src/coreclr/ildasm/dasm.cpp b/src/coreclr/ildasm/dasm.cpp index c068407ca28b9b..617a9b98d517f3 100644 --- a/src/coreclr/ildasm/dasm.cpp +++ b/src/coreclr/ildasm/dasm.cpp @@ -456,24 +456,6 @@ void Uninit() } } // Uninit -HRESULT IsClassRefInScope(mdTypeRef classref) -{ - HRESULT hr = S_OK; - const char *pszNameSpace; - const char *pszClassName; - mdTypeDef classdef; - mdToken tkRes; - - IfFailRet(g_pImport->GetNameOfTypeRef(classref, &pszNameSpace, &pszClassName)); - MAKE_NAME_IF_NONE(pszClassName,classref); - IfFailRet(g_pImport->GetResolutionScopeOfTypeRef(classref, &tkRes)); - - hr = g_pImport->FindTypeDef(pszNameSpace, pszClassName, - (TypeFromToken(tkRes) == mdtTypeRef) ? tkRes : mdTokenNil, &classdef); - - return hr; -} - BOOL EnumClasses() { HRESULT hr; diff --git a/src/coreclr/ildasm/dis.cpp b/src/coreclr/ildasm/dis.cpp index 2176d3f0154bba..9afb147a4847f8 100644 --- a/src/coreclr/ildasm/dis.cpp +++ b/src/coreclr/ildasm/dis.cpp @@ -1,9 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// // Disassembler -// + #include "ildasmpch.h" #include "debugmacros.h" @@ -194,28 +193,6 @@ void printLine(void* GUICookie, _In_ __nullterminated const char* string) ToGUIOrFile(sz,GUICookie); } -void printLineW(void* GUICookie, _In_ __nullterminated const WCHAR* string) -{ - const char* sz = (const char*)string; - - if (GUICookie == NULL) - { - UnicodeToConsoleOrMsgBox(string); - return; - } - if(g_uCodePage == 0xFFFFFFFF) - { - UnicodeToFile(string,(FILE*)GUICookie); - return; - } - else if(g_uCodePage == CP_UTF8) - sz = UnicodeToUtf(string); - else if(g_uCodePage == g_uConsoleCP) - sz = UnicodeToAnsi(string); - - ToGUIOrFile(sz,GUICookie); -} - char * DumpQString(void* GUICookie, _In_ __nullterminated const char* szToDump, _In_ __nullterminated const char* szPrefix, diff --git a/src/coreclr/ildasm/dis.h b/src/coreclr/ildasm/dis.h index 1b60192a60b82e..0a475063273a45 100644 --- a/src/coreclr/ildasm/dis.h +++ b/src/coreclr/ildasm/dis.h @@ -31,7 +31,6 @@ struct LineCodeDescr }; void printLine(void* GUICookie, _In_ __nullterminated const char* string); -void printLineW(void* GUICookie, _In_ __nullterminated const WCHAR* string); void printError(void* GUICookie, _In_ __nullterminated const char* string); char* AnsiToUtf(_In_ __nullterminated const char* sz); @@ -155,5 +154,3 @@ char *DumpGenericPars(_Inout_updates_(SZSTRING_SIZE) char* szString, #define SZSTRING_SIZE_M4 (SZSTRING_SIZE - 4) #define CHECK_REMAINING_SIZE if(ovadd_le((size_t)szString, SZSTRING_SIZE_M4, (size_t)szptr)) break; #define SZSTRING_REMAINING_SIZE(x) (ovadd_le((size_t)szString,SZSTRING_SIZE,(size_t)(x))?0:(SZSTRING_SIZE-((size_t)(x)-(size_t)szString))) - - diff --git a/src/coreclr/inc/arraylist.h b/src/coreclr/inc/arraylist.h index ee8d5c5b59d5d0..5a9a2c4204d40a 100644 --- a/src/coreclr/inc/arraylist.h +++ b/src/coreclr/inc/arraylist.h @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - #ifndef ARRAYLIST_H_ #define ARRAYLIST_H_ @@ -96,7 +95,6 @@ class ArrayListBase HRESULT Append(void *element); enum { NOT_FOUND = -1 }; - DWORD FindElement(DWORD start, PTR_VOID element) const; void Clear() noexcept; diff --git a/src/coreclr/inc/corimage.h b/src/coreclr/inc/corimage.h index 7304afb83f4559..608855346cd4a8 100644 --- a/src/coreclr/inc/corimage.h +++ b/src/coreclr/inc/corimage.h @@ -1,15 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - -// - /*============================================================ -** ** CorImage.h ** ** IMAGEHLP routines so we can avoid early binding to that DLL. -** ===========================================================*/ #ifndef _CORIMAGE_H_ @@ -24,31 +19,6 @@ extern "C" { IMAGE_NT_HEADERS *Cor_RtlImageNtHeader(VOID *pvBase, ULONG FileLength); -PIMAGE_SECTION_HEADER -Cor_RtlImageRvaToSection(PTR_IMAGE_NT_HEADERS NtHeaders, - ULONG Rva, - ULONG FileLength); - -PIMAGE_SECTION_HEADER -Cor_RtlImageRvaRangeToSection(PTR_IMAGE_NT_HEADERS NtHeaders, - ULONG Rva, - ULONG Range, - ULONG FileLength); - -DWORD Cor_RtlImageRvaToOffset(PTR_IMAGE_NT_HEADERS NtHeaders, - ULONG Rva, - ULONG FileLength); - -PBYTE Cor_RtlImageRvaToVa(PTR_IMAGE_NT_HEADERS NtHeaders, - PBYTE Base, - ULONG Rva, - ULONG FileLength); - -PBYTE Cor_RtlImageDirToVa(PTR_IMAGE_NT_HEADERS NtHeaders, - PBYTE Base, - UINT DirIndex, - ULONG FileLength); - PBYTE Cor_RtlImageRvaToVa32(PTR_IMAGE_NT_HEADERS32 NtHeaders, PBYTE Base, ULONG Rva, diff --git a/src/coreclr/inc/crosscomp.h b/src/coreclr/inc/crosscomp.h index 9cc8fdf4691283..de0829acd50938 100644 --- a/src/coreclr/inc/crosscomp.h +++ b/src/coreclr/inc/crosscomp.h @@ -1,8 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// + // crosscomp.h - cross-compilation enablement structures. -// #pragma once @@ -412,9 +411,6 @@ enum // however, almost no one implements more than 4 of each. // -#define LOONGARCH64_MAX_BREAKPOINTS 8 -#define LOONGARCH64_MAX_WATCHPOINTS 2 - #ifndef CONTEXT_UNWOUND_TO_CALL #define CONTEXT_UNWOUND_TO_CALL 0x20000000 #endif @@ -547,9 +543,6 @@ typedef struct _T_KNONVOLATILE_CONTEXT_POINTERS { // will track. // -#define RISCV64_MAX_BREAKPOINTS 8 -#define RISCV64_MAX_WATCHPOINTS 2 - #ifndef CONTEXT_UNWOUND_TO_CALL #define CONTEXT_UNWOUND_TO_CALL 0x20000000 #endif diff --git a/src/coreclr/inc/executableallocator.h b/src/coreclr/inc/executableallocator.h index 591ec28bf08e66..f0e76c48a7eb3d 100644 --- a/src/coreclr/inc/executableallocator.h +++ b/src/coreclr/inc/executableallocator.h @@ -1,10 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// // Allocator and holders for double mapped executable memory -// #pragma once @@ -246,10 +243,6 @@ class ExecutableAllocator // possible to reserve memory in such range, the method returns NULL. void* ReserveWithinRange(size_t size, const void* loAddress, const void* hiAddress); - // Reserve the specified amount of virtual address space for executable mapping - // exactly at the given address. - void* ReserveAt(void* baseAddressRX, size_t size); - // Commit the specified range of memory. The memory can be committed as executable (RX) // or non-executable (RW) based on the passed in isExecutable flag. The non-executable // allocations are used to allocate data structures that need to be close to the diff --git a/src/coreclr/inc/loaderheap.h b/src/coreclr/inc/loaderheap.h index 0d7c7a349939ea..89bfd9ca0d02ff 100644 --- a/src/coreclr/inc/loaderheap.h +++ b/src/coreclr/inc/loaderheap.h @@ -1,16 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // LoaderHeap.h -// - // // Utility functions for managing memory allocations that typically do not // need releasing. -// //***************************************************************************** - #ifndef __LoaderHeap_h__ #define __LoaderHeap_h__ @@ -263,8 +260,6 @@ class UnlockedLoaderHeapBase : public UnlockedLoaderHeapBaseTraversable, public return m_dwDebugWastedBytes + GetBytesAvailCommittedRegion(); } - void DumpFreeList(); - // Extra CallTracing support void UnlockedClearEvents(); //Discard saved events void UnlockedCompactEvents(); //Discard matching alloc/free events @@ -460,9 +455,6 @@ class UnlockedLoaderHeap : public UnlockedLoaderHeapBase size_t AllocMem_TotalSize(size_t dwRequestedSize); public: -#ifdef _DEBUG - void DumpFreeList(); -#endif private: static void ValidateFreeList(UnlockedLoaderHeap *pHeap); static void WeGotAFaultNowWhat(UnlockedLoaderHeap *pHeap); diff --git a/src/coreclr/inc/longfilepathwrappers.h b/src/coreclr/inc/longfilepathwrappers.h index ca028bf6d625a1..adcd3517a43b24 100644 --- a/src/coreclr/inc/longfilepathwrappers.h +++ b/src/coreclr/inc/longfilepathwrappers.h @@ -27,16 +27,6 @@ CreateFileWrapper( int u16_fopen_wrapper(FILE** stream, const WCHAR* filename, const WCHAR* mode); -BOOL -CopyFileExWrapper( - _In_ LPCWSTR lpExistingFileName, - _In_ LPCWSTR lpNewFileName, - _In_opt_ LPPROGRESS_ROUTINE lpProgressRoutine, - _In_opt_ LPVOID lpData, - _When_(pbCancel != NULL, _Pre_satisfies_(*pbCancel == FALSE)) - _Inout_opt_ LPBOOL pbCancel, - _In_ DWORD dwCopyFlags - ); #endif //HOST_WINDOWS DWORD @@ -61,4 +51,3 @@ DWORD WINAPI GetEnvironmentVariableWrapper( ); #endif //_WIN_PATH_APIS_WRAPPER_ - diff --git a/src/coreclr/inc/palclr.h b/src/coreclr/inc/palclr.h index b6f814756b783c..7268fe8eb3472a 100644 --- a/src/coreclr/inc/palclr.h +++ b/src/coreclr/inc/palclr.h @@ -1,11 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + // =========================================================================== // File: palclr.h // // Various macros and constants that are necessary to make the CLR portable. -// - // =========================================================================== #ifndef __PALCLR_H__ @@ -381,13 +380,6 @@ #define PAL_CPP_CATCH_NON_DERIVED(type, obj) catch (type obj) #define PAL_CPP_CATCH_NON_DERIVED_NOARG(type) catch (type) #define PAL_CPP_CATCH_ALL catch (...) -#define PAL_CPP_CATCH_EXCEPTION_NOARG catch (Exception *) - - -#if defined(SOURCE_FORMATTING) -#define __annotation(x) -#endif - #if defined(_DEBUG_IMPL) && !defined(JIT_BUILD) && !defined(CROSS_COMPILE) && !defined(DISABLE_CONTRACTS) #define PAL_TRY_HANDLER_DBG_BEGIN \ diff --git a/src/coreclr/inc/pedecoder.h b/src/coreclr/inc/pedecoder.h index 1a16bc39f1f4c8..524a9557f7e953 100644 --- a/src/coreclr/inc/pedecoder.h +++ b/src/coreclr/inc/pedecoder.h @@ -1,10 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -------------------------------------------------------------------------------- -// PEDecoder.h -// - -// -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // PEDecoder - Utility class for reading and verifying PE files. @@ -22,7 +17,6 @@ // you verify the size in some other way. // -------------------------------------------------------------------------------- - #ifndef PEDECODER_H_ #define PEDECODER_H_ @@ -122,10 +116,6 @@ inline CHECK CheckOverflow(RVA value1, COUNT_T value2) typedef DPTR(class PEDecoder) PTR_PEDecoder; -typedef bool (*PEDecoder_ResourceTypesCallbackFunction)(LPCWSTR lpType, void* context); -typedef bool (*PEDecoder_ResourceNamesCallbackFunction)(LPCWSTR lpName, LPCWSTR lpType, void* context); -typedef bool (*PEDecoder_ResourceCallbackFunction)(LPCWSTR lpName, LPCWSTR lpType, DWORD langid, BYTE* data, COUNT_T cbData, void* context); - class PEDecoder { friend class PEImageLayout; @@ -205,11 +195,6 @@ class PEDecoder // Look up a named symbol in the export directory PTR_VOID GetExport(LPCSTR exportName) const; - // Win32 resources - bool EnumerateWin32ResourceTypes(PEDecoder_ResourceTypesCallbackFunction callback, void* context) const; - bool EnumerateWin32ResourceNames(LPCWSTR lpType, PEDecoder_ResourceNamesCallbackFunction callback, void* context) const; - bool EnumerateWin32Resources(LPCWSTR lpName, LPCWSTR lpType, PEDecoder_ResourceCallbackFunction callback, void* context) const; - // COR header fields CHECK CheckCorHeader() const; @@ -234,17 +219,12 @@ class PEDecoder // Not part of the standalone PEDecoder public API. // ------------------------------------------------------------ - const void *GetHeaders(COUNT_T *pSize = NULL) const; - WORD GetSubsystem() const; WORD GetDllCharacteristics() const; DWORD GetCheckSum() const; WORD GetCharacteristics() const; SIZE_T GetSizeOfStackReserve() const; SIZE_T GetSizeOfStackCommit() const; - SIZE_T GetSizeOfHeapReserve() const; - SIZE_T GetSizeOfHeapCommit() const; - UINT32 GetLoaderFlags() const; UINT32 GetWin32VersionValue() const; COUNT_T GetNumberOfRvaAndSizes() const; @@ -282,8 +262,6 @@ class PEDecoder PTR_VOID GetTlsRange(COUNT_T *pSize = NULL) const; UINT32 GetTlsIndex() const; - void *GetWin32Resource(LPCWSTR lpName, LPCWSTR lpType, COUNT_T *pSize = NULL) const; - const void *GetResources(COUNT_T *pSize = NULL) const; CHECK CheckResource(COUNT_T offset) const; const void *GetResource(COUNT_T offset, COUNT_T *pSize = NULL) const; diff --git a/src/coreclr/inc/pedecoder.inl b/src/coreclr/inc/pedecoder.inl index 3049c32f7cd92b..2f72f81a1d36e7 100644 --- a/src/coreclr/inc/pedecoder.inl +++ b/src/coreclr/inc/pedecoder.inl @@ -1,10 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -------------------------------------------------------------------------------- -// PEDecoder.inl -// - -// -------------------------------------------------------------------------------- #ifndef _PEDECODER_INL_ #define _PEDECODER_INL_ @@ -239,24 +234,6 @@ inline BOOL PEDecoder::Has32BitNTHeaders() const return FindNTHeaders()->OptionalHeader.Magic == VAL16(IMAGE_NT_OPTIONAL_HDR32_MAGIC); } -inline const void *PEDecoder::GetHeaders(COUNT_T *pSize) const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - //even though some data in OptionalHeader is different for 32 and 64, this field is the same - if (pSize != NULL) - *pSize = VAL32(FindNTHeaders()->OptionalHeader.SizeOfHeaders); - - return (const void *) m_base; -} - inline BOOL PEDecoder::IsDll() const { CONTRACTL @@ -407,58 +384,6 @@ inline WORD PEDecoder::GetCharacteristics() const return VAL16(FindNTHeaders()->FileHeader.Characteristics); } -inline SIZE_T PEDecoder::GetSizeOfHeapReserve() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (Has32BitNTHeaders()) - return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfHeapReserve); - else - return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfHeapReserve); -} - - -inline SIZE_T PEDecoder::GetSizeOfHeapCommit() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (Has32BitNTHeaders()) - return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfHeapCommit); - else - return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfHeapCommit); -} - -inline UINT32 PEDecoder::GetLoaderFlags() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (Has32BitNTHeaders()) - return VAL32(GetNTHeaders32()->OptionalHeader.LoaderFlags); - else - return VAL32(GetNTHeaders64()->OptionalHeader.LoaderFlags); -} - inline UINT32 PEDecoder::GetWin32VersionValue() const { CONTRACTL diff --git a/src/coreclr/inc/pesectionman.h b/src/coreclr/inc/pesectionman.h index d74770dcd64b42..04aff76a988733 100644 --- a/src/coreclr/inc/pesectionman.h +++ b/src/coreclr/inc/pesectionman.h @@ -1,9 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + // Section Manager for portable executables // Common to both Memory Only and Static (EXE making) code - #ifndef PESectionMan_H #define PESectionMan_H @@ -32,9 +32,6 @@ class PESectionMan unsigned flags, // IMAGE_SCN_* flags. eg. IMAGE_SCN_CNT_INITIALIZED_DATA PESection **section); - // Since we allocate, we must delete (Bug in VC, see knowledge base Q122675) - void sectionDestroy(PESection **section); - // Apply all the relocs for in memory conversion HRESULT applyRelocs(CeeGenTokenMapper *pTokenMapper); diff --git a/src/coreclr/inc/pgo_formatprocessing.h b/src/coreclr/inc/pgo_formatprocessing.h index e176c92523383b..a062d115a99977 100644 --- a/src/coreclr/inc/pgo_formatprocessing.h +++ b/src/coreclr/inc/pgo_formatprocessing.h @@ -308,30 +308,6 @@ inline bool CountInstrumentationDataSize(const uint8_t *pByte, size_t cbDataMax, return ReadInstrumentationSchema(pByte, cbDataMax, [pInstrumentationSchemaCount](const ICorJitInfo::PgoInstrumentationSchema& schema) { (*pInstrumentationSchemaCount)++; return true; }); } -inline bool ComparePgoSchemaEquals(const uint8_t *pByte, size_t cbDataMax, const ICorJitInfo::PgoInstrumentationSchema* schemaTable, size_t cSchemas) -{ - size_t iSchema = 0; - return ReadInstrumentationSchema(pByte, cbDataMax, [schemaTable, cSchemas, &iSchema](const ICorJitInfo::PgoInstrumentationSchema& schema) - { - if (iSchema >= cSchemas) - return false; - - if (schema.InstrumentationKind != schemaTable[iSchema].InstrumentationKind) - return false; - - if (schema.ILOffset != schemaTable[iSchema].ILOffset) - return false; - - if (schema.Count != schemaTable[iSchema].Count) - return false; - - if (schema.Other != schemaTable[iSchema].Other) - return false; - - return true; - }); -} - inline void LayoutPgoInstrumentationSchema(const ICorJitInfo::PgoInstrumentationSchema& prevSchema, ICorJitInfo::PgoInstrumentationSchema* currentSchema) { size_t instrumentationSize = InstrumentationKindToSize(currentSchema->InstrumentationKind); diff --git a/src/coreclr/inc/sstring.h b/src/coreclr/inc/sstring.h index 98dd8144b996b1..a5672cce7d8a08 100644 --- a/src/coreclr/inc/sstring.h +++ b/src/coreclr/inc/sstring.h @@ -1,10 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// --------------------------------------------------------------------------- -// SString.h (Safe String) -// - -// --------------------------------------------------------------------------- // ------------------------------------------------------------------------------------------ // SString is the "standard" string representation for the EE. Its has two purposes. @@ -38,7 +33,6 @@ // @todo: argument & overflow/underflow checking needs to be added // ------------------------------------------------------------------------------------------ - #ifndef _SSTRING_H_ #define _SSTRING_H_ @@ -467,7 +461,6 @@ class EMPTY_BASES SString : private SBuffer const WCHAR *GetUnicode(const CIterator &i) const; void LowerCase(); - void UpperCase(); // Helper function to convert string in-place to lower-case (no allocation overhead for SString instance) static void LowerCase(__inout_z LPWSTR wszString); @@ -685,7 +678,6 @@ class EMPTY_BASES SString : private SBuffer private: void ClearNormalized() const; - void EnsureWritable() const; void ConvertToFixed() const; void ConvertToIteratable() const; diff --git a/src/coreclr/inc/sstring.inl b/src/coreclr/inc/sstring.inl index 502bdd20aad107..8dbac2fcec3101 100644 --- a/src/coreclr/inc/sstring.inl +++ b/src/coreclr/inc/sstring.inl @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// - #ifndef _SSTRING_INL_ #define _SSTRING_INL_ @@ -1688,29 +1686,6 @@ inline void SString::CloseBuffer(COUNT_T finalCount) NullTerminate(); } -//---------------------------------------------------------------------------- -// EnsureWritable -// Ensures that the buffer is writable -//---------------------------------------------------------------------------- -inline void SString::EnsureWritable() const -{ -#ifdef SSTRING_EXTRA_CHECKS - CONTRACTL - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - THROWS; - } - CONTRACTL_END; -#else //SSTRING_EXTRA_CHECKS - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_THROWS; -#endif //SSTRING_EXTRA_CHECKS - - if (IsLiteral()) - const_cast(this)->Resize(GetRawCount(), GetRepresentation(), PRESERVE); -} - //----------------------------------------------------------------------------- // Convert the internal representation to be a fixed size //----------------------------------------------------------------------------- diff --git a/src/coreclr/inc/utilcode.h b/src/coreclr/inc/utilcode.h index c605175ef7b62d..159aac8908e729 100644 --- a/src/coreclr/inc/utilcode.h +++ b/src/coreclr/inc/utilcode.h @@ -1,10 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // UtilCode.h // // Utility functions implemented in UtilCode.lib. -// //***************************************************************************** #ifndef __UtilCode_h__ @@ -449,38 +449,6 @@ inline int CountBits(int iNum) return (iBits); } -// Convert the currency to a decimal and canonicalize. -inline void VarDecFromCyCanonicalize(CY cyIn, DECIMAL* dec) -{ - WRAPPER_NO_CONTRACT; - - (*(ULONG*)dec) = 0; - DECIMAL_HI32(*dec) = 0; - if (cyIn.int64 == 0) // For compatibility, a currency of 0 emits the Decimal "0.0000" (scale set to 4). - { - DECIMAL_SCALE(*dec) = 4; - DECIMAL_LO32(*dec) = 0; - DECIMAL_MID32(*dec) = 0; - return; - } - - if (cyIn.int64 < 0) { - DECIMAL_SIGN(*dec) = DECIMAL_NEG; - cyIn.int64 = -cyIn.int64; - } - - BYTE scale = 4; - ULONGLONG absoluteCy = (ULONGLONG)cyIn.int64; - while (scale != 0 && ((absoluteCy % 10) == 0)) - { - scale--; - absoluteCy /= 10; - } - DECIMAL_SCALE(*dec) = scale; - DECIMAL_LO32(*dec) = (ULONG)absoluteCy; - DECIMAL_MID32(*dec) = (ULONG)(absoluteCy >> 32); -} - //***************************************************************************** // // Paths functions. Use these instead of the CRT. @@ -568,8 +536,6 @@ class CPUGroupInfo static BOOL GetCPUGroupRange(WORD group_number, WORD* group_begin, WORD* group_size); }; -DWORD_PTR GetCurrentProcessCpuMask(); - #endif // HOST_WINDOWS int GetTotalProcessorCount(); @@ -2203,23 +2169,6 @@ class CClosedHashBase void *pData); // Key value to delete. -//***************************************************************************** -// Callback function passed to DeleteLoop. -//***************************************************************************** - typedef BOOL (* DELETELOOPFUNC)( // Delete current item? - BYTE *pEntry, // Bucket entry to evaluate - void *pCustomizer); // User-defined value - -//***************************************************************************** -// Iterates over all active values, passing each one to pDeleteLoopFunc. -// If pDeleteLoopFunc returns TRUE, the entry is deleted. This is safer -// and faster than using FindNext() and Delete(). -//***************************************************************************** - void DeleteLoop( - DELETELOOPFUNC pDeleteLoopFunc, // Decides whether to delete item - void *pCustomizer); // Extra value passed to deletefunc. - - //***************************************************************************** // Lookup a key value and return a pointer to the element if found. //***************************************************************************** diff --git a/src/coreclr/inc/yieldprocessornormalized.h b/src/coreclr/inc/yieldprocessornormalized.h index e37bf79f0c5089..e80f992627d7be 100644 --- a/src/coreclr/inc/yieldprocessornormalized.h +++ b/src/coreclr/inc/yieldprocessornormalized.h @@ -84,7 +84,6 @@ class YieldProcessorNormalizationInfo friend void YieldProcessorNormalized(const YieldProcessorNormalizationInfo &); friend void YieldProcessorNormalized(const YieldProcessorNormalizationInfo &, unsigned int); friend void YieldProcessorNormalizedForPreSkylakeCount(const YieldProcessorNormalizationInfo &, unsigned int); - friend void YieldProcessorWithBackOffNormalized(const YieldProcessorNormalizationInfo &, unsigned int); }; // See YieldProcessorNormalized() for preliminary info. Typical usage: @@ -249,44 +248,5 @@ FORCEINLINE void YieldProcessorNormalizedForPreSkylakeCount(unsigned int preSkyl } while (--n != 0); } -// See YieldProcessorNormalized() for preliminary info. This function is to be used when there is a decent possibility that the -// condition would not be satisfied within a short duration. The current implementation increases the delay per spin-wait -// iteration exponentially up to a limit. Typical usage: -// if (!conditionThatMayNotBeSatisfiedSoon) -// { -// YieldProcessorNormalizationInfo normalizationInfo; -// do -// { -// YieldProcessorWithBackOffNormalized(normalizationInfo); // maybe Sleep(0) occasionally -// } while (!conditionThatMayNotBeSatisfiedSoon); -// } -FORCEINLINE void YieldProcessorWithBackOffNormalized( - const YieldProcessorNormalizationInfo &normalizationInfo, - unsigned int spinIteration) -{ - // This shift value should be adjusted based on the asserted conditions below - const uint8_t MaxShift = 3; - static_assert( - ((unsigned int)1 << MaxShift) <= YieldProcessorNormalization::MaxOptimalMaxNormalizedYieldsPerSpinIteration, ""); - static_assert( - ((unsigned int)1 << (MaxShift + 1)) > YieldProcessorNormalization::MaxOptimalMaxNormalizedYieldsPerSpinIteration, ""); - - unsigned int n; - if (spinIteration <= MaxShift && - ((unsigned int)1 << spinIteration) < normalizationInfo.optimalMaxNormalizedYieldsPerSpinIteration) - { - n = ((unsigned int)1 << spinIteration) * normalizationInfo.yieldsPerNormalizedYield; - } - else - { - n = normalizationInfo.optimalMaxYieldsPerSpinIteration; - } - _ASSERTE(n != 0); - do - { - System_YieldProcessor(); - } while (--n != 0); -} - #undef DISABLE_CONSTRUCT_COPY #undef DISABLE_COPY diff --git a/src/coreclr/md/ceefilegen/pesectionman.cpp b/src/coreclr/md/ceefilegen/pesectionman.cpp index 10d9b2b74016a4..81bc2332f6bb1b 100644 --- a/src/coreclr/md/ceefilegen/pesectionman.cpp +++ b/src/coreclr/md/ceefilegen/pesectionman.cpp @@ -1,8 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// PESectionMan implementation -// +// PESectionMan implementation #include "stdafx.h" @@ -29,36 +28,6 @@ HRESULT PESectionMan::Cleanup() return S_OK; } -/*****************************************************************/ -// this class is located in it's own DLL (MsCorXvt.dll) -// Since DLL allocates, The DLL must delete; we can't simply delete from -// the client (This is a bug in VC, see knowledge base Q122675) -void PESectionMan::sectionDestroy(PESection **section) -{ - // check if this section is referenced in other sections' relocs - for(PESection** ptr = sectStart; ptr < sectCur; ptr++) - { - if(ptr != section) - { - for(PESectionReloc* cur = (*ptr)->m_relocStart; cur < (*ptr)->m_relocCur; cur++) - { - if(cur->section == *section) // here it is! Delete the reference - { - for(PESectionReloc* tmp = cur; tmp < (*ptr)->m_relocCur; tmp++) - { - memcpy(tmp,(tmp+1),sizeof(PESectionReloc)); - } - (*ptr)->m_relocCur--; - cur--; // no position shift this time - } - } - } - } - delete *section; - *section = NULL; -} -/*****************************************************************/ - /******************************************************************/ // Apply the relocs for all the sections // Called by: ClassConverter after loading up during an in-memory conversion, diff --git a/src/coreclr/md/compiler/filtermanager.cpp b/src/coreclr/md/compiler/filtermanager.cpp index a641f348bec140..d4ed7162ace14c 100644 --- a/src/coreclr/md/compiler/filtermanager.cpp +++ b/src/coreclr/md/compiler/filtermanager.cpp @@ -1,13 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // FilterManager.cpp -// - // // contains utility code to MD directory -// //***************************************************************************** + #include "stdafx.h" #include "filtermanager.h" @@ -596,35 +595,6 @@ HRESULT FilterManager::MarkDeclSecuritiesWithParentToken(mdToken tkParent) return hr; } // HRESULT FilterManager::MarkDeclSecuritiesWithParentToken() - -//***************************************************************************** -// cascading Mark of all MemberRefs associated with a parent token -//***************************************************************************** -HRESULT FilterManager::MarkMemberRefsWithParentToken(mdToken tk) -{ - HRESULT hr = NOERROR; - RID ulEnd; - RID index; - mdToken tkParent; - MemberRefRec *pRec; - - ulEnd = m_pMiniMd->getCountMemberRefs(); - - for (index = 1; index <= ulEnd; index ++ ) - { - // memberRef table is not sorted. Table scan is needed. - IfFailGo(m_pMiniMd->GetMemberRefRecord(index, &pRec)); - tkParent = m_pMiniMd->getClassOfMemberRef(pRec); - if ( tk == tkParent ) - { - IfFailGo( MarkMemberRef( TokenFromRid(index, mdtMemberRef) ) ); - } - } -ErrExit: - return hr; -} // HRESULT FilterManager::MarkMemberRefsWithParentToken() - - //***************************************************************************** // cascading Mark of a ParamDef token //***************************************************************************** @@ -1453,5 +1423,3 @@ HRESULT FilterManager::UnmarkTypeDef( return hr; } // HRESULT FilterManager::UnmarkTypeDef() - - diff --git a/src/coreclr/md/compiler/filtermanager.h b/src/coreclr/md/compiler/filtermanager.h index 24fcd0128c2dc7..def0440e56053d 100644 --- a/src/coreclr/md/compiler/filtermanager.h +++ b/src/coreclr/md/compiler/filtermanager.h @@ -1,13 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // FilterManager.h -// - // // Contains utility code for MD directory -// //***************************************************************************** + #ifndef __FilterManager__h__ #define __FilterManager__h__ @@ -48,7 +47,6 @@ class FilterManager HRESULT MarkCustomAttributesWithParentToken(mdToken tkParent); HRESULT MarkDeclSecuritiesWithParentToken(mdToken tkParent); - HRESULT MarkMemberRefsWithParentToken(mdToken tk); HRESULT MarkParam(mdParamDef pd); HRESULT MarkMethod(mdMethodDef md); diff --git a/src/coreclr/md/compressedinteger.h b/src/coreclr/md/compressedinteger.h deleted file mode 100644 index 7d2159f46db197..00000000000000 --- a/src/coreclr/md/compressedinteger.h +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// -// File: CompressedInteger.h -// - -// -// Class code:MetaData::CompressedInteger provides secure access to a compressed integer (as defined in CLI -// ECMA specification). The integer is compressed into 1, 2 or 4 bytes. See code:CompressedInteger#Format -// for full format description. -// -// ====================================================================================== - -#pragma once - -#include "external.h" - -namespace MetaData -{ - -// -------------------------------------------------------------------------------------- -// -// This class provides secure access to a compressed integer (as defined in CLI ECMA specification). The -// integer is compressed into 1, 2 or 4 bytes. See code:CompressedInteger#Format for full format description. -// -class CompressedInteger -{ -// #Format -// -// The format/encoding of compressed integer is (defined in ECMA CLI specification): -// The encoding is 1, 2 or 4 bytes long and depends on the first byte value. If the first byte is (binary): -// * 0xxx xxxx ... then it's 1 byte long and the value is 0xxx xxxx. -// * 10xx xxxx ... then it's 2 bytes long and the value is 00xx xxxx yyyy yyyy, where yyyy yyyy is the -// second byte. Though values smaller than code:const_Max1Byte are technically invalid -// when encoded with 2 bytes. -// * 110x xxxx ... then it's 4 bytes long and the value is 000x xxxx yyyy yyyy zzzz zzzz wwww wwww, where -// yyyy yyyy is the 2nd byte, zzzz zzzz is the 3rd byte and wwww wwww is the 4th byte. -// Though values smaller than code:const_Max2Bytes are technically invalid when encoded -// with 4 bytes. -// * 111x xxxx ... then it's invalid encoding. -// -// Note: Some encodings are invalid, but CLR accepts them (see code:DataBlob::GetCompressedU), -// e.g. 1000 0000 0000 0000 (0x8000) encodes 0 while correct/valid encoding is 0000 0000 (0x00). -// -private: - // This class has only static methods and shouldn't be instantiated. - CompressedInteger() {} - -public: - static const UINT32 const_MaxEncodingSize = 4; - - static const UINT32 const_Max1Byte = 0x7f; - static const UINT32 const_Max2Bytes = 0x3fff; - static const UINT32 const_Max4Bytes = 0x1fffffff; - - static const UINT32 const_Max = const_Max4Bytes; - -public: - // - // Operations - // - - // Returns TRUE if the value (nValue) fits into 1-byte, 2-bytes or 4-bytes encoding and fills - // *pcbEncodingSize with 1, 2 or 4. - // Returns FALSE if the value cannot be encoded as compressed integer, doesn't fill *pcbEncodingSize - // then. - __checkReturn - __success(return) - static inline BOOL GetEncodingSize( - UINT32 nValue, - _Out_ UINT32 *pcbEncodingSize); - // Returns TRUE if the value (nValue) fits into 1-byte, 2-bytes or 4-bytes encoding and fills - // *pcbEncodingSize with 1, 2 or 4 and *pnEncodedValue with the encoded value. - // Returns FALSE if the value cannot be encoded as compressed integer, doesn't fill *pcbEncodingSize - // nor *pnEncodedValue then. - __success(return) - static inline BOOL Encode( - UINT32 nValue, - _Out_ UINT32 *pnEncodedValue, - _Out_ UINT32 *pcbEncodingSize); - -}; // class CompressedInteger - -}; // namespace MetaData - -#include "compressedinteger.inl" diff --git a/src/coreclr/md/compressedinteger.inl b/src/coreclr/md/compressedinteger.inl deleted file mode 100644 index 384b1b219b7208..00000000000000 --- a/src/coreclr/md/compressedinteger.inl +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// -// File: CompressedInteger.inl -// - -// -// Class code:MetaData::CompressedInteger provides secure access to a compressed integer (as defined in CLI -// ECMA specification). The integer is compressed into 1, 2 or 4 bytes. See code:CompressedInteger#Format -// for full format description. -// -// ====================================================================================== - -#pragma once - -#include "compressedinteger.h" - -namespace MetaData -{ - -// -------------------------------------------------------------------------------------- -// -// Returns TRUE if the value (nValue) fits into 1-byte, 2-bytes or 4-bytes encoding and fills -// *pcbEncodingSize with 1, 2 or 4. -// Returns FALSE if the value cannot be encoded as compressed integer, doesn't fill *pcbEncodingSize then. -// -__checkReturn -//static -inline -BOOL -CompressedInteger::GetEncodingSize( - UINT32 nValue, - _Out_ UINT32 *pcbEncodingSize) -{ - // Does it fit into 1-byte encoding? - if (nValue <= const_Max1Byte) - { // The value fits into 1 byte (binary format 0xxx xxxx) - *pcbEncodingSize = 1; - return TRUE; - } - // Does it fit into 2-bytes encoding? - if (nValue <= const_Max2Bytes) - { // The value fits into 2 bytes (binary format 10xx xxxx yyyy yyyy) - *pcbEncodingSize = 2; - return TRUE; - } - // Does it fit into 4-bytes encoding? - if (nValue <= const_Max4Bytes) - { // The value fits into 4 bytes (binary format 110x xxxx yyyy yyyy zzzz zzzz wwww wwww) - *pcbEncodingSize = 4; - return TRUE; - } - // The value cannot be encoded as compressed integer - return FALSE; -} // CompressedInteger::GetEncodingSize - -// -------------------------------------------------------------------------------------- -// -// Returns TRUE if the value (nValue) fits into 1-byte, 2-bytes or 4-bytes encoding and fills -// *pcbEncodingSize with 1, 2 or 4 and *pnEncodedValue with the encoded value. -// Returns FALSE if the value cannot be encoded as compressed integer, doesn't fill *pcbEncodingSize -// nor *pnEncodedValue then. -// -__checkReturn -//static -inline -BOOL -CompressedInteger::Encode( - UINT32 nValue, - _Out_ UINT32 *pnEncodedValue, - _Out_ UINT32 *pcbEncodingSize) -{ - // Does it fit into 1-byte encoding? - if (nValue <= const_Max1Byte) - { // The value fits into 1 byte (binary format 0xxx xxxx) - *pnEncodedValue = nValue; - *pcbEncodingSize = 1; - return TRUE; - } - // Does it fit into 2-bytes encoding? - if (nValue <= const_Max2Bytes) - { // The value fits into 2 bytes (binary format 10xx xxxx yyyy yyyy) - *pnEncodedValue = 0x8000 | nValue; - *pcbEncodingSize = 2; - return TRUE; - } - // Does it fit into 4-bytes encoding? - if (nValue <= const_Max4Bytes) - { // The value fits into 4 bytes (binary format 110x xxxx yyyy yyyy zzzz zzzz wwww wwww) - *pnEncodedValue = 0xC0000000 | nValue; - *pcbEncodingSize = 4; - return TRUE; - } - // The value cannot be encoded as compressed integer - return FALSE; -} // CompressedInteger::Encode - -}; // namespace MetaData diff --git a/src/coreclr/md/datablob.h b/src/coreclr/md/datablob.h index 15876d799cdffd..b7deb3f26e0eee 100644 --- a/src/coreclr/md/datablob.h +++ b/src/coreclr/md/datablob.h @@ -1,13 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: DataBlob.h -// +// ====================================================================================== +// File: DataBlob.h // // Class code:MetaData::DataBlob provides secure access to a block of memory from MetaData (i.e. with fixed // endianness). -// // ====================================================================================== #pragma once @@ -79,7 +77,7 @@ class DataBlob __checkReturn __success(return) inline BOOL GetU4(_Out_ UINT32 *pnValue); __checkReturn __success(return) inline BOOL GetU8(_Out_ UINT64 *pnValue); - // Reads compressed integer (1, 2 or 4 bytes of format code:CompressedInteger#Format - returns the size + // Reads compressed integer (1, 2 or 4 bytes of format ECMA-335 II.23.2 - returns the size // in *pcbCompressedValueSize) from the data blob without skipping the read data. // Returns FALSE if there's not enough data in the blob or the compression is invalid (starts with byte // 111? ????), doesn't initialize the value *pnValue nor the size of the compressed value @@ -91,7 +89,7 @@ class DataBlob inline BOOL PeekCompressedU( _Out_ UINT32 *pnValue, _Out_ UINT32 *pcbCompressedValueSize); - // Reads compressed integer (1, 2 or 4 bytes of format code:CompressedInteger#Format) from the data blob + // Reads compressed integer (1, 2 or 4 bytes of format ECMA-335 II.23.2) from the data blob // and skips the read data. // Returns FALSE if there's not enough data in the blob or the compression is invalid (starts with byte // 111? ????), doesn't initialize the value *pnValue then. @@ -99,7 +97,7 @@ class DataBlob __checkReturn __success(return) inline BOOL GetCompressedU(_Out_ UINT32 *pnValue); - // Reads compressed integer (1, 2 or 4 bytes of format code:CompressedInteger#Format - returns the size + // Reads compressed integer (1, 2 or 4 bytes of format ECMA-335 II.23.2 - returns the size // in *pcbCompressedValueSize) from the data blob and skips the read data. // Returns FALSE if there's not enough data in the blob or the compression is invalid (starts with byte // 111? ????), doesn't initialize the value *pnValue nor the size of the compressed value @@ -196,15 +194,6 @@ class DataBlob // Setters // - // Writes compressed integer (1, 2 or 4 bytes of format code:CompressedInteger#Format) to the data blob - // and skips the written data. - // Returns FALSE if there's not enough data in the blob or the value cannot be encoded as compressed - // integer (bigger than code:CompressedInteger::const_Max). - // Returns TRUE on success and moves the memory block behind the written data. - __checkReturn - __success(return) - inline BOOL StoreCompressedU(UINT32 nValue); - // Writes data from *pSource to the data blob and skips the written data. // Returns FALSE if there's not enough data in the blob. // Returns TRUE on success and moves memory block behind the written data. diff --git a/src/coreclr/md/datablob.inl b/src/coreclr/md/datablob.inl index f28f42745bf583..9d467f519242c2 100644 --- a/src/coreclr/md/datablob.inl +++ b/src/coreclr/md/datablob.inl @@ -1,19 +1,16 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: DataBlob.inl -// +// ====================================================================================== +// File: DataBlob.inl // // Class code:MetaData::DataBlob provides secure access to a block of memory from MetaData (i.e. with fixed // endianness). -// // ====================================================================================== #pragma once #include "datablob.h" -#include "compressedinteger.h" #include "debug_metadata.h" @@ -261,7 +258,7 @@ DataBlob::GetU8(_Out_ UINT64 *pnValue) // -------------------------------------------------------------------------------------- // -// Reads compressed integer (1, 2 or 4 bytes of format code:CompressedInteger#Format) from the data blob +// Reads compressed integer (1, 2 or 4 bytes of format ECMA-335 II.23.2) from the data blob // and skips the read data. // Returns FALSE if there's not enough data in the blob or the compression is invalid (starts with byte // 111? ????), doesn't initialize the value *pnValue then. @@ -278,7 +275,7 @@ DataBlob::GetCompressedU(_Out_ UINT32 *pnValue) // -------------------------------------------------------------------------------------- // -// Reads compressed integer (1, 2 or 4 bytes of format code:CompressedInteger#Format - returns the size +// Reads compressed integer (1, 2 or 4 bytes of format ECMA-335 II.23.2 - returns the size // in *pcbCompressedValueSize) from the data blob without skipping the read data. // Returns FALSE if there's not enough data in the blob or the compression is invalid (starts with byte // 111? ????), doesn't initialize the value *pnValue nor the size of the compressed value @@ -294,7 +291,7 @@ DataBlob::PeekCompressedU( _Out_ UINT32 *pnValue, _Out_ UINT32 *pcbCompressedValueSize) { - // This algorithm has to be in sync with code:CompressedInteger#Format encoding definition. + // This algorithm implements the compressed integer encoding defined in ECMA-335 II.23.2. // // Note that this algorithm accepts technically invalid encodings, e.g. // encoding of value 0 is accepted as 0000 0000 (0x00, valid) and 1000 0000 0000 000 (0x8000, invalid). @@ -350,7 +347,7 @@ DataBlob::PeekCompressedU( // -------------------------------------------------------------------------------------- // -// Reads compressed integer (1, 2 or 4 bytes of format code:CompressedInteger#Format - returns the size +// Reads compressed integer (1, 2 or 4 bytes of format ECMA-335 II.23.2 - returns the size // in *pcbCompressedValueSize) from the data blob and skips the read data. // Returns FALSE if there's not enough data in the blob or the compression is invalid (starts with byte // 111? ????), doesn't initialize the value *pnValue nor the size of the compressed value @@ -487,57 +484,6 @@ DataBlob::Debug_GetByteAtOffset(UINT32 nOffset) const } // DataBlob::Debug_GetByteAtOffset #endif //_DEBUG -// -------------------------------------------------------------------------------------- -// -// Writes compressed integer (1, 2 or 4 bytes of format code:CompressedInteger#Format) to the data blob -// and skips the written data. -// Returns FALSE if there's not enough data in the blob or the value cannot be encoded as compressed -// integer (bigger than code:CompressedInteger::const_Max). -// Returns TRUE on success and moves the memory block behind the written data. -// -__checkReturn -inline -BOOL -DataBlob::StoreCompressedU(UINT32 nValue) -{ - if (nValue <= CompressedInteger::const_Max1Byte) - { // The value fits into 1 byte - if (m_cbSize < 1) - { // The data blob is empty, we cannot store compressed integer as 1 byte - return FALSE; - } - *m_pbData = (BYTE)nValue; - SkipBytes_InternalInsecure(1); - return TRUE; - } - if (nValue <= CompressedInteger::const_Max2Bytes) - { // The value fits into 2 bytes - if (m_cbSize < 2) - { // The data blob is too short, we cannot store compressed integer as 2 bytes - return FALSE; - } - *m_pbData = (BYTE)(nValue >> 8) | 0x80; - *(m_pbData + 1) = (BYTE)(nValue & 0xff); - SkipBytes_InternalInsecure(2); - return TRUE; - } - if (nValue <= CompressedInteger::const_Max4Bytes) - { // The value fits into 4 bytes - if (m_cbSize < 4) - { // The data blob is too short, we cannot store compressed integer as 4 bytes - return FALSE; - } - *m_pbData = (BYTE)(nValue >> 24) | 0xC0; - *(m_pbData + 1) = (BYTE)((nValue >> 16) & 0xff); - *(m_pbData + 2) = (BYTE)((nValue >> 8) & 0xff); - *(m_pbData + 3) = (BYTE)(nValue & 0xff); - SkipBytes_InternalInsecure(4); - return TRUE; - } - // The value cannot be encoded as compressed integer - return FALSE; -} // DataBlob::StoreCompressedU - // -------------------------------------------------------------------------------------- // // Writes data from *pSource to the data blob and skips the written data. diff --git a/src/coreclr/md/databuffer.h b/src/coreclr/md/databuffer.h index 3d18c5a205fa34..f70af645e95c46 100644 --- a/src/coreclr/md/databuffer.h +++ b/src/coreclr/md/databuffer.h @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: DataBuffer.h -// +// ====================================================================================== +// File: DataBuffer.h // // Class code:DataBuffer provides secure access to a block of memory. -// // ====================================================================================== #pragma once @@ -65,17 +63,6 @@ class DataBuffer __checkReturn inline BOOL PeekData( _Outptr_ T **ppTypeData); - // Reads data of type T at offset nOffset without skipping the read data (returns pointer to the type in - // *ppTypeData). - // Returns FALSE if there's not enough data (of size T) at offset nOffset in the buffer, doesn't - // initialize the pointer *ppTypeData then. - // Returns TRUE otherwise, fills *ppTypeData with the type start, but doesn't move the memory block - // (doesn't skip any "read" data). - template - __checkReturn - inline BOOL PeekDataAt( - UINT32 nOffset, - _Outptr_ T **ppTypeData); // Reads data of type T and skips the data (instead of reading the bytes, returns pointer to the type in // *ppTypeData). // Returns FALSE if there's not enough data (of size T) in the blob, doesn't initialize the pointer diff --git a/src/coreclr/md/databuffer.inl b/src/coreclr/md/databuffer.inl index ba3d6d03827048..f3c5161b73a960 100644 --- a/src/coreclr/md/databuffer.inl +++ b/src/coreclr/md/databuffer.inl @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: DataBuffer.inl -// +// ====================================================================================== +// File: DataBuffer.inl // // Class code:DataBuffer provides secure access to a block of memory. -// // ====================================================================================== #pragma once @@ -109,35 +107,6 @@ DataBuffer::PeekData( return TRUE; } // DataBuffer::PeekData -// -------------------------------------------------------------------------------------- -// -// Reads data of type T at offset nOffset without skipping the read data (returns pointer to the type in -// *ppTypeData). -// Returns FALSE if there's not enough data (of size T) at offset nOffset in the buffer, doesn't -// initialize the pointer *ppTypeData then. -// Returns TRUE otherwise, fills *ppTypeData with the type start, but doesn't move the memory block -// (doesn't skip any "read" data). -template -__checkReturn -inline -BOOL -DataBuffer::PeekDataAt( - UINT32 nOffset, - _Outptr_ T **ppTypeData) -{ - if (m_cbSize < nOffset) - { // The offset is not in the memory block - return FALSE; - } - if ((m_cbSize - nOffset) < sizeof(T)) - { // The type is not fully in the memory block - return FALSE; - } - // Fill the start of the "read" type - *ppTypeData = reinterpret_cast(m_pbData + nOffset); - return TRUE; -} // DataBuffer::PeekDataAt - // -------------------------------------------------------------------------------------- // // Reads data of type T and skips the data (instead of reading the bytes, returns pointer to the type in diff --git a/src/coreclr/md/enc/metamodelrw.cpp b/src/coreclr/md/enc/metamodelrw.cpp index f2d567b42d83fa..443655f5d4eba6 100644 --- a/src/coreclr/md/enc/metamodelrw.cpp +++ b/src/coreclr/md/enc/metamodelrw.cpp @@ -1,13 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // MetaModelRW.cpp -// - // // Implementation for the Read/Write MiniMD code. -// //***************************************************************************** + #include "stdafx.h" #include #include @@ -5032,74 +5031,6 @@ CMiniMdRW::FindMethodImplHelper( return hr; } // CMiniMdRW::FindMethodImplHelper - -//***************************************************************************** -// Find helper for a GenericParam. -// This will trigger GenericParam table to be sorted if it is not. -//***************************************************************************** -__checkReturn -HRESULT -CMiniMdRW::FindGenericParamHelper( - mdToken tkOwner, // Token for the GenericParams' owner. - HENUMInternal *phEnum) // fill in the enum -{ - HRESULT hr = NOERROR; - RID ridStart, ridEnd; // Start, end of range of tokens. - RID index; // A loop counter. - GenericParamRec *pGenericParam; - CLookUpHash *pHashTable = m_pLookUpHashes[TBL_GenericParam]; - - if (IsSorted(TBL_GenericParam)) - { - mdToken tk; - tk = encodeToken(RidFromToken(tkOwner), TypeFromToken(tkOwner), mdtTypeOrMethodDef, ARRAY_SIZE(mdtTypeOrMethodDef)); - IfFailGo(SearchTableForMultipleRows(TBL_GenericParam, - _COLDEF(GenericParam,Owner), - tk, - &ridEnd, - &ridStart)); - HENUMInternal::InitSimpleEnum(mdtGenericParam, ridStart, ridEnd, phEnum); - } - else if (pHashTable) - { - TOKENHASHENTRY *p; - ULONG iHash; - int pos; - - // Hash the data. - HENUMInternal::InitDynamicArrayEnum(phEnum); - iHash = HashToken(tkOwner); - - // Go through every entry in the hash chain looking for ours. - for (p = pHashTable->FindFirst(iHash, pos); - p; - p = pHashTable->FindNext(pos)) - { - IfFailGo(GetGenericParamRecord(p->tok, &pGenericParam)); - if (getOwnerOfGenericParam(pGenericParam) == tkOwner) - { - IfFailGo( HENUMInternal::AddElementToEnum(phEnum, TokenFromRid(p->tok, mdtGenericParam)) ); - } - } - } - else - { - // linear search - HENUMInternal::InitDynamicArrayEnum(phEnum); - for (index = 1; index <= getCountGenericParams(); index++) - { - IfFailGo(GetGenericParamRecord(index, &pGenericParam)); - if (getOwnerOfGenericParam(pGenericParam) == tkOwner) - { - IfFailGo( HENUMInternal::AddElementToEnum(phEnum, TokenFromRid(index, mdtGenericParam)) ); - } - } - } -ErrExit: - return hr; -} // CMiniMdRW::FindGenericParamHelper - - //***************************************************************************** // Find helper for a GenericParamConstraint. // This will trigger GenericParamConstraint table to be sorted if it is not. @@ -6280,41 +6211,6 @@ CMiniMdRW::AddNamedItemToHash( return hr; } // CMiniMdRW::AddNamedItemToHash -//***************************************************************************** -// Check a given mr token to see if this one is a match. -//***************************************************************************** -__checkReturn -HRESULT -CMiniMdRW::CompareNamedItems( // S_OK match, S_FALSE no match. - ULONG ixTbl, // Table with the item. - mdToken tk, // Token to check. - LPCUTF8 szName, // Name of item. - mdToken tkParent) // Token of parent, if any. -{ - HRESULT hr; - BYTE *pNamedItem; // Item to check. - LPCUTF8 szNameUtf8Tmp; // Name of item to check. - - // Get the record. - IfFailRet(m_Tables[ixTbl].GetRecord(RidFromToken(tk), &pNamedItem)); - - // Name is cheaper to get than coded token parent, and fails pretty quickly. - IfFailRet(getString(GetCol(ixTbl, g_TblIndex[ixTbl].m_iName, pNamedItem), &szNameUtf8Tmp)); - if (strcmp(szNameUtf8Tmp, szName) != 0) - return S_FALSE; - - // Name matched, try parent, if any. - if (g_TblIndex[ixTbl].m_iParent != (ULONG)-1) - { - mdToken tkPar = GetToken(ixTbl, g_TblIndex[ixTbl].m_iParent, pNamedItem); - if (tkPar != tkParent) - return S_FALSE; - } - - // Made it to here, so everything matched. - return S_OK; -} // CMiniMdRW::CompareNamedItems - //***************************************************************************** // Add entry to the MethodDef map look up table //***************************************************************************** diff --git a/src/coreclr/md/enc/stgio.cpp b/src/coreclr/md/enc/stgio.cpp index ac9fb05735c49e..48b8c68c58718f 100644 --- a/src/coreclr/md/enc/stgio.cpp +++ b/src/coreclr/md/enc/stgio.cpp @@ -1,9 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // StgIO.h -// - // // This module handles disk/memory i/o for a generic set of storage solutions, // including: @@ -33,6 +32,7 @@ // only the portion of the file with the .clb in it. // //***************************************************************************** + #include "stdafx.h" // Standard headers. #include "stgio.h" // Our definitions. #include "corerror.h" @@ -910,42 +910,6 @@ HRESULT StgIO::MapFileToMem( // Return code. return (hr); } - -//***************************************************************************** -// Free the mapping object for shared memory but keep the rest of the internal -// state intact. -//***************************************************************************** -HRESULT StgIO::ReleaseMappingObject() // Return code. -{ - // Check type first. - if (m_iType != STGIO_SHAREDMEM) - { - _ASSERTE(FALSE); - return S_OK; - } - - // Must have an allocated handle. - _ASSERTE(m_hMapping != 0); - - // Freeing the mapping object doesn't do any good if you still have the file. - _ASSERTE(m_hFile == INVALID_HANDLE_VALUE); - - // Unmap the memory we allocated before freeing the handle. But keep the - // memory address intact. - if (m_pData) - VERIFY(UnmapViewOfFile(m_pData)); - - // Free the handle. - if (m_hMapping != 0) - { - VERIFY(CloseHandle(m_hMapping)); - m_hMapping = 0; - } - return S_OK; -} - - - //***************************************************************************** // Resets the logical base address and size to the value given. This is for // cases like finding a section embedded in another format, like the .clb inside @@ -1334,4 +1298,3 @@ void FreeMemory(void *pbData) _ASSERTE(pbData); delete [] (BYTE *) pbData; } - diff --git a/src/coreclr/md/enc/stgtiggerstorage.cpp b/src/coreclr/md/enc/stgtiggerstorage.cpp index 422bb302c3a183..22551616b43508 100644 --- a/src/coreclr/md/enc/stgtiggerstorage.cpp +++ b/src/coreclr/md/enc/stgtiggerstorage.cpp @@ -1,16 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // StgTiggerStorage.cpp -// - // // TiggerStorage is a stripped down version of compound doc files. Doc files // have some very useful and complex features to them, unfortunately nothing // comes for free. Given the incredibly tuned format of existing .tlb files, // every single byte counts and 10% added by doc files is just too expensive. -// //***************************************************************************** + #include "stdafx.h" // Standard header. #include "stgio.h" // I/O subsystem. #include "stgtiggerstorage.h" // Our interface. @@ -966,34 +965,3 @@ HRESULT TiggerStorage::VerifyHeader() //***************************************************************************** // Print the sizes of the various streams. //***************************************************************************** -#if defined(_DEBUG) -ULONG TiggerStorage::PrintSizeInfo(bool verbose) -{ - ULONG total = 0; - - printf("Storage Header: %zu\n", sizeof(STORAGEHEADER)); - if (m_pStreamList != NULL) - { - PSTORAGESTREAM storStream = m_pStreamList; - PSTORAGESTREAM pNext; - for (int i = 0; i < m_StgHdr.GetiStreams(); i++) - { - pNext = storStream->NextStream(); - printf("Stream #%d (%s) Header: %zd, Data: %u\n",i,storStream->GetName(), (size_t)((BYTE*)pNext - (BYTE*)storStream), storStream->GetSize()); - total += storStream->GetSize(); - storStream = pNext; - } - } - else - { - //todo: Add support for the case where m_Streams exists and m_pStreamList does not - } - - if (m_pbExtra != NULL) - { - printf("Extra bytes: %d\n",*(ULONG*)m_pbExtra); - total += *(ULONG*)m_pbExtra; - } - return total; -} -#endif // _DEBUG diff --git a/src/coreclr/md/inc/metamodel.h b/src/coreclr/md/inc/metamodel.h index ee5027f1116e9e..db67f82052e2d7 100644 --- a/src/coreclr/md/inc/metamodel.h +++ b/src/coreclr/md/inc/metamodel.h @@ -1,11 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // MetaModel.h -- header file for compressed CLR metadata. -// - -// //***************************************************************************** + #ifndef _METAMODEL_H_ #define _METAMODEL_H_ @@ -434,14 +433,6 @@ class CMiniMdBase : public IMetaModelCommonRO ULONG ulTarget, // target for search RID *pRid) = 0; - // Search for a custom value with a given type. - __checkReturn - HRESULT FindCustomAttributeFor(// RID of custom value, or 0. - RID rid, // The object's rid. - mdToken tkOjb, // The object's type. - mdToken tkType, // Type of custom value. - RID *pFoundRid); - // Search for the specified Column Definition array in the global cache BOOL FindSharedColDefs(// TRUE if we found a match in the global cache and updated pTable, FALSE otherwise CMiniTableDef *pTable, // The table def that wants the column definition array diff --git a/src/coreclr/md/inc/metamodelrw.h b/src/coreclr/md/inc/metamodelrw.h index 52463024450a28..3991e4e56f698c 100644 --- a/src/coreclr/md/inc/metamodelrw.h +++ b/src/coreclr/md/inc/metamodelrw.h @@ -3,12 +3,10 @@ //***************************************************************************** // MetaModelRW.h -- header file for Read/Write compressed CLR metadata. -// - // // Used by Emitters and by E&C. -// //***************************************************************************** + #ifndef _METAMODELRW_H_ #define _METAMODELRW_H_ @@ -773,13 +771,6 @@ class CMiniMdRW : public CMiniMdTemplate LPCUTF8 szName, // Name of item. mdToken tkParent); // Token of parent, if any. - __checkReturn - HRESULT CompareNamedItems( // S_OK match, S_FALSE no match. - ULONG ixTbl, // Table with the item. - mdToken tk, // Token to check. - LPCUTF8 szName, // Name of item. - mdToken tkParent); // Token of parent, if any. - FORCEINLINE ULONG HashNamedItem(mdToken tkPar, LPCUTF8 szName) { return HashBytes((const BYTE *) &tkPar, sizeof(mdToken)) + HashStringA(szName); } @@ -869,14 +860,6 @@ class CMiniMdRW : public CMiniMdTemplate mdTypeDef td, // TypeDef token for the Class. HENUMInternal *phEnum); // fill in the enum - //***************************************************************************** - // Find helper for a GenericParams - //***************************************************************************** - __checkReturn - HRESULT FindGenericParamHelper( // Return HRESULT - mdToken tkOwner, // Token for the GenericParams' owner - HENUMInternal *phEnum); // Fill in the enum. - //***************************************************************************** // Find helper for a Generic Constraints //***************************************************************************** diff --git a/src/coreclr/md/inc/recordpool.h b/src/coreclr/md/inc/recordpool.h index 8b8f31fdd341cd..870bf5a56e8d21 100644 --- a/src/coreclr/md/inc/recordpool.h +++ b/src/coreclr/md/inc/recordpool.h @@ -1,11 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // RecordPool.h -- header file for record heaps. -// - -// //***************************************************************************** + #ifndef _RECORDPOOL_H_ #define _RECORDPOOL_H_ @@ -91,12 +90,6 @@ class RecordPool : public StgPool virtual ULONG GetIndexForRecord( // 1-based index of Record in pool. const void *pRecord); // Pointer to Record in pool. -//***************************************************************************** -// Given a purported pointer to a record, determine if the pointer is valid. -//***************************************************************************** - virtual int IsValidPointerForRecord( // true or false. - const void *pRecord); // Pointer to Record in pool. - //***************************************************************************** // How many objects are there in the pool? If the count is 0, you don't need // to persist anything at all to disk. @@ -140,16 +133,6 @@ class RecordPool : public StgPool void *GetFirstRecord( // Pointer to Record in pool. void **pContext); // Store context here. -//***************************************************************************** -// Given a pointer to a record, return a pointer to the next record. -// Note that this scheme does pretty minimal error checking. In particular, -// this will let the caller walk off of the end of valid data in the last -// segment. -//***************************************************************************** - void *GetNextRecord( // Pointer to Record in pool. - void *pRecord, // Current record. - void **pContext); // Stored context here. - private: DAC_ALIGNAS(StgPool) // Align first member to alignment of base class UINT32 m_cbRec; // How large is each record? diff --git a/src/coreclr/md/inc/stgio.h b/src/coreclr/md/inc/stgio.h index d46c9119a7db49..a9561d1445a6d8 100644 --- a/src/coreclr/md/inc/stgio.h +++ b/src/coreclr/md/inc/stgio.h @@ -1,9 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // StgIO.h -// - // // This module handles disk/memory i/o for a generic set of storage solutions, // including: @@ -33,6 +32,7 @@ // only the portion of the file with the .clb in it. // //***************************************************************************** + #ifndef __STGIO_H_ #define __STGIO_H_ @@ -152,12 +152,6 @@ class StgIO ULONG *pcbSize, // Return size of data. LPSECURITY_ATTRIBUTES pAttributes=0); // Security token. -//***************************************************************************** -// Free the mapping object for shared memory but keep the rest of the internal -// state intact. -//***************************************************************************** - HRESULT ReleaseMappingObject(); // Return code. - //***************************************************************************** // Resets the logical base address and size to the value given. This is for // cases like finding a section embedded in another format, like the .clb inside diff --git a/src/coreclr/md/inc/stgpool.h b/src/coreclr/md/inc/stgpool.h index 5d9e5dd7e95b86..aae42491642ef3 100644 --- a/src/coreclr/md/inc/stgpool.h +++ b/src/coreclr/md/inc/stgpool.h @@ -1,16 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // StgPool.h -// - // // Pools are used to reduce the amount of data actually required in the database. // This allows for duplicate string and binary values to be folded into one // copy shared by the rest of the database. Strings are tracked in a hash // table when insert/changing data to find duplicates quickly. The strings // are then persisted consecutively in a stream in the database format. -// //***************************************************************************** #ifndef __StgPool_h__ @@ -259,15 +257,6 @@ friend class MetaData::BlobHeapRO; return hr; } -//***************************************************************************** -// Convert a string to UNICODE into the caller's buffer. -//***************************************************************************** - __checkReturn - virtual HRESULT GetStringW( // Return code. - ULONG iOffset, // Offset of string in pool. - _Out_writes_(cchBuffer) LPWSTR szOut, // Output buffer for string. - int cchBuffer); // Size of output buffer. - //***************************************************************************** // Copy a GUID into the caller's buffer. //***************************************************************************** diff --git a/src/coreclr/md/inc/stgtiggerstorage.h b/src/coreclr/md/inc/stgtiggerstorage.h index e4e97e67560fdb..d2c5000955ec2d 100644 --- a/src/coreclr/md/inc/stgtiggerstorage.h +++ b/src/coreclr/md/inc/stgtiggerstorage.h @@ -1,9 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // StgTiggerStorage.h -// - // // TiggerStorage is a stripped down version of compound doc files. Doc files // have some very useful and complex features to them, unfortunately nothing @@ -41,8 +40,8 @@ // backing storage, whatever scheme that may be. There are no consistency // checks on the data (for example crc's) due to the expense in computation // required. There is a signature at the front of the file and in the header. -// //***************************************************************************** + #ifndef __StgTiggerStorage_h__ #define __StgTiggerStorage_h__ @@ -271,11 +270,6 @@ friend class TiggerStream; StgIO *GetStgIO() { return (m_pStgIO); } -#if defined(_DEBUG) - ULONG PrintSizeInfo( // Size of streams. - bool verbose); // Be verbose? -#endif - protected: HRESULT Write( // Return code. LPCSTR szName, // Name of stream we're writing. diff --git a/src/coreclr/md/inc/streamutil.h b/src/coreclr/md/inc/streamutil.h index 6c69b7b4f261ec..7dd8ba45355fc5 100644 --- a/src/coreclr/md/inc/streamutil.h +++ b/src/coreclr/md/inc/streamutil.h @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// - #if !defined( __STREAMUTIL_H__ ) #define __STREAMUTIL_H__ @@ -61,29 +59,6 @@ HRESULT WriteToStream( IStream * strm, BYTE val, UINT32 * totalBytes = NULL ) return WritePODToStream( strm, val, totalBytes ); } - -// Align to DWORD boundary -// -inline -HRESULT AlignDWORD( IStream * strm, UINT32 * totalBytes ) -{ - HRESULT hr = S_OK; - - UINT32 aligned = (*totalBytes + 3) & ~3; - if (aligned > *totalBytes) - { // The *totalBytes were not aligned to DWORD, we need to add padding - DWORD data = 0; - hr = WriteToStream( strm, & data, aligned - *totalBytes, totalBytes ); - } - else if (aligned < *totalBytes) - { // We got an integer overflow in 'aligned' expression above - hr = COR_E_OVERFLOW; - } - - return hr; -} - - // Get stream position // inline diff --git a/src/coreclr/md/runtime/metamodel.cpp b/src/coreclr/md/runtime/metamodel.cpp index e7f55f21715254..9e9479ea3c9fb6 100644 --- a/src/coreclr/md/runtime/metamodel.cpp +++ b/src/coreclr/md/runtime/metamodel.cpp @@ -1,11 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // MetaModel.cpp -- Base portion of compressed CLR metadata. -// - -// //***************************************************************************** + #include "stdafx.h" #include @@ -1042,87 +1041,6 @@ CMiniMdBase::FindEventMapFor( } } // CMiniMdBase::FindEventMapFor - -//***************************************************************************** -// Search for a custom value with a given type. -//***************************************************************************** -__checkReturn -HRESULT -CMiniMdBase::FindCustomAttributeFor( - RID rid, // The object's rid. - mdToken tkObj, // The object's type. - mdToken tkType, // Type of custom value. - RID *pFoundRid) // RID of custom value, or 0. -{ - HRESULT hr; - int ixFound; // index of some custom value row. - ULONG ulTarget = encodeToken(rid,tkObj,mdtHasCustomAttribute, ARRAY_SIZE(mdtHasCustomAttribute)); // encoded token representing target. - ULONG ixCur; // Current row being examined. - mdToken tkFound; // Type of some custom value row. - void *pCur; // A custom value entry. - - // Search for any entry in CustomAttribute table. Convert to RID. - IfFailRet(vSearchTable(TBL_CustomAttribute, _COLDEF(CustomAttribute,Parent), ulTarget, (RID *)&ixFound)); - if (ixFound == 0) - { - *pFoundRid = 0; - return S_OK; - } - - // Found an entry that matches the item. Could be anywhere in a range of - // custom values for the item, somewhat at random. Search for a match - // on name. On entry to the first loop, we know the object is the desired - // one, so the object test is at the bottom. - ixCur = ixFound; - IfFailRet(vGetRow(TBL_CustomAttribute, ixCur, &pCur)); - for(;;) - { - // Test the type of the current row. - tkFound = getIX(pCur, _COLDEF(CustomAttribute,Type)); - tkFound = decodeToken(tkFound, mdtCustomAttributeType, ARRAY_SIZE(mdtCustomAttributeType)); - if (tkFound == tkType) - { - *pFoundRid = ixCur; - return S_OK; - } - // Was this the last row of the CustomAttribute table? - if (ixCur == GetCountRecs(TBL_CustomAttribute)) - break; - // No match, more rows, try for the next row. - ++ixCur; - // Get the row and see if it is for the same object. - IfFailRet(vGetRow(TBL_CustomAttribute, ixCur, &pCur)); - if (getIX(pCur, _COLDEF(CustomAttribute,Parent)) != ulTarget) - break; - } - // Didn't find the name looking up. Try looking down. - ixCur = ixFound - 1; - for(;;) - { - // Run out of table yet? - if (ixCur == 0) - break; - // Get the row and see if it is for the same object. - IfFailRet(vGetRow(TBL_CustomAttribute, ixCur, &pCur)); - // still looking at the same object? - if (getIX(pCur, _COLDEF(CustomAttribute,Parent)) != ulTarget) - break; - // Test the type of the current row. - tkFound = getIX(pCur, _COLDEF(CustomAttribute,Type)); - tkFound = decodeToken(tkFound, mdtCustomAttributeType, ARRAY_SIZE(mdtCustomAttributeType)); - if (tkFound == tkType) - { - *pFoundRid = ixCur; - return S_OK; - } - // No match, try for the previous row. - --ixCur; - } - // Didn't find anything. - *pFoundRid = 0; - return S_OK; -} // CMiniMdBase::FindCustomAttributeFor - //***************************************************************************** // See if we can find a globally shared Column Def Array for this table //***************************************************************************** diff --git a/src/coreclr/md/runtime/recordpool.cpp b/src/coreclr/md/runtime/recordpool.cpp index e3e336842f4e7b..5cc7002aed3bd1 100644 --- a/src/coreclr/md/runtime/recordpool.cpp +++ b/src/coreclr/md/runtime/recordpool.cpp @@ -1,11 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // RecordPool.cpp -- Implementation of record heaps. -// - -// //***************************************************************************** + #include "stdafx.h" #include @@ -276,39 +275,6 @@ void *RecordPool::GetFirstRecord( // Pointer to Record in pool. return (*ppSeg)->m_pSegData; } // void *RecordPool::GetFirstRecord() -//***************************************************************************** -// Given a pointer to a record, return a pointer to the next record. -// Note that this scheme does pretty minimal error checking. In particular, -// this will let the caller walk off of the end of valid data in the last -// segment. -//***************************************************************************** -void *RecordPool::GetNextRecord( // Pointer to Record in pool. - void *pRecord, // Current record. - void **pContext) // Stored context here. -{ - BYTE *pbRec = reinterpret_cast(pRecord); - StgPoolSeg **ppSeg = reinterpret_cast(pContext); - - // Get the next record. - pbRec += m_cbRec; - - // Is the next record outside of the current segment? - if (static_cast(pbRec - (*ppSeg)->m_pSegData) >= (*ppSeg)->m_cbSegSize) - { - // Better be exactly one past current segment. - _ASSERTE(static_cast(pbRec - (*ppSeg)->m_pSegData) == (*ppSeg)->m_cbSegSize); - // Switch the context pointer. - *ppSeg = (*ppSeg)->m_pNextSeg; - // Next record is start of next segment. - if (*ppSeg) - return (*ppSeg)->m_pSegData; - else - return 0; - } - - return pbRec; -} // void *RecordPool::GetNextRecord() - //***************************************************************************** // Given a pointer to a record, determine the index corresponding to the // record. @@ -339,27 +305,6 @@ ULONG RecordPool::GetIndexForRecord( // 1-based index of Record in pool. } } // ULONG RecordPool::GetIndexForRecord() -//***************************************************************************** -// Given a purported pointer to a record, determine if the pointer is valid. -//***************************************************************************** -int RecordPool::IsValidPointerForRecord(// true or false. - const void *pvRecord) // Pointer to Record in pool. -{ - const StgPoolSeg *pSeg; - const BYTE *pRecord = reinterpret_cast(pvRecord); - const BYTE *pSegData = NULL; - for (pSeg = this; (pSeg); pSeg = pSeg->GetNextSeg()) - { // Does the current segment contain the record? - pSegData = pSeg->GetSegData(); - if ((pRecord >= pSegData) && (pRecord < pSegData + pSeg->GetSegSize())) - { // The pointer should be to the start of a record. - return (((pRecord - pSegData) % m_cbRec) == 0); - } - _ASSERTE((pSeg->GetSegSize() % m_cbRec) == 0); - } - return 0; -} // int RecordPool::IsValidPointerForRecord() - //***************************************************************************** // Replace the contents of this pool with those from another pool. The other // pool loses ownership of the memory. diff --git a/src/coreclr/md/runtime/stgpool.cpp b/src/coreclr/md/runtime/stgpool.cpp index 2d6d1a549345b5..d0d3524ae6ea88 100644 --- a/src/coreclr/md/runtime/stgpool.cpp +++ b/src/coreclr/md/runtime/stgpool.cpp @@ -1663,7 +1663,6 @@ StgBlobPool::GetBlobWithSizePrefix( IfFailGo(COR_E_BADIMAGEFORMAT); } //_ASSERTE(cbBlobSizePrefixSize <= 4); - //_ASSERTE(cbBlobContentSize <= CompressedInteger::const_Max); // Cannot overflow, because previous asserts hold (in comments) UINT32 cbBlobSize; diff --git a/src/coreclr/md/runtime/stgpoolreadonly.cpp b/src/coreclr/md/runtime/stgpoolreadonly.cpp index 8f96a7f14c67a0..3fdef788f77cb0 100644 --- a/src/coreclr/md/runtime/stgpoolreadonly.cpp +++ b/src/coreclr/md/runtime/stgpoolreadonly.cpp @@ -1,13 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // StgPoolReadOnly.cpp -// - // // Read only pools are used to reduce the amount of data actually required in the database. -// //***************************************************************************** + #include "stdafx.h" // Standard include. #include // Our interface definitions. @@ -73,27 +72,6 @@ void StgPoolReadOnly::Uninit() noexcept m_pNextSeg = 0; } - -//***************************************************************************** -// Convert a string to UNICODE into the caller's buffer. -//***************************************************************************** -HRESULT StgPoolReadOnly::GetStringW( // Return code. - ULONG iOffset, // Offset of string in pool. - _Out_writes_(cchBuffer) LPWSTR szOut, // Output buffer for string. - int cchBuffer) // Size of output buffer. -{ - STATIC_CONTRACT_NOTHROW; - HRESULT hr; - LPCSTR pString; // The string in UTF8. - int iChars; - - IfFailRet(GetString(iOffset, &pString)); - iChars = ::MultiByteToWideChar(CP_UTF8, 0, pString, -1, szOut, cchBuffer); - if (iChars == 0) - return (BadError(HRESULT_FROM_NT(GetLastError()))); - return S_OK; -} - //***************************************************************************** // Return a pointer to a null terminated blob given an offset previously // handed out by Addblob or Findblob. diff --git a/src/coreclr/nativeaot/Runtime/CommonMacros.h b/src/coreclr/nativeaot/Runtime/CommonMacros.h index be9b2fa167ce4b..bb218c51f0385d 100644 --- a/src/coreclr/nativeaot/Runtime/CommonMacros.h +++ b/src/coreclr/nativeaot/Runtime/CommonMacros.h @@ -6,9 +6,6 @@ #include "rhassert.h" #include -#ifdef PROFILE_STARTUP -#include -#endif #define EXTERN_C extern "C" @@ -258,21 +255,4 @@ typedef int32_t FC_BOOL_ARG; #define NOT_IN_DAC(x) #endif -enum STARTUP_TIMELINE_EVENT_ID -{ - PROCESS_ATTACH_BEGIN = 0, - NONGC_INIT_COMPLETE, - GC_INIT_COMPLETE, - PROCESS_ATTACH_COMPLETE, - - NUM_STARTUP_TIMELINE_EVENTS -}; - -#ifdef PROFILE_STARTUP -extern uint64_t g_startupTimelineEvents[NUM_STARTUP_TIMELINE_EVENTS]; -#define STARTUP_TIMELINE_EVENT(eventid) g_startupTimelineEvents[eventid] = (uint64_t)minipal_hires_ticks(); -#else // PROFILE_STARTUP -#define STARTUP_TIMELINE_EVENT(eventid) -#endif // PROFILE_STARTUP - #endif // __COMMONMACROS_H__ diff --git a/src/coreclr/nativeaot/Runtime/startup.cpp b/src/coreclr/nativeaot/Runtime/startup.cpp index eb219b0d37ac7f..59340150212eae 100644 --- a/src/coreclr/nativeaot/Runtime/startup.cpp +++ b/src/coreclr/nativeaot/Runtime/startup.cpp @@ -1,5 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + #include "common.h" #include "CommonTypes.h" #include "CommonMacros.h" @@ -32,10 +33,6 @@ #ifndef DACCESS_COMPILE -#ifdef PROFILE_STARTUP -uint64_t g_startupTimelineEvents[NUM_STARTUP_TIMELINE_EVENTS] = { 0 }; -#endif // PROFILE_STARTUP - #ifdef HOST_WINDOWS LONG WINAPI RhpVectoredExceptionHandler(PEXCEPTION_POINTERS pExPtrs); #else @@ -134,13 +131,9 @@ static bool InitDLL(HANDLE hPalInstance) } #endif // STRESS_LOG - STARTUP_TIMELINE_EVENT(NONGC_INIT_COMPLETE); - if (!InitializeGC()) return false; - STARTUP_TIMELINE_EVENT(GC_INIT_COMPLETE); - #ifdef FEATURE_PERFTRACING // Finish setting up rest of EventPipe - specifically enable SampleProfiler if it was requested at startup. // SampleProfiler needs to cooperate with the GC which hasn't fully finished setting up in the first part of the @@ -233,46 +226,6 @@ bool InitGSCookie() } #endif // TARGET_UNIX -#ifdef PROFILE_STARTUP -static void AppendInt64(char * pBuffer, uint32_t* pLen, uint64_t value) -{ - char localBuffer[20]; - int cch = 0; - - do - { - localBuffer[cch++] = '0' + (value % 10); - value = value / 10; - } while (value); - - for (int i = 0; i < cch; i++) - { - pBuffer[(*pLen)++] = localBuffer[cch - i - 1]; - } - - pBuffer[(*pLen)++] = ','; - pBuffer[(*pLen)++] = ' '; -} -#endif // PROFILE_STARTUP - -static void UninitDLL() -{ -#ifdef PROFILE_STARTUP - char buffer[1024]; - - uint32_t len = 0; - - AppendInt64(buffer, &len, g_startupTimelineEvents[PROCESS_ATTACH_BEGIN]); - AppendInt64(buffer, &len, g_startupTimelineEvents[NONGC_INIT_COMPLETE]); - AppendInt64(buffer, &len, g_startupTimelineEvents[GC_INIT_COMPLETE]); - AppendInt64(buffer, &len, g_startupTimelineEvents[PROCESS_ATTACH_COMPLETE]); - - buffer[len++] = '\n'; - - fwrite(buffer, len, 1, stdout); -#endif // PROFILE_STARTUP -} - #ifdef HOST_WINDOWS // This is set to the thread that initiates and performs the shutdown and may run // after other threads are rudely terminated. So far this is a Windows-specific concern. diff --git a/src/coreclr/nativeaot/Runtime/threadstore.cpp b/src/coreclr/nativeaot/Runtime/threadstore.cpp index 56828b71418704..4b2a6d43d4d1a3 100644 --- a/src/coreclr/nativeaot/Runtime/threadstore.cpp +++ b/src/coreclr/nativeaot/Runtime/threadstore.cpp @@ -1,5 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + #include "common.h" #include "gcenv.h" #include "gcheaputilities.h" @@ -412,27 +413,6 @@ void ThreadStore::SaveCurrentThreadOffsetForDAC() GPTR_IMPL(uint32_t, p_tls_index); GVAL_IMPL(uint32_t, SECTIONREL__tls_CurrentThread); -// -// This routine supports the !Thread debugger extension routine -// -// static -PTR_Thread ThreadStore::GetThreadFromTEB(TADDR pTEB) -{ - if (pTEB == NULL) - return NULL; - - uint32_t tlsIndex = *p_tls_index; - TADDR pTls = *(PTR_TADDR)(pTEB + OFFSETOF__TEB__ThreadLocalStoragePointer); - if (pTls == NULL) - return NULL; - - TADDR pOurTls = *(PTR_TADDR)(pTls + (tlsIndex * sizeof(void*))); - if (pOurTls == NULL) - return NULL; - - return (PTR_Thread)(pOurTls + SECTIONREL__tls_CurrentThread); -} - #endif // DACCESS_COMPILE #else // _WIN32 diff --git a/src/coreclr/nativeaot/Runtime/threadstore.h b/src/coreclr/nativeaot/Runtime/threadstore.h index 88991fb8b80753..ad8af339bc5611 100644 --- a/src/coreclr/nativeaot/Runtime/threadstore.h +++ b/src/coreclr/nativeaot/Runtime/threadstore.h @@ -57,8 +57,6 @@ class ThreadStore static void DetachCurrentThread(); #ifndef DACCESS_COMPILE static void SaveCurrentThreadOffsetForDAC(); -#else - static PTR_Thread GetThreadFromTEB(TADDR pvTEB); #endif void Destroy(); diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index c90d2a23f77b6b..4484ca3f4fef63 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -126,7 +126,6 @@ extern bool g_arm64_atomics_present; #define __assume(condition) do { if (!(condition)) __builtin_unreachable(); } while (0) #endif // __has_builtin(__builtin_assume) -#define __annotation(x) #endif //!MSC_VER #define UNALIGNED @@ -395,9 +394,6 @@ typedef struct _SECURITY_ATTRIBUTES { BOOL bInheritHandle; } SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; -#define FILE_READ_DATA ( 0x0001 ) // file & pipe -#define FILE_APPEND_DATA ( 0x0004 ) // file - #define GENERIC_READ (0x80000000L) #define GENERIC_WRITE (0x40000000L) @@ -411,12 +407,6 @@ typedef struct _SECURITY_ATTRIBUTES { #define OPEN_ALWAYS 4 #define TRUNCATE_EXISTING 5 -#define FILE_ATTRIBUTE_READONLY 0x00000001 -#define FILE_ATTRIBUTE_HIDDEN 0x00000002 -#define FILE_ATTRIBUTE_SYSTEM 0x00000004 -#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 -#define FILE_ATTRIBUTE_ARCHIVE 0x00000020 -#define FILE_ATTRIBUTE_DEVICE 0x00000040 #define FILE_ATTRIBUTE_NORMAL 0x00000080 #define FILE_FLAG_WRITE_THROUGH 0x80000000 @@ -561,13 +551,6 @@ GetFullPathNameW( #define GetFullPathName GetFullPathNameA #endif -PALIMPORT -DWORD -PALAPI -GetTempPathW( - IN DWORD nBufferLength, - OUT LPWSTR lpBuffer); - PALIMPORT DWORD PALAPI @@ -575,13 +558,6 @@ GetTempPathA( IN DWORD nBufferLength, OUT LPSTR lpBuffer); - -#ifdef UNICODE -#define GetTempPath GetTempPathW -#else -#define GetTempPath GetTempPathA -#endif - PALIMPORT DWORD PALAPI @@ -614,7 +590,6 @@ GetCurrentThread(); typedef struct _STARTUPINFOW STARTUPINFOW, *LPSTARTUPINFOW; typedef STARTUPINFOW STARTUPINFO; -typedef LPSTARTUPINFOW LPSTARTUPINFO; typedef struct _PROCESS_INFORMATION PROCESS_INFORMATION, *PPROCESS_INFORMATION, *LPPROCESS_INFORMATION; @@ -659,8 +634,6 @@ BOOL PALAPI SwitchToThread(); -#define DEBUG_PROCESS 0x00000001 -#define DEBUG_ONLY_THIS_PROCESS 0x00000002 #define CREATE_SUSPENDED 0x00000004 #define STACK_SIZE_PARAM_IS_A_RESERVATION 0x00010000 @@ -754,8 +727,6 @@ typedef struct _FLOATING_SAVE_AREA { DWORD Cr0NpxState; } FLOATING_SAVE_AREA; -typedef FLOATING_SAVE_AREA *PFLOATING_SAVE_AREA; - typedef struct _CONTEXT { ULONG ContextFlags; @@ -790,15 +761,6 @@ typedef struct _CONTEXT { UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]; } CONTEXT, *PCONTEXT, *LPCONTEXT; -// To support saving and loading xmm register context we need to know the offset in the ExtendedRegisters -// section at which they are stored. This has been determined experimentally since I have found no -// documentation thus far but it corresponds to the offset we'd expect if a fxsave instruction was used to -// store the regular FP state along with the XMM registers at the start of the extended registers section. -// Technically the offset doesn't really matter if no code in the PAL or runtime knows what the offset should -// be either (as long as we're consistent across GetThreadContext() and SetThreadContext() and we don't -// support any other values in the ExtendedRegisters) but we might as well be as accurate as we can. -#define CONTEXT_EXREG_XMM_OFFSET 160 - typedef struct _KNONVOLATILE_CONTEXT { DWORD Edi; @@ -1376,9 +1338,6 @@ typedef struct _IMAGE_ARM_RUNTIME_FUNCTION_ENTRY { // Define initial Cpsr/Fpscr value // -#define INITIAL_CPSR 0x10 -#define INITIAL_FPSCR 0 - // begin_ntoshvp // @@ -1574,9 +1533,6 @@ typedef union IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA { // however, almost no one implements more than 4 of each. // -#define LOONGARCH64_MAX_BREAKPOINTS 8 -#define LOONGARCH64_MAX_WATCHPOINTS 2 - typedef struct DECLSPEC_ALIGN(16) _CONTEXT { // @@ -1694,9 +1650,6 @@ typedef struct _KNONVOLATILE_CONTEXT_POINTERS { // however, almost no one implements more than 4 of each. // -#define RISCV64_MAX_BREAKPOINTS 8 -#define RISCV64_MAX_WATCHPOINTS 2 - typedef struct DECLSPEC_ALIGN(16) _CONTEXT { // @@ -2497,24 +2450,14 @@ WideCharToMultiByte( #define EXCEPTION_NESTED_CALL 0x10 // Nested exception handler call #define EXCEPTION_TARGET_UNWIND 0x20 // Target unwind in progress #define EXCEPTION_COLLIDED_UNWIND 0x40 // Collided exception handler call -#define EXCEPTION_SKIP_VEH 0x200 #define EXCEPTION_UNWIND (EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND | \ EXCEPTION_TARGET_UNWIND | EXCEPTION_COLLIDED_UNWIND) -#define IS_DISPATCHING(Flag) ((Flag & EXCEPTION_UNWIND) == 0) -#define IS_UNWINDING(Flag) ((Flag & EXCEPTION_UNWIND) != 0) -#define IS_TARGET_UNWIND(Flag) (Flag & EXCEPTION_TARGET_UNWIND) - #define EXCEPTION_IS_SIGNAL 0x100 #define EXCEPTION_MAXIMUM_PARAMETERS 15 -// Index in the ExceptionInformation array where we will keep the reference -// to the native exception that needs to be deleted when dispatching -// exception in managed code. -#define NATIVE_EXCEPTION_ASYNC_SLOT (EXCEPTION_MAXIMUM_PARAMETERS-1) - typedef struct _EXCEPTION_RECORD { DWORD ExceptionCode; DWORD ExceptionFlags; @@ -2553,14 +2496,7 @@ typedef struct _RUNTIME_FUNCTION { } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION; #endif // HOST_ARM64 -#define STANDARD_RIGHTS_REQUIRED (0x000F0000L) #define SYNCHRONIZE (0x00100000L) -#define READ_CONTROL (0x00020000L) -#define MAXIMUM_ALLOWED (0x02000000L) - -#define MUTANT_QUERY_STATE (0x0001) -#define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | MUTANT_QUERY_STATE) -#define MUTEX_ALL_ACCESS MUTANT_ALL_ACCESS PALIMPORT VOID @@ -2920,8 +2856,6 @@ Define_InterlockMethod( __sync_sub_and_fetch(lpAddend, (LONG)1) ) -#define InterlockedDecrementRelease InterlockedDecrement - Define_InterlockMethod( LONGLONG, InterlockedDecrement64(IN OUT LONGLONG volatile *lpAddend), @@ -3238,12 +3172,8 @@ GetSystemInfo( // // The types of events that can be logged. // -#define EVENTLOG_SUCCESS 0x0000 #define EVENTLOG_ERROR_TYPE 0x0001 -#define EVENTLOG_WARNING_TYPE 0x0002 #define EVENTLOG_INFORMATION_TYPE 0x0004 -#define EVENTLOG_AUDIT_SUCCESS 0x0008 -#define EVENTLOG_AUDIT_FAILURE 0x0010 #if defined FEATURE_PAL_ANSI #include "palprivate.h" @@ -3288,7 +3218,6 @@ PALIMPORT WCHAR * __cdecl PAL_wcscpy(WCHAR *, const WCHAR *); PALIMPORT WCHAR * __cdecl PAL_wcsncpy(WCHAR *, const WCHAR *, size_t); PALIMPORT DLLEXPORT const WCHAR * __cdecl PAL_wcschr(const WCHAR *, WCHAR); PALIMPORT DLLEXPORT const WCHAR * __cdecl PAL_wcsrchr(const WCHAR *, WCHAR); -PALIMPORT WCHAR _WConst_return * __cdecl PAL_wcspbrk(const WCHAR *, const WCHAR *); PALIMPORT DLLEXPORT WCHAR _WConst_return * __cdecl PAL_wcsstr(const WCHAR *, const WCHAR *); PALIMPORT DLLEXPORT ULONG __cdecl PAL_wcstoul(const WCHAR *, WCHAR **, int); PALIMPORT DLLEXPORT ULONGLONG __cdecl PAL__wcstoui64(const WCHAR *, WCHAR **, int); @@ -3322,8 +3251,6 @@ inline WCHAR *PAL_wcschr(WCHAR* S, WCHAR C) {return ((WCHAR *)PAL_wcschr((const WCHAR *)S, C)); } inline WCHAR *PAL_wcsrchr(WCHAR* S, WCHAR C) {return ((WCHAR *)PAL_wcsrchr((const WCHAR *)S, C)); } -inline WCHAR *PAL_wcspbrk(WCHAR* S, const WCHAR* P) - {return ((WCHAR *)PAL_wcspbrk((const WCHAR *)S, P)); } inline WCHAR *PAL_wcsstr(WCHAR* S, const WCHAR* P) {return ((WCHAR *)PAL_wcsstr((const WCHAR *)S, P)); } } @@ -3372,7 +3299,6 @@ unsigned int __cdecl _rotr(unsigned int value, int shift) #endif // !__has_builtin(_rotr) PALIMPORT DLLEXPORT char * __cdecl PAL_getenv(const char *); -PALIMPORT DLLEXPORT int __cdecl _putenv(const char *); #ifndef ERANGE #define ERANGE 34 @@ -3414,8 +3340,6 @@ PAL_SEHException TargetIp = ex.TargetIp; RecordsOnStack = ex.RecordsOnStack; IsExternal = ex.IsExternal; - ManagedToNativeExceptionCallback = ex.ManagedToNativeExceptionCallback; - ManagedToNativeExceptionCallbackContext = ex.ManagedToNativeExceptionCallbackContext; ex.Clear(); } @@ -3441,9 +3365,6 @@ PAL_SEHException // the well known runtime helpers bool IsExternal; - void(*ManagedToNativeExceptionCallback)(void* context); - void* ManagedToNativeExceptionCallbackContext; - PAL_SEHException(EXCEPTION_RECORD *pExceptionRecord, CONTEXT *pContextRecord, bool onStack = false) { ExceptionPointers.ExceptionRecord = pExceptionRecord; @@ -3452,8 +3373,6 @@ PAL_SEHException TargetIp = 0; RecordsOnStack = onStack; IsExternal = false; - ManagedToNativeExceptionCallback = NULL; - ManagedToNativeExceptionCallbackContext = NULL; } PAL_SEHException() @@ -3492,8 +3411,6 @@ PAL_SEHException TargetIp = 0; RecordsOnStack = false; IsExternal = false; - ManagedToNativeExceptionCallback = NULL; - ManagedToNativeExceptionCallbackContext = NULL; } bool HasTargetFrame() @@ -3510,19 +3427,6 @@ PAL_SEHException { return ExceptionPointers.ExceptionRecord; } - - bool HasPropagateExceptionCallback() - { - return ManagedToNativeExceptionCallback != NULL; - } - - void SetPropagateExceptionCallback( - void(*callback)(void*), - void* context) - { - ManagedToNativeExceptionCallback = callback; - ManagedToNativeExceptionCallbackContext = context; - } }; typedef BOOL (*PHARDWARE_EXCEPTION_HANDLER)(PAL_SEHException* ex); @@ -3665,8 +3569,6 @@ class CatchHardwareExceptionHolder #define PAL_CPP_THROW(type, obj) { throw obj; } #define PAL_CPP_RETHROW { throw; } #define PAL_CPP_TRY try { HardwareExceptionHolder -#define PAL_CPP_CATCH_EXCEPTION(ident) } catch (Exception *ident) { -#define PAL_CPP_CATCH_EXCEPTION_NOARG } catch (Exception *) { #define PAL_CPP_CATCH_DERIVED(type, ident) } catch (type *ident) { #define PAL_CPP_CATCH_NON_DERIVED(type, ident) } catch (type ident) { #define PAL_CPP_CATCH_NON_DERIVED_NOARG(type) } catch (type) { @@ -3693,7 +3595,6 @@ class CatchHardwareExceptionHolder #define MAKEDLLNAME(x) MAKEDLLNAME_A(x) #endif -#define PAL_SHLIB_PREFIX "lib" #define PAL_SHLIB_PREFIX_W u"lib" #if __APPLE__ @@ -3704,19 +3605,12 @@ class CatchHardwareExceptionHolder #define PAL_SHLIB_SUFFIX_W u".so" #endif -#define DBG_EXCEPTION_HANDLED ((DWORD )0x00010001L) #define DBG_CONTINUE ((DWORD )0x00010002L) #define DBG_EXCEPTION_NOT_HANDLED ((DWORD )0x80010001L) -#define DBG_TERMINATE_THREAD ((DWORD )0x40010003L) -#define DBG_TERMINATE_PROCESS ((DWORD )0x40010004L) #define DBG_CONTROL_C ((DWORD )0x40010005L) -#define DBG_RIPEXCEPTION ((DWORD )0x40010007L) -#define DBG_CONTROL_BREAK ((DWORD )0x40010008L) -#define DBG_COMMAND_EXCEPTION ((DWORD )0x40010009L) #define STATUS_USER_APC ((DWORD )0x000000C0L) -#define STATUS_GUARD_PAGE_VIOLATION ((DWORD )0x80000001L) #define STATUS_DATATYPE_MISALIGNMENT ((DWORD )0x80000002L) #define STATUS_BREAKPOINT ((DWORD )0x80000003L) #define STATUS_SINGLE_STEP ((DWORD )0x80000004L) @@ -3724,7 +3618,6 @@ class CatchHardwareExceptionHolder #define STATUS_UNWIND_CONSOLIDATE ((DWORD )0x80000029L) #define STATUS_ACCESS_VIOLATION ((DWORD )0xC0000005L) #define STATUS_IN_PAGE_ERROR ((DWORD )0xC0000006L) -#define STATUS_INVALID_HANDLE ((DWORD )0xC0000008L) #define STATUS_NO_MEMORY ((DWORD )0xC0000017L) #define STATUS_ILLEGAL_INSTRUCTION ((DWORD )0xC000001DL) #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD )0xC0000025L) @@ -3741,7 +3634,6 @@ class CatchHardwareExceptionHolder #define STATUS_INTEGER_OVERFLOW ((DWORD )0xC0000095L) #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD )0xC0000096L) #define STATUS_STACK_OVERFLOW ((DWORD )0xC00000FDL) -#define STATUS_CONTROL_C_EXIT ((DWORD )0xC000013AL) #define WAIT_IO_COMPLETION STATUS_USER_APC @@ -3755,7 +3647,6 @@ class CatchHardwareExceptionHolder #define EXCEPTION_FLT_INEXACT_RESULT STATUS_FLOAT_INEXACT_RESULT #define EXCEPTION_FLT_INVALID_OPERATION STATUS_FLOAT_INVALID_OPERATION #define EXCEPTION_FLT_OVERFLOW STATUS_FLOAT_OVERFLOW -#define EXCEPTION_FLT_STACK_CHECK STATUS_FLOAT_STACK_CHECK #define EXCEPTION_FLT_UNDERFLOW STATUS_FLOAT_UNDERFLOW #define EXCEPTION_INT_DIVIDE_BY_ZERO STATUS_INTEGER_DIVIDE_BY_ZERO #define EXCEPTION_INT_OVERFLOW STATUS_INTEGER_OVERFLOW @@ -3765,10 +3656,6 @@ class CatchHardwareExceptionHolder #define EXCEPTION_NONCONTINUABLE_EXCEPTION STATUS_NONCONTINUABLE_EXCEPTION #define EXCEPTION_STACK_OVERFLOW STATUS_STACK_OVERFLOW #define EXCEPTION_INVALID_DISPOSITION STATUS_INVALID_DISPOSITION -#define EXCEPTION_GUARD_PAGE STATUS_GUARD_PAGE_VIOLATION -#define EXCEPTION_INVALID_HANDLE STATUS_INVALID_HANDLE - -#define CONTROL_C_EXIT STATUS_CONTROL_C_EXIT /******************* HRESULT types ****************************************/ diff --git a/src/coreclr/pal/src/cruntime/wchar.cpp b/src/coreclr/pal/src/cruntime/wchar.cpp index 959ebd6f576fb5..aa44b2adc87ef8 100644 --- a/src/coreclr/pal/src/cruntime/wchar.cpp +++ b/src/coreclr/pal/src/cruntime/wchar.cpp @@ -2,15 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - Module Name: - wchar.c Abstract: - Implementation of wide char string functions. - --*/ #include "pal/palinternal.h" @@ -637,41 +633,6 @@ PAL_wcsrchr( } -/*++ -Function: - PAL_wcspbrk - -See MSDN or man page for wcspbrk. ---*/ -const wchar_16 * -__cdecl -PAL_wcspbrk( - const wchar_16 *string, - const wchar_16 *strCharSet) -{ - PERF_ENTRY(wcspbrk); - ENTRY("wcspbrk (string=%p (%S), strCharSet=%p (%S))\n", - string?string:W16_NULLSTRING, - string?string:W16_NULLSTRING, strCharSet?strCharSet:W16_NULLSTRING, strCharSet?strCharSet:W16_NULLSTRING); - - while (*string) - { - if (PAL_wcschr(strCharSet, *string) != NULL) - { - LOGEXIT("wcspbrk returning wchar_t %p (%S)\n", string, string); - PERF_EXIT(wcspbrk); - return (wchar_16 *) string; - } - - string++; - } - - LOGEXIT("wcspbrk returning wchar_t NULL\n"); - PERF_EXIT(wcspbrk); - return NULL; -} - - /*++ Function: PAL_wcsstr diff --git a/src/coreclr/pal/src/debug/debug.cpp b/src/coreclr/pal/src/debug/debug.cpp index ec690bfc4c4beb..8b53535e32cb03 100644 --- a/src/coreclr/pal/src/debug/debug.cpp +++ b/src/coreclr/pal/src/debug/debug.cpp @@ -2,24 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - - - Module Name: - debug.c Abstract: - Implementation of Win32 debugging API functions. - -Revision History: - - - --*/ - #include "pal/dbgmsg.h" SET_DEFAULT_DEBUG_CHANNEL(DEBUG); // some headers have code with asserts, so do this first @@ -77,12 +66,6 @@ using namespace CorUnix; extern "C" void DBG_DebugBreak_End(); -#if HAVE_PROCFS_CTL -#define CTL_ATTACH "attach" -#define CTL_DETACH "detach" -#define CTL_WAIT "wait" -#endif // HAVE_PROCFS_CTL - /* ------------------- Constant definitions ----------------------------------*/ #if !HAVE_VM_READ && !HAVE_PROCFS_CTL @@ -365,7 +348,7 @@ DebugBreakCommand() variables in the child process, but if we do that we can't check for errors. putenv/setenv can fail when out of memory */ - if (!EnvironPutenv (pid_buf, FALSE) || !EnvironPutenv (exe_buf, FALSE)) + if (!EnvironPutenv (pid_buf) || !EnvironPutenv (exe_buf)) { goto FAILED; } diff --git a/src/coreclr/pal/src/exception/machexception.h b/src/coreclr/pal/src/exception/machexception.h index 7099c9ba351683..0c1e96343515ae 100644 --- a/src/coreclr/pal/src/exception/machexception.h +++ b/src/coreclr/pal/src/exception/machexception.h @@ -2,14 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - Module Name: - machexception.h Abstract: Private mach exception handling utilities for SEH - --*/ #ifndef _MACHEXCEPTION_H_ @@ -33,7 +30,6 @@ extern "C" // Process and thread initialization/cleanup/context routines BOOL SEHInitializeMachExceptions(DWORD flags); -void MachExceptionInitializeDebug(void); PAL_NORETURN void MachSetThreadContext(CONTEXT *lpContext); #ifdef __cplusplus @@ -41,4 +37,3 @@ PAL_NORETURN void MachSetThreadContext(CONTEXT *lpContext); #endif // __cplusplus #endif /* _MACHEXCEPTION_H_ */ - diff --git a/src/coreclr/pal/src/exception/machmessage.cpp b/src/coreclr/pal/src/exception/machmessage.cpp index 96fbd08bd0aea6..2e288203c8cd5e 100644 --- a/src/coreclr/pal/src/exception/machmessage.cpp +++ b/src/coreclr/pal/src/exception/machmessage.cpp @@ -2,15 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - Module Name: - machmessage.cpp Abstract: - Abstraction over Mach messages used during exception handling. - --*/ #include "config.h" @@ -393,25 +389,6 @@ mach_msg_type_number_t MachMessage::GetThreadState(thread_state_flavor_t eFlavor return count; } -// Fetch the return code from a reply type message. -kern_return_t MachMessage::GetReturnCode() -{ - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_REPLY_64_MESSAGE_ID: - return m_pMessage->data.raise_reply_64.ret; - - case EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID: - return m_pMessage->data.raise_state_reply_64.ret; - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID: - return m_pMessage->data.raise_state_identity_reply_64.ret; - - default: - NONPAL_RETAIL_ASSERT("Unsupported message type: %u", m_pMessage->header.msgh_id); - } -} - // Initialize and send a request to set the register context of a particular thread. void MachMessage::SendSetThread(mach_port_t hServerPort, CONTEXT *pContext) { diff --git a/src/coreclr/pal/src/exception/machmessage.h b/src/coreclr/pal/src/exception/machmessage.h index e82e1c808d88ff..c403dd420e6788 100644 --- a/src/coreclr/pal/src/exception/machmessage.h +++ b/src/coreclr/pal/src/exception/machmessage.h @@ -2,15 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - Module Name: - machmessage.h Abstract: - Abstraction over Mach messages used during exception handling. - --*/ #include @@ -165,9 +161,6 @@ class MachMessage // exception messages or passed explicitly for reply messages). mach_msg_type_number_t GetThreadState(thread_state_flavor_t eFlavor, thread_state_t pState, thread_act_t thread = NULL); - // Fetch the return code from a reply type message. - kern_return_t GetReturnCode(); - // Initialize and send a request to set the register context of a particular thread. void SendSetThread(mach_port_t hServerPort, CONTEXT *pContext); diff --git a/src/coreclr/pal/src/file/file.cpp b/src/coreclr/pal/src/file/file.cpp index 30b16e472b1944..f7e524d1152408 100644 --- a/src/coreclr/pal/src/file/file.cpp +++ b/src/coreclr/pal/src/file/file.cpp @@ -2,15 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - Module Name: - file.cpp Abstract: - Implementation of the file WIN API for the PAL - --*/ #include "pal/dbgmsg.h" @@ -2008,12 +2004,6 @@ FlushFileBuffers( return NO_ERROR == palError; } -#define ENSURE_UNIQUE_NOT_ZERO \ - if ( uUniqueSeed == 0 ) \ - {\ - uUniqueSeed++;\ - } - /*++ Function: FILEGetLastErrorFromErrno diff --git a/src/coreclr/pal/src/file/path.cpp b/src/coreclr/pal/src/file/path.cpp index 671180397f8abc..ff4e0dad2542a8 100644 --- a/src/coreclr/pal/src/file/path.cpp +++ b/src/coreclr/pal/src/file/path.cpp @@ -2,21 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - - - Module Name: - path.c Abstract: - Implementation of all functions related to path support - -Revision History: - - - --*/ #include "pal/thread.hpp" @@ -372,114 +362,6 @@ GetTempPathA( return dwPathLen; } -/*++ -Function: - GetTempPathW - -See MSDN. -See also the comment for GetTempPathA. ---*/ -DWORD -PALAPI -GetTempPathW( - IN DWORD nBufferLength, - OUT LPWSTR lpBuffer) -{ - PERF_ENTRY(GetTempPathW); - ENTRY("GetTempPathW(nBufferLength=%u, lpBuffer=%p)\n", - nBufferLength, lpBuffer); - - if (!lpBuffer) - { - ERROR("lpBuffer was not a valid pointer.\n") - SetLastError(ERROR_INVALID_PARAMETER); - LOGEXIT("GetTempPathW returns DWORD 0\n"); - PERF_EXIT(GetTempPathW); - return 0; - } - - char* tempBuffer = (char*)alloca(nBufferLength > 0 ? nBufferLength : 1); - DWORD dwRetVal = GetTempPathA( nBufferLength, tempBuffer ); - - if ( dwRetVal >= nBufferLength ) - { - ERROR( "lpBuffer was not large enough.\n" ) - SetLastError( ERROR_INSUFFICIENT_BUFFER ); - *lpBuffer = '\0'; - } - else if ( dwRetVal != 0 ) - { - /* Convert to wide. */ - if ( 0 == MultiByteToWideChar( CP_ACP, 0, tempBuffer, -1, - lpBuffer, dwRetVal + 1 ) ) - { - ASSERT( "An error occurred while converting the string to wide.\n" ); - SetLastError( ERROR_INTERNAL_ERROR ); - dwRetVal = 0; - } - } - else - { - ERROR( "The function failed.\n" ); - *lpBuffer = '\0'; - } - - LOGEXIT("GetTempPathW returns DWORD %u\n", dwRetVal ); - PERF_EXIT(GetTempPathW); - return dwRetVal; -} - - -/*++ -Function: - FILEGetDirectoryFromFullPathA - -Parse the given path. If it contains a directory part and a file part, -put the directory part into the supplied buffer, and return the number of -characters written to the buffer. If the buffer is not large enough, -return the required size of the buffer including the NULL character. If -there is no directory part in the path, return 0. ---*/ -DWORD FILEGetDirectoryFromFullPathA( LPCSTR lpFullPath, - DWORD nBufferLength, - LPSTR lpBuffer ) -{ - size_t full_len, dir_len, i; - LPCSTR lpDirEnd; - DWORD dwRetLength; - - full_len = strlen( lpFullPath ); - - /* look for the first path separator backwards */ - lpDirEnd = lpFullPath + full_len - 1; - while( lpDirEnd >= lpFullPath && *lpDirEnd != '/') - --lpDirEnd; - - dir_len = lpDirEnd - lpFullPath + 1; /* +1 for fencepost */ - - if ( dir_len <= 0 ) - { - dwRetLength = 0; - } - else if (dir_len >= nBufferLength) - { - dwRetLength = dir_len + 1; /* +1 for NULL char */ - } - else - { - /* put the directory into the buffer, including 1 or more - trailing path separators */ - for( i = 0; i < dir_len; ++i ) - *(lpBuffer + i) = *(lpFullPath + i); - - *(lpBuffer + i) = '\0'; - - dwRetLength = dir_len; - } - - return( dwRetLength ); -} - /*++ FILECanonicalizePath Removes all instances of '/./', '/../' and '//' from an absolute path. diff --git a/src/coreclr/pal/src/include/pal/dbgmsg.h b/src/coreclr/pal/src/include/pal/dbgmsg.h index 0d0c5e4aed4cee..4103f2c54c8529 100644 --- a/src/coreclr/pal/src/include/pal/dbgmsg.h +++ b/src/coreclr/pal/src/include/pal/dbgmsg.h @@ -2,17 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - - - Module Name: - include/pal/dbgmsg.h Abstract: Header file for Debug Message utilities. Output macros, type definitions, extern variables. See overview section below for usage details. - --*/ /* @@ -39,7 +34,7 @@ Available macros : usage : TRACE("printf format string", params...); - - TRACE_, ENTRY_, WARN_, ERROR_, DBGOUT_ + - TRACE_, ERROR_ Use this to autput debug messages to a channel other than the default. @@ -144,9 +139,6 @@ Using Debug channels at Run Time Normally, if the file specified by PAL_API_TRACING exists, its content will be overwritten when a PAL process starts using it. If --enable-appendtraces is used, debug output will be appended at the end of the file instead. - - - */ #ifndef _PAL_DBGMSG_H_ @@ -234,14 +226,10 @@ extern Volatile dbg_master_switch ; #define TRACE NOTRACE #define TRACE_(x) NOTRACE #define WARN NOTRACE -#define WARN_(x) NOTRACE #define ENTRY_EXTERNAL NOTRACE #define ENTRY NOTRACE -#define ENTRY_(x) NOTRACE #define LOGEXIT NOTRACE -#define LOGEXIT_(x) NOTRACE #define DBGOUT NOTRACE -#define DBGOUT_(x) NOTRACE #define ERROR NOTRACE #define ERROR_(x) NOTRACE #define DBG_PRINTF(level, channel, bHeader) NOTRACE @@ -271,9 +259,6 @@ extern Volatile dbg_master_switch ; #define WARN \ DBG_PRINTF(DLI_WARN,defdbgchan,TRUE) -#define WARN_(x) \ - DBG_PRINTF(DLI_WARN,DCI_##x,TRUE) - #if _DEBUG && defined(__APPLE__) bool DBG_ShouldCheckStackAlignment(); #define CHECK_STACK_ALIGN if (DBG_ShouldCheckStackAlignment()) DBG_CheckStackAlignment() @@ -289,22 +274,12 @@ bool DBG_ShouldCheckStackAlignment(); CHECK_STACK_ALIGN; \ DBG_PRINTF(DLI_ENTRY, defdbgchan,TRUE) -#define ENTRY_(x) \ - CHECK_STACK_ALIGN; \ - DBG_PRINTF(DLI_ENTRY, DCI_##x,TRUE) - #define LOGEXIT \ DBG_PRINTF(DLI_EXIT, defdbgchan,TRUE) -#define LOGEXIT_(x) \ - DBG_PRINTF(DLI_EXIT, DCI_##x,TRUE) - #define DBGOUT \ DBG_PRINTF(DLI_TRACE,defdbgchan,FALSE) -#define DBGOUT_(x) \ - DBG_PRINTF(DLI_TRACE,DCI_##x,FALSE) - /*Added this code here to stop error messages *from appearing in retail build*/ #define ERROR \ @@ -383,43 +358,6 @@ Function : --*/ BOOL DBG_init_channels(void); -/*++ -Function : - DBG_close_channels - - Close the output file for debug messages. - - (no parameters, no return value) ---*/ -void DBG_close_channels(void); - -/*++ -Function : - DBG_preprintf - - Internal function for debug channels; don't use. - This function outputs the header information for debug messages (channel, - level, etc). - -Parameters : - DBG_CHANNEL_ID channel : debug channel to use - DBG_LEVEL_ID level : debug message level - BOOL bHeader : whether or not to output message header (thread id, etc) - LPSTR file : current file - INT line : line number - -Return Value : - TRUE if there's an output file, FALSE otherwise. this is so that - DBG_printf_plain doesn't get called unnecessarily. - -Notes : - This function is only used with compilers that don't support - variable-argument macros. It enters a critical section, which is left in - DBG_printf_plain. ---*/ -BOOL DBG_preprintf(DBG_CHANNEL_ID channel, DBG_LEVEL_ID level, BOOL bHeader, - LPSTR file, INT line); - /*++ Function : DBG_printf @@ -456,27 +394,6 @@ int DBG_printf(DBG_CHANNEL_ID channel, DBG_LEVEL_ID level, BOOL bHeader, LPCSTR function, LPCSTR file, INT line, LPCSTR format, ...); #endif -/*++ -Function : - DBG_printf_plain - - Internal function for debug channels; don't use. - This function output the user-specified part of a debug-message. - -Parameters : - LPSTR format, ... : standard printf parameter list. - -Return value : - always 1. - -Notes : - This function is only used with compilers that don't support - variable-argument macros. It will leave the critical section entered in - DBG_preprintf. - ---*/ -int DBG_printf_plain(LPSTR format, ...); - /*++ Function : DBG_change_entrylevel @@ -524,5 +441,3 @@ void PAL_DisplayDialogFormatted(const char *szTitle, const char *szTextFormat, . #endif // __cplusplus #endif /* _PAL_DBGMSG_H_ */ - - diff --git a/src/coreclr/pal/src/include/pal/environ.h b/src/coreclr/pal/src/include/pal/environ.h index 14262470c4474d..77e58d3d140d27 100644 --- a/src/coreclr/pal/src/include/pal/environ.h +++ b/src/coreclr/pal/src/include/pal/environ.h @@ -2,17 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - - - Module Name: - include/pal/environ.h Abstract: Header file for functions manipulating environment variables - - --*/ #ifndef __ENVIRON_H_ @@ -60,7 +54,7 @@ char *EnvironGetenv(const char *name, BOOL copyValue = TRUE); Add the environment variable string provided to the PAL version of the environment. --*/ -BOOL EnvironPutenv(const char *string, BOOL deleteIfEmpty); +BOOL EnvironPutenv(const char *string); /*++ Function: @@ -76,4 +70,3 @@ void EnvironUnsetenv(const char *name); #endif // __cplusplus #endif /* __ENVIRON_H_ */ - diff --git a/src/coreclr/pal/src/include/pal/file.h b/src/coreclr/pal/src/include/pal/file.h index 2598b664d18dc6..399c42cff18466 100644 --- a/src/coreclr/pal/src/include/pal/file.h +++ b/src/coreclr/pal/src/include/pal/file.h @@ -59,20 +59,6 @@ Notes : --*/ void FILECanonicalizePath(LPSTR lpUnixPath); -/*++ -Function: - FILEGetDirectoryFromFullPathA - -Parse the given path. If it contains a directory part and a file part, -put the directory part into the supplied buffer, and return the number of -characters written to the buffer. If the buffer is not large enough, -return the required size of the buffer including the NULL character. If -there is no directory part in the path, return 0. ---*/ -DWORD FILEGetDirectoryFromFullPathA( LPCSTR lpFullPath, - DWORD nBufferLength, - LPSTR lpBuffer ); - /*++ Function: FILEGetLastErrorFromErrno @@ -119,4 +105,3 @@ void FILEGetProperNotFoundError( LPCSTR lpPath, LPDWORD lpErrorCode ); #endif // __cplusplus #endif /* _PAL_FILE_H_ */ - diff --git a/src/coreclr/pal/src/include/pal/file.hpp b/src/coreclr/pal/src/include/pal/file.hpp index 9f162b70ff4934..f7b36f01572d90 100644 --- a/src/coreclr/pal/src/include/pal/file.hpp +++ b/src/coreclr/pal/src/include/pal/file.hpp @@ -165,20 +165,6 @@ Notes : --*/ void FILECanonicalizePath(LPSTR lpUnixPath); -/*++ -Function: - FILEGetDirectoryFromFullPathA - -Parse the given path. If it contains a directory part and a file part, -put the directory part into the supplied buffer, and return the number of -characters written to the buffer. If the buffer is not large enough, -return the required size of the buffer including the NULL character. If -there is no directory part in the path, return 0. ---*/ -DWORD FILEGetDirectoryFromFullPathA( LPCSTR lpFullPath, - DWORD nBufferLength, - LPSTR lpBuffer ); - /*++ Function: FILEGetLastErrorFromErrno @@ -215,4 +201,3 @@ void FILEGetProperNotFoundError( LPCSTR lpPath, LPDWORD lpErrorCode ); } #endif /* _PAL_FILE_HPP_ */ - diff --git a/src/coreclr/pal/src/include/pal/init.h b/src/coreclr/pal/src/include/pal/init.h index 1ab428de9e3082..cbda34b9fe1fe3 100644 --- a/src/coreclr/pal/src/include/pal/init.h +++ b/src/coreclr/pal/src/include/pal/init.h @@ -2,21 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - - - Module Name: - include/pal/init.h Abstract: Header file for PAL init utility functions. Those functions are only use by the PAL itself. - -Revision History: - - - --*/ #ifndef _PAL_INIT_H_ @@ -27,15 +18,6 @@ extern "C" { #endif // __cplusplus -/*++ -Function: - PALCommonCleanup - -Utility function to prepare for shutdown. - ---*/ -void PALCommonCleanup(); - extern Volatile init_count; extern SIZE_T g_defaultStackSize; @@ -67,24 +49,6 @@ Returns TRUE if startup has reached a point where thread data is available BOOL PALIsThreadDataInitialized(); -/*++ -Function: - PALIsShuttingDown - -Returns TRUE if the some thread has declared intent to shutdown ---*/ -BOOL -PALIsShuttingDown(); - -/*++ -Function: - PALSetShutdownIntent - -Delcares intent to shutdown ---*/ -void -PALSetShutdownIntent(); - /*++ Function: PALInitLock @@ -100,16 +64,6 @@ Return value : --*/ BOOL PALInitLock(void); -/*++ -Function: - PALInitUnlock - -Release the initialization critical section (init_critsec). - -(no parameters, no return value) ---*/ -void PALInitUnlock(void); - #ifdef __cplusplus } #endif // __cplusplus diff --git a/src/coreclr/pal/src/include/pal/list.h b/src/coreclr/pal/src/include/pal/list.h index 78c840969021cf..c0cf3fb6ef7c73 100644 --- a/src/coreclr/pal/src/include/pal/list.h +++ b/src/coreclr/pal/src/include/pal/list.h @@ -2,21 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - - - Module Name: - list.h Abstract: - Doubly-linked list manipulation macros (from ntrtl.h) - -Revision History: - - - --*/ #ifndef _LIST_H_INCLUDED @@ -62,10 +52,6 @@ typedef struct _LIST_ENTRY { // ); // -#define RemoveHeadList(ListHead) \ - (ListHead)->Flink;\ - {RemoveEntryList((ListHead)->Flink)} - // // PLIST_ENTRY // RemoveTailList( @@ -120,17 +106,6 @@ typedef struct _LIST_ENTRY { // ); // -#define InsertHeadList(ListHead,Entry) {\ - PLIST_ENTRY _EX_Flink;\ - PLIST_ENTRY _EX_ListHead;\ - _EX_ListHead = (ListHead);\ - _EX_Flink = _EX_ListHead->Flink;\ - (Entry)->Flink = _EX_Flink;\ - (Entry)->Blink = _EX_ListHead;\ - _EX_Flink->Blink = (Entry);\ - _EX_ListHead->Flink = (Entry);\ - } - #define CONTAINING_RECORD(address, type, field) ((type *)( \ (PCHAR)(address) - \ (ULONG_PTR)offsetof(type, field))) @@ -140,4 +115,3 @@ typedef struct _LIST_ENTRY { #endif // __cplusplus #endif // _LIST_H_INCLUDED - diff --git a/src/coreclr/pal/src/include/pal/palinternal.h b/src/coreclr/pal/src/include/pal/palinternal.h index 871fb86ed65ddf..b76051e6e3bf5e 100644 --- a/src/coreclr/pal/src/include/pal/palinternal.h +++ b/src/coreclr/pal/src/include/pal/palinternal.h @@ -2,15 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - - - Module Name: - palinternal.h Abstract: - CoreCLR Platform Adaptation Layer (PAL) header file used by source file part of the PAL implementation. This is a wrapper over pal/inc/pal.h. It allows avoiding name collisions when including @@ -18,7 +13,6 @@ Module Name: to their PAL counterpart Details : - A] Rationale (see B] for the quick recipe) There are 2 types of namespace collisions that must be handled. @@ -132,9 +126,6 @@ When overriding a system function with the PAL's own implementation : - implement the function in the pal, naming it PAL_function_name - within the PAL, call PAL_function_name() to call the PAL's implementation, function_name() to call the system's implementation - - - --*/ #ifndef _PAL_INTERNAL_H_ @@ -230,8 +221,6 @@ function_name() to call the system's implementation #define TEMP_DIRECTORY_PATH "/data/local/tmp/" #endif -#define PROCESS_PIPE_NAME_PREFIX ".dotnet-pal-processpipe" - #ifdef __APPLE__ #define APPLICATION_CONTAINER_BASE_PATH_SUFFIX "/Library/Group Containers/" diff --git a/src/coreclr/pal/src/include/pal/process.h b/src/coreclr/pal/src/include/pal/process.h index 569ba156c0c6dd..0561760c9ca227 100644 --- a/src/coreclr/pal/src/include/pal/process.h +++ b/src/coreclr/pal/src/include/pal/process.h @@ -2,21 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - - - Module Name: - include/pal/process.h Abstract: - Miscellaneous process related functions. - -Revision History: - - - --*/ #ifndef _PAL_PROCESS_H_ @@ -54,26 +44,6 @@ extern int gApplicationGroupIdLength; #endif // __APPLE__ extern PathCharString *gSharedFilesPath; -/*++ -Function: - PROCCreateInitialProcess - -Abstract - Initialize all the structures for the initial process. - -Parameter - lpwstrCmdLine: Command line. - lpwstrFullPath : Full path to executable - -Return - TRUE: if successful - FALSE: otherwise - -Notes : - This function takes ownership of lpwstrCmdLine, but not of lpwstrFullPath ---*/ -BOOL PROCCreateInitialProcess(LPWSTR lpwstrCmdLine, LPWSTR lpwstrFullPath); - /*++ Function PROCAbortInitialize() diff --git a/src/coreclr/pal/src/include/pal/seh.hpp b/src/coreclr/pal/src/include/pal/seh.hpp index 5109eca56d79bd..14ca0c6d7acc93 100644 --- a/src/coreclr/pal/src/include/pal/seh.hpp +++ b/src/coreclr/pal/src/include/pal/seh.hpp @@ -2,18 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - - - Module Name: - include/pal/seh.hpp Abstract: Header file for public Structured Exception Handling stuff - - - --*/ #ifndef _PAL_SEH_HPP_ @@ -87,29 +80,6 @@ SEHProcessException(PAL_SEHException* exception); VOID AllocateExceptionRecords(EXCEPTION_RECORD** exceptionRecord, CONTEXT** contextRecord); -#if !HAVE_MACH_EXCEPTIONS -// TODO: Implement for Mach exceptions. Not in CoreCLR surface area. -/*++ -Function : - SEHHandleControlEvent - - handle Control-C and Control-Break events (call handler routines, - notify debugger) - -Parameters : - DWORD event : event that occurred - LPVOID eip : instruction pointer when exception occurred - -(no return value) - -Notes : - Handlers are called on a last-installed, first called basis, until a - handler returns TRUE. If no handler returns TRUE (or no hanlder is - installed), the default behavior is to call ExitProcess ---*/ -void SEHHandleControlEvent(DWORD event, LPVOID eip); -#endif // !HAVE_MACH_EXCEPTIONS - extern "C" { @@ -153,4 +123,3 @@ extern int g_hardware_exception_context_locvar_offset; extern int g_inject_activation_context_locvar_offset; #endif /* _PAL_SEH_HPP_ */ - diff --git a/src/coreclr/pal/src/include/pal/thread.hpp b/src/coreclr/pal/src/include/pal/thread.hpp index 7f9a905e22bb24..4b99a362381e59 100644 --- a/src/coreclr/pal/src/include/pal/thread.hpp +++ b/src/coreclr/pal/src/include/pal/thread.hpp @@ -2,18 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - - - Module Name: - include/pal/thread.hpp Abstract: Header file for thread structures - - - --*/ #ifndef _PAL_THREAD_HPP_ @@ -82,14 +75,6 @@ namespace CorUnix CPalThread *pThread ); - PAL_ERROR - InternalCreateDummyThread( - CPalThread *pThread, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - CPalThread **ppDummyThread, - HANDLE *phThread - ); - PAL_ERROR CreateThreadData( CPalThread **ppThread @@ -166,15 +151,6 @@ namespace CorUnix HANDLE* ); - friend - PAL_ERROR - InternalCreateDummyThread( - CPalThread *pThread, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - CPalThread **ppDummyThread, - HANDLE *phThread - ); - friend PAL_ERROR InternalSetThreadPriority( diff --git a/src/coreclr/pal/src/include/pal/utils.h b/src/coreclr/pal/src/include/pal/utils.h index ef6ff34010c596..c0ca7e93cdbbda 100644 --- a/src/coreclr/pal/src/include/pal/utils.h +++ b/src/coreclr/pal/src/include/pal/utils.h @@ -2,18 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - - - Module Name: - include/pal/utils.h Abstract: Miscellaneous helper functions for the PAL, which don't fit anywhere else - - - --*/ #ifndef _PAL_UTILS_H_ @@ -84,42 +77,6 @@ extern "C" { #endif // __cplusplus -/*++ -Function: - UTIL_inverse_wcspbrk - - Opposite of wcspbrk : searches a string for the first character NOT in the - given set - -Parameters : - LPWSTR lpwstr : string to search - LPCWSTR charset : list of characters to search for - -Return value : - pointer to first character of lpwstr that isn't in the set - NULL if all characters are in the set ---*/ -LPWSTR UTIL_inverse_wcspbrk(LPWSTR lpwstr, LPCWSTR charset); - -/*++ -Function : - UTIL_IsReadOnlyBitsSet - - Takes a struct stat * - Returns true if the file is read only, ---*/ -BOOL UTIL_IsReadOnlyBitsSet( struct stat * stat_data ); - -/*++ -Function : - UTIL_IsExecuteBitsSet - - Takes a struct stat * - Returns true if the file is executable. ---*/ -BOOL UTIL_IsExecuteBitsSet( struct stat * stat_data ); - - /*++ Function : UTIL_WCToMB_Alloc diff --git a/src/coreclr/pal/src/include/pal/wasi/pal_wasi_missing.h b/src/coreclr/pal/src/include/pal/wasi/pal_wasi_missing.h index a38bb37f286b17..0e0113e599953f 100644 --- a/src/coreclr/pal/src/include/pal/wasi/pal_wasi_missing.h +++ b/src/coreclr/pal/src/include/pal/wasi/pal_wasi_missing.h @@ -55,11 +55,4 @@ static inline int dladdr(const void *addr, Dl_info *info) return 0; } -// WASI has no user/group concept; PAL uses these only for st_uid/st_gid -// permission checks. Always-zero makes the owner-equals-process branches behave. -static inline uid_t getuid(void) { return 0; } -static inline uid_t geteuid(void) { return 0; } -static inline gid_t getgid(void) { return 0; } -static inline gid_t getegid(void) { return 0; } - #endif // _PAL_WASI_MISSING_H_ diff --git a/src/coreclr/pal/src/init/pal.cpp b/src/coreclr/pal/src/init/pal.cpp index 3b1cee417edc5e..71d0eba0f33775 100644 --- a/src/coreclr/pal/src/init/pal.cpp +++ b/src/coreclr/pal/src/init/pal.cpp @@ -2,15 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - Module Name: - init/pal.cpp Abstract: - Implementation of PAL exported functions not part of the Win32 API. - --*/ #include "pal/dbgmsg.h" @@ -100,7 +96,6 @@ bool g_arm64_atomics_present = false; #endif Volatile init_count = 0; -Volatile shutdown_intent = 0; Volatile g_coreclrInitialized = 0; static BOOL g_fThreadDataAvailable = FALSE; static pthread_mutex_t init_critsec_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -143,30 +138,6 @@ PAL_Initialize( return Initialize(PAL_INITIALIZE); } -/*++ -Function: - PAL_InitializeWithFlags - -Abstract: - This function is the first function of the PAL to be called. - Internal structure initialization is done here. It could be called - several time by the same process, a reference count is kept. - -Return: - 0 if successful - -1 if it failed - ---*/ -int -PALAPI -PAL_InitializeWithFlags( - int argc, - const char *const argv[], - DWORD flags) -{ - return Initialize(flags); -} - /*++ Function: PAL_InitializeDLL @@ -701,9 +672,6 @@ PAL_TerminateEx( LOGEXIT("PAL_Terminate returns.\n"); } - // Declare the beginning of shutdown - PALSetShutdownIntent(); - LOGEXIT("PAL_TerminateEx is exiting the current process.\n"); exit(exitCode); } @@ -719,46 +687,6 @@ BOOL PALIsThreadDataInitialized() return g_fThreadDataAvailable; } -/*++ -Function: - PALCommonCleanup - - Utility function to prepare for shutdown. - ---*/ -void -PALCommonCleanup() -{ - static bool cleanupDone = false; - - // Declare the beginning of shutdown - PALSetShutdownIntent(); - - if (!cleanupDone) - { - cleanupDone = true; - - } -} - -BOOL PALIsShuttingDown() -{ - /* TODO: This function may be used to provide a reader/writer-like - mechanism (or a ref counting one) to prevent PAL APIs that need to access - PAL runtime data, from working when PAL is shutting down. Each of those API - should acquire a read access while executing. The shutting down code would - acquire a write lock, i.e. suspending any new incoming reader, and waiting - for the current readers to be done. That would allow us to get rid of the - dangerous suspend-all-other-threads at shutdown time */ - return shutdown_intent; -} - -void PALSetShutdownIntent() -{ - /* TODO: See comment in PALIsShuttingDown */ - shutdown_intent = TRUE; -} - /*++ Function: PALInitLock @@ -783,24 +711,6 @@ BOOL PALInitLock(void) return TRUE; } -/*++ -Function: - PALInitUnlock - -Release the initialization critical section (init_critsec). - -(no parameters, no return value) ---*/ -void PALInitUnlock(void) -{ - if(!init_critsec) - { - return; - } - - minipal_mutex_leave(init_critsec); -} - /* Internal functions *********************************************************/ /*++ diff --git a/src/coreclr/pal/src/misc/dbgmsg.cpp b/src/coreclr/pal/src/misc/dbgmsg.cpp index 65e18bbde4710b..8ec68fb5530a85 100644 --- a/src/coreclr/pal/src/misc/dbgmsg.cpp +++ b/src/coreclr/pal/src/misc/dbgmsg.cpp @@ -2,15 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - Module Name: - misc/dbgmsg.cpp Abstract: Implementation of Debug Message utilies. Relay channel information, output functions, etc. - --*/ /* PAL headers */ @@ -44,9 +41,6 @@ Module Name: using namespace CorUnix; -/* append mode file I/O is safer */ -#define _PAL_APPEND_DBG_OUTPUT_ - static const char FOPEN_FLAGS[] = "at"; /* number of ENTRY nesting levels to indicate with a '.' */ @@ -369,44 +363,6 @@ BOOL DBG_init_channels(void) return TRUE; } -/*++ -Function : - DBG_close_channels - - Stop outputting debug messages by closing the associated file. - - (no parameters, no return value) ---*/ -void DBG_close_channels() -{ - if(output_file && output_file != stderr && output_file != stdout) - { - if (fclose(output_file) != 0) - { - fprintf(stderr, "ERROR : fclose() failed errno:%d (%s)\n", - errno, strerror(errno)); - } - } - - output_file = NULL; - - minipal_mutex_destroy(&fprintf_crit_section); - - /* if necessary, release TLS key for entry nesting level */ - if(0 != max_entry_level) - { - int retval; - - retval = pthread_key_delete(entry_level_key); - if(0 != retval) - { - fprintf(stderr, "ERROR : pthread_key_delete() returned %d! (%s)\n", - retval, strerror(retval)); - } - } -} - - static const void *DBG_get_module_id() { static const void *s_module_id = NULL; diff --git a/src/coreclr/pal/src/misc/environ.cpp b/src/coreclr/pal/src/misc/environ.cpp index 4a9eb640e2e64a..919496a124f7bb 100644 --- a/src/coreclr/pal/src/misc/environ.cpp +++ b/src/coreclr/pal/src/misc/environ.cpp @@ -2,21 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - - - Module Name: - environ.cpp Abstract: - Implementation of functions manipulating environment variables. - -Revision History: - - - --*/ #include "pal/palinternal.h" @@ -567,7 +557,7 @@ SetEnvironmentVariableA( } sprintf_s(string, iLen, "%s=%s", lpName, lpValue); - nResult = EnvironPutenv(string, FALSE) ? 0 : -1; + nResult = EnvironPutenv(string) ? 0 : -1; free(string); string = nullptr; @@ -693,21 +683,17 @@ Parameters entry [in] The variable string to add. Should be in the format - "name=value", where value might be empty (see below). - deleteIfEmpty - [in] If this is TRUE, "name=" will unset the 'name' variable. + "name=value", where value might be empty. Return Values TRUE on success, FALSE otherwise --*/ -BOOL EnvironPutenv(const char* entry, BOOL deleteIfEmpty) +BOOL EnvironPutenv(const char* entry) { BOOL result = FALSE; - bool fOwningCS = false; - CPalThread * pthrCurrent = InternalGetCurrentThread(); const char *equalsSignPosition = strchr(entry, '='); @@ -725,83 +711,59 @@ BOOL EnvironPutenv(const char* entry, BOOL deleteIfEmpty) int nameLength = equalsSignPosition - entry; - if (equalsSignPosition[1] == '\0' && deleteIfEmpty) - { - // "foo=" removes foo from the environment in _putenv() on Windows. - // The same string can result from a call to SetEnvironmentVariable() - // with the empty string as the value, but in that case we want to - // set the variable's value to "". deleteIfEmpty will be FALSE in - // that case. + // See if we are replacing an item or adding one. - // Change '=' to '\0' - copy[nameLength] = '\0'; - - EnvironUnsetenv(copy); - free(copy); + minipal_mutex_enter(&gcsEnvironment); - result = TRUE; - } - else + int i; + for (i = 0; palEnvironment[i] != nullptr; i++) { - // See if we are replacing an item or adding one. - - minipal_mutex_enter(&gcsEnvironment); - fOwningCS = true; + const char *existingEquals = strchr(palEnvironment[i], '='); + if (existingEquals == nullptr) + { + // The PAL screens out malformed strings, but the strings which + // came from the system during initialization might not have the + // equals sign. We treat the entire string as a name in that case. + existingEquals = palEnvironment[i] + strlen(palEnvironment[i]); + } - int i; - for (i = 0; palEnvironment[i] != nullptr; i++) + if (existingEquals - palEnvironment[i] == nameLength) { - const char *existingEquals = strchr(palEnvironment[i], '='); - if (existingEquals == nullptr) + if (memcmp(entry, palEnvironment[i], nameLength) == 0) { - // The PAL screens out malformed strings, but the strings which - // came from the system during initialization might not have the - // equals sign. We treat the entire string as a name in that case. - existingEquals = palEnvironment[i] + strlen(palEnvironment[i]); - } + free(palEnvironment[i]); + palEnvironment[i] = copy; - if (existingEquals - palEnvironment[i] == nameLength) - { - if (memcmp(entry, palEnvironment[i], nameLength) == 0) - { - free(palEnvironment[i]); - palEnvironment[i] = copy; - - result = TRUE; - break; - } + result = TRUE; + break; } } + } - if (palEnvironment[i] == nullptr) + if (palEnvironment[i] == nullptr) + { + _ASSERTE(i < palEnvironmentCapacity); + if (i == (palEnvironmentCapacity - 1)) { - _ASSERTE(i < palEnvironmentCapacity); - if (i == (palEnvironmentCapacity - 1)) + // We found the first null, but it's the last element in our environment + // block. We need more space in our environment, so let's double its size. + int resizeRet = ResizeEnvironment(palEnvironmentCapacity * 2); + if (resizeRet != TRUE) { - // We found the first null, but it's the last element in our environment - // block. We need more space in our environment, so let's double its size. - int resizeRet = ResizeEnvironment(palEnvironmentCapacity * 2); - if (resizeRet != TRUE) - { - free(copy); - goto done; - } + free(copy); + goto done; } + } - _ASSERTE(copy != nullptr); - palEnvironment[i] = copy; - palEnvironment[i + 1] = nullptr; - palEnvironmentCount++; + _ASSERTE(copy != nullptr); + palEnvironment[i] = copy; + palEnvironment[i + 1] = nullptr; + palEnvironmentCount++; - result = TRUE; - } + result = TRUE; } done: - - if (fOwningCS) - { - minipal_mutex_leave(&gcsEnvironment); - } + minipal_mutex_leave(&gcsEnvironment); return result; } @@ -979,38 +941,6 @@ EnvironInitialize(void) /*++ -Function : _putenv. - -See MSDN for more details. - -Note: The BSD implementation can cause - memory leaks. See man pages for more details. ---*/ -int -__cdecl -_putenv( const char * envstring ) -{ - int ret = -1; - - PERF_ENTRY(_putenv); - ENTRY( "_putenv( %p (%s) )\n", envstring ? envstring : "NULL", envstring ? envstring : "NULL") ; - - if (envstring != nullptr) - { - ret = EnvironPutenv(envstring, TRUE) ? 0 : -1; - } - else - { - ERROR( "_putenv() called with NULL envstring!\n"); - } - - LOGEXIT( "_putenv returning %d\n", ret); - PERF_EXIT(_putenv); - return ret; -} - -/*++ - Function : PAL_getenv See MSDN for more details. diff --git a/src/coreclr/pal/src/misc/utils.cpp b/src/coreclr/pal/src/misc/utils.cpp index 61566e4b0b68d8..1ed44775e7d30e 100644 --- a/src/coreclr/pal/src/misc/utils.cpp +++ b/src/coreclr/pal/src/misc/utils.cpp @@ -2,19 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - - - Module Name: - misc/utils.c Abstract: - Miscellaneous helper functions for the PAL, which don't fit anywhere else - - - --*/ #include "pal/dbgmsg.h" @@ -44,125 +36,6 @@ SET_DEFAULT_DEBUG_CHANNEL(MISC); // some headers have code with asserts, so do t // should be placed after the SET_DEFAULT_DEBUG_CHANNEL(MISC) #include -/*++ -Function: - UTIL_inverse_wcspbrk - - Opposite of wcspbrk : searches a string for the first character NOT in the - given set - -Parameters : - LPWSTR lpwstr : string to search - LPCWSTR charset : list of characters to search for - -Return value : - pointer to first character of lpwstr that isn't in the set - NULL if all characters are in the set ---*/ -LPWSTR UTIL_inverse_wcspbrk(LPWSTR lpwstr, LPCWSTR charset) -{ - while(*lpwstr) - { - if(NULL == PAL_wcschr(charset,*lpwstr)) - { - return lpwstr; - } - lpwstr++; - } - return NULL; -} - - -/*++ -Function : - UTIL_IsReadOnlyBitsSet - - Takes a struct stat * - Returns true if the file is read only, ---*/ -BOOL UTIL_IsReadOnlyBitsSet( struct stat * stat_data ) -{ - BOOL bRetVal = FALSE; - - /* Check for read permissions. */ - if ( stat_data->st_uid == geteuid() ) - { - /* The process owner is the file owner as well. */ - if ( ( stat_data->st_mode & S_IRUSR ) && !( stat_data->st_mode & S_IWUSR ) ) - { - bRetVal = TRUE; - } - } - else if ( stat_data->st_gid == getegid() ) - { - /* The process's owner is in the same group as the file's owner. */ - if ( ( stat_data->st_mode & S_IRGRP ) && !( stat_data->st_mode & S_IWGRP ) ) - { - bRetVal = TRUE; - } - } - else - { - /* Check the other bits to see who can access the file. */ - if ( ( stat_data->st_mode & S_IROTH ) && !( stat_data->st_mode & S_IWOTH ) ) - { - bRetVal = TRUE; - } - } - - return bRetVal; -} - -/*++ -Function : - UTIL_IsExecuteBitsSet - - Takes a struct stat * - Returns true if the file is executable, ---*/ -BOOL UTIL_IsExecuteBitsSet( struct stat * stat_data ) -{ - BOOL bRetVal = FALSE; - - if ( (stat_data->st_mode & S_IFMT) == S_IFDIR ) - { - return FALSE; - } - - /* Check for read permissions. */ - if ( 0 == geteuid() ) - { - /* The process owner is root */ - bRetVal = TRUE; - } - else if ( stat_data->st_uid == geteuid() ) - { - /* The process owner is the file owner as well. */ - if ( ( stat_data->st_mode & S_IXUSR ) ) - { - bRetVal = TRUE; - } - } - else if ( stat_data->st_gid == getegid() ) - { - /* The process's owner is in the same group as the file's owner. */ - if ( ( stat_data->st_mode & S_IXGRP ) ) - { - bRetVal = TRUE; - } - } - else - { - /* Check the other bits to see who can access the file. */ - if ( ( stat_data->st_mode & S_IXOTH ) ) - { - bRetVal = TRUE; - } - } - - return bRetVal; -} - /*++ Function : UTIL_WCToMB_Alloc diff --git a/src/coreclr/pal/src/thread/process.cpp b/src/coreclr/pal/src/thread/process.cpp index 071bfdd12acc39..308b77ad282f94 100644 --- a/src/coreclr/pal/src/thread/process.cpp +++ b/src/coreclr/pal/src/thread/process.cpp @@ -2,15 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*++ - Module Name: - process.cpp Abstract: - Implementation of process object and functions related to processes. - --*/ #include "pal/dbgmsg.h" @@ -223,11 +219,6 @@ struct UnambiguousProcessDescriptor }; #pragma pack(pop) -static -DWORD -StartupHelperThread( - LPVOID p); - static BOOL GetProcessIdDisambiguationKey( @@ -2074,17 +2065,6 @@ PROCAbort(int signal, siginfo_t* siginfo, void* context) abort(); } -#define FATAL_ASSERT(e, msg) \ - do \ - { \ - if (!(e)) \ - { \ - fprintf(stderr, "FATAL ERROR: " msg); \ - PROCAbort(); \ - } \ - } \ - while(0) - /*++ Function: CreateInitialProcessAndThreadObjects @@ -2192,7 +2172,6 @@ CorUnix::TerminateCurrentProcessNoExit(BOOL bTerminateUnconditionally) if(locked && PALIsInitialized()) { PROCNotifyProcessShutdown(); - PALCommonCleanup(); } } diff --git a/src/coreclr/pal/src/thread/thread.cpp b/src/coreclr/pal/src/thread/thread.cpp index 2d9c243bfbb2ab..e288018834ec52 100644 --- a/src/coreclr/pal/src/thread/thread.cpp +++ b/src/coreclr/pal/src/thread/thread.cpp @@ -1744,111 +1744,6 @@ CorUnix::CreateThreadObject( return palError; } -PAL_ERROR -CorUnix::InternalCreateDummyThread( - CPalThread *pThread, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - CPalThread **ppDummyThread, - HANDLE *phThread - ) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pDummyThread = NULL; - IPalObject *pobjThread = NULL; - IPalObject *pobjThreadRegistered = NULL; - IDataLock *pDataLock; - CThreadProcessLocalData *pLocalData; - CObjectAttributes oa(NULL, lpThreadAttributes); - bool fThreadDataStoredInObject = FALSE; - - pDummyThread = AllocTHREAD(); - if (NULL == pDummyThread) - { - palError = ERROR_OUTOFMEMORY; - goto InternalCreateDummyThreadExit; - } - - pDummyThread->m_fIsDummy = TRUE; - - palError = g_pObjectManager->AllocateObject( - pThread, - &otThread, - &oa, - &pobjThread - ); - - if (NO_ERROR != palError) - { - goto InternalCreateDummyThreadExit; - } - - palError = pobjThread->GetProcessLocalData( - pThread, - WriteLock, - &pDataLock, - reinterpret_cast(&pLocalData) - ); - - if (NO_ERROR != palError) - { - goto InternalCreateDummyThreadExit; - } - - pLocalData->pThread = pDummyThread; - pDataLock->ReleaseLock(pThread, TRUE); - fThreadDataStoredInObject = TRUE; - - palError = g_pObjectManager->RegisterObject( - pThread, - pobjThread, - &aotThread, - phThread, - &pobjThreadRegistered - ); - - // - // pobjThread is invalidated by the above call, so NULL - // it out here - // - - pobjThread = NULL; - - if (NO_ERROR != palError) - { - goto InternalCreateDummyThreadExit; - } - - // - // Note the we do NOT store the registered object for the - // thread w/in pDummyThread. Since this thread is not actually - // executing that reference would never be released (and thus - // the thread object would never be cleaned up...) - // - - *ppDummyThread = pDummyThread; - -InternalCreateDummyThreadExit: - - if (NULL != pobjThreadRegistered) - { - pobjThreadRegistered->ReleaseReference(pThread); - } - - if (NULL != pobjThread) - { - pobjThread->ReleaseReference(pThread); - } - - if (NO_ERROR != palError - && NULL != pDummyThread - && !fThreadDataStoredInObject) - { - pDummyThread->ReleaseThreadReference(); - } - - return palError; -} - PAL_ERROR CorUnix::InternalGetThreadDataFromHandle( CPalThread *pThread, diff --git a/src/coreclr/pal/tests/palsuite/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/CMakeLists.txt index 74c39df378a723..7c2970656d190d 100644 --- a/src/coreclr/pal/tests/palsuite/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/CMakeLists.txt @@ -95,7 +95,6 @@ add_executable_clr(paltests c_runtime/wcslen/test1/test1.cpp c_runtime/wcsncmp/test1/test1.cpp c_runtime/wcsncpy/test1/test1.cpp - c_runtime/wcspbrk/test1/test1.cpp c_runtime/wcsrchr/test1/test1.cpp c_runtime/wcsstr/test1/test1.cpp c_runtime/wcstod/test1/test1.cpp @@ -107,10 +106,6 @@ add_executable_clr(paltests c_runtime/wcstoul/test5/test5.cpp c_runtime/wcstoul/test6/test6.cpp c_runtime/_alloca/test1/test1.cpp - c_runtime/_putenv/test1/test1.cpp - c_runtime/_putenv/test2/test2.cpp - c_runtime/_putenv/test3/test3.cpp - c_runtime/_putenv/test4/test4.cpp c_runtime/_rotl/test1/test1.cpp c_runtime/_rotr/test1/test1.cpp c_runtime/_vsnprintf_s/test1/test1.cpp @@ -238,7 +233,6 @@ add_executable_clr(paltests file_io/GetStdHandle/test1/GetStdHandle.cpp file_io/GetStdHandle/test2/GetStdHandle.cpp file_io/gettemppatha/test1/gettemppatha.cpp - file_io/GetTempPathW/test1/GetTempPathW.cpp file_io/ReadFile/test1/ReadFile.cpp file_io/ReadFile/test2/ReadFile.cpp file_io/ReadFile/test3/ReadFile.cpp diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test1/test1.cpp deleted file mode 100644 index 6b9b6d94ee5302..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test1/test1.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Create an environment variable with _putenv and then use getenv -** to check it. Check that we get the expected errors with invalid input. -** -** -**===================================================================*/ - -#include - -struct TestElement -{ - char _putenvString[1024]; /* argument string sent to putenv */ - char varName[1024]; /* variable component of argument string */ - char varValue[1024]; /* value component of argument string */ - BOOL bValidString; /* valid argument string identifier */ -}; - -PALTEST(c_runtime__putenv_test1_paltest_putenv_test1, "c_runtime/_putenv/test1/paltest_putenv_test1") -{ - struct TestElement TestCases[] = - { - {"PalTestingEnvironmentVariable=A value", "PalTestingEnvironmentVariable", - "A value", TRUE}, - {"AnotherVariable=", "AnotherVariable", "", TRUE}, - {"YetAnotherVariable", "", "", FALSE}, - {"=ADifferentVariable", "", "ADifferentVariable", FALSE}, - {"", "", "", FALSE} - - }; - - int i; - char *variableValue; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - for (i = 0; i < (sizeof(TestCases)/sizeof(struct TestElement)) ; i++) - { - if((_putenv(TestCases[i]._putenvString) == -1) && - ( TestCases[i].bValidString == TRUE)) - { - Fail("ERROR: _putenv failed to set an environment " - "variable with a valid format.\n Call was" - "_putenv(%s)\n", TestCases[i]._putenvString); - } - /* - * For valid _putenvString values, check to see the variable was set - */ - if (TestCases[i].bValidString == TRUE) - { - variableValue = PAL_getenv(TestCases[i].varName); - - if (variableValue == NULL) - { - if (*TestCases[i].varValue != '\0') - { - Fail("ERROR: getenv(%s) call returned NULL.\nThe call " - "should have returned \"%s\"\n", TestCases[i].varName - , TestCases[i].varValue); - } - } - else if ( strcmp(variableValue, TestCases[i].varValue) != 0) - { - Fail("ERROR: _putenv(%s)\nshould have set the variable " - "%s\n to \"%s\".\nA subsequent call to getenv(%s)\n" - "returned \"%s\" instead.\n", TestCases[i]._putenvString - , TestCases[i].varName, TestCases[i].varValue - , TestCases[i].varName, variableValue); - } - } - else - /* - * Check to see that putenv fails for malformed _putenvString values - */ - { - variableValue = PAL_getenv(TestCases[i].varName); - - if (variableValue != NULL) - { - Fail("ERROR: getenv(%s) call should have returned NULL.\n" - "Instead it returned \"%s\".\n", TestCases[i].varName - , TestCases[i].varValue); - } - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test2/test2.cpp deleted file mode 100644 index ef118e513260b5..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test2/test2.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Create an environment variable with _putenv and then use getenv -** to check it. This test resets an environment variable. -** -** -**===================================================================*/ - -#include - -const char *_putenvString0 = "AnUnusualVariable=AnUnusualValue"; -const char *_putenvString1 = "AnUnusualVariable="; -const char *variable = "AnUnusualVariable"; -const char *value = "AnUnusualValue"; - -PALTEST(c_runtime__putenv_test2_paltest_putenv_test2, "c_runtime/_putenv/test2/paltest_putenv_test2") -{ - - char *variableValue; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - if(_putenv(_putenvString0) == -1) - { - Fail("ERROR: _putenv failed to set an environment " - "variable with a valid format.\n Call was" - "_putenv(%s)\n", _putenvString0); - } - - variableValue = PAL_getenv(variable); - - if (variableValue == NULL) - { - Fail("ERROR: getenv(%s) call returned NULL\nThe call " - "should have returned '%s'\n", variable, value); - } - else - { - if ( strcmp(variableValue, value) != 0 ) - { - Fail("ERROR: _putenv(%s)\nshould have set the variable " - "'%s'\n to '%s'.\nA subsequent call to getenv(%s)\n" - "returned '%s' instead.\n", _putenvString0, - variable, value, variable, variableValue); - } - else - { - if(_putenv(_putenvString1) == -1) - { - Fail("ERROR: _putenv failed to set an environment " - "variable with a valid format.\n Call was" - "_putenv(%s)\n", _putenvString1); - } - - variableValue = PAL_getenv(variable); - - if (variableValue != NULL) - { - Fail("ERROR: getenv(%s) call did not return NULL.\nThe call " - "returned '%s'.\n", variable, value); - } - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test3/test3.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test3/test3.cpp deleted file mode 100644 index 07380e1a514523..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test3/test3.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Create environment variables that differ only in Case, and -** verify that the BSD operating system treats the variables -** differently. -** -** -**===================================================================*/ - -#include - -PALTEST(c_runtime__putenv_test3_paltest_putenv_test3, "c_runtime/_putenv/test3/paltest_putenv_test3") -{ -#if WIN32 - - return PASS; - -#else - - const char* FirstVariable = "PalTestingEnvironmentVariable=The value"; - const char* SecondVariable = "PALTESTINGEnvironmentVariable=Different value"; - const char* FirstVarName = "PalTestingEnvironmentVariable"; - const char* FirstVarValue = "The value"; - char* result; - - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Use _putenv to set an environment variable. This ensures that the - variable we're testing on is always present. - */ - - if(_putenv(FirstVariable) != 0) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - - /* Call getenv -- ensure it doesn't return NULL and the string it returns - is the value we set above. Also make sure that each environment variable, - differing only by case, returns it's own value. - */ - - result = PAL_getenv(FirstVarName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment variable was not " - "found.\n"); - } - - if(strcmp(result, FirstVarValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - FirstVarValue, - result); - } - - /* Set the second environment variable, which only differs in Case */ - if(_putenv(SecondVariable) != 0) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - /* Verify that the environment variables - */ - - result = PAL_getenv(FirstVarName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment variable was not " - "found.\n"); - } - - if(strcmp(result, FirstVarValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - FirstVarValue, - result); - } - - PAL_Terminate(); - return PASS; - -#endif -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test4/test4.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test4/test4.cpp deleted file mode 100644 index 4e438fb3476308..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test4/test4.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Create an environment variable and try to retrieve -** it using the same name but with different case. This -** is to show that the Win32 representation of _putenv -** is case insensitive. -** -** -**===================================================================*/ - -#include - -PALTEST(c_runtime__putenv_test4_paltest_putenv_test4, "c_runtime/_putenv/test4/paltest_putenv_test4") -{ -#if WIN32 - - const char* FirstVariable = "PalTestingEnvironmentVariable=The value"; - const char* ModifiedName = "PALTESTINGEnvironmentVariable"; - const char* FirstVarValue = "The value"; - char* result; - - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Use _putenv to set an environment variable. This ensures that the - variable we're testing on is always present. - */ - - if(_putenv(FirstVariable) != 0) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - - /* Call getenv -- ensure it doesn't return NULL and the string it returns - is the value we set above. Also make sure that each environment variable, - differing only by case, doesn't affect the return value. - */ - - result = getenv(ModifiedName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment variable was not " - "found.\n"); - } - - if(strcmp(result, FirstVarValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - FirstVarValue, - result); - } - - - PAL_Terminate(); - return PASS; - -#else - return PASS; - -#endif -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/wcspbrk/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/wcspbrk/test1/test1.cpp deleted file mode 100644 index 780d737d5b9d86..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/wcspbrk/test1/test1.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Tests that wcspbrk returns a pointer to the first element in the first -** string that matches a character in the second (or NULL). -** -** -**==========================================================================*/ - -#include - -PALTEST(c_runtime_wcspbrk_test1_paltest_wcspbrk_test1, "c_runtime/wcspbrk/test1/paltest_wcspbrk_test1") -{ - WCHAR *string; - WCHAR *key1; - WCHAR *key2; - WCHAR key3[] = {0}; - WCHAR *result; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - string = convert("foo bar baz bar"); - key1 = convert("z "); - key2 = convert("Q"); - - result = wcspbrk(string, key1); - if (result != string + 3) - { - Fail("ERROR: Got incorrect result in scanning \"%s\" with the set \"%s\".\n" - "Expected to get pointer to %#p, got %#p\n", convertC(string), - convertC(key1), string + 3, result); - } - - result = wcspbrk(string, key2); - if (result != NULL) - { - Fail("ERROR: Got incorrect result in scanning \"%s\" with the set \"%s\".\n" - "Expected to get pointer to %#p, got %#p\n", convertC(string), - convertC(key2), NULL, result); - } - - result = wcspbrk(string, key3); - if (result != NULL) - { - Fail("ERROR: Got incorrect result in scanning \"%s\" with the set \"%s\".\n" - "Expected to get pointer to %#p, got %#p\n", convertC(string), - convertC(key3), NULL, result); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/common/palsuite.h b/src/coreclr/pal/tests/palsuite/common/palsuite.h index 0b6afaa5687526..0c3591534e49ce 100644 --- a/src/coreclr/pal/tests/palsuite/common/palsuite.h +++ b/src/coreclr/pal/tests/palsuite/common/palsuite.h @@ -2,15 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================ -** ** Source: palsuite.h ** ** Purpose: Define constants and implement functions that are useful to ** multiple function categories. If common functions are useful ** only amongst the test cases for a particular function, a separate ** header file is placed in the root of those test cases. -** -** **==========================================================================*/ #ifndef __PALSUITE_H__ @@ -188,7 +185,6 @@ DeleteFileW( #define wcsncmp PAL_wcsncmp #define wcschr PAL_wcschr #define wcsrchr PAL_wcsrchr -#define wcspbrk PAL_wcspbrk #define wcsstr PAL_wcsstr #define wcscmp PAL_wcscmp #define wcsncpy PAL_wcsncpy diff --git a/src/coreclr/pal/tests/palsuite/compilableTests.txt b/src/coreclr/pal/tests/palsuite/compilableTests.txt index 6b07778dc060b8..3ce650782436ac 100644 --- a/src/coreclr/pal/tests/palsuite/compilableTests.txt +++ b/src/coreclr/pal/tests/palsuite/compilableTests.txt @@ -54,7 +54,6 @@ c_runtime/wcscpy/test1/paltest_wcscpy_test1 c_runtime/wcslen/test1/paltest_wcslen_test1 c_runtime/wcsncmp/test1/paltest_wcsncmp_test1 c_runtime/wcsncpy/test1/paltest_wcsncpy_test1 -c_runtime/wcspbrk/test1/paltest_wcspbrk_test1 c_runtime/wcsrchr/test1/paltest_wcsrchr_test1 c_runtime/wcsstr/test1/paltest_wcsstr_test1 c_runtime/wcstod/test1/paltest_wcstod_test1 @@ -66,10 +65,6 @@ c_runtime/wcstoul/test4/paltest_wcstoul_test4 c_runtime/wcstoul/test5/paltest_wcstoul_test5 c_runtime/wcstoul/test6/paltest_wcstoul_test6 c_runtime/_alloca/test1/paltest_alloca_test1 -c_runtime/_putenv/test1/paltest_putenv_test1 -c_runtime/_putenv/test2/paltest_putenv_test2 -c_runtime/_putenv/test3/paltest_putenv_test3 -c_runtime/_putenv/test4/paltest_putenv_test4 c_runtime/_rotl/test1/paltest_rotl_test1 c_runtime/_rotr/test1/paltest_rotr_test1 c_runtime/_vsnprintf_s/test1/paltest_vsnprintf_test1 @@ -172,7 +167,6 @@ file_io/GetFullPathNameW/test4/paltest_getfullpathnamew_test4 file_io/GetStdHandle/test1/paltest_getstdhandle_test1 file_io/GetStdHandle/test2/paltest_getstdhandle_test2 file_io/gettemppatha/test1/paltest_gettemppatha_test1 -file_io/GetTempPathW/test1/paltest_gettemppathw_test1 file_io/ReadFile/test1/paltest_readfile_test1 file_io/ReadFile/test2/paltest_readfile_test2 file_io/ReadFile/test3/paltest_readfile_test3 diff --git a/src/coreclr/pal/tests/palsuite/file_io/GetTempPathW/test1/GetTempPathW.cpp b/src/coreclr/pal/tests/palsuite/file_io/GetTempPathW/test1/GetTempPathW.cpp deleted file mode 100644 index e0c9b932834c5b..00000000000000 --- a/src/coreclr/pal/tests/palsuite/file_io/GetTempPathW/test1/GetTempPathW.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: GetTempPathW.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetTempPathW function. -** -** -**===================================================================*/ - -#include - -static void SetTmpDir(const WCHAR path[]) -{ - DWORD result = SetEnvironmentVariableW(W("TMPDIR"), path); - if (!result) - { - Fail("ERROR -> SetEnvironmentVariableW failed with result %d and error code %d.\n", - result, GetLastError()); - } -} - -static void SetAndCompare(const WCHAR tmpDirPath[], const WCHAR expected[]) -{ - const DWORD dwBufferLength = _MAX_DIR; - WCHAR path[dwBufferLength]; - - SetTmpDir(tmpDirPath); - - DWORD dwResultLen = GetTempPathW(dwBufferLength, path); - if (dwResultLen <= 0) - { - Fail("ERROR: GetTempPathW returned %d with error code %d.\n", dwResultLen, GetLastError()); - } - if (dwResultLen >= dwBufferLength) - { - Fail("ERROR: Buffer of length %d passed to GetTempPathA was too small to hold %d chars..\n", dwBufferLength, dwResultLen); - } - if (wcscmp(expected, path) != 0) - { - Fail("ERROR: GetTempPathW expected to get '%S' but instead got '%S'.\n", expected, path); - } - if (expected[dwResultLen - 1] != '/') - { - Fail("ERROR: GetTempPathW returned '%S', which should have ended in '/'.\n", path); - } -} - -static void SetAndCheckLength(const WCHAR tmpDirPath [], int bufferLength, int expectedResultLength) -{ - WCHAR* path = (WCHAR*)alloca(bufferLength); - - SetTmpDir(tmpDirPath); - DWORD dwResultLen = GetTempPathW(bufferLength, path); - - if (dwResultLen != expectedResultLength) - { - Fail("GetTempPathW(%d, %S) expected to return %d but returned %d.\n", - bufferLength, tmpDirPath?tmpDirPath:W("NULL"), expectedResultLength, dwResultLen); - } -} - -PALTEST(file_io_GetTempPathW_test1_paltest_gettemppathw_test1, "file_io/GetTempPathW/test1/paltest_gettemppathw_test1") -{ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - SetAndCompare(W("/tmp"), W("/tmp/")); - SetAndCompare(W("/tmp/"), W("/tmp/")); - SetAndCompare(W(""), W("/tmp/")); - SetAndCompare(NULL, W("/tmp/")); - SetAndCompare(W("/"), W("/")); - SetAndCompare(W("/var/tmp"), W("/var/tmp/")); - SetAndCompare(W("/var/tmp/"), W("/var/tmp/")); - SetAndCompare(W("~"), W("~/")); - SetAndCompare(W("~/"), W("~/")); - SetAndCompare(W(".tmp"), W(".tmp/")); - SetAndCompare(W("./tmp"), W("./tmp/")); - SetAndCompare(W("/home/someuser/sometempdir"), W("/home/someuser/sometempdir/")); - SetAndCompare(NULL, W("/tmp/")); - - DWORD dwResultLen = GetTempPathA(0, NULL); - if (dwResultLen != 0 || GetLastError() != ERROR_INVALID_PARAMETER) - { - Fail("GetTempPathW(NULL, ...) returned %d with error code %d but " - "should have failed with ERROR_INVALID_PARAMETER (%d).\n", - dwResultLen, GetLastError(), ERROR_INVALID_PARAMETER); - } - - SetAndCheckLength(W("abc/"), 5, 4); - SetAndCheckLength(W("abcd"), 5, 6); - SetAndCheckLength(W("abcde"), 5, 7); - SetAndCheckLength(W("abcdef/"), 5, 9); - SetAndCheckLength(NULL, 5, 6); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/CreateFileMapping_neg.cpp b/src/coreclr/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/CreateFileMapping_neg.cpp index 91400a3a5c7e78..061a8cfff974e8 100644 --- a/src/coreclr/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/CreateFileMapping_neg.cpp +++ b/src/coreclr/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/CreateFileMapping_neg.cpp @@ -41,7 +41,7 @@ PALTEST(filemapping_memmgt_CreateFileMappingW_CreateFileMapping_neg1_paltest_cre FILE_SHARE_READ, NULL, CREATE_ALWAYS, - FILE_ATTRIBUTE_ARCHIVE, + FILE_ATTRIBUTE_NORMAL, NULL); //free this memory diff --git a/src/coreclr/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CreateFileMappingW.cpp b/src/coreclr/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CreateFileMappingW.cpp index ff18c512c4b926..efea083074bc63 100644 --- a/src/coreclr/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CreateFileMappingW.cpp +++ b/src/coreclr/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CreateFileMappingW.cpp @@ -48,7 +48,7 @@ PALTEST(filemapping_memmgt_CreateFileMappingW_test2_paltest_createfilemappingw_t FILE_SHARE_READ, NULL, OPEN_EXISTING, - FILE_ATTRIBUTE_ARCHIVE, + FILE_ATTRIBUTE_NORMAL, NULL); //free this memory diff --git a/src/coreclr/pal/tests/palsuite/paltestlist.txt b/src/coreclr/pal/tests/palsuite/paltestlist.txt index 6c72b9e4b58a6c..af60b06eb4fa5d 100644 --- a/src/coreclr/pal/tests/palsuite/paltestlist.txt +++ b/src/coreclr/pal/tests/palsuite/paltestlist.txt @@ -53,7 +53,6 @@ c_runtime/wcscpy/test1/paltest_wcscpy_test1 c_runtime/wcslen/test1/paltest_wcslen_test1 c_runtime/wcsncmp/test1/paltest_wcsncmp_test1 c_runtime/wcsncpy/test1/paltest_wcsncpy_test1 -c_runtime/wcspbrk/test1/paltest_wcspbrk_test1 c_runtime/wcsrchr/test1/paltest_wcsrchr_test1 c_runtime/wcsstr/test1/paltest_wcsstr_test1 c_runtime/wcstod/test1/paltest_wcstod_test1 @@ -65,10 +64,6 @@ c_runtime/wcstoul/test4/paltest_wcstoul_test4 c_runtime/wcstoul/test5/paltest_wcstoul_test5 c_runtime/wcstoul/test6/paltest_wcstoul_test6 c_runtime/_alloca/test1/paltest_alloca_test1 -c_runtime/_putenv/test1/paltest_putenv_test1 -c_runtime/_putenv/test2/paltest_putenv_test2 -c_runtime/_putenv/test3/paltest_putenv_test3 -c_runtime/_putenv/test4/paltest_putenv_test4 c_runtime/_rotl/test1/paltest_rotl_test1 c_runtime/_rotr/test1/paltest_rotr_test1 c_runtime/_vsnprintf_s/test1/paltest_vsnprintf_test1 @@ -156,7 +151,6 @@ file_io/GetFullPathNameW/test3/paltest_getfullpathnamew_test3 file_io/GetFullPathNameW/test4/paltest_getfullpathnamew_test4 file_io/GetStdHandle/test2/paltest_getstdhandle_test2 file_io/gettemppatha/test1/paltest_gettemppatha_test1 -file_io/GetTempPathW/test1/paltest_gettemppathw_test1 file_io/ReadFile/test2/paltest_readfile_test2 file_io/ReadFile/test3/paltest_readfile_test3 file_io/ReadFile/test4/paltest_readfile_test4 diff --git a/src/coreclr/pal/tests/palsuite/paltestlist_to_be_reviewed.txt b/src/coreclr/pal/tests/palsuite/paltestlist_to_be_reviewed.txt index b943a4571fb871..2ef293d3841a24 100644 --- a/src/coreclr/pal/tests/palsuite/paltestlist_to_be_reviewed.txt +++ b/src/coreclr/pal/tests/palsuite/paltestlist_to_be_reviewed.txt @@ -41,7 +41,6 @@ file_io/GetFullPathNameA/test2/paltest_getfullpathnamea_test2 file_io/GetFullPathNameW/test2/paltest_getfullpathnamew_test2 file_io/GetStdHandle/test1/paltest_getstdhandle_test1 file_io/gettemppatha/test1/paltest_gettemppatha_test1 -file_io/GetTempPathW/test1/paltest_gettemppathw_test1 file_io/ReadFile/test1/paltest_readfile_test1 file_io/WriteFile/test2/paltest_writefile_test2 loader/LoadLibraryA/test1/paltest_loadlibrarya_test1 diff --git a/src/coreclr/tools/superpmi/superpmi/parallelsuperpmi.cpp b/src/coreclr/tools/superpmi/superpmi/parallelsuperpmi.cpp index dc45751239a550..26362868f660f8 100644 --- a/src/coreclr/tools/superpmi/superpmi/parallelsuperpmi.cpp +++ b/src/coreclr/tools/superpmi/superpmi/parallelsuperpmi.cpp @@ -809,7 +809,7 @@ static bool RegisterCtrlHandler() static bool GetTempFolderPath(char* tempPath) { - if (!GetTempPath(MAX_PATH, tempPath)) + if (!GetTempPathA(MAX_PATH, tempPath)) { LogError("Failed to get path to temp folder."); return false; diff --git a/src/coreclr/utilcode/arraylist.cpp b/src/coreclr/utilcode/arraylist.cpp index 24da8273af63ea..396eafb34dd585 100644 --- a/src/coreclr/utilcode/arraylist.cpp +++ b/src/coreclr/utilcode/arraylist.cpp @@ -106,82 +106,6 @@ HRESULT ArrayListBase::Append(void *element) #endif // #ifndef DACCESS_COMPILE -DWORD ArrayListBase::FindElement(DWORD start, PTR_VOID element) const -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END - - DWORD index = start; - - _ASSERTE(index <= m_count); - - ArrayListBlock *b = (ArrayListBlock*)&m_firstBlock; - - // - // Skip to the block containing start. - // index should be the index of start in the block. - // - - while (b != NULL && index >= b->m_blockSize) - { - index -= b->m_blockSize; - b = b->m_next; - } - - // - // Adjust start to be the index of the start of the block - // - - start -= index; - - // - // Compute max number of entries from the start of the block - // - - DWORD max = m_count - start; - - while (b != NULL) - { - // - // Compute end of search in this block - either end of the block - // or end of the array - // - - DWORD blockMax; - if (max < b->m_blockSize) - blockMax = max; - else - blockMax = b->m_blockSize; - - // - // Scan for element, until the end. - // - - while (index < blockMax) - { - if (b->m_array[index] == element) - return start + index; - index++; - } - - // - // Otherwise, increment block start index, decrement max count, - // reset index, and go to the next block (if any) - // - - start += b->m_blockSize; - max -= b->m_blockSize; - index = 0; - b = b->m_next; - } - - return (DWORD) NOT_FOUND; -} - BOOL ArrayListBase::Iterator::Next() { LIMITED_METHOD_DAC_CONTRACT; diff --git a/src/coreclr/utilcode/collections.cpp b/src/coreclr/utilcode/collections.cpp index 05310cd64cd647..e6a165efbb6a3d 100644 --- a/src/coreclr/utilcode/collections.cpp +++ b/src/coreclr/utilcode/collections.cpp @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // Collections.cpp -// - // // This contains Collections C++ utility classes. -// //***************************************************************************** #include "stdafx.h" @@ -381,99 +379,6 @@ void CClosedHashBase::Delete( } } - -//***************************************************************************** -// Iterates over all active values, passing each one to pDeleteLoopFunc. -// If pDeleteLoopFunc returns TRUE, the entry is deleted. This is safer -// and faster than using FindNext() and Delete(). -//***************************************************************************** -void CClosedHashBase::DeleteLoop( - DELETELOOPFUNC pDeleteLoopFunc, // Decides whether to delete item - void *pCustomizer) // Extra value passed to deletefunc. -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - int i; - - if (m_rgData == 0) - { - return; - } - - for (i = 0; i < m_iSize; i++) - { - BYTE *pEntry = EntryPtr(i); - if (Status(pEntry) == USED) - { - if (pDeleteLoopFunc(pEntry, pCustomizer)) - { - if (m_bPerfect) - { - SetStatus(pEntry, FREE); - // One less non free entry. - --m_iCount; - } - else - { - SetStatus(pEntry, DELETED); - } - } - } - } - - if (!m_bPerfect) - { - // Now free DELETED entries that are no longer part of a chain. - for (i = 0; i < m_iSize; i++) - { - if (Status(EntryPtr(i)) == FREE) - { - break; - } - } - if (i != m_iSize) - { - int iFirstFree = i; - - do - { - if (i-- == 0) - { - i = m_iSize - 1; - } - while (Status(EntryPtr(i)) == DELETED) - { - SetStatus(EntryPtr(i), FREE); - - - // One less non free entry. - --m_iCount; - - if (i-- == 0) - { - i = m_iSize - 1; - } - } - - while (Status(EntryPtr(i)) != FREE) - { - if (i-- == 0) - { - i = m_iSize - 1; - } - } - - } - while (i != iFirstFree); - } - } - -} - //***************************************************************************** // Lookup a key value and return a pointer to the element if found. //***************************************************************************** diff --git a/src/coreclr/utilcode/corimage.cpp b/src/coreclr/utilcode/corimage.cpp index 7eb3adb7a07bc3..cd31a7359dce61 100644 --- a/src/coreclr/utilcode/corimage.cpp +++ b/src/coreclr/utilcode/corimage.cpp @@ -1,14 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// - /*============================================================ -** ** CorImage.cpp ** ** IMAGEHLP routines so we can avoid early binding to that DLL. -** ===========================================================*/ #include "stdafx.h" @@ -118,24 +114,6 @@ Cor_RtlImageRvaToSection64(PTR_IMAGE_NT_HEADERS64 NtHeaders, return NULL; } -EXTERN_C PIMAGE_SECTION_HEADER -Cor_RtlImageRvaToSection(PTR_IMAGE_NT_HEADERS NtHeaders, - ULONG Rva, - ULONG FileLength) -{ - LIMITED_METHOD_CONTRACT; - if (NtHeaders->OptionalHeader.Magic == VAL16(IMAGE_NT_OPTIONAL_HDR32_MAGIC)) - return Cor_RtlImageRvaToSection32((PTR_IMAGE_NT_HEADERS32)NtHeaders, - Rva, FileLength); - else if(NtHeaders->OptionalHeader.Magic == VAL16(IMAGE_NT_OPTIONAL_HDR64_MAGIC)) - return Cor_RtlImageRvaToSection64((PTR_IMAGE_NT_HEADERS64)NtHeaders, - Rva, FileLength); - else { - _ASSERTE(!"Invalid File Type"); - return NULL; - } -} - EXTERN_C PBYTE Cor_RtlImageRvaToVa32(PTR_IMAGE_NT_HEADERS32 NtHeaders, PBYTE Base, ULONG Rva, @@ -173,87 +151,3 @@ EXTERN_C PBYTE Cor_RtlImageRvaToVa64(PTR_IMAGE_NT_HEADERS64 NtHeaders, else return NULL; } - -EXTERN_C PBYTE Cor_RtlImageRvaToVa(PTR_IMAGE_NT_HEADERS NtHeaders, - PBYTE Base, - ULONG Rva, - ULONG FileLength) -{ - LIMITED_METHOD_CONTRACT; - if (NtHeaders->OptionalHeader.Magic == VAL16(IMAGE_NT_OPTIONAL_HDR32_MAGIC)) - return Cor_RtlImageRvaToVa32((PTR_IMAGE_NT_HEADERS32)NtHeaders, - Base, Rva, FileLength); - else if(NtHeaders->OptionalHeader.Magic == VAL16(IMAGE_NT_OPTIONAL_HDR64_MAGIC)) - return Cor_RtlImageRvaToVa64((PTR_IMAGE_NT_HEADERS64)NtHeaders, - Base, Rva, FileLength); - else { - _ASSERTE(!"Invalid File Type"); - return NULL; - } -} - -EXTERN_C PBYTE Cor_RtlImageDirToVa(PTR_IMAGE_NT_HEADERS NtHeaders, - PBYTE Base, - UINT DirIndex, - ULONG FileLength) -{ - LIMITED_METHOD_CONTRACT; - if (NtHeaders->OptionalHeader.Magic == VAL16(IMAGE_NT_OPTIONAL_HDR32_MAGIC)) - return Cor_RtlImageRvaToVa32((PTR_IMAGE_NT_HEADERS32)NtHeaders, Base, - VAL32(((PTR_IMAGE_NT_HEADERS32)NtHeaders)->OptionalHeader.DataDirectory[DirIndex].VirtualAddress), - FileLength); - else if(NtHeaders->OptionalHeader.Magic == VAL16(IMAGE_NT_OPTIONAL_HDR64_MAGIC)) - return Cor_RtlImageRvaToVa64((PTR_IMAGE_NT_HEADERS64)NtHeaders, Base, - VAL32(((PTR_IMAGE_NT_HEADERS64)NtHeaders)->OptionalHeader.DataDirectory[DirIndex].VirtualAddress), - FileLength); - else { - _ASSERTE(!"Invalid File Type"); - return NULL; - } -} - -EXTERN_C PIMAGE_SECTION_HEADER -Cor_RtlImageRvaRangeToSection(PTR_IMAGE_NT_HEADERS NtHeaders, - ULONG Rva, - ULONG Range, - ULONG FileLength) -{ - LIMITED_METHOD_CONTRACT; - ULONG i; - PTR_IMAGE_SECTION_HEADER NtSection; - - if (!Range) - return Cor_RtlImageRvaToSection(NtHeaders, Rva, FileLength); - - NtSection = PTR_IMAGE_FIRST_SECTION( NtHeaders ); - for (i=0; iFileHeader.NumberOfSections); i++) { - if (FileLength && - ((VAL32(NtSection->PointerToRawData) > FileLength) || - (VAL32(NtSection->SizeOfRawData) > FileLength - VAL32(NtSection->PointerToRawData)))) - return NULL; - if (Rva >= VAL32(NtSection->VirtualAddress) && - Rva + Range <= VAL32(NtSection->VirtualAddress) + VAL32(NtSection->SizeOfRawData)) - return NtSection; - - ++NtSection; - } - - return NULL; -} - -EXTERN_C DWORD Cor_RtlImageRvaToOffset(PTR_IMAGE_NT_HEADERS NtHeaders, - ULONG Rva, - ULONG FileLength) -{ - LIMITED_METHOD_CONTRACT; - PIMAGE_SECTION_HEADER NtSection = - Cor_RtlImageRvaToSection(NtHeaders, - Rva, - FileLength); - - if (NtSection) - return ((Rva - VAL32(NtSection->VirtualAddress)) + - VAL32(NtSection->PointerToRawData)); - else - return 0; -} diff --git a/src/coreclr/utilcode/executableallocator.cpp b/src/coreclr/utilcode/executableallocator.cpp index fc772dafb6ebec..a95eab066edcd5 100644 --- a/src/coreclr/utilcode/executableallocator.cpp +++ b/src/coreclr/utilcode/executableallocator.cpp @@ -814,49 +814,6 @@ void* ExecutableAllocator::Reserve(size_t size) return result; } -// Reserve a block of executable memory at the specified virtual address. If it is not -// possible, the method returns NULL. -void* ExecutableAllocator::ReserveAt(void* baseAddressRX, size_t size) -{ - LIMITED_METHOD_CONTRACT; - -#ifdef LOG_EXECUTABLE_ALLOCATOR_STATISTICS - InterlockedIncrement64(&g_reserveCount); -#endif - - _ASSERTE((size & (Granularity() - 1)) == 0); - - if (IsDoubleMappingEnabled()) - { - CRITSEC_Holder csh(m_CriticalSection); - - bool isFreeBlock; - BlockRX* block = AllocateBlock(size, &isFreeBlock); - if (block == NULL) - { - return NULL; - } - - void* result = VMToOSInterface::ReserveDoubleMappedMemory(m_doubleMemoryMapperHandle, block->offset, size, baseAddressRX, baseAddressRX); - - if (result != NULL) - { - block->baseRX = result; - AddRXBlock(block); - } - else - { - BackoutBlock(block, isFreeBlock); - } - - return result; - } - else - { - return VirtualAlloc(baseAddressRX, size, MEM_RESERVE, PAGE_NOACCESS); - } -} - // Map an executable memory block as writeable. If there is already a mapping // covering the specified block, return that mapping instead of creating a new one. // Return starting address of the writeable mapping. diff --git a/src/coreclr/utilcode/loaderheap.cpp b/src/coreclr/utilcode/loaderheap.cpp index 4472b272ff4627..611a2c646c5940 100644 --- a/src/coreclr/utilcode/loaderheap.cpp +++ b/src/coreclr/utilcode/loaderheap.cpp @@ -109,28 +109,6 @@ UnlockedLoaderHeap::~UnlockedLoaderHeap() #endif // #ifndef DACCESS_COMPILE -#if 0 -// Disables access to all pages in the heap - useful when trying to determine if someone is -// accessing something in the low frequency heap -void UnlockedLoaderHeap::DebugGuardHeap() -{ - WRAPPER_NO_CONTRACT; - LoaderHeapBlock *pSearch, *pNext; - - for (pSearch = m_pFirstBlock; pSearch; pSearch = pNext) - { - void * pResult; - void * pVirtualAddress; - - pVirtualAddress = pSearch->pVirtualAddress; - pNext = pSearch->pNext; - - pResult = ClrVirtualAlloc(pVirtualAddress, pSearch->dwVirtualSize, MEM_COMMIT, PAGE_NOACCESS); - _ASSERTE(pResult != NULL); - } -} -#endif - size_t UnlockedLoaderHeap::GetBytesAvailReservedRegion() { LIMITED_METHOD_CONTRACT; @@ -780,55 +758,6 @@ void *UnlockedLoaderHeap::UnlockedAllocAlignedMem(size_t dwRequestedSize, } #endif // #ifndef DACCESS_COMPILE - -#ifdef _DEBUG - -void UnlockedLoaderHeap::DumpFreeList() -{ - LIMITED_METHOD_CONTRACT; - if (m_pFirstFreeBlock == NULL) - { - minipal_log_print_info("FREEDUMP: FreeList is empty\n"); - } - else - { - InlineSString<128> buf; - LoaderHeapFreeBlock *pBlock = m_pFirstFreeBlock; - while (pBlock != NULL) - { - size_t dwsize = pBlock->m_dwSize; - BOOL ccbad = FALSE; - BOOL sizeunaligned = FALSE; - - if ( 0 != (dwsize & ALLOC_ALIGN_CONSTANT) ) - { - sizeunaligned = TRUE; - } - - for (size_t i = sizeof(LoaderHeapFreeBlock); i < dwsize; i++) - { - if ( ((BYTE*)pBlock)[i] != 0xcc ) - { - ccbad = TRUE; - break; - } - } - - buf.Printf("Addr = %pxh, Size = %xh", pBlock, ((ULONG)dwsize)); - if (ccbad) buf.AppendUTF8(" *** ERROR: NOT CC'd ***"); - if (sizeunaligned) buf.AppendUTF8(" *** ERROR: size not a multiple of ALLOC_ALIGN_CONSTANT ***"); - buf.AppendUTF8("\n"); - - minipal_log_print_info("%s", buf.GetUTF8()); - buf.Clear(); - - pBlock = pBlock->m_pNext; - } - } -} - -#endif //_DEBUG - #ifndef DACCESS_COMPILE /*static*/ void LoaderHeapFreeBlock::InsertFreeBlock(LoaderHeapFreeBlock **ppHead, void *pMem, size_t dwTotalSize, UnlockedLoaderHeap *pHeap) { diff --git a/src/coreclr/utilcode/longfilepathwrappers.cpp b/src/coreclr/utilcode/longfilepathwrappers.cpp index fbe9e37ae7ff8e..2b4f2d54e15200 100644 --- a/src/coreclr/utilcode/longfilepathwrappers.cpp +++ b/src/coreclr/utilcode/longfilepathwrappers.cpp @@ -375,61 +375,6 @@ int u16_fopen_wrapper(FILE** stream, const WCHAR* filename, const WCHAR* mode) return -1; } -BOOL -CopyFileExWrapper( - _In_ LPCWSTR lpExistingFileName, - _In_ LPCWSTR lpNewFileName, - _In_opt_ LPPROGRESS_ROUTINE lpProgressRoutine, - _In_opt_ LPVOID lpData, - _When_(pbCancel != NULL, _Pre_satisfies_(*pbCancel == FALSE)) - _Inout_opt_ LPBOOL pbCancel, - _In_ DWORD dwCopyFlags - ) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - HRESULT hr = S_OK; - BOOL ret = FALSE; - DWORD lastError = 0; - - EX_TRY - { - LongPathString Existingpath(LongPathString::Literal, lpExistingFileName); - LongPathString Newpath(LongPathString::Literal, lpNewFileName); - - if (SUCCEEDED(LongFile::NormalizePath(Existingpath)) && SUCCEEDED(LongFile::NormalizePath(Newpath))) - { - ret = CopyFileExW( - Existingpath.GetUnicode(), - Newpath.GetUnicode(), - lpProgressRoutine, - lpData, - pbCancel, - dwCopyFlags - ); - } - - lastError = GetLastError(); - } - EX_CATCH_HRESULT(hr); - - if (hr != S_OK ) - { - SetLastError(hr); - } - else if(ret == FALSE) - { - SetLastError(lastError); - } - - return ret; -} - //Implementation of LongFile Helpers const WCHAR LongFile::DirectorySeparatorChar = W('\\'); const WCHAR LongFile::AltDirectorySeparatorChar = W('/'); diff --git a/src/coreclr/utilcode/pedecoder.cpp b/src/coreclr/utilcode/pedecoder.cpp index 905d7009b008f8..ed7183d3501322 100644 --- a/src/coreclr/utilcode/pedecoder.cpp +++ b/src/coreclr/utilcode/pedecoder.cpp @@ -1,10 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -------------------------------------------------------------------------------- -// PEDecoder.cpp -// - -// -------------------------------------------------------------------------------- #include "stdafx.h" @@ -1546,422 +1541,6 @@ CHECK PEDecoder::CheckILOnlyEntryPoint() const } #endif // TARGET_X86 - -bool ReadResourceDirectoryHeader(const PEDecoder *pDecoder, DWORD rvaOfResourceSection, DWORD rva, IMAGE_RESOURCE_DIRECTORY_ENTRY** ppDirectoryEntries, IMAGE_RESOURCE_DIRECTORY **ppResourceDirectory) -{ - if (!pDecoder->CheckRva(rva, sizeof(IMAGE_RESOURCE_DIRECTORY))) - { - return false; - } - - *ppResourceDirectory = (IMAGE_RESOURCE_DIRECTORY *)pDecoder->GetRvaData(rva); - - // Check to see if entire resource directory is accessible - if (!pDecoder->CheckRva(rva + sizeof(IMAGE_RESOURCE_DIRECTORY), - (sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY) * (*ppResourceDirectory)->NumberOfNamedEntries) + - (sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY) * (*ppResourceDirectory)->NumberOfIdEntries))) - { - return false; - } - - *ppDirectoryEntries = (IMAGE_RESOURCE_DIRECTORY_ENTRY *)pDecoder->GetRvaData(rva + sizeof(IMAGE_RESOURCE_DIRECTORY)); - return true; -} - -bool ReadNameFromResourceDirectoryEntry(const PEDecoder *pDecoder, DWORD rvaOfResourceSection, IMAGE_RESOURCE_DIRECTORY_ENTRY* pDirectoryEntries, DWORD iEntry, DWORD *pNameUInt, WCHAR **pNameStr) -{ - *pNameStr = NULL; - *pNameUInt = 0; - - if (!IS_INTRESOURCE(pDirectoryEntries[iEntry].Name)) - { - DWORD entryName = pDirectoryEntries[iEntry].Name; - if (!(entryName & IMAGE_RESOURCE_NAME_IS_STRING)) - return false; - DWORD entryNameRva = (entryName & ~IMAGE_RESOURCE_NAME_IS_STRING) + rvaOfResourceSection; - - if (!pDecoder->CheckRva(entryNameRva, sizeof(WORD))) - return false; - - size_t entryNameLen = *(WORD*)pDecoder->GetRvaData(entryNameRva); - if (!pDecoder->CheckRva(entryNameRva, (COUNT_T)(sizeof(WORD) * (1 + entryNameLen)))) - return false; - *pNameStr = new(nothrow) WCHAR[entryNameLen + 1]; - if ((*pNameStr) == NULL) - return false; - memcpy((*pNameStr), (WCHAR*)pDecoder->GetRvaData(entryNameRva + sizeof(WORD)), entryNameLen * sizeof(WCHAR)); - (*pNameStr)[entryNameLen] = 0; - } - else - { - DWORD name = pDirectoryEntries[iEntry].Name; - if (!IS_INTRESOURCE(name)) - return false; - - *pNameUInt = name; - } - - return true; -} - -DWORD ReadResourceDirectory(const PEDecoder *pDecoder, DWORD rvaOfResourceSection, DWORD rva, LPCWSTR name, BOOL *pisDirectory) -{ - *pisDirectory = FALSE; - - IMAGE_RESOURCE_DIRECTORY* pResourceDirectory; - IMAGE_RESOURCE_DIRECTORY_ENTRY* pDirectoryEntries; - if (!ReadResourceDirectoryHeader(pDecoder, rvaOfResourceSection, rva, &pDirectoryEntries, &pResourceDirectory)) - { - return 0; - } - - // A fast implementation of resource lookup uses a binary search, but our needs are simple, and a linear search - // is easier to prove correct, so do that instead. - DWORD iEntryCount = (DWORD)pResourceDirectory->NumberOfNamedEntries + (DWORD)pResourceDirectory->NumberOfIdEntries; - - for (DWORD iEntry = 0; iEntry < iEntryCount; iEntry++) - { - BOOL foundEntry = FALSE; - - if (IS_INTRESOURCE(name)) - { - // name is id - if (pDirectoryEntries[iEntry].Name == (DWORD)(SIZE_T)name) - foundEntry = TRUE; - } - else - { - // name is string - DWORD entryName = pDirectoryEntries[iEntry].Name; - if (!(entryName & IMAGE_RESOURCE_NAME_IS_STRING)) - continue; - - DWORD entryNameRva = (entryName & ~IMAGE_RESOURCE_NAME_IS_STRING) + rvaOfResourceSection; - - if (!pDecoder->CheckRva(entryNameRva, sizeof(WORD))) - return 0; - - size_t entryNameLen = *(WORD*)pDecoder->GetRvaData(entryNameRva); - if (u16_strlen(name) != entryNameLen) - continue; - - if (!pDecoder->CheckRva(entryNameRva, (COUNT_T)(sizeof(WORD) * (1 + entryNameLen)))) - return 0; - - if (memcmp((WCHAR*)pDecoder->GetRvaData(entryNameRva + sizeof(WORD)), name, entryNameLen * sizeof(WCHAR)) == 0) - foundEntry = TRUE; - } - - if (!foundEntry) - continue; - - *pisDirectory = !!(pDirectoryEntries[iEntry].OffsetToData & IMAGE_RESOURCE_DATA_IS_DIRECTORY); - DWORD offsetToData = pDirectoryEntries[iEntry].OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY; - DWORD dataRva = rvaOfResourceSection + offsetToData; - return dataRva; - } - - return 0; -} - -DWORD ReadResourceDataEntry(const PEDecoder *pDecoder, DWORD rva, COUNT_T *pSize) -{ - *pSize = 0; - - if (!pDecoder->CheckRva(rva, sizeof(IMAGE_RESOURCE_DATA_ENTRY))) - { - return 0; - } - - IMAGE_RESOURCE_DATA_ENTRY *pDataEntry = (IMAGE_RESOURCE_DATA_ENTRY *)pDecoder->GetRvaData(rva); - *pSize = pDataEntry->Size; - return pDataEntry->OffsetToData; -} - -void * PEDecoder::GetWin32Resource(LPCWSTR lpName, LPCWSTR lpType, COUNT_T *pSize /*=NULL*/) const -{ - CONTRACTL { - INSTANCE_CHECK; - PRECONDITION(IsMapped()); - NOTHROW; - GC_NOTRIGGER; - } CONTRACTL_END; - - COUNT_T sizeUnused = 0; // Use this variable if pSize is null - if (pSize == NULL) - pSize = &sizeUnused; - - *pSize = 0; - - if (!HasDirectoryEntry(IMAGE_DIRECTORY_ENTRY_RESOURCE)) - return NULL; - - COUNT_T resourceDataSize = 0; - IMAGE_DATA_DIRECTORY *pDir = GetDirectoryEntry(IMAGE_DIRECTORY_ENTRY_RESOURCE); - - if (pDir->VirtualAddress == 0) - return NULL; - - BOOL isDirectory = FALSE; - DWORD nameTableRva = ReadResourceDirectory(this, pDir->VirtualAddress, pDir->VirtualAddress, lpType, &isDirectory); - - if (!isDirectory) - return NULL; - - if (nameTableRva == 0) - return NULL; - - DWORD languageTableRva = ReadResourceDirectory(this, pDir->VirtualAddress, nameTableRva, lpName, &isDirectory); - if (!isDirectory) - return NULL; - - if (languageTableRva == 0) - return NULL; - - // This api is designed to find resources with LANGID = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) - // This translates to LANGID 0 as the initial lookup point, which is sufficient for the needs of this api at this time - // (FindResource in the Windows api implements a large number of fallback paths which this api does not implement) - - DWORD resourceDataEntryRva = ReadResourceDirectory(this, pDir->VirtualAddress, languageTableRva, 0, &isDirectory); - if (isDirectory) // This must not be a resource directory itself - return NULL; - - if (resourceDataEntryRva == 0) - return NULL; - - DWORD resourceDataRva = ReadResourceDataEntry(this, resourceDataEntryRva, pSize); - if (!CheckRva(resourceDataRva, *pSize)) - { - *pSize = 0; - return NULL; - } - - return (void*)GetRvaData(resourceDataRva); -} - -typedef bool (*PEDecoder_EnumerateResourceTableFunction)(const PEDecoder *pDecoder, DWORD rvaOfResourceSection, bool isDirectory, LPCWSTR name, DWORD dataRVA, void *context); - -struct ResourceEnumerateNamesState -{ - PEDecoder_ResourceNamesCallbackFunction namesCallback; - PEDecoder_ResourceCallbackFunction langIDcallback; - void *context; - LPCWSTR nameType; - LPCWSTR nameName; - PEDecoder_EnumerateResourceTableFunction callbackPerName; - PEDecoder_EnumerateResourceTableFunction callbackPerLangID; -}; - -struct ResourceEnumerateTypesState -{ - PEDecoder_ResourceTypesCallbackFunction callback; - void *context; - LPCWSTR nameType; -}; - -bool EnumerateWin32ResourceTable(const PEDecoder *pDecoder, DWORD rvaOfResourceSection, DWORD rvaOfResourceTable, PEDecoder_EnumerateResourceTableFunction resourceTableEnumerator, void *context) -{ - IMAGE_RESOURCE_DIRECTORY* pResourceDirectory; - IMAGE_RESOURCE_DIRECTORY_ENTRY* pDirectoryEntries; - if (!ReadResourceDirectoryHeader(pDecoder, rvaOfResourceSection, rvaOfResourceTable, &pDirectoryEntries, &pResourceDirectory)) - { - return false; - } - - DWORD iEntryCount = (DWORD)pResourceDirectory->NumberOfNamedEntries + (DWORD)pResourceDirectory->NumberOfIdEntries; - - for (DWORD iEntry = 0; iEntry < iEntryCount; iEntry++) - { - DWORD nameUInt; - NewArrayHolder nameString; - if (!ReadNameFromResourceDirectoryEntry(pDecoder, rvaOfResourceSection, pDirectoryEntries, iEntry, &nameUInt, &nameString)) - return false; - - LPCWSTR name = MAKEINTRESOURCEW(nameUInt); - if (nameString != NULL) - name = &nameString[0]; - - bool isDirectory = !!(pDirectoryEntries[iEntry].OffsetToData & IMAGE_RESOURCE_DATA_IS_DIRECTORY); - DWORD offsetToData = pDirectoryEntries[iEntry].OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY; - DWORD dataRva = rvaOfResourceSection + offsetToData; - - if (!resourceTableEnumerator(pDecoder, rvaOfResourceSection, isDirectory, name, dataRva, context)) - return false; - } - - return true; -} - -bool DoesResourceNameMatch(LPCWSTR nameA, LPCWSTR nameB) -{ - bool foundEntry = false; - - if (IS_INTRESOURCE(nameA)) - { - // name is id - if (nameA == nameB) - foundEntry = true; - } - else - { - // name is a string. - - // Check for name enumerated is an id. If so, it doesn't match, skip to next. - if (IS_INTRESOURCE(nameB)) - return false; - else - foundEntry = !u16_strcmp(nameB, nameA); - } - - return foundEntry; -} - -bool EnumerateLangIDs(const PEDecoder *pDecoder, DWORD rvaOfResourceSection, bool isDirectory, LPCWSTR name, DWORD dataRVA, void *context) -{ - ResourceEnumerateNamesState *state = (ResourceEnumerateNamesState*)context; - if (isDirectory) - return false; - - // Only LangIDs are permitted here - if (!IS_INTRESOURCE(name)) - return false; - - if (dataRVA == 0) - return false; - - COUNT_T cbData; - DWORD resourceDataRva = ReadResourceDataEntry(pDecoder, dataRVA, &cbData); - if (!pDecoder->CheckRva(resourceDataRva, cbData)) - { - return false; - } - - BYTE *pData = (BYTE*)pDecoder->GetRvaData(resourceDataRva); - - return state->langIDcallback(state->nameName, state->nameType, (DWORD)(uintptr_t)name, pData, cbData, state->context); -} - - -bool EnumerateNames(const PEDecoder *pDecoder, DWORD rvaOfResourceSection, bool isDirectory, LPCWSTR name, DWORD dataRVA, void *context) -{ - ResourceEnumerateNamesState *state = (ResourceEnumerateNamesState*)context; - if (!isDirectory) - return false; - - state->nameName = name; - return state->namesCallback(state->nameName, state->nameType, state->context); -} - -bool EnumerateNamesForLangID(const PEDecoder *pDecoder, DWORD rvaOfResourceSection, bool isDirectory, LPCWSTR name, DWORD dataRVA, void *context) -{ - ResourceEnumerateNamesState *state = (ResourceEnumerateNamesState*)context; - if (!isDirectory) - return false; - - bool foundEntry = DoesResourceNameMatch(state->nameName, name); - - if (foundEntry) - return EnumerateWin32ResourceTable(pDecoder, rvaOfResourceSection, dataRVA, state->callbackPerLangID, context); - else - return true; // Keep scanning -} - - -bool EnumerateTypes(const PEDecoder *pDecoder, DWORD rvaOfResourceSection, bool isDirectory, LPCWSTR name, DWORD dataRVA, void *context) -{ - ResourceEnumerateTypesState *state = (ResourceEnumerateTypesState*)context; - if (!isDirectory) - return false; - - state->nameType = name; - return state->callback(name, state->context); -} - -bool EnumerateTypesForNames(const PEDecoder *pDecoder, DWORD rvaOfResourceSection, bool isDirectory, LPCWSTR name, DWORD dataRVA, void *context) -{ - ResourceEnumerateNamesState *state = (ResourceEnumerateNamesState*)context; - if (!isDirectory) - return false; - - bool foundEntry = DoesResourceNameMatch(state->nameType, name); - - if (foundEntry) - return EnumerateWin32ResourceTable(pDecoder, rvaOfResourceSection, dataRVA, state->callbackPerName, context); - else - return true; // Keep scanning -} - - -bool PEDecoder::EnumerateWin32ResourceTypes(PEDecoder_ResourceTypesCallbackFunction callback, void* context) const -{ - if (!HasDirectoryEntry(IMAGE_DIRECTORY_ENTRY_RESOURCE)) - return true; - - COUNT_T resourceDataSize = 0; - IMAGE_DATA_DIRECTORY *pDir = GetDirectoryEntry(IMAGE_DIRECTORY_ENTRY_RESOURCE); - - if (pDir->VirtualAddress == 0) - return true; - - DWORD rvaOfResourceSection = pDir->VirtualAddress; - - ResourceEnumerateTypesState state; - state.context = context; - state.callback = callback; - - return EnumerateWin32ResourceTable(this, rvaOfResourceSection, rvaOfResourceSection, EnumerateTypes, &state); -} - -bool PEDecoder::EnumerateWin32ResourceNames(LPCWSTR lpType, PEDecoder_ResourceNamesCallbackFunction callback, void* context) const -{ - if (!HasDirectoryEntry(IMAGE_DIRECTORY_ENTRY_RESOURCE)) - return true; - - COUNT_T resourceDataSize = 0; - IMAGE_DATA_DIRECTORY *pDir = GetDirectoryEntry(IMAGE_DIRECTORY_ENTRY_RESOURCE); - - if (pDir->VirtualAddress == 0) - return true; - - DWORD rvaOfResourceSection = pDir->VirtualAddress; - - ResourceEnumerateNamesState state; - state.context = context; - state.namesCallback = callback; - state.langIDcallback = NULL; - state.nameType = lpType; - state.nameName = NULL; - state.callbackPerName = EnumerateNames; - state.callbackPerLangID = NULL; - - return EnumerateWin32ResourceTable(this, rvaOfResourceSection, rvaOfResourceSection, EnumerateTypesForNames, &state); -} - -bool PEDecoder::EnumerateWin32Resources(LPCWSTR lpName, LPCWSTR lpType, PEDecoder_ResourceCallbackFunction callback, void* context) const -{ - if (!HasDirectoryEntry(IMAGE_DIRECTORY_ENTRY_RESOURCE)) - return true; - - COUNT_T resourceDataSize = 0; - IMAGE_DATA_DIRECTORY *pDir = GetDirectoryEntry(IMAGE_DIRECTORY_ENTRY_RESOURCE); - - if (pDir->VirtualAddress == 0) - return true; - - DWORD rvaOfResourceSection = pDir->VirtualAddress; - - ResourceEnumerateNamesState state; - state.context = context; - state.namesCallback = NULL; - state.langIDcallback = callback; - state.nameType = lpType; - state.nameName = lpName; - state.callbackPerName = EnumerateNamesForLangID; - state.callbackPerLangID = EnumerateLangIDs; - - return EnumerateWin32ResourceTable(this, rvaOfResourceSection, rvaOfResourceSection, EnumerateTypesForNames, &state); -} - READYTORUN_HEADER * PEDecoder::FindReadyToRunHeader() const { CONTRACTL diff --git a/src/coreclr/utilcode/sstring.cpp b/src/coreclr/utilcode/sstring.cpp index a7681e8fec75b6..276615aa22f581 100644 --- a/src/coreclr/utilcode/sstring.cpp +++ b/src/coreclr/utilcode/sstring.cpp @@ -1,10 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// --------------------------------------------------------------------------- -// SString.cpp -// - -// --------------------------------------------------------------------------- #include "stdafx.h" #include "sstring.h" @@ -1647,31 +1642,6 @@ void SString::LowerCase(__inout_z LPWSTR wszString) } } -//----------------------------------------------------------------------------- -// Convert string to unicode uppercase using the invariant culture -// Note: Please don't use it in PATH as multiple character can map to the same -// upper case symbol -//----------------------------------------------------------------------------- -void SString::UpperCase() -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - if (IsRepresentation(REPRESENTATION_UNICODE)) NOTHROW; else THROWS; - GC_NOTRIGGER; - SUPPORTS_DAC; - } - SS_CONTRACT_END; - - ConvertToUnicode(); - - for (WCHAR *pwch = GetRawUnicode(); pwch < GetRawUnicode() + GetRawCount(); ++pwch) - { - *pwch = (CAN_SIMPLE_UPCASE(*pwch) ? SIMPLE_UPCASE(*pwch) : MapChar(*pwch, LCMAP_UPPERCASE)); - } -} - //----------------------------------------------------------------------------- // Safe version of sprintf. // Prints formatted ansi text w/ var args to this buffer. diff --git a/src/coreclr/utilcode/stresslog.cpp b/src/coreclr/utilcode/stresslog.cpp index 1ecde44185a6d3..867af04d4e234b 100644 --- a/src/coreclr/utilcode/stresslog.cpp +++ b/src/coreclr/utilcode/stresslog.cpp @@ -1,12 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -/*************************************************************************************/ -/* StressLog.cpp */ -/*************************************************************************************/ - -/*************************************************************************************/ - #include "stdafx.h" // precompiled headers #include "switches.h" @@ -710,26 +704,6 @@ BOOL StressLog::ReserveStressLogChunks (unsigned chunksToReserve) return msgs->chunkListLength >= (LONG)chunksToReserve; } -void (*FSwitchToSOTolerant)(); -void (*FSwitchToSOIntolerant)(); -void TrackSO(BOOL tolerance) -{ - if (tolerance) - { - if (FSwitchToSOTolerant) - { - FSwitchToSOTolerant(); - } - } - else - { - if (FSwitchToSOIntolerant) - { - FSwitchToSOIntolerant(); - } - } -} - /*********************************************************************************/ /* fetch a buffer that can be used to write a stress message, it is thread safe */ FORCEINLINE void ThreadStressLog::LogMsg(unsigned facility, int cArgs, const char* format, va_list Args) diff --git a/src/coreclr/utilcode/util.cpp b/src/coreclr/utilcode/util.cpp index 7304af85d462d3..5def303a7b28fb 100644 --- a/src/coreclr/utilcode/util.cpp +++ b/src/coreclr/utilcode/util.cpp @@ -1,13 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //***************************************************************************** // util.cpp -// - // // This contains a bunch of C++ utility classes. -// //***************************************************************************** + #include "stdafx.h" // Precompiled header key. #include "utilcode.h" #include "metadata.h" @@ -1057,29 +1056,6 @@ int GetCurrentProcessCpuCount() return count; } -#ifdef HOST_WINDOWS -DWORD_PTR GetCurrentProcessCpuMask() -{ - CONTRACTL - { - NOTHROW; - CANNOT_TAKE_LOCK; - } - CONTRACTL_END; - -#ifdef HOST_WINDOWS - DWORD_PTR pmask, smask; - - if (!GetProcessAffinityMask(GetCurrentProcess(), &pmask, &smask)) - return 1; - - return pmask; -#else - return 0; -#endif -} -#endif // HOST_WINDOWS - //============================================================================= // AssemblyNamesList //============================================================================= diff --git a/src/coreclr/vm/CMakeLists.txt b/src/coreclr/vm/CMakeLists.txt index ad6b44d9dff0f3..44ee5e0d84f947 100644 --- a/src/coreclr/vm/CMakeLists.txt +++ b/src/coreclr/vm/CMakeLists.txt @@ -315,7 +315,6 @@ set(VM_SOURCES_WKS callstubgenerator.cpp clrconfignative.cpp clrex.cpp - comdatetime.cpp comdelegate.cpp comdependenthandle.cpp comdynamic.cpp @@ -430,7 +429,6 @@ set(VM_HEADERS_WKS ceemain.h clrconfignative.h clrex.h - comdatetime.h comdelegate.h comdependenthandle.h comdynamic.h diff --git a/src/coreclr/vm/amd64/cgenamd64.cpp b/src/coreclr/vm/amd64/cgenamd64.cpp index 8a88987d909323..221234925988ea 100644 --- a/src/coreclr/vm/amd64/cgenamd64.cpp +++ b/src/coreclr/vm/amd64/cgenamd64.cpp @@ -394,40 +394,6 @@ BOOL GetAnyThunkTarget (CONTEXT *pctx, TADDR *pTarget, TADDR *pTargetMethodDesc) #ifndef DACCESS_COMPILE -void EncodeLoadAndJumpThunk (LPBYTE pBuffer, LPVOID pv, LPVOID pTarget) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - MODE_ANY; - - PRECONDITION(CheckPointer(pBuffer)); - } - CONTRACTL_END; - - // mov r10, pv 49 ba xx xx xx xx xx xx xx xx - - pBuffer[0] = 0x49; - pBuffer[1] = 0xBA; - - SET_UNALIGNED_64(&pBuffer[2], pv); - - // mov rax, pTarget 48 b8 xx xx xx xx xx xx xx xx - - pBuffer[10] = 0x48; - pBuffer[11] = 0xB8; - - SET_UNALIGNED_64(&pBuffer[12], pTarget); - - // jmp rax ff e0 - - pBuffer[20] = 0xFF; - pBuffer[21] = 0xE0; - - _ASSERTE(DbgIsExecutable(pBuffer, 22)); -} - void emitBackToBackJump(LPBYTE pBufferRX, LPBYTE pBufferRW, LPVOID target) { CONTRACTL @@ -524,69 +490,6 @@ INT32 rel32UsingJumpStub(INT32 UNALIGNED * pRel32, PCODE target, MethodDesc *pMe return static_cast(offset); } -INT32 rel32UsingPreallocatedJumpStub(INT32 UNALIGNED * pRel32, PCODE target, PCODE jumpStubAddrRX, PCODE jumpStubAddrRW, bool emitJump) -{ - CONTRACTL - { - THROWS; // emitBackToBackJump may throw (see emitJump) - GC_NOTRIGGER; - } - CONTRACTL_END; - - TADDR baseAddr = (TADDR)pRel32 + 4; - _ASSERTE(FitsInI4(jumpStubAddrRX - baseAddr)); - - INT_PTR offset = target - baseAddr; - if (!FitsInI4(offset) INDEBUG(|| PEDecoder::GetForceRelocs())) - { - offset = jumpStubAddrRX - baseAddr; - if (!FitsInI4(offset)) - { - _ASSERTE(!"jump stub was not in expected range"); - EEPOLICY_HANDLE_FATAL_ERROR(COR_E_EXECUTIONENGINE); - } - - if (emitJump) - { - emitBackToBackJump((LPBYTE)jumpStubAddrRX, (LPBYTE)jumpStubAddrRW, (LPVOID)target); - } - else - { - _ASSERTE(decodeBackToBackJump(jumpStubAddrRX) == target); - } - } - - _ASSERTE(FitsInI4(offset)); - return static_cast(offset); -} -// -// Some AMD64 assembly functions have one or more DWORDS at the end of the function -// that specify the offsets where significant instructions are -// we use this function to get at these offsets -// -DWORD GetOffsetAtEndOfFunction(ULONGLONG uImageBase, - PT_RUNTIME_FUNCTION pFunctionEntry, - int offsetNum /* = 1*/) -{ - CONTRACTL - { - MODE_ANY; - NOTHROW; - GC_NOTRIGGER; - PRECONDITION((offsetNum > 0) && (offsetNum < 20)); /* we only allow reasonable offsetNums 1..19 */ - } - CONTRACTL_END; - - DWORD functionSize = pFunctionEntry->EndAddress - pFunctionEntry->BeginAddress; - BYTE* pEndOfFunction = (BYTE*) (uImageBase + pFunctionEntry->EndAddress); - DWORD* pOffset = (DWORD*) (pEndOfFunction) - offsetNum; - DWORD offsetInFunc = *pOffset; - - _ASSERTE_ALL_BUILDS((offsetInFunc >= 0) && (offsetInFunc < functionSize)); - - return offsetInFunc; -} - #ifdef FEATURE_READYTORUN // diff --git a/src/coreclr/vm/amd64/cgencpu.h b/src/coreclr/vm/amd64/cgencpu.h index 52449554b2ef5d..f0c29085a74417 100644 --- a/src/coreclr/vm/amd64/cgencpu.h +++ b/src/coreclr/vm/amd64/cgencpu.h @@ -1,13 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + // CGENCPU.H - // // Various helper routines for generating AMD64 assembly code. // // DO NOT INCLUDE THIS FILE DIRECTLY - ALWAYS USE CGENSYS.H INSTEAD -// - - #ifndef TARGET_AMD64 #error Should only include "AMD64\cgencpu.h" for AMD64 builds @@ -486,20 +484,10 @@ inline TADDR GetSecondArgReg(CONTEXT *context) extern "C" void* GetCurrentSP(); -// Emits: -// mov r10, pv1 -// mov rax, pTarget -// jmp rax -void EncodeLoadAndJumpThunk (LPBYTE pBuffer, LPVOID pv, LPVOID pTarget); - - // Get Rel32 destination, emit jumpStub if necessary INT32 rel32UsingJumpStub(INT32 UNALIGNED * pRel32, PCODE target, MethodDesc *pMethod, LoaderAllocator *pLoaderAllocator = NULL, bool throwOnOutOfMemoryWithinRange = true); -// Get Rel32 destination, emit jumpStub if necessary into a preallocated location -INT32 rel32UsingPreallocatedJumpStub(INT32 UNALIGNED * pRel32, PCODE target, PCODE jumpStubAddr, PCODE jumpStubAddrRW, bool emitJump); - void emitBackToBackJump(LPBYTE pBufferRX, LPBYTE pBufferRW, LPVOID target); bool isBackToBackJump(PCODE pCode); @@ -540,14 +528,6 @@ struct HijackArgs }; }; -#ifndef DACCESS_COMPILE - -DWORD GetOffsetAtEndOfFunction(ULONGLONG uImageBase, - PT_RUNTIME_FUNCTION pFunctionEntry, - int offsetNum = 1); - -#endif // DACCESS_COMPILE - // ClrFlushInstructionCache is used when we want to call FlushInstructionCache // for a specific architecture in the common code, but not for other architectures. // We call ClrFlushInstructionCache whenever we create or modify code in the heap. diff --git a/src/coreclr/vm/appdomain.cpp b/src/coreclr/vm/appdomain.cpp index be380486e356ca..c9a99a46bf89e8 100644 --- a/src/coreclr/vm/appdomain.cpp +++ b/src/coreclr/vm/appdomain.cpp @@ -429,23 +429,6 @@ void PinnedHeapHandleTable::EnumStaticGCRefs(promote_func* fn, ScanContext* sc) #undef LOADERHEAP_PROFILE_COUNTER -void AppDomain::ClearBinderContext() -{ - CONTRACTL - { - NOTHROW; - GC_TRIGGERS; - MODE_PREEMPTIVE; - } - CONTRACTL_END; - - if (m_pDefaultBinder) - { - delete m_pDefaultBinder; - m_pDefaultBinder = NULL; - } -} - void AppDomain::ShutdownFreeLoaderAllocators() { // If we're called from managed code (i.e. the finalizer thread) we take a lock in @@ -769,26 +752,6 @@ void SystemDomain::DetachBegin() m_pSystemDomain->Stop(); } -void SystemDomain::DetachEnd() -{ - CONTRACTL - { - NOTHROW; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - // Shut down the domain and its children (but don't deallocate anything just - // yet). - if(m_pSystemDomain) - { - GCX_PREEMP(); - AppDomain* pAppDomain = GetAppDomain(); - if (pAppDomain) - pAppDomain->ClearBinderContext(); - } -} - void SystemDomain::Stop() { WRAPPER_NO_CONTRACT; @@ -1330,12 +1293,6 @@ Module* SystemDomain::GetCallersModule(StackCrawlMark* stackMark) return NULL; } -struct CallersData -{ - int skip; - MethodDesc* pMethod; -}; - /*static*/ Assembly* SystemDomain::GetCallersAssembly(StackCrawlMark *stackMark) { @@ -1442,26 +1399,6 @@ StackWalkAction SystemDomain::CallersMethodCallbackWithStackMark(CrawlFrame* pCf return SWA_ABORT; } -/*private static*/ -StackWalkAction SystemDomain::CallersMethodCallback(CrawlFrame* pCf, VOID* data) -{ - LIMITED_METHOD_CONTRACT; - MethodDesc *pFunc = pCf->GetFunction(); - - /* We asked to be called back only for functions */ - _ASSERTE(pFunc); - - CallersData* pCaller = (CallersData*) data; - if(pCaller->skip == 0) { - pCaller->pMethod = pFunc; - return SWA_ABORT; - } - else { - pCaller->skip--; - return SWA_CONTINUE; - } -} - void AppDomain::Create() { STANDARD_VM_CONTRACT; @@ -1558,45 +1495,6 @@ void SystemDomain::NotifyProfilerStartup() } } -HRESULT SystemDomain::NotifyProfilerShutdown() -{ - CONTRACTL - { - NOTHROW; - GC_TRIGGERS; - MODE_PREEMPTIVE; - } - CONTRACTL_END; - - { - BEGIN_PROFILER_CALLBACK(CORProfilerTrackAppDomainLoads()); - _ASSERTE(System()); - (&g_profControlBlock)->AppDomainShutdownStarted((AppDomainID) System()); - END_PROFILER_CALLBACK(); - } - - { - BEGIN_PROFILER_CALLBACK(CORProfilerTrackAppDomainLoads()); - _ASSERTE(System()); - (&g_profControlBlock)->AppDomainShutdownFinished((AppDomainID) System(), S_OK); - END_PROFILER_CALLBACK(); - } - - { - BEGIN_PROFILER_CALLBACK(CORProfilerTrackAppDomainLoads()); - _ASSERTE(AppDomain::GetCurrentDomain()); - (&g_profControlBlock)->AppDomainShutdownStarted((AppDomainID) AppDomain::GetCurrentDomain()); - END_PROFILER_CALLBACK(); - } - - { - BEGIN_PROFILER_CALLBACK(CORProfilerTrackAppDomainLoads()); - _ASSERTE(AppDomain::GetCurrentDomain()); - (&g_profControlBlock)->AppDomainShutdownFinished((AppDomainID) AppDomain::GetCurrentDomain(), S_OK); - END_PROFILER_CALLBACK(); - } - return S_OK; -} #endif // PROFILING_SUPPORTED AppDomain::AppDomain() diff --git a/src/coreclr/vm/appdomain.hpp b/src/coreclr/vm/appdomain.hpp index 1a014b6d66814c..644cc0da8ce26b 100644 --- a/src/coreclr/vm/appdomain.hpp +++ b/src/coreclr/vm/appdomain.hpp @@ -2,15 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. /*============================================================ -** ** Header: AppDomain.cpp -** - ** ** Purpose: Implements AppDomain (loader domain) architecture -** -** ===========================================================*/ + #ifndef _APPDOMAIN_H #define _APPDOMAIN_H @@ -1206,9 +1202,6 @@ class AppDomain final DefaultAssemblyBinder *CreateDefaultBinder(); DefaultAssemblyBinder *GetDefaultBinder() {LIMITED_METHOD_CONTRACT; return m_pDefaultBinder; } - // Only call this routine when you can guarantee there are no loads in progress. - void ClearBinderContext(); - static void RaiseExitProcessEvent(); Assembly* RaiseResourceResolveEvent(Assembly* pAssembly, LPCSTR szName); Assembly* RaiseTypeResolveEventThrowing(Assembly* pAssembly, LPCSTR szName, ASSEMBLYREF *pResultingAssemblyRef); @@ -1567,13 +1560,6 @@ class SystemDomain final // DetachBegin stops all domains, while DetachEnd deallocates domain resources. static void DetachBegin(); - //**************************************************************************************** - // - // To be run during shutdown. This must be done after all operations - // that require the use of system classes (i.e., exceptions). - // DetachBegin stops release resources held by systemdomain and the default domain. - static void DetachEnd(); - //**************************************************************************************** // // Initializes and shutdowns the single instance of the SystemDomain @@ -1716,11 +1702,6 @@ class SystemDomain final // Tell profiler about system created domains which are created before the profiler is // actually activated. static void NotifyProfilerStartup(); - - //**************************************************************************************** - // Tell profiler at shutdown that system created domains are going away. They are not - // torn down using the normal sequence. - static HRESULT NotifyProfilerShutdown(); #endif // PROFILING_SUPPORTED #ifndef DACCESS_COMPILE @@ -1778,9 +1759,6 @@ class SystemDomain final void PreallocateSpecialObjects(); - //**************************************************************************************** - // - static StackWalkAction CallersMethodCallback(CrawlFrame* pCrawlFrame, VOID* pClientData); static StackWalkAction CallersMethodCallbackWithStackMark(CrawlFrame* pCrawlFrame, VOID* pClientData); #ifndef DACCESS_COMPILE diff --git a/src/coreclr/vm/arm/cgencpu.h b/src/coreclr/vm/arm/cgencpu.h index 4e91a45ccab0cd..cb708407f6f23d 100644 --- a/src/coreclr/vm/arm/cgencpu.h +++ b/src/coreclr/vm/arm/cgencpu.h @@ -1,7 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// - #ifndef TARGET_ARM #error Should only include "cGenCpu.h" for ARM builds @@ -277,53 +275,6 @@ inline void ClearITState(T_CONTEXT *context) { context->Cpsr = context->Cpsr & 0xf9ff03ff; } -//------------------------------------------------------------------------ -inline void emitUnconditionalBranchThumb(LPBYTE pBuffer, int16_t offset) -{ - LIMITED_METHOD_CONTRACT; - - uint16_t *pInstr = (uint16_t *) pBuffer; - - // offset from -2KB to +2KB - _ASSERTE (offset >= - MAX_OFFSET_UNCONDITIONAL_BRANCH_THUMB && offset < MAX_OFFSET_UNCONDITIONAL_BRANCH_THUMB); - - if (offset >= 0) - { - offset = offset >> 1; - } - else - { - offset = ((MAX_OFFSET_UNCONDITIONAL_BRANCH_THUMB + offset) >> 1) | 0x400; - } - - *pInstr = 0xE000 | offset; -} - -//------------------------------------------------------------------------ -inline int16_t decodeUnconditionalBranchThumb(LPBYTE pBuffer) -{ - LIMITED_METHOD_CONTRACT; - - uint16_t *pInstr = (uint16_t *) pBuffer; - - int16_t offset = (~0xE000) & (*pInstr); - - if ((offset & 0x400) == 0) - { - offset = offset << 1; - } - else - { - offset = (~0x400) & offset; - offset = (offset << 1) - MAX_OFFSET_UNCONDITIONAL_BRANCH_THUMB; - } - - // offset from -2KB to +2KB - _ASSERTE (offset >= - MAX_OFFSET_UNCONDITIONAL_BRANCH_THUMB && offset < MAX_OFFSET_UNCONDITIONAL_BRANCH_THUMB); - - return offset; -} - //------------------------------------------------------------------------ inline void emitBackToBackJump(LPBYTE pBufferRX, LPBYTE pBufferRW, LPVOID target) { diff --git a/src/coreclr/vm/callhelpers.cpp b/src/coreclr/vm/callhelpers.cpp index d97b56360ad75f..8cbe221e8b198d 100644 --- a/src/coreclr/vm/callhelpers.cpp +++ b/src/coreclr/vm/callhelpers.cpp @@ -139,69 +139,6 @@ void CopyReturnedFpStructFromRegisters(void* dest, UINT64 returnRegs[2], FpStruc } #endif // TARGET_RISCV64 || TARGET_LOONGARCH64 -// Helper for VM->managed calls with simple signatures. -void* DispatchCallSimple( - SIZE_T *pSrc, - DWORD numStackSlotsToCopy, - PCODE pTargetAddress, - BOOL fCriticalCall) -{ - CONTRACTL - { - GC_TRIGGERS; - THROWS; - MODE_COOPERATIVE; - } - CONTRACTL_END; - -#ifdef DEBUGGING_SUPPORTED - if (CORDebuggerTraceCall()) - g_pDebugInterface->TraceCall((const BYTE *)pTargetAddress); -#endif // DEBUGGING_SUPPORTED - - CallDescrData callDescrData; - -#ifdef CALLDESCR_ARGREGS - callDescrData.pSrc = pSrc + NUM_ARGUMENT_REGISTERS; - callDescrData.numStackSlots = numStackSlotsToCopy; - callDescrData.pArgumentRegisters = (ArgumentRegisters *)pSrc; -#else - callDescrData.pSrc = pSrc; - callDescrData.numStackSlots = numStackSlotsToCopy; -#endif - -#ifdef CALLDESCR_RETBUFFARGREG - UINT64 retBuffArgPlaceholder = 0; - callDescrData.pRetBuffArg = &retBuffArgPlaceholder; -#endif - -#ifdef CALLDESCR_FPARGREGS - callDescrData.pFloatArgumentRegisters = NULL; -#endif -#ifdef CALLDESCR_REGTYPEMAP - callDescrData.dwRegTypeMap = 0; -#endif - callDescrData.fpReturnSize = 0; - callDescrData.pTarget = pTargetAddress; - -#ifdef TARGET_WASM - static_assert(2*sizeof(ARGHOLDER_TYPE) == INTERP_STACK_SLOT_SIZE); - callDescrData.nArgsSize = numStackSlotsToCopy * sizeof(ARGHOLDER_TYPE)*2; - callDescrData.hasRetBuff = false; - callDescrData.pTransitionBlock = NULL; - LPVOID pOrigSrc = callDescrData.pSrc; - callDescrData.pSrc = (LPVOID)_alloca(callDescrData.nArgsSize); - for (int i = 0; i < numStackSlotsToCopy; i++) - { - ((ARGHOLDER_TYPE*)callDescrData.pSrc)[i*2] = ((ARGHOLDER_TYPE*)pOrigSrc)[i]; - } -#endif // TARGET_WASM - - CallDescrWorkerWithHandler(&callDescrData, fCriticalCall); - - return *(void **)(&callDescrData.returnValue); -} - #ifdef CALLDESCR_REGTYPEMAP //******************************************************************************* void FillInRegTypeMap(int argOffset, CorElementType typ, BYTE * pMap) diff --git a/src/coreclr/vm/callhelpers.h b/src/coreclr/vm/callhelpers.h index 52ebf3d36db066..d38962e6c8cfd3 100644 --- a/src/coreclr/vm/callhelpers.h +++ b/src/coreclr/vm/callhelpers.h @@ -76,13 +76,6 @@ void CallDescrWorkerWithHandler( CallDescrData * pCallDescrData, BOOL fCriticalCall = FALSE); -// Helper for VM->managed calls with simple signatures. -void* DispatchCallSimple( - SIZE_T *pSrc, - DWORD numStackSlotsToCopy, - PCODE pTargetAddress, - BOOL fCriticalCall); - #if defined(TARGET_RISCV64) || defined(TARGET_LOONGARCH64) // Copy structs returned according to floating-point calling convention from 'returnRegs' containing struct fields // (each returned in one register) as they are filled by CallDescrWorkerInternal, to the final destination in memory diff --git a/src/coreclr/vm/ceeload.cpp b/src/coreclr/vm/ceeload.cpp index 27b228c0ed5cb0..bb715fff159c96 100644 --- a/src/coreclr/vm/ceeload.cpp +++ b/src/coreclr/vm/ceeload.cpp @@ -1,15 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + // =========================================================================== // File: CEELOAD.CPP // - -// - // CEELOAD reads in the PE file format using LoadLibrary // =========================================================================== - #include "common.h" #include "array.h" @@ -866,8 +863,6 @@ BOOL Module::IsCollectible() } #ifndef DACCESS_COMPILE -#include "staticallocationhelpers.inl" - // initialize Crst controlling the Dynamic IL hashtable void Module::InitializeDynamicILCrst() { @@ -1560,66 +1555,6 @@ void Module::StartUnload() SetBeingUnloaded(); } -#if defined(FEATURE_READYTORUN) -//--------------------------------------------------------------------------------------- -// Check if the target module is in the same version bubble as this one -// The current implementation uses the presence of an AssemblyRef for the target module's assembly in -// the native manifest metadata. -// -// Arguments: -// * target - target module to check -// -// Return Value: -// TRUE if the target module is in the same version bubble as this one -// -BOOL Module::IsInSameVersionBubble(Module *target) -{ - STANDARD_VM_CONTRACT; - - if (this == target) - { - return TRUE; - } - - if (!IsReadyToRun()) - { - return FALSE; - } - - NativeImage *nativeImage = this->GetCompositeNativeImage(); - - if (nativeImage != NULL) - { - if (nativeImage == target->GetCompositeNativeImage()) - { - // Fast path for modules contained within the same native image - return TRUE; - } - } - - IMDInternalImport* pMdImport = GetReadyToRunInfo()->GetNativeManifestModule()->GetMDImport(); - if (pMdImport == NULL) - return FALSE; - - LPCUTF8 targetName = target->GetAssembly()->GetSimpleName(); - - HENUMInternal assemblyEnum; - HRESULT hr = pMdImport->EnumAllInit(mdtAssemblyRef, &assemblyEnum); - mdAssemblyRef assemblyRef; - while (pMdImport->EnumNext(&assemblyEnum, &assemblyRef)) - { - LPCSTR assemblyName; - hr = pMdImport->GetAssemblyRefProps(assemblyRef, NULL, NULL, &assemblyName, NULL, NULL, NULL, NULL); - if (strcmp(assemblyName, targetName) == 0) - { - return TRUE; - } - } - - return FALSE; -} -#endif // FEATURE_READYTORUN - //--------------------------------------------------------------------------------------- #ifdef PROFILING_SUPPORTED // diff --git a/src/coreclr/vm/ceeload.h b/src/coreclr/vm/ceeload.h index 2f680bed66da50..8d779b0caa1906 100644 --- a/src/coreclr/vm/ceeload.h +++ b/src/coreclr/vm/ceeload.h @@ -1,9 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + // =========================================================================== // File: CEELOAD.H -// - // // CEELOAD.H defines the class use to represent the PE file // =========================================================================== @@ -1054,11 +1053,6 @@ class Module : public ModuleBase HRESULT GetReadablePublicMetaDataInterface(DWORD dwOpenFlags, REFIID riid, LPVOID * ppvInterface); #endif // PROFILING_SUPPORTED -#if defined(FEATURE_READYTORUN) - BOOL IsInSameVersionBubble(Module *target); -#endif // FEATURE_READYTORUN - - LPCWSTR GetPathForErrorMessages() final; diff --git a/src/coreclr/vm/codeman.cpp b/src/coreclr/vm/codeman.cpp index f8134ceb764ec9..c115a131e49832 100644 --- a/src/coreclr/vm/codeman.cpp +++ b/src/coreclr/vm/codeman.cpp @@ -1,9 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// // codeman.cpp - a managment class for handling multiple code managers -// #include "common.h" #include "jitinterface.h" @@ -1442,9 +1440,6 @@ EEJitManager::EEJitManager() m_jit = NULL; m_JITCompiler = NULL; -#ifdef TARGET_AMD64 - m_pEmergencyJumpStubReserveList = NULL; -#endif #if defined(TARGET_X86) || defined(TARGET_AMD64) m_JITCompilerOther = NULL; #endif @@ -2542,121 +2537,6 @@ void ThrowOutOfMemoryWithinRange() EX_THROW(EEMessageException, (kOutOfMemoryException, IDS_EE_OUT_OF_MEMORY_WITHIN_RANGE)); } -#ifdef TARGET_AMD64 -BYTE * EEJitManager::AllocateFromEmergencyJumpStubReserve(const BYTE * loAddr, const BYTE * hiAddr, SIZE_T * pReserveSize) -{ - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(m_CodeHeapLock.OwnedByCurrentThread()); - } CONTRACTL_END; - - for (EmergencyJumpStubReserve ** ppPrev = &m_pEmergencyJumpStubReserveList; *ppPrev != NULL; ppPrev = &(*ppPrev)->m_pNext) - { - EmergencyJumpStubReserve * pList = *ppPrev; - - if (loAddr <= pList->m_ptr && - pList->m_ptr + pList->m_size < hiAddr) - { - *ppPrev = pList->m_pNext; - - BYTE * pBlock = pList->m_ptr; - *pReserveSize = pList->m_size; - - delete pList; - - return pBlock; - } - } - - return NULL; -} - -VOID EEJitManager::EnsureJumpStubReserve(BYTE * pImageBase, SIZE_T imageSize, SIZE_T reserveSize) -{ - CONTRACTL { - THROWS; - GC_NOTRIGGER; - } CONTRACTL_END; - - CrstHolder ch(&m_CodeHeapLock); - - BYTE * loAddr = pImageBase + imageSize + INT32_MIN; - if (loAddr > pImageBase) loAddr = NULL; // overflow - - BYTE * hiAddr = pImageBase + INT32_MAX; - if (hiAddr < pImageBase) hiAddr = (BYTE *)UINT64_MAX; // overflow - - for (EmergencyJumpStubReserve * pList = m_pEmergencyJumpStubReserveList; pList != NULL; pList = pList->m_pNext) - { - if (loAddr <= pList->m_ptr && - pList->m_ptr + pList->m_size < hiAddr) - { - SIZE_T used = min(reserveSize, pList->m_free); - pList->m_free -= used; - - reserveSize -= used; - if (reserveSize == 0) - return; - } - } - - // Try several different strategies - the most efficient one first - int allocMode = 0; - - // Try to reserve at least 16MB at a time - SIZE_T allocChunk = max(ALIGN_UP(reserveSize, VIRTUAL_ALLOC_RESERVE_GRANULARITY), 16*1024*1024); - - while (reserveSize > 0) - { - NewHolder pNewReserve(new EmergencyJumpStubReserve()); - - while (true) - { - BYTE * loAddrCurrent = loAddr; - BYTE * hiAddrCurrent = hiAddr; - - switch (allocMode) - { - case 0: - // First, try to allocate towards the center of the allowed range. It is more likely to - // satisfy subsequent reservations. - loAddrCurrent = loAddr + (hiAddr - loAddr) / 8; - hiAddrCurrent = hiAddr - (hiAddr - loAddr) / 8; - break; - case 1: - // Try the whole allowed range - break; - case 2: - // If the large allocation failed, retry with small chunk size - allocChunk = VIRTUAL_ALLOC_RESERVE_GRANULARITY; - break; - default: - return; // Unable to allocate the reserve - give up - } - - pNewReserve->m_ptr = (BYTE*)ExecutableAllocator::Instance()->ReserveWithinRange(allocChunk, loAddrCurrent, hiAddrCurrent); - - if (pNewReserve->m_ptr != NULL) - break; - - // Retry with the next allocation strategy - allocMode++; - } - - SIZE_T used = min(allocChunk, reserveSize); - reserveSize -= used; - - pNewReserve->m_size = allocChunk; - pNewReserve->m_free = allocChunk - used; - - // Add it to the list - pNewReserve->m_pNext = m_pEmergencyJumpStubReserveList; - m_pEmergencyJumpStubReserveList = pNewReserve.Extract(); - } -} -#endif // TARGET_AMD64 - static size_t GetDefaultReserveForJumpStubs(size_t codeHeapSize) { LIMITED_METHOD_CONTRACT; @@ -2709,7 +2589,6 @@ HeapList* LoaderCodeHeap::CreateCodeHeap(CodeHeapRequestInfo *pInfo, LoaderHeap BYTE * pBaseAddr = NULL; DWORD dwSizeAcquiredFromInitialBlock = 0; - bool fAllocatedFromEmergencyJumpStubReserve = false; size_t allocationSize = pCodeHeap->m_LoaderHeap.AllocMem_TotalSize(initialRequestSize); #if defined(TARGET_64BIT) @@ -2753,19 +2632,11 @@ HeapList* LoaderCodeHeap::CreateCodeHeap(CodeHeapRequestInfo *pInfo, LoaderHeap if (!pBaseAddr) { - // Conserve emergency jump stub reserve until when it is really needed if (!pInfo->GetThrowOnOutOfMemoryWithinRange()) { return NULL; } -#ifdef TARGET_AMD64 - pBaseAddr = ExecutionManager::GetEEJitManager()->AllocateFromEmergencyJumpStubReserve(loAddr, hiAddr, &reserveSize); - if (!pBaseAddr) - ThrowOutOfMemoryWithinRange(); - fAllocatedFromEmergencyJumpStubReserve = true; -#else ThrowOutOfMemoryWithinRange(); -#endif // TARGET_AMD64 } } else @@ -2813,7 +2684,7 @@ HeapList* LoaderCodeHeap::CreateCodeHeap(CodeHeapRequestInfo *pInfo, LoaderHeap } else { - pHp->reserveForJumpStubs = fAllocatedFromEmergencyJumpStubReserve ? pHp->maxCodeHeapSize : GetDefaultReserveForJumpStubs(pHp->maxCodeHeapSize); + pHp->reserveForJumpStubs = GetDefaultReserveForJumpStubs(pHp->maxCodeHeapSize); } _ASSERTE(heapSize >= initialRequestSize); diff --git a/src/coreclr/vm/codeman.h b/src/coreclr/vm/codeman.h index 21ab76810e1676..d788a4feb7acbf 100644 --- a/src/coreclr/vm/codeman.h +++ b/src/coreclr/vm/codeman.h @@ -1,17 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - - - /****************************************************************************** - Module Name: - codeman.h Abstract: - Wrapper to facilitate multiple JITcompiler support in the CLR The ExecutionManager is responsible for managing the RangeSections. @@ -51,7 +45,6 @@ Module Name: +--------+ R +--------+ R |ICodeMan| |ICodeMan| (RangeSections) +--------+ +--------+ - ******************************************************************************/ #ifndef __CODEMAN_HPP__ @@ -2362,26 +2355,6 @@ class EEJitManager final : public EECodeGenManager private : Crst m_JitLoadLock; -#ifdef TARGET_AMD64 -private: - // - // List of reserved memory blocks to be used for jump stub allocation if no suitable memory block is found - // via the regular mechanism - // - struct EmergencyJumpStubReserve - { - EmergencyJumpStubReserve * m_pNext; - BYTE * m_ptr; - SIZE_T m_size; - SIZE_T m_free; - }; - EmergencyJumpStubReserve * m_pEmergencyJumpStubReserveList; - -public: - BYTE * AllocateFromEmergencyJumpStubReserve(const BYTE * loAddr, const BYTE * hiAddr, SIZE_T * pReserveSize); - VOID EnsureJumpStubReserve(BYTE * pImageBase, SIZE_T imageSize, SIZE_T reserveSize); -#endif - public: ICorJitCompiler * m_jit; HINSTANCE m_JITCompiler; diff --git a/src/coreclr/vm/comdatetime.cpp b/src/coreclr/vm/comdatetime.cpp deleted file mode 100644 index 376dca4eab3267..00000000000000 --- a/src/coreclr/vm/comdatetime.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - - -#include "common.h" -#include "object.h" -#include "excep.h" -#include "frames.h" -#include "vars.hpp" -#include "comdatetime.h" - -const INT64 COMDateTime::TicksPerMillisecond = 10000; -const INT64 COMDateTime::TicksPerSecond = TicksPerMillisecond * 1000; -const INT64 COMDateTime::TicksPerMinute = TicksPerSecond * 60; -const INT64 COMDateTime::TicksPerHour = TicksPerMinute * 60; -const INT64 COMDateTime::TicksPerDay = TicksPerHour * 24; - -const INT64 COMDateTime::MillisPerSecond = 1000; -const INT64 COMDateTime::MillisPerDay = MillisPerSecond * 60 * 60 * 24; - -const int COMDateTime::DaysPer4Years = 365 * 4 + 1; -const int COMDateTime::DaysPer100Years = DaysPer4Years * 25 - 1; -const int COMDateTime::DaysPer400Years = DaysPer100Years * 4 + 1; - -// Number of days from 1/1/0001 to 1/1/10000 -const int COMDateTime::DaysTo10000 = DaysPer400Years * 25 - 366; - -const int COMDateTime::DaysTo1899 = DaysPer400Years * 4 + DaysPer100Years * 3 - 367; - -const INT64 COMDateTime::DoubleDateOffset = DaysTo1899 * TicksPerDay; - -// OA Min Date is Jan 1, 100 AD. This is after converting to ticks. -const INT64 COMDateTime::OADateMinAsTicks = (DaysPer100Years - 365) * TicksPerDay; - -// All OA dates must be greater than (not >=) OADateMinAsDouble -const double COMDateTime::OADateMinAsDouble = -657435.0; - -// All OA dates must be less than (not <=) OADateMaxAsDouble -const double COMDateTime::OADateMaxAsDouble = 2958466.0; - -const INT64 COMDateTime::MaxTicks = DaysTo10000 * TicksPerDay; -const INT64 COMDateTime::MaxMillis = DaysTo10000 * MillisPerDay; - -const INT64 TicksMask = 0x3FFFFFFFFFFFFFFFLL; - -// This function is duplicated in DateTime.cs -INT64 COMDateTime::DoubleDateToTicks(const double d) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_COOPERATIVE; - } CONTRACTL_END; - - // Make sure this date is a valid OleAut date. This is the check from the internal - // OleAut macro IsValidDate, found in oledisp.h. Eventually at least the 64 bit - // build of oleaut will define these gregorian max and min values as public constants. - // The check done this way will take care of NaN - if (!(d < OADateMaxAsDouble) || !(d > OADateMinAsDouble)) - COMPlusThrow(kArgumentException, W("Arg_OleAutDateInvalid")); - - // Conversion to int64 will not cause an overflow here, as at this point the "d" is in between OADateMinAsDouble and OADateMaxAsDouble - INT64 millis = (INT64)(d * MillisPerDay + (d >= 0? 0.5: -0.5)); - if (millis < 0) millis -= (millis % MillisPerDay) * 2; - // There are cases when we are very close to -1 and 1 in which case millis%MillisPerDay is 0 since we have exactly one day due to rounding issues. - millis += DoubleDateOffset / TicksPerMillisecond; - - if (millis < 0 || millis >= MaxMillis) - { - COMPlusThrow(kArgumentException, W("Arg_OleAutDateScale")); // Cannot be equal to MaxMillis. - } - return millis * TicksPerMillisecond; -} - -// This function is duplicated in DateTime.cs -double COMDateTime::TicksToDoubleDate(INT64 ticks) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_COOPERATIVE; - } CONTRACTL_END; - - // - - // Workaround to handle uninitialized DateTime objects in the CLR - // See explanation in DateTime.cs's TicksToOADate function. - - // Strip off the extra kind state - ticks = (ticks & TicksMask); - - if (ticks == 0) - return 0.0; // OA's 0 date (12/30/1899). - - if (ticks < OADateMinAsTicks) - { - //We've special-cased day 0 (01/01/0001 in the Gregorian Calendar) such that the - //date can be used to represent a DateTime the contains only a time. OA uses - //day 0 (12/30/1899) for the same purpose, so we'll do a mapping from our day 0 - //to their day 0. - if (ticks < TicksPerDay) - ticks+=DoubleDateOffset; - else - COMPlusThrow(kOverflowException, W("Arg_OleAutDateInvalid")); - } - - INT64 millis = (ticks - DoubleDateOffset) / TicksPerMillisecond; - if (millis < 0) - { - INT64 frac = millis % MillisPerDay; - if (frac != 0) millis -= (MillisPerDay + frac) * 2; - } - - double d = (double)millis / MillisPerDay; - - // Make sure this date is a valid OleAut date. This is the check from the internal - // OleAut macro IsValidDate, found in oledisp.h. Eventually at least the 64 bit - // build of oleaut will define these gregorian max and min values as public constants. - _ASSERTE(d < OADateMaxAsDouble && d > OADateMinAsDouble); - - return d; -} diff --git a/src/coreclr/vm/comdatetime.h b/src/coreclr/vm/comdatetime.h deleted file mode 100644 index 3724e7f03112ae..00000000000000 --- a/src/coreclr/vm/comdatetime.h +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - - -#ifndef _COMDATETIME_H_ -#define _COMDATETIME_H_ - -#include "fcall.h" - -#include - -class COMDateTime { - static const INT64 TicksPerMillisecond; - static const INT64 TicksPerSecond; - static const INT64 TicksPerMinute; - static const INT64 TicksPerHour; - static const INT64 TicksPerDay; - - static const INT64 MillisPerSecond; - static const INT64 MillisPerDay; - - static const int DaysPer4Years; - static const int DaysPer100Years; - static const int DaysPer400Years; - // Number of days from 1/1/0001 to 1/1/10000 - static const int DaysTo10000; - - static const int DaysTo1899; - - static const INT64 DoubleDateOffset; - static const INT64 OADateMinAsTicks; // in ticks - static const double OADateMinAsDouble; - static const double OADateMaxAsDouble; - - static const INT64 MaxTicks; - static const INT64 MaxMillis; - -public: - - // Native util functions for other classes. - static INT64 DoubleDateToTicks(const double d); // From OleAut Date - static double TicksToDoubleDate(const INT64 ticks); -}; - -#include - -#endif // _COMDATETIME_H_ diff --git a/src/coreclr/vm/comutilnative.cpp b/src/coreclr/vm/comutilnative.cpp index f198b037840b5e..c88ce7a47dd585 100644 --- a/src/coreclr/vm/comutilnative.cpp +++ b/src/coreclr/vm/comutilnative.cpp @@ -1,21 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// - -// /*============================================================ -** ** File: COMUtilNative ** -** -** ** Purpose: A dumping ground for classes which aren't large ** enough to get their own file in the EE. -** -** -** ===========================================================*/ + #include "common.h" #include "object.h" #include "excep.h" @@ -1073,25 +1065,6 @@ FORCEINLINE UINT64 GCInterface::InterlockedAdd (UINT64 *pAugend, UINT64 addend) return newMemValue; } -FORCEINLINE UINT64 GCInterface::InterlockedSub(UINT64 *pMinuend, UINT64 subtrahend) { - WRAPPER_NO_CONTRACT; - - UINT64 oldMemValue; - UINT64 newMemValue; - - do { - oldMemValue = *pMinuend; - newMemValue = oldMemValue - subtrahend; - - // check for underflow - if (newMemValue > oldMemValue) - newMemValue = 0; - - } while (InterlockedCompareExchange64((LONGLONG*) pMinuend, (LONGLONG) newMemValue, (LONGLONG) oldMemValue) != (LONGLONG) oldMemValue); - - return newMemValue; -} - extern "C" void QCALLTYPE GCInterface_AddMemoryPressure(UINT64 bytesAllocated, QCallExceptionStatus* qcallError) { QCALL_CONTRACT; diff --git a/src/coreclr/vm/comutilnative.h b/src/coreclr/vm/comutilnative.h index 0c0fe5ca63bcdc..5abcfc6a3e8f9c 100644 --- a/src/coreclr/vm/comutilnative.h +++ b/src/coreclr/vm/comutilnative.h @@ -1,19 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// - -// /*============================================================ -** ** Header: COMUtilNative ** -** ** Purpose: A dumping ground for classes which aren't large ** enough to get their own file in the VM. -** -** ===========================================================*/ + #ifndef _COMUTILNATIVE_H_ #define _COMUTILNATIVE_H_ @@ -152,7 +146,6 @@ class GCInterface { public: static FORCEINLINE UINT64 InterlockedAdd(UINT64 *pAugend, UINT64 addend); - static FORCEINLINE UINT64 InterlockedSub(UINT64 *pMinuend, UINT64 subtrahend); FCDECL0(static INT64, GetTotalPauseDuration); FCDECL2(static void, GetMemoryInfo, Object* objUNSAFE, int kind); diff --git a/src/coreclr/vm/corelib.cpp b/src/coreclr/vm/corelib.cpp index 0861e8b748575f..ac1706f092ae01 100644 --- a/src/coreclr/vm/corelib.cpp +++ b/src/coreclr/vm/corelib.cpp @@ -28,7 +28,6 @@ #include "floatdouble.h" #include "floatsingle.h" #include "divmodint.h" -#include "comdatetime.h" #include "debugdebugger.h" #include "assemblynative.hpp" diff --git a/src/coreclr/vm/dbginterface.h b/src/coreclr/vm/dbginterface.h index 5b154399ee861a..293e96824a60dc 100644 --- a/src/coreclr/vm/dbginterface.h +++ b/src/coreclr/vm/dbginterface.h @@ -1,10 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// CLR Debug Interface Header -// - +// CLR Debug Interface Header #ifndef _dbgInterface_h_ #define _dbgInterface_h_ @@ -293,18 +290,12 @@ class DebugInterface virtual void LockDebuggerForShutdown(void) = 0; - virtual void DisableDebugger(void) = 0; - virtual HRESULT NameChangeEvent(AppDomain *pAppDomain, Thread *pThread) = 0; // send an event to the RS indicating that there's a Ctrl-C or Ctrl-Break virtual BOOL SendCtrlCToDebugger(DWORD dwCtrlType) = 0; - // Allows the debugger to keep an up to date list of special threads - virtual HRESULT UpdateSpecialThreadList(DWORD cThreadArrayLength, - DWORD *rgdwThreadIDArray) = 0; - virtual DWORD GetRCThreadId(void) = 0; virtual HRESULT GetVariablesFromOffset(MethodDesc *pMD, @@ -352,7 +343,6 @@ class DebugInterface virtual HRESULT ReDaclEvents(PSECURITY_DESCRIPTOR securityDescriptor) = 0; - virtual BOOL ShouldAutoAttach() = 0; virtual BOOL FallbackJITAttachPrompt() = 0; #ifdef FEATURE_INTEROP_DEBUGGING @@ -377,7 +367,6 @@ class DebugInterface #ifndef DACCESS_COMPILE virtual HRESULT DeoptimizeMethod(Module* pModule, mdMethodDef methodDef) = 0; - virtual HRESULT IsMethodDeoptimized(Module *pModule, mdMethodDef methodDef, BOOL *pResult) = 0; virtual void MulticastTraceNextStep(DELEGATEREF pbDel, INT32 count) = 0; virtual void ExternalMethodFixupNextStep(PCODE address) = 0; virtual void ProcessAnyPendingEvals(Thread* pThread) = 0; diff --git a/src/coreclr/vm/dispatchinfo.cpp b/src/coreclr/vm/dispatchinfo.cpp index 7d6cdf620b4b7c..60714dbf8e3c49 100644 --- a/src/coreclr/vm/dispatchinfo.cpp +++ b/src/coreclr/vm/dispatchinfo.cpp @@ -1,14 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: DispatchInfo.cpp -// +// File: DispatchInfo.cpp // // Implementation of helpers used to expose IDispatch // and IDispatchEx to COM. -// - #include "common.h" @@ -2257,107 +2253,6 @@ bool DispatchInfo::IsPropertyAccessorVisible(bool fIsSetter, OBJECTREF* pMemberI return false; } -MethodDesc* DispatchInfo::GetFieldInfoMD(BinderMethodID Method, TypeHandle hndFieldInfoType) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END - - MethodDesc *pMD; - - // If the current class is the standard implementation then return the cached method desc - if (CoreLibBinder::IsClass(hndFieldInfoType.GetMethodTable(), CLASS__FIELD)) - { - pMD = CoreLibBinder::GetMethod(Method); - } - else - { - pMD = MemberLoader::FindMethod(hndFieldInfoType.GetMethodTable(), - CoreLibBinder::GetMethodName(Method), CoreLibBinder::GetMethodSig(Method)); - } - _ASSERTE(pMD && "Unable to find specified FieldInfo method"); - - // Return the specified method desc. - return pMD; -} - -MethodDesc* DispatchInfo::GetPropertyInfoMD(BinderMethodID Method, TypeHandle hndPropInfoType) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END - - MethodDesc *pMD; - - // If the current class is the standard implementation then return the cached method desc if present. - if (CoreLibBinder::IsClass(hndPropInfoType.GetMethodTable(), CLASS__PROPERTY)) - { - pMD = CoreLibBinder::GetMethod(Method); - } - else - { - pMD = MemberLoader::FindMethod(hndPropInfoType.GetMethodTable(), - CoreLibBinder::GetMethodName(Method), CoreLibBinder::GetMethodSig(Method)); - } - _ASSERTE(pMD && "Unable to find specified PropertyInfo method"); - - // Return the specified method desc. - return pMD; -} - -MethodDesc* DispatchInfo::GetMethodInfoMD(BinderMethodID Method, TypeHandle hndMethodInfoType) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END - - MethodDesc *pMD; - - // If the current class is the standard implementation then return the cached method desc. - if (CoreLibBinder::IsClass(hndMethodInfoType.GetMethodTable(), CLASS__METHOD)) - { - pMD = CoreLibBinder::GetMethod(Method); - } - else - { - pMD = MemberLoader::FindMethod(hndMethodInfoType.GetMethodTable(), - CoreLibBinder::GetMethodName(Method), CoreLibBinder::GetMethodSig(Method)); - } - _ASSERTE(pMD && "Unable to find specified MethodInfo method"); - - // Return the specified method desc. - return pMD; -} - -MethodDesc* DispatchInfo::GetCustomAttrProviderMD(TypeHandle hndCustomAttrProvider) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - - MethodTable *pMT = hndCustomAttrProvider.AsMethodTable(); - MethodDesc *pMD = pMT->GetMethodDescForInterfaceMethod(CoreLibBinder::GetMethod(METHOD__ICUSTOM_ATTR_PROVIDER__GET_CUSTOM_ATTRIBUTES), TRUE /* throwOnConflict */); - - // Return the specified method desc. - return pMD; -} - // This method synchronizes the DispatchInfo's members with the ones in the method tables type. // The return value will be set to TRUE if the object was out of synch and members where // added and it will be set to FALSE otherwise. diff --git a/src/coreclr/vm/dispatchinfo.h b/src/coreclr/vm/dispatchinfo.h index 2ebba7263d6599..8e4a462e608727 100644 --- a/src/coreclr/vm/dispatchinfo.h +++ b/src/coreclr/vm/dispatchinfo.h @@ -1,14 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: DispatchInfo.h -// +// File: DispatchInfo.h // // Definition of helpers used to expose IDispatch // and IDispatchEx to COM. -// - #ifndef _DISPATCHINFO_H #define _DISPATCHINFO_H @@ -280,12 +276,6 @@ class DispatchInfo int* pManagedMethodParamIndexMap, VARIANT** aByrefArgOleVariant); - // Methods to retrieve the cached MD's - static MethodDesc* GetFieldInfoMD(BinderMethodID Method, TypeHandle hndFieldInfoType); - static MethodDesc* GetPropertyInfoMD(BinderMethodID Method, TypeHandle hndPropInfoType); - static MethodDesc* GetMethodInfoMD(BinderMethodID Method, TypeHandle hndMethodInfoType); - static MethodDesc* GetCustomAttrProviderMD(TypeHandle hndCustomAttrProvider); - // This method synchronizes the DispatchInfo's members with the ones in managed world. // The return value will be set to TRUE if the object was out of synch and members where // added and it will be set to FALSE otherwise. diff --git a/src/coreclr/vm/dwbucketmanager.hpp b/src/coreclr/vm/dwbucketmanager.hpp index c51c6f0f3ac411..6576f6e0600984 100644 --- a/src/coreclr/vm/dwbucketmanager.hpp +++ b/src/coreclr/vm/dwbucketmanager.hpp @@ -1,15 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// + +// ============================================================================ // FILE: dwbucketmanager.hpp // // This file contains the manager types for differents types of Watson buckets // and various helper types. -// - -// - -// // ============================================================================ #ifndef DWBUCKETMANAGER_HPP @@ -302,7 +298,6 @@ class BaseBucketParamsManager // misc helper functions DWORD GetILOffset(); bool GetFileVersionInfoForModule(Module* pModule, USHORT& major, USHORT& minor, USHORT& build, USHORT& revision); - bool IsCodeContractsFrame(MethodDesc* pMD); OBJECTREF GetRealExceptionObject(); WCHAR* GetParamBufferForIndex(BucketParameterIndex paramIndex); void LogParam(_In_z_ LPCWSTR paramValue, BucketParameterIndex paramIndex); @@ -885,40 +880,6 @@ bool BaseBucketParamsManager::GetFileVersionInfoForModule(Module* pModule, USHOR return succeeded; } -// attempts to determine if the specified MethodDesc is one of the code contracts methods. -// this is defined as any method on the System.Diagnostics.Contracts.__ContractsRuntime type. -bool BaseBucketParamsManager::IsCodeContractsFrame(MethodDesc* pMD) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - PRECONDITION(pMD != NULL); - } - CONTRACTL_END; - - if (!pMD) - return false; - - MethodTable* pMT = pMD->GetMethodTable(); - LPCUTF8 pszNamespace = NULL; - LPCUTF8 pszName = NULL; - pszName = pMT->GetFullyQualifiedNameInfo(&pszNamespace); - - if (!pszName || !pszNamespace) - return false; - - LPCUTF8 pszContractsNamespace = "System.Diagnostics.Contracts"; - LPCUTF8 pszContractsRuntimeType = "__ContractsRuntime"; - - if (strcmp(pszNamespace, pszContractsNamespace) == 0 && - strcmp(pszName, pszContractsRuntimeType) == 0) - return true; - - return false; -} - // gets the "real" exception object. it might be m_pException or the exception object on the thread OBJECTREF BaseBucketParamsManager::GetRealExceptionObject() { diff --git a/src/coreclr/vm/dwreport.cpp b/src/coreclr/vm/dwreport.cpp index afe7893afd2620..c4536c4d5a1e38 100644 --- a/src/coreclr/vm/dwreport.cpp +++ b/src/coreclr/vm/dwreport.cpp @@ -1,10 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// FILE: dwreport.cpp -// - #include "common.h" #include "dwreport.h" @@ -156,136 +152,6 @@ HRESULT DwGetFileVersionInfo( return result; } -// Read the description from the resource section. -// -// Parameters -// wszFilePath Path to a file from which to extract the description -// pBuf [out] Put description here. -// cchBuf [in] Size of buf, wide chars. -// -// Returns -// The number of characters stored. Zero if error or no description. -// -// Exceptions -// None -//------------------------------------------------------------------------------ -int DwGetAppDescription( // Number of characters written. - _In_z_ LPCWSTR wszFilePath, // Path to the executable. - SString& pBuf // Put description here. - ) // Size of buf, wide chars. -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - DWORD dwHandle = 0; - DWORD bufSize = 0; // Size of allocation for VersionInfo. - DWORD ret; - - // Find the buffer size for the version info structure we need to create - EX_TRY - { - bufSize = GetFileVersionInfoSizeW(wszFilePath, &dwHandle); - } - EX_CATCH - { - bufSize = 0; - } - EX_END_CATCH - - if (!bufSize) - { - return 0; - } - - // Allocate the buffer for the version info structure - // _alloca() can't return NULL -- raises STATUS_STACK_OVERFLOW. - BYTE* pVersionInfoBuffer = reinterpret_cast< BYTE* >(_alloca(bufSize)); - - // Extract the version information blob. The version information - // contains much more than the actual item of interest. - { - // If the previoud GetFileVersionInfoSizeW succeeds, version.dll has been loaded - // in the process, and delay load of GetFileVersionInfoW will not throw. - CONTRACT_VIOLATION(ThrowsViolation); - ret = GetFileVersionInfoW(wszFilePath, dwHandle, bufSize, pVersionInfoBuffer); - } - - if (!ret) - { - return 0; - } - - // Extract the description. - - // Get the language and codepage for the version info. - UINT size = 0; - struct - { - WORD language; - WORD codePage; - }* translation; - - { - // If the previoud GetFileVersionInfoSizeW succeeds, version.dll has been loaded - // in the process, and delay load of GetFileVersionInfoW will not throw. - CONTRACT_VIOLATION(ThrowsViolation); - ret = VerQueryValueW(pVersionInfoBuffer, W("\\VarFileInfo\\Translation"), - reinterpret_cast< void **>(&translation), &size); - } - - if (!ret || size == 0) - { - return 0; - } - - // Build the query key for the language-specific file description resource. - WCHAR buf[64]; //----+----1----+----2----+----3----+----4----+ - _snwprintf_s(buf, ARRAY_SIZE(buf), _TRUNCATE, W("\\StringFileInfo\\%04x%04x\\FileDescription"), - translation->language, translation->codePage); - - // Get the file description. - WCHAR* fileDescription; - { - // If the previoud GetFileVersionInfoSizeW succeeds, version.dll has been loaded - // in the process, and delay load of GetFileVersionInfoW will not throw. - CONTRACT_VIOLATION(ThrowsViolation); - ret = VerQueryValueW(pVersionInfoBuffer, buf, - reinterpret_cast< void** >(&fileDescription), &size); - } - - // If the call failed, or there is no file description, done. - if (!ret || size == 0) - { - return 0; - } - - // If the description is a single space, ignore it. - if (u16_strcmp(fileDescription, W(" ")) == 0) - { - return 0; - } - - // Copy back the description. - EX_TRY - { - wcsncpy_s(pBuf.OpenUnicodeBuffer(size), size, fileDescription, size); - pBuf.CloseBuffer(size); - } - EX_CATCH - { - size = 0; - } - EX_END_CATCH - - - return size; -} // int DwGetAppDescription() - //------------------------------------------------------------------------------ // Description // Extract the assembly version from an executable. diff --git a/src/coreclr/vm/eedbginterface.h b/src/coreclr/vm/eedbginterface.h index 244ee3c9681bf0..293f003928984b 100644 --- a/src/coreclr/vm/eedbginterface.h +++ b/src/coreclr/vm/eedbginterface.h @@ -1,9 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// // EE to Debugger Interface Header -// #ifndef _eedbginterface_h_ #define _eedbginterface_h_ @@ -92,12 +90,6 @@ class EEDebugInterface virtual void *GetObjectFromHandle(OBJECTHANDLE handle) = 0; - virtual OBJECTHANDLE GetHandleFromObject(void *obj, - bool fStrongNewRef, - AppDomain *pAppDomain) = 0; - - virtual void DbgDestroyHandle( OBJECTHANDLE oh, bool fStrongNewRef ) = 0; - virtual OBJECTHANDLE GetThreadException(Thread *pThread) = 0; virtual bool IsThreadExceptionNull(Thread *pThread) = 0; diff --git a/src/coreclr/vm/eedbginterfaceimpl.cpp b/src/coreclr/vm/eedbginterfaceimpl.cpp index 75e8efe38bb190..db6d21304934bf 100644 --- a/src/coreclr/vm/eedbginterfaceimpl.cpp +++ b/src/coreclr/vm/eedbginterfaceimpl.cpp @@ -171,62 +171,6 @@ void* EEDbgInterfaceImpl::GetObjectFromHandle(OBJECTHANDLE handle) return OBJECTREFToObject(ObjectFromHandle(handle)); } -OBJECTHANDLE EEDbgInterfaceImpl::GetHandleFromObject(void *obj, - bool fStrongNewRef, - AppDomain *pAppDomain) -{ - CONTRACTL - { - THROWS; // From CreateHandle - GC_NOTRIGGER; - PRECONDITION(CheckPointer(pAppDomain)); - } - CONTRACTL_END; - - OBJECTHANDLE oh; - - if (fStrongNewRef) - { - oh = pAppDomain->CreateStrongHandle(ObjectToOBJECTREF((Object *)obj)); - - LOG((LF_CORDB, LL_INFO1000, "EEI::GHFO: Given objectref %p," - "created strong handle %p!\n", obj, oh)); - } - else - { - oh = pAppDomain->CreateLongWeakHandle( ObjectToOBJECTREF((Object *)obj)); - - LOG((LF_CORDB, LL_INFO1000, "EEI::GHFO: Given objectref %p," - "created long weak handle %p!\n", obj, oh)); - } - - return oh; -} - -void EEDbgInterfaceImpl::DbgDestroyHandle(OBJECTHANDLE oh, - bool fStrongNewRef) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - LOG((LF_CORDB, LL_INFO1000, "EEI::GHFO: Destroyed given handle %p," - "fStrong: 0x%x!\n", oh, fStrongNewRef)); - - if (fStrongNewRef) - { - DestroyStrongHandle(oh); - } - else - { - DestroyLongWeakHandle(oh); - } -} - - OBJECTHANDLE EEDbgInterfaceImpl::GetThreadException(Thread *pThread) { CONTRACTL diff --git a/src/coreclr/vm/eedbginterfaceimpl.h b/src/coreclr/vm/eedbginterfaceimpl.h index 3ce49af0e7e594..d4b3df0700f84c 100644 --- a/src/coreclr/vm/eedbginterfaceimpl.h +++ b/src/coreclr/vm/eedbginterfaceimpl.h @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - /* - * * EE to Debugger Interface Implementation - * */ + #ifndef _eedbginterfaceimpl_h_ #define _eedbginterfaceimpl_h_ @@ -79,13 +77,6 @@ class EEDbgInterfaceImpl : public EEDebugInterface void* GetObjectFromHandle(OBJECTHANDLE handle); - OBJECTHANDLE GetHandleFromObject(void *obj, - bool fStrongNewRef, - AppDomain *pAppDomain); - - void DbgDestroyHandle(OBJECTHANDLE oh, - bool fStrongNewRef); - OBJECTHANDLE GetThreadException(Thread *pThread); bool IsThreadExceptionNull(Thread *pThread); diff --git a/src/coreclr/vm/excep.cpp b/src/coreclr/vm/excep.cpp index 4fc4845dbec2cf..514003f6ecbd69 100644 --- a/src/coreclr/vm/excep.cpp +++ b/src/coreclr/vm/excep.cpp @@ -277,32 +277,6 @@ HRESULT GetExceptionHResult(OBJECTREF throwable) return hr; } // HRESULT GetExceptionHResult() -DWORD GetExceptionXCode(OBJECTREF throwable) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_COOPERATIVE; - } - CONTRACTL_END; - - HRESULT hr = E_FAIL; - if (throwable == NULL) - return hr; - - // Since any object can be thrown in managed code, not only instances of System.Exception subclasses - // we need to check to see if we are dealing with an exception before attempting to retrieve - // the HRESULT field. If we are not dealing with an exception, then we will simply return E_FAIL. - _ASSERTE(IsException(throwable->GetMethodTable())); // what is the pathway here? - if (IsException(throwable->GetMethodTable())) - { - hr = ((EXCEPTIONREF)throwable)->GetXCode(); - } - - return hr; -} // DWORD GetExceptionXCode() - //------------------------------------------------------------------------------ // This function will extract some information from an Access Violation SEH // exception, and store it in the System.AccessViolationException object. @@ -575,47 +549,6 @@ void CreateTypeInitializationExceptionObject(LPCWSTR pTypeThatFailed, CONSISTENCY_CHECK(*pInitException != NULL || !pInnerException); } -// ========================================================================== -// ComputeEnclosingHandlerNestingLevel -// -// This is code factored out of COMPlusThrowCallback to figure out -// what the number of nested exception handlers is. -// ========================================================================== -DWORD ComputeEnclosingHandlerNestingLevel(IJitManager *pIJM, - const METHODTOKEN& mdTok, - SIZE_T offsNat) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - // Determine the nesting level of EHClause. Just walk the table - // again, and find out how many handlers enclose it - DWORD nestingLevel = 0; - EH_CLAUSE_ENUMERATOR pEnumState; - unsigned EHCount = pIJM->InitializeEHEnumeration(mdTok, &pEnumState); - - for (unsigned j=0; jGetNextEHClause(&pEnumState,&EHClause); - _ASSERTE(EHClause.HandlerEndPC != (DWORD) -1); // remove, only protects against a deprecated convention - - if ((offsNat > EHClause.HandlerStartPC) && - (offsNat < EHClause.HandlerEndPC)) - { - nestingLevel++; - } - } - - return nestingLevel; -} - // ******************************* EHRangeTreeNode ************************** // EHRangeTreeNode::EHRangeTreeNode(void) { @@ -2772,30 +2705,6 @@ BOOL IsExceptionOfType(RuntimeExceptionKind reKind, OBJECTREF *pThrowable) return CoreLibBinder::IsException(pThrowableMT, reKind); } -BOOL IsUncatchable(OBJECTREF *pThrowable) -{ - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - MODE_COOPERATIVE; - } CONTRACTL_END; - - _ASSERTE(pThrowable != NULL); - - Thread *pThread = GetThreadNULLOk(); - - if (pThread) - { - if (pThread->IsAbortInitiated()) - return TRUE; - - if (OBJECTREFToObject(*pThrowable)->GetMethodTable() == g_pExecutionEngineExceptionClass) - return TRUE; - } - - return FALSE; -} - BOOL IsStackOverflowException(Thread* pThread, EXCEPTION_RECORD* pExceptionRecord) { if (pExceptionRecord->ExceptionCode == STATUS_STACK_OVERFLOW) @@ -3670,62 +3579,6 @@ LONG DefaultCatchFilter(EXCEPTION_POINTERS *ep, PVOID pv) return EXCEPTION_EXECUTE_HANDLER; } // LONG DefaultCatchFilter() - -//****************************************************************************** -// -// DefaultCatchNoSwallowFilter -// -// The new default except filter (v2.0). For user breakpoints, call out to UserBreakpointFilter(). -// Otherwise consults host policy and config file to return EXECUTE_HANDLER / CONTINUE_SEARCH. -// -// Parameters: -// pExceptionInfo EXCEPTION_POINTERS for current exception -// pv A constant as an INT_PTR. Must be COMPLUS_EXCEPTION_EXECUTE_HANDLER. -// -// Returns: -// EXCEPTION_CONTINUE_SEARCH Generally returns this to let the exception go unhandled. -// EXCEPTION_EXECUTE_HANDLER May return this to swallow the exception. -// -// IMPORTANT!! READ ME!! -// -// This filter is very similar to DefaultCatchFilter, except when unhandled -// exception policy/config dictate swallowing the exception. -// If you make any changes to this function, look to see if the other one also needs -// the same change. -// -LONG DefaultCatchNoSwallowFilter(EXCEPTION_POINTERS *ep, PVOID pv) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - - DefaultCatchFilterParam *pParam; pParam = (DefaultCatchFilterParam *) pv; - - // the only valid parameter for DefaultCatchFilter so far - _ASSERTE(pParam->pv == COMPLUS_EXCEPTION_EXECUTE_HANDLER); - - PEXCEPTION_RECORD er = ep->ExceptionRecord; - DWORD code = er->ExceptionCode; - - if (code == STATUS_SINGLE_STEP || code == STATUS_BREAKPOINT) - { - return UserBreakpointFilter(ep); - } - - // If the exception is of a type that is always swallowed (ThreadAbort, AppDomainUnload)... - if (ExceptionIsAlwaysSwallowed(ep)) - { // ...return EXCEPTION_EXECUTE_HANDLER to swallow the exception. - return EXCEPTION_EXECUTE_HANDLER; - } - - // Otherwise, continue search. i.e. let the exception go unhandled (at least for now). - return EXCEPTION_CONTINUE_SEARCH; -} // LONG DefaultCatchNoSwallowFilter() - // We keep a pointer to the previous unhandled exception filter. After we install, we use // this to call the previous guy. @@ -6889,54 +6742,6 @@ LONG NotifyOfCHFFilterWrapper( return ret; } // LONG NotifyOfCHFFilterWrapper() -// This filter will be used process exceptions escaping out of dynamic reflection invocation as -// unhandled and will eventually be caught in the VM to be made as inner exception of -// TargetInvocationException that will be thrown from the VM. -LONG ReflectionInvocationExceptionFilter( - EXCEPTION_POINTERS *pExceptionInfo, // the pExceptionInfo passed to a filter function. - PVOID pParam) -{ - // Ideally, we would be NOTHROW here. However, NotifyOfCHFFilterWrapper calls into - // NotifyOfCHFFilter that is THROWS. Thus, to prevent contract violation, - // we abide by the rules and be THROWS. - // - // Same rationale for GC_TRIGGERS as well. - CONTRACTL - { - GC_TRIGGERS; - MODE_ANY; - THROWS; - } - CONTRACTL_END; - - ULONG ret = EXCEPTION_CONTINUE_SEARCH; - - // First, call into NotifyOfCHFFilterWrapper - ret = NotifyOfCHFFilterWrapper(pExceptionInfo, pParam); - -#ifndef TARGET_UNIX - // Setup the watson bucketing details if the escaping - // exception is preallocated. - if (SetupWatsonBucketsForEscapingPreallocatedExceptions()) - { - // Set the flag that these were captured during Reflection Invocation - DEBUG_STMT(GetThread()->GetExceptionState()->GetUEWatsonBucketTracker()->SetCapturedAtReflectionInvocation()); - } - - // Attempt to capture buckets for non-preallocated exceptions just before the ReflectionInvocation boundary - { - GCX_COOP(); - OBJECTREF oThrowable = GetThread()->GetThrowable(); - if ((oThrowable != NULL) && (CLRException::IsPreallocatedExceptionObject(oThrowable) == FALSE)) - { - SetupWatsonBucketsForNonPreallocatedExceptions(); - } - } -#endif // !TARGET_UNIX - - return ret; -} // LONG ReflectionInvocationExceptionFilter() - #endif // !DACCESS_COMPILE #ifdef _DEBUG @@ -9412,46 +9217,6 @@ struct TAResetStateCallbackData StackFrame sfSeedCrawlFrame; }; -// This callback helps the 64bit EH attempt to determine if there is more managed code -// up the stack (or not). Currently, it is used to conditionally reset the thread abort state -// as the unwind passes by. -StackWalkAction TAResetStateCallback(CrawlFrame* pCf, void* data) -{ - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - TAResetStateCallbackData *pTAResetStateCallbackData = static_cast(data); - StackWalkAction retStatus = SWA_CONTINUE; - - if(pCf->IsFrameless()) - { - IJitManager* pJitManager = pCf->GetJitManager(); - _ASSERTE(pJitManager); - if (pJitManager && (!pTAResetStateCallbackData->fDoWeHaveMoreManagedCodeOnStack)) - { - // The stackwalker can give us a callback for the seeding CrawlFrame (or other crawlframes) - // depending upon which is closer to the leaf: the seeding crawlframe or the explicit frame - // specified when starting the stackwalk. - // - // Since we are interested in checking if there is more managed code up the stack from - // the seeding crawlframe, we check if the current crawlframe is above it or not. If it is, - // then we have found managed code up the stack and should stop the stack walk. Otherwise, - // continue searching. - StackFrame sfCurrentFrame = StackFrame::FromRegDisplay(pCf->GetRegisterSet()); - if (pTAResetStateCallbackData->sfSeedCrawlFrame < sfCurrentFrame) - { - // We have found managed code on the stack. Flag it and stop the stackwalk. - pTAResetStateCallbackData->fDoWeHaveMoreManagedCodeOnStack = TRUE; - retStatus = SWA_ABORT; - } - } - } - - return retStatus; -} #endif // !DACCESS_COMPILE diff --git a/src/coreclr/vm/excep.h b/src/coreclr/vm/excep.h index 18b104a962e237..78064a233c8999 100644 --- a/src/coreclr/vm/excep.h +++ b/src/coreclr/vm/excep.h @@ -106,11 +106,9 @@ EXTERN_C VOID STDCALL ResetCurrentContext(); void UnwindFrameChain(Thread *pThread, LPVOID pvLimitSP) noexcept; DWORD MapWin32FaultToCOMPlusException(EXCEPTION_RECORD *pExceptionRecord); -DWORD ComputeEnclosingHandlerNestingLevel(IJitManager *pIJM, const METHODTOKEN& mdTok, SIZE_T offsNat); BOOL IsException(MethodTable *pMT); BOOL IsExceptionOfType(RuntimeExceptionKind reKind, OBJECTREF *pThrowable); BOOL IsExceptionOfType(RuntimeExceptionKind reKind, Exception *pException); -BOOL IsUncatchable(OBJECTREF *pThrowable); VOID FixupOnRethrow(Thread *pCurThread, EXCEPTION_POINTERS *pExceptionPointers); BOOL UpdateCurrentThrowable(PEXCEPTION_RECORD pExceptionRecord); BOOL IsStackOverflowException(Thread* pThread, EXCEPTION_RECORD* pExceptionRecord); @@ -288,7 +286,6 @@ ULONG GetExceptionMessage(OBJECTREF throwable, void GetExceptionMessage(OBJECTREF throwable, SString &result); STRINGREF GetExceptionMessage(OBJECTREF throwable); HRESULT GetExceptionHResult(OBJECTREF throwable); -DWORD GetExceptionXCode(OBJECTREF throwable); void ExceptionPreserveStackTrace(OBJECTREF throwable); @@ -629,11 +626,6 @@ inline void CopyOSContext(T_CONTEXT* pDest, T_CONTEXT* pSrc) void SaveCurrentExceptionInfo(PEXCEPTION_RECORD pRecord, PT_CONTEXT pContext); -// See implementation for detailed comments in excep.cpp -LONG ReflectionInvocationExceptionFilter( - EXCEPTION_POINTERS *pExceptionInfo, // the pExceptionInfo passed to a filter function. - PVOID pParam); - #ifndef DACCESS_COMPILE // exception filter invoked for unhandled exceptions on the entry point thread (thread 0) LONG EntryPointFilter(PEXCEPTION_POINTERS pExceptionInfo, PVOID _pData); diff --git a/src/coreclr/vm/exceptionhandling.cpp b/src/coreclr/vm/exceptionhandling.cpp index bcba0b1585dbd6..53b5ae8eca5e29 100644 --- a/src/coreclr/vm/exceptionhandling.cpp +++ b/src/coreclr/vm/exceptionhandling.cpp @@ -117,7 +117,6 @@ inline void RestoreNonvolatileRegisterPointers(PT_KNONVOLATILE_CONTEXT_POINTERS // Unfortunately, I cannot articulate why at the moment. // #ifdef _DEBUG -void DumpClauses(IJitManager* pJitMan, const METHODTOKEN& MethToken, UINT_PTR uMethodStartPC, UINT_PTR dwControlPc); static void DoEHLog(DWORD lvl, _In_z_ const char *fmt, ...); #define EH_LOG(expr) { DoEHLog expr ; } #else @@ -173,127 +172,6 @@ void InitializeExceptionHandling() #endif // TARGET_UNIX } -struct UpdateObjectRefInResumeContextCallbackState -{ - UINT_PTR uResumeSP; - Frame *pHighestFrameWithRegisters; - TADDR uResumeFrameFP; - TADDR uICFCalleeSavedFP; - -#ifdef _DEBUG - UINT nFrames; - bool fFound; -#endif -}; - -// Stack unwind callback for UpdateObjectRefInResumeContext(). -StackWalkAction UpdateObjectRefInResumeContextCallback(CrawlFrame* pCF, LPVOID pData) -{ - CONTRACTL - { - MODE_ANY; - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - UpdateObjectRefInResumeContextCallbackState *pState = (UpdateObjectRefInResumeContextCallbackState*)pData; - CONTEXT* pSrcContext = pCF->GetRegisterSet()->pCurrentContext; - - INDEBUG(pState->nFrames++); - - // Check to see if we have reached the resume frame. - if (pCF->IsFrameless()) - { - // At this point, we are trying to find the managed frame containing the catch handler to be invoked. - // This is done by comparing the SP of the managed frame for which this callback was invoked with the - // SP the OS passed to our personality routine for the current managed frame. If they match, then we have - // reached the target frame. - // - // It is possible that a managed frame may execute a PInvoke after performing a stackalloc: - // - // 1) The ARM JIT will always inline the PInvoke in the managed frame, whether or not the frame - // contains EH. As a result, the ICF will live in the same frame which performs stackalloc. - // - // 2) JIT64 will only inline the PInvoke in the managed frame if the frame *does not* contain EH. If it does, - // then pinvoke will be performed via an ILStub and thus, stackalloc will be performed in a frame different - // from the one (ILStub) that contains the ICF. - // - // Thus, for the scenario where the catch handler lives in the frame that performed stackalloc, in case of - // ARM JIT, the SP returned by the OS will be the SP *after* the stackalloc has happened. However, - // the stackwalker will invoke this callback with the CrawlFrameSP that was initialized at the time ICF was setup, i.e., - // it will be the SP after the prolog has executed (refer to InlinedCallFrame::UpdateRegDisplay). - // - // Thus, checking only the SP will not work for this scenario when using the ARM JIT. - // - // To address this case, the callback data also contains the frame pointer (FP) passed by the OS. This will - // be the value that is saved in the "CalleeSavedFP" field of the InlinedCallFrame during ICF - // initialization. When the stackwalker sees an ICF and invokes this callback, we copy the value of "CalleeSavedFP" in the data - // structure passed to this callback. - // - // Later, when the stackwalker invokes the callback for the managed frame containing the ICF, and the check - // for SP comaprison fails, we will compare the FP value we got from the ICF with the FP value the OS passed - // to us. If they match, then we have reached the resume frame. - // - // Note: This problem/scenario is not applicable to JIT64 since it does not perform pinvoke inlining if the - // method containing pinvoke also contains EH. Thus, the SP check will never fail for it. - if (pState->uResumeSP == GetSP(pSrcContext)) - { - INDEBUG(pState->fFound = true); - - return SWA_ABORT; - } - - // Perform the FP check, as explained above. - if ((pState->uICFCalleeSavedFP !=0) && (pState->uICFCalleeSavedFP == pState->uResumeFrameFP)) - { - // FP from ICF is the one that was also copied to the FP register in InlinedCallFrame::UpdateRegDisplay. - _ASSERTE(pState->uICFCalleeSavedFP == GetFP(pSrcContext)); - - INDEBUG(pState->fFound = true); - - return SWA_ABORT; - } - - // Reset the ICF FP in callback data - pState->uICFCalleeSavedFP = 0; - } - else - { - Frame *pFrame = pCF->GetFrame(); - - if (pFrame->NeedsUpdateRegDisplay()) - { - CONSISTENCY_CHECK(pFrame >= pState->pHighestFrameWithRegisters); - pState->pHighestFrameWithRegisters = pFrame; - - // Is this an InlinedCallFrame? - if (pFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame) - { - // If we are here, then ICF is expected to be active. - _ASSERTE(InlinedCallFrame::FrameHasActiveCall(pFrame)); - - // Copy the CalleeSavedFP to the data structure that is passed this callback - // by the stackwalker. This is the value of frame pointer when ICF is setup - // in a managed frame. - // - // Setting this value here is based upon the assumption (which holds true on X64 and ARM) that - // the stackwalker invokes the callback for explicit frames before their - // container/corresponding managed frame. - pState->uICFCalleeSavedFP = ((PTR_InlinedCallFrame)pFrame)->GetCalleeSavedFP(); - } - else - { - // For any other frame, simply reset uICFCalleeSavedFP field - pState->uICFCalleeSavedFP = 0; - } - } - } - - return SWA_CONTINUE; -} - - //static void ExInfo::UpdateNonvolatileRegisters(CONTEXT *pContextRecord, REGDISPLAY *pRegDisplay, bool fAborting) { @@ -826,40 +704,6 @@ UINT_PTR ExInfo::DebugComputeNestingLevel() return uNestingLevel; } -void DumpClauses(IJitManager* pJitMan, const METHODTOKEN& MethToken, UINT_PTR uMethodStartPC, UINT_PTR dwControlPc) -{ - EH_CLAUSE_ENUMERATOR EnumState; - unsigned EHCount; - - EH_LOG((LL_INFO1000, " | uMethodStartPC: %p, ControlPc at offset %x\n", uMethodStartPC, dwControlPc - uMethodStartPC)); - - EHCount = pJitMan->InitializeEHEnumeration(MethToken, &EnumState); - for (unsigned i = 0; i < EHCount; i++) - { - EE_ILEXCEPTION_CLAUSE EHClause; - pJitMan->GetNextEHClause(&EnumState, &EHClause); - - EH_LOG((LL_INFO1000, " | %s clause [%x, %x], handler: [%x, %x]", - (IsFault(&EHClause) ? "fault" : - (IsFinally(&EHClause) ? "finally" : - (IsFilterHandler(&EHClause) ? "filter" : - (IsTypedHandler(&EHClause) ? "typed" : "unknown")))), - EHClause.TryStartPC , // + uMethodStartPC, - EHClause.TryEndPC , // + uMethodStartPC, - EHClause.HandlerStartPC , // + uMethodStartPC, - EHClause.HandlerEndPC // + uMethodStartPC - )); - - if (IsFilterHandler(&EHClause)) - { - LOG((LF_EH, LL_INFO1000, " filter: [%x, ...]", - EHClause.FilterOffset));// + uMethodStartPC - } - - LOG((LF_EH, LL_INFO1000, "\n")); - } - -} #define STACK_ALLOC_ARRAY(numElements, type) \ ((type *)_alloca((numElements)*(sizeof(type)))) @@ -953,19 +797,6 @@ static VOID UpdateContextForPropagationCallback( //--------------------------------------------------------------------------------------- // -// Function to update the current context for exception propagation. -// -// Arguments: -// exception - the PAL_SEHException representing the propagating exception. -// currentContext - the current context to update. -// -static VOID UpdateContextForPropagationCallback( - PAL_SEHException& ex, - CONTEXT* startContext) -{ - UpdateContextForPropagationCallback(ex.ManagedToNativeExceptionCallback, ex.ManagedToNativeExceptionCallbackContext, startContext); -} - extern void* g_hostingApiReturnAddress; VOID DECLSPEC_NORETURN DispatchManagedException(PAL_SEHException& ex, bool isHardwareException) @@ -2400,49 +2231,6 @@ bool ExInfo::StackRange::IsSupersededBy(StackFrame sf) return (sf >= m_sfLowBound); } -void ExInfo::StackRange::CombineWith(StackFrame sfCurrent, StackRange* pPreviousRange) -{ - LIMITED_METHOD_CONTRACT; - - if ((pPreviousRange->m_sfHighBound < sfCurrent) && IsEmpty()) - { - // This case comes from an unusual situation. It is possible for a new nested tracker to start its - // first pass at a higher SP than any previously scanned frame in the previous "enclosing" tracker. - // Typically this doesn't happen because the ProcessCLRException callback is made multiple times for - // the frame where the nesting first occurs and that will ensure that the stack range of the new - // nested exception is extended to contain the scan range of the previous tracker's scan. However, - // if the exception dispatch calls a C++ handler (e.g. a finally) and then that handler tries to - // reverse-pinvoke into the runtime, AND we trigger an exception (e.g. ThreadAbort) - // before we reach another managed frame (which would have the CLR personality - // routine associated with it), the first callback to ProcessCLRException for this new exception - // will occur on a frame that has never been seen before by the current tracker. - // - // So in this case, we'll see a sfCurrent that is larger than the previous tracker's high bound and - // we'll have an empty scan range for the current tracker. And we'll just need to pre-init the - // scanned stack range for the new tracker to the previous tracker's range. This maintains the - // invariant that the scanned range for nested trackers completely cover the scanned range of their - // previous tracker once they "escape" the previous tracker. - STRESS_LOG3(LF_EH, LL_INFO100, - "Initializing current StackRange with previous tracker's StackRange. sfCurrent: %p, prev low: %p, prev high: %p\n", - (void*)sfCurrent.SP, (void*)pPreviousRange->m_sfLowBound.SP, (void*)pPreviousRange->m_sfHighBound.SP); - - *this = *pPreviousRange; - } - else - { -#ifdef TARGET_UNIX - // When the current range is empty, copy the low bound too. Otherwise a degenerate range would get - // created and tests for stack frame in the stack range would always fail. - // TODO: Check if we could enable it for non-PAL as well. - if (IsEmpty()) - { - m_sfLowBound = pPreviousRange->m_sfLowBound; - } -#endif // TARGET_UNIX - m_sfHighBound = pPreviousRange->m_sfHighBound; - } -} - bool ExInfo::StackRange::Contains(StackFrame sf) { LIMITED_METHOD_CONTRACT; @@ -4096,23 +3884,6 @@ extern "C" CLR_BOOL QCALLTYPE SfiInit(StackFrameIterator* pThis, CONTEXT* pStack return result; } -static StackWalkAction MoveToNextNonSkippedFrame(StackFrameIterator* pStackFrameIterator) -{ - StackWalkAction retVal; - - do - { - retVal = pStackFrameIterator->Next(); - if (retVal == SWA_FAILED) - { - break; - } - } - while (pStackFrameIterator->GetFrameState() == StackFrameIterator::SFITER_SKIPPED_FRAME_FUNCTION); - - return retVal; -} - CLR_BOOL SfiNextWorker(StackFrameIterator* pThis, uint* uExCollideClauseIdx, CLR_BOOL* fUnwoundReversePInvoke, CLR_BOOL* pfIsExceptionIntercepted) { CONTRACTL diff --git a/src/coreclr/vm/exceptmacros.h b/src/coreclr/vm/exceptmacros.h index f6e21f5c8cfcd6..05ca857aff2b21 100644 --- a/src/coreclr/vm/exceptmacros.h +++ b/src/coreclr/vm/exceptmacros.h @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// // EXCEPTMACROS.H - // // This header file exposes mechanisms to: @@ -26,7 +25,6 @@ // COMPlusThrow() must only be called within the scope of a EX_TRY // block. See below for more information. // -// // THROWING A RUNTIME EXCEPTION // ---------------------------- // COMPlusThrow() is overloaded to take a constant describing @@ -50,8 +48,6 @@ // IDS_CANTREFORMATCDRIVEBECAUSE, // W("Formatting C drive permissions not granted.")); // -// -// // TO CATCH CLR EXCEPTIONS: // ---------------------------- // @@ -59,7 +55,6 @@ // // #include "exceptmacros.h" // -// // OBJECTREF pThrownObject; // // EX_TRY { @@ -68,7 +63,6 @@ // ...handler... // } EX_END_CATCH // -// // EX_TRY blocks can be nested. // // From within the handler, you can call the GET_THROWABLE() macro to @@ -89,7 +83,6 @@ // self-document its contract, the checked version of this will fire // an assert if the function is ever called without being in scope. // -// // AVOIDING EX_TRY GOTCHAS // ---------------------------- // EX_TRY/EX_CATCH actually expands into a Win32 SEH @@ -104,7 +97,6 @@ // of these things is not simple (you can wrap another EX_TRY // around the call to simulate a CLR "try-finally" but EX_TRY // is relatively expensive compared to the real thing.) -// #ifndef __exceptmacros_h__ #define __exceptmacros_h__ @@ -596,8 +588,6 @@ void COMPlusCooperativeTransitionHandler(Frame* pFrame); extern LONG UserBreakpointFilter(EXCEPTION_POINTERS *ep); extern LONG DefaultCatchFilter(EXCEPTION_POINTERS *ep, LPVOID pv); -extern LONG DefaultCatchNoSwallowFilter(EXCEPTION_POINTERS *ep, LPVOID pv); - // the only valid parameter for DefaultCatchFilter #define COMPLUS_EXCEPTION_EXECUTE_HANDLER (PVOID)EXCEPTION_EXECUTE_HANDLER diff --git a/src/coreclr/vm/exinfo.h b/src/coreclr/vm/exinfo.h index bda9282f0b667f..199d25b8d78b2d 100644 --- a/src/coreclr/vm/exinfo.h +++ b/src/coreclr/vm/exinfo.h @@ -57,7 +57,6 @@ struct ExInfo void Reset(); bool IsEmpty(); bool IsSupersededBy(StackFrame sf); - void CombineWith(StackFrame sfCurrent, StackRange* pPreviousRange); bool Contains(StackFrame sf); void ExtendUpperBound(StackFrame sf); void ExtendLowerBound(StackFrame sf); diff --git a/src/coreclr/vm/fieldmarshaler.cpp b/src/coreclr/vm/fieldmarshaler.cpp index 6c3c51e650a584..dd72bc086c5f3a 100644 --- a/src/coreclr/vm/fieldmarshaler.cpp +++ b/src/coreclr/vm/fieldmarshaler.cpp @@ -18,7 +18,6 @@ #include "dllimport.h" #include "comdelegate.h" #include "eeconfig.h" -#include "comdatetime.h" #include #include #include diff --git a/src/coreclr/vm/hash.cpp b/src/coreclr/vm/hash.cpp index a2b0698c5cf769..7b49a46db52b5a 100644 --- a/src/coreclr/vm/hash.cpp +++ b/src/coreclr/vm/hash.cpp @@ -1,15 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - -/*++ - -Module Name: - - synchash.cpp - ---*/ - #include "common.h" #include "hash.h" @@ -1104,77 +1095,3 @@ HashMap::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) } #endif // DACCESS_COMPILE - -#if 0 // Perf test code, enabled on-demand for private testing. -#ifndef DACCESS_COMPILE -// This is for testing purposes only! -void HashMap::HashMapTest() -{ - minipal_log_print_info("HashMap test\n"); - - const unsigned int MinValue = 2; // Deleted is reserved, and is 1. - const unsigned int MinThreshold = 10000; - const unsigned int MaxThreshold = 30000; - HashMap * table = new HashMap(); - Crst m_lock("HashMap", CrstSyncHashLock, CrstFlags(CRST_REENTRANCY | CRST_UNSAFE_ANYMODE)); - CrstHolder holder(&m_lock); - LockOwner lock = {&m_lock, IsOwnerOfCrst}; - table->Init(10, (CompareFnPtr) NULL, false, &lock); - for(unsigned int i=MinValue; i < MinThreshold; i++) - table->InsertValue(i, i); - minipal_log_print_info("Added %d values.\n", MinThreshold); - //table.DumpStatistics(); - - LookupPerfTest(table, MinThreshold); - - INT64 t0 = minipal_lowres_ticks(); - INT64 t1; - for(int rep = 0; rep < 10000000; rep++) { - for(unsigned int i=MinThreshold; i < MaxThreshold; i++) { - table->InsertValue(rep + i, rep + i); - } - for(unsigned int i=MinThreshold; i < MaxThreshold; i++) { - table->DeleteValue(rep + i, rep + i); - } - for(unsigned int i=MinValue; i < MinThreshold; i++) - table->DeleteValue(i, i); - for(unsigned int i=MinValue; i < MinThreshold; i++) - table->InsertValue(i, i); - - if (rep % 500 == 0) { - t1 = minipal_lowres_ticks(); - minipal_log_print_info("Repetition %d, took %d ms\n", rep, (int) (t1-t0)); - t0 = t1; - LookupPerfTest(table, MinThreshold); - //table.DumpStatistics(); - } - } - delete table; -} - -// For testing purposes only. -void HashMap::LookupPerfTest(HashMap * table, const unsigned int MinThreshold) -{ - INT64 t0 = minipal_lowres_ticks(); - for(int rep = 0; rep < 1000; rep++) { - for(unsigned int i=2; iLookupValue(i, i); - if (v != i) { - minipal_log_print_info("LookupValue didn't return the expected value!\n"); - _ASSERTE(v == i); - } - } - } - INT64 t1 = minipal_lowres_ticks(); - for(unsigned int i = MinThreshold * 80; i < MinThreshold * 80 + 1000; i++) - table->LookupValue(i, i); - //cout << "Lookup perf test (1000 * " << MinThreshold << ": " << (t1-t0) << " ms." << endl; -#ifdef HASHTABLE_PROFILE - minipal_log_print_info("Lookup perf test time: %d ms table size: %d max failure probe: %d longest collision chain: %d\n", (int) (t1-t0), (int) GetSize(table->Buckets()), (int) table->maxFailureProbe, (int) table->m_cbMaxCollisionLength); - table->DumpStatistics(); -#else // !HASHTABLE_PROFILE - minipal_log_print_info("Lookup perf test time: %d ms table size: %d\n", (int) (t1-t0), GetSize(table->Buckets())); -#endif // !HASHTABLE_PROFILE -} -#endif // !DACCESS_COMPILE -#endif // 0 // Perf test code, enabled on-demand for private testing. diff --git a/src/coreclr/vm/hash.h b/src/coreclr/vm/hash.h index ecf6846f56d05d..867c61a97c7d5e 100644 --- a/src/coreclr/vm/hash.h +++ b/src/coreclr/vm/hash.h @@ -1,15 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - /*++--------------------------------------------------------------------------------------- - Module Name: - hash.h Abstract: - Fast hash table classes, --*/ @@ -263,13 +259,6 @@ class HashMap void DumpStatistics(); #endif // HASHTABLE_PROFILE -#if 0 // Test-only code for debugging this class. -#ifndef DACCESS_COMPILE - static void LookupPerfTest(HashMap * table, const unsigned int MinThreshold); - static void HashMapTest(); -#endif // !DACCESS_COMPILE -#endif // 0 // Test-only code for debugging this class. - protected: // static helper function static UPTR PutEntry (Bucket* rgBuckets, UPTR key, UPTR value); diff --git a/src/coreclr/vm/ilmarshalers.cpp b/src/coreclr/vm/ilmarshalers.cpp index 8de4f54be9f2f3..b61f5391634c5f 100644 --- a/src/coreclr/vm/ilmarshalers.cpp +++ b/src/coreclr/vm/ilmarshalers.cpp @@ -14,7 +14,6 @@ #ifdef FEATURE_COMINTEROP #include "olevariant.h" #endif // FEATURE_COMINTEROP -#include "comdatetime.h" #include "fieldmarshaler.h" LocalDesc ILReflectionObjectMarshaler::GetManagedType() diff --git a/src/coreclr/vm/inlinetracking.cpp b/src/coreclr/vm/inlinetracking.cpp index aee920ffa47452..4b8e8a9467798c 100644 --- a/src/coreclr/vm/inlinetracking.cpp +++ b/src/coreclr/vm/inlinetracking.cpp @@ -1,5 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + // ============================================================================================= // Code for tracking method inlinings in NGen and R2R images. // The only information stored is "who" got inlined "where", no offsets or inlining depth tracking. @@ -7,6 +8,7 @@ // This information is later exposed to profilers and can be useful for ReJIT. // Runtime inlining is not being tracked because profilers can deduce it via callbacks anyway. // ============================================================================================= + #include "common.h" #include "inlinetracking.h" #include "ceeload.h" @@ -82,38 +84,6 @@ bool MethodInModule::operator !=(const MethodInModule& other) const m_module != other.m_module; } - -void InlineTrackingEntry::SortAndDeduplicate() -{ - STANDARD_VM_CONTRACT; - - //Sort - MethodInModule *begin = &m_inliners[0]; - MethodInModule *end = begin + m_inliners.GetCount(); - util::sort(begin, end); - - //Deduplicate - MethodInModule *left = begin; - MethodInModule *right = left + 1; - while (right < end) - { - auto rvalue = *right; - if (*left != rvalue) - { - left++; - if (left != right) - { - *left = rvalue; - } - } - right++; - } - - //Shrink - int newCount = (int)(left - begin + 1); - m_inliners.SetCount(newCount); -} - InlineTrackingEntry::InlineTrackingEntry(const InlineTrackingEntry& other) :m_inlinee(other.m_inlinee) { diff --git a/src/coreclr/vm/inlinetracking.h b/src/coreclr/vm/inlinetracking.h index 8788e289b99002..7826ad26c1a8a1 100644 --- a/src/coreclr/vm/inlinetracking.h +++ b/src/coreclr/vm/inlinetracking.h @@ -1,5 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + // ============================================================================================= // Definitions for tracking method inlinings in NGen and R2R images. // The only information stored is "who" got inlined "where", no offsets or inlining depth tracking. @@ -86,7 +87,6 @@ struct InlineTrackingEntry } void Add(PTR_MethodDesc inliner); - void SortAndDeduplicate(); }; class InlineTrackingMapTraits : public NoRemoveSHashTraits > diff --git a/src/coreclr/vm/interoputil.cpp b/src/coreclr/vm/interoputil.cpp index 10bd06467e9e5a..3b159a44b9be0e 100644 --- a/src/coreclr/vm/interoputil.cpp +++ b/src/coreclr/vm/interoputil.cpp @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - #include "common.h" #include "vars.hpp" #include "excep.h" @@ -897,84 +896,6 @@ ReadBestFitCustomAttribute(Module* pModule, mdTypeDef cl, BOOL* BestFit, BOOL* T } } - -int InternalWideToAnsi(_In_reads_(iNumWideChars) LPCWSTR szWideString, int iNumWideChars, _Out_writes_bytes_opt_(cbAnsiBufferSize) LPSTR szAnsiString, int cbAnsiBufferSize, BOOL fBestFit, BOOL fThrowOnUnmappableChar) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - - - if ((szWideString == 0) || (iNumWideChars == 0) || (szAnsiString == 0) || (cbAnsiBufferSize == 0)) - return 0; - - DWORD flags = 0; - int retval; - - if (fBestFit == FALSE) - flags = WC_NO_BEST_FIT_CHARS; - - if (fThrowOnUnmappableChar) - { - BOOL DefaultCharUsed = FALSE; - retval = WideCharToMultiByte(CP_ACP, - flags, - szWideString, - iNumWideChars, - szAnsiString, - cbAnsiBufferSize, - NULL, - &DefaultCharUsed); - DWORD lastError = GetLastError(); - - if (retval == 0) - { - INSTALL_UNWIND_AND_CONTINUE_HANDLER_EX; - COMPlusThrowHR(HRESULT_FROM_WIN32(lastError)); - UNINSTALL_UNWIND_AND_CONTINUE_HANDLER_EX(true); - } - - if (DefaultCharUsed) - { - struct HelperThrow - { - static void Throw() - { - COMPlusThrow( kArgumentException, IDS_EE_MARSHAL_UNMAPPABLE_CHAR ); - } - }; - - ENCLOSE_IN_EXCEPTION_HANDLER( HelperThrow::Throw ); - } - - } - else - { - retval = WideCharToMultiByte(CP_ACP, - flags, - szWideString, - iNumWideChars, - szAnsiString, - cbAnsiBufferSize, - NULL, - NULL); - DWORD lastError = GetLastError(); - - if (retval == 0) - { - INSTALL_UNWIND_AND_CONTINUE_HANDLER_EX; - COMPlusThrowHR(HRESULT_FROM_WIN32(lastError)); - UNINSTALL_UNWIND_AND_CONTINUE_HANDLER_EX(true); - } - } - - return retval; -} - namespace { HRESULT TryParseClassInterfaceAttribute( @@ -1580,29 +1501,6 @@ HRESULT SafeVariantChangeType(_Inout_ VARIANT* pVarRes, _In_ VARIANT* pVarSrc, return hr; } -//-------------------------------------------------------------------------------- -HRESULT SafeVariantChangeTypeEx(_Inout_ VARIANT* pVarRes, _In_ VARIANT* pVarSrc, - LCID lcid, unsigned short wFlags, VARTYPE vt) -{ - CONTRACTL - { - NOTHROW; - GC_TRIGGERS; - MODE_ANY; - PRECONDITION(CheckPointer(pVarRes)); - PRECONDITION(CheckPointer(pVarSrc)); - } - CONTRACTL_END; - - GCX_PREEMP(); - _ASSERTE(GetModuleHandleA("oleaut32.dll") != NULL); - CONTRACT_VIOLATION(ThrowsViolation); - - HRESULT hr = VariantChangeTypeEx (pVarRes, pVarSrc,lcid,wFlags,vt); - - return hr; -} - //-------------------------------------------------------------------------------- void SafeVariantInit(VARIANT* pVar) { diff --git a/src/coreclr/vm/interoputil.h b/src/coreclr/vm/interoputil.h index 053b98c58b0614..eedfd5269f51af 100644 --- a/src/coreclr/vm/interoputil.h +++ b/src/coreclr/vm/interoputil.h @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - #ifndef _H_INTEROP_UTIL #define _H_INTEROP_UTIL @@ -75,7 +74,6 @@ BOOL IsComObjectClass(TypeHandle type); //--------------------------------------------------------- VOID ReadBestFitCustomAttribute(MethodDesc* pMD, BOOL* BestFit, BOOL* ThrowOnUnmappableChar); VOID ReadBestFitCustomAttribute(Module* pModule, mdTypeDef cl, BOOL* BestFit, BOOL* ThrowOnUnmappableChar); -int InternalWideToAnsi(_In_reads_(iNumWideChars) LPCWSTR szWideString, int iNumWideChars, _Out_writes_bytes_opt_(cbAnsiBufferSize) LPSTR szAnsiString, int cbAnsiBufferSize, BOOL fBestFit, BOOL fThrowOnUnmappableChar); //--------------------------------------------------------- // Read the ClassInterfaceType custom attribute info from @@ -192,11 +190,6 @@ ULONG SafeAddRefPreemp(IUnknown* pUnk); HRESULT SafeVariantChangeType(_Inout_ VARIANT* pVarRes, _In_ VARIANT* pVarSrc, unsigned short wFlags, VARTYPE vt); -//-------------------------------------------------------------------------------- -// Release helper, enables and disables GC during call-outs -HRESULT SafeVariantChangeTypeEx(_Inout_ VARIANT* pVarRes, _In_ VARIANT* pVarSrc, - LCID lcid, unsigned short wFlags, VARTYPE vt); - //-------------------------------------------------------------------------------- // Init helper, enables and disables GC during call-outs void SafeVariantInit(VARIANT* pVar); diff --git a/src/coreclr/vm/invokeutil.cpp b/src/coreclr/vm/invokeutil.cpp index 35eeca88e483e2..4a803de5ebb7d4 100644 --- a/src/coreclr/vm/invokeutil.cpp +++ b/src/coreclr/vm/invokeutil.cpp @@ -1,16 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// //////////////////////////////////////////////////////////////////////////////// // This module defines a Utility Class used by reflection -// -// - //////////////////////////////////////////////////////////////////////////////// - #include "common.h" #include "invokeutil.h" #include "corpriv.h" @@ -122,141 +116,6 @@ void *InvokeUtil::GetIntPtrValue(OBJECTREF pObj) { return *(void **)((pObj)->UnBox()); } -void InvokeUtil::CopyArg(TypeHandle th, PVOID argRef, ArgDestination *argDest) { - CONTRACTL { - THROWS; - GC_NOTRIGGER; // Caller does not protect object references - MODE_COOPERATIVE; - PRECONDITION(!th.IsNull()); - } - CONTRACTL_END; - - void *pArgDst = argDest->GetDestinationAddress(); - CorElementType type = th.GetInternalCorElementType(); - - switch (type) { -#ifdef TARGET_RISCV64 - // RISC-V call convention requires integer scalars narrower than XLEN bits to be widened according to the sign - // of their type up to 32 bits, then sign-extended to XLEN bits. In practice it means type-extending all ints - // except `uint` which is sign-extended regardless. - case ELEMENT_TYPE_BOOLEAN: - case ELEMENT_TYPE_U1: - _ASSERTE(argRef != NULL); - *(UINT64 *)pArgDst = *(UINT8 *)argRef; - break; - - case ELEMENT_TYPE_I1: - _ASSERTE(argRef != NULL); - *(INT64 *)pArgDst = *(INT8 *)argRef; - break; - - case ELEMENT_TYPE_U2: - case ELEMENT_TYPE_CHAR: - _ASSERTE(argRef != NULL); - *(UINT64 *)pArgDst = *(UINT16 *)argRef; - break; - - case ELEMENT_TYPE_I2: - _ASSERTE(argRef != NULL); - *(INT64 *)pArgDst = *(INT16 *)argRef; - break; - - case ELEMENT_TYPE_R4: - _ASSERTE(argRef != NULL); - argDest->CopySingleFloatToRegister(argRef); - break; - - case ELEMENT_TYPE_I4: - case ELEMENT_TYPE_U4: - _ASSERTE(argRef != NULL); - *(INT64 *)pArgDst = *(INT32 *)argRef; - break; - -#else // !TARGET_RISCV64 - case ELEMENT_TYPE_BOOLEAN: - case ELEMENT_TYPE_U1: - case ELEMENT_TYPE_I1: - { - _ASSERTE(argRef != NULL); - *(INT8 *)pArgDst = *(INT8 *)argRef; - break; - } - - case ELEMENT_TYPE_I2: - case ELEMENT_TYPE_U2: - case ELEMENT_TYPE_CHAR: - { - _ASSERTE(argRef != NULL); - *(INT16 *)pArgDst = *(INT16 *)argRef; - break; - } - - case ELEMENT_TYPE_I4: - case ELEMENT_TYPE_U4: - case ELEMENT_TYPE_R4: - IN_TARGET_32BIT(case ELEMENT_TYPE_U:) - IN_TARGET_32BIT(case ELEMENT_TYPE_I:) - { - _ASSERTE(argRef != NULL); - *(INT32 *)pArgDst = *(INT32 *)argRef; - break; - } -#endif // TARGET_RISCV64 - - case ELEMENT_TYPE_I8: - case ELEMENT_TYPE_U8: - case ELEMENT_TYPE_R8: - IN_TARGET_64BIT(case ELEMENT_TYPE_I:) - IN_TARGET_64BIT(case ELEMENT_TYPE_U:) - { - _ASSERTE(argRef != NULL); - *(INT64 *)pArgDst = *(INT64 *)argRef; - break; - } - - case ELEMENT_TYPE_VALUETYPE: - { - MethodTable* pMT = th.GetMethodTable(); - CopyValueClassArg(argDest, argRef, pMT, 0); - break; - } - - case ELEMENT_TYPE_STRING: // System.String - case ELEMENT_TYPE_CLASS: // Class - case ELEMENT_TYPE_OBJECT: // System.Object - case ELEMENT_TYPE_SZARRAY: // Single Dim - case ELEMENT_TYPE_ARRAY: // General Array - case ELEMENT_TYPE_VAR: - { - if (argRef == NULL) - *(PVOID *)pArgDst = 0; - else - *(PVOID *)pArgDst = OBJECTREFToObject((OBJECTREF)(Object*)*(PVOID*)argRef); - break; - } - - case ELEMENT_TYPE_BYREF: - { - *(PVOID *)pArgDst = argRef; - break; - } - - case ELEMENT_TYPE_PTR: - case ELEMENT_TYPE_FNPTR: - { - _ASSERTE(argRef != NULL); - MethodTable* pMT = th.GetMethodTable(); - CopyValueClassArg(argDest, argRef, pMT, 0); - break; - } - - case ELEMENT_TYPE_VOID: - default: - _ASSERTE(!"Unknown Type"); - COMPlusThrow(kNotSupportedException); - } -} - // CreatePrimitiveValue // This routine will validate the object and then place the value into // the destination @@ -517,66 +376,6 @@ void InvokeUtil::ValidField(TypeHandle th, OBJECTREF* value) COMPlusThrow(kArgumentException,W("Arg_ObjObj")); } -// -// CreateObjectAfterInvoke -// This routine will create the specified object from the value returned by the Invoke target. -// -// This does not handle the ELEMENT_TYPE_VALUETYPE case. The caller must preallocate the box object and -// copy the value type into it afterward. -// -OBJECTREF InvokeUtil::CreateObjectAfterInvoke(TypeHandle th, void * pValue) { - CONTRACTL { - THROWS; - GC_TRIGGERS; - MODE_COOPERATIVE; - PRECONDITION(!th.IsNull()); - - } - CONTRACTL_END; - - CorElementType type = th.GetSignatureCorElementType(); - OBJECTREF obj = NULL; - - // WARNING: pValue can be an inner reference into a managed object and it is not protected from GC. You must do nothing that - // triggers a GC until the all the data it points to has been captured in a GC-protected location. - - // Handle the non-table types - switch (type) { - case ELEMENT_TYPE_VOID: - break; - - case ELEMENT_TYPE_PTR: - { - obj = CreatePointer(th, *(LPVOID*)pValue); - break; - } - - case ELEMENT_TYPE_CLASS: // Class - case ELEMENT_TYPE_SZARRAY: // Single Dim, Zero - case ELEMENT_TYPE_ARRAY: // General Array - case ELEMENT_TYPE_STRING: - case ELEMENT_TYPE_OBJECT: - case ELEMENT_TYPE_VAR: - obj = ObjectToOBJECTREF(*(Object**)pValue); - break; - - case ELEMENT_TYPE_FNPTR: - { - LPVOID capturedValue = *(LPVOID*)pValue; - INDEBUG(pValue = (LPVOID)(size_t)0xcccccccc); // We're about to allocate a GC object - can no longer trust pValue - obj = AllocateObject(CoreLibBinder::GetElementType(ELEMENT_TYPE_I)); - *(LPVOID*)(obj->UnBox()) = capturedValue; - } - break; - - default: - _ASSERTE(!"Unknown Type"); - COMPlusThrow(kNotSupportedException); - } - - return obj; -} - OBJECTREF InvokeUtil::CreateTargetExcept(OBJECTREF* except) { CONTRACTL { THROWS; diff --git a/src/coreclr/vm/invokeutil.h b/src/coreclr/vm/invokeutil.h index 2d13dbac87e7ee..ead36161145bac 100644 --- a/src/coreclr/vm/invokeutil.h +++ b/src/coreclr/vm/invokeutil.h @@ -1,16 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// //////////////////////////////////////////////////////////////////////////////// // This module defines a Utility Class used by reflection -// -// - //////////////////////////////////////////////////////////////////////////////// - #ifndef __INVOKEUTIL_H__ #define __INVOKEUTIL_H__ @@ -51,13 +45,6 @@ class InvokeUtil { public: - static void CopyArg(TypeHandle th, PVOID argRef, ArgDestination *argDest); - - // Given a type, this routine will convert an return value representing that - // type into an ObjectReference. If the type is a primitive, the - // value is wrapped in one of the Value classes. - static OBJECTREF CreateObjectAfterInvoke(TypeHandle th, void * pValue); - // This is a special purpose Exception creation function. It // creates the TargetInvocationException placing the passed // exception into it. diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 8d951f96c3dc95..b83bb080cf5aa3 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -1,10 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// =========================================================================== -// File: JITinterface.CPP -// =========================================================================== - #include "common.h" #include #include "jitinterface.h" @@ -3439,23 +3435,6 @@ void CEEInfo::AddTransientMethodDetails(TransientMethodDetails details) m_transientDetails->Append(std::move(details)); } -TransientMethodDetails CEEInfo::RemoveTransientMethodDetails(MethodDesc* pMD) -{ - STANDARD_VM_CONTRACT; - _ASSERTE(pMD != NULL); - - TransientMethodDetails local{}; - TransientMethodDetails* details; - if (FindTransientMethodDetails(pMD, &details)) - { - // Details found, move contents to return - // and default initialize the found instance. - local = std::move(*details); - *details = {}; - } - return local; -} - bool CEEInfo::FindTransientMethodDetails(MethodDesc* pMD, TransientMethodDetails** details) { STANDARD_VM_CONTRACT; diff --git a/src/coreclr/vm/jitinterface.h b/src/coreclr/vm/jitinterface.h index 71305defd4aa75..c8f22d71990d75 100644 --- a/src/coreclr/vm/jitinterface.h +++ b/src/coreclr/vm/jitinterface.h @@ -1,11 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// =========================================================================== -// File: JITinterface.H -// -// =========================================================================== - #ifndef JITINTERFACE_H #define JITINTERFACE_H @@ -383,7 +378,6 @@ class CEEInfo : public ICorJitInfo // Add/Remove/Find transient method details. void AddTransientMethodDetails(TransientMethodDetails details); - TransientMethodDetails RemoveTransientMethodDetails(MethodDesc* pMD); bool FindTransientMethodDetails(MethodDesc* pMD, TransientMethodDetails** details); protected: diff --git a/src/coreclr/vm/loaderallocator.hpp b/src/coreclr/vm/loaderallocator.hpp index 7bcfca4b8f8fc1..5b0b5c84066d31 100644 --- a/src/coreclr/vm/loaderallocator.hpp +++ b/src/coreclr/vm/loaderallocator.hpp @@ -2,14 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. /*============================================================ -** ** Header: LoaderAllocator.hpp -** - ** ** Purpose: Implements collection of loader heaps -** -** ===========================================================*/ #ifndef __LoaderAllocator_h__ @@ -768,11 +763,6 @@ class LoaderAllocator #endif // FEATURE_PGO #endif // !defined(DACCESS_COMPILE) - - // This function is only safe to call if the handle is known to be a handle in a collectible - // LoaderAllocator, and the handle is allocated, and the LoaderAllocator is also not collected. - FORCEINLINE OBJECTREF GetHandleValueFastCannotFailType2(LOADERHANDLE handle); - // These functions are designed to be used for maximum performance to access handle values // The GetHandleValueFast will handle the scenario where a loader allocator pointer does not // need to be acquired to do the handle lookup, and the GetHandleValueFastPhase2 handles diff --git a/src/coreclr/vm/loaderallocator.inl b/src/coreclr/vm/loaderallocator.inl index 9c8a616676d945..db01274c767c6a 100644 --- a/src/coreclr/vm/loaderallocator.inl +++ b/src/coreclr/vm/loaderallocator.inl @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - #ifndef _LOADER_ALLOCATOR_I #define _LOADER_ALLOCATOR_I @@ -138,23 +137,6 @@ FORCEINLINE BOOL LoaderAllocator::GetHandleValueFastPhase2(LOADERHANDLE handle, return TRUE; } -FORCEINLINE OBJECTREF LoaderAllocator::GetHandleValueFastCannotFailType2(LOADERHANDLE handle) -{ - SUPPORTS_DAC; - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_MODE_COOPERATIVE; - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - - /* This is lockless access to the handle table, be careful */ - OBJECTREF loaderAllocatorAsObjectRef = ObjectFromHandle(m_hLoaderAllocatorObjectHandle); - LOADERALLOCATORREF loaderAllocator = dac_cast(loaderAllocatorAsObjectRef); - PTRARRAYREF handleTable = loaderAllocator->DangerousGetHandleTable(); - UINT_PTR index = (((UINT_PTR)handle) >> 1) - 1; - - return handleTable->GetAt(index); -} - inline bool SegmentedHandleIndexStack::Push(DWORD value) { LIMITED_METHOD_CONTRACT; @@ -229,4 +211,3 @@ inline bool SegmentedHandleIndexStack::IsEmpty() } #endif // _LOADER_ALLOCATOR_I - diff --git a/src/coreclr/vm/memberload.cpp b/src/coreclr/vm/memberload.cpp index 9d2d544b0546a0..55b8eee2f304b9 100644 --- a/src/coreclr/vm/memberload.cpp +++ b/src/coreclr/vm/memberload.cpp @@ -1,14 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: memberload.cpp -// - - -// - -// -// ============================================================================ #include "common.h" #include "clsload.hpp" @@ -1365,33 +1356,6 @@ MemberLoader::FindMethodByName(MethodTable * pMT, LPCUTF8 pszName, FM_Flags flag return NULL; } -//******************************************************************************* -MethodDesc * -MemberLoader::FindPropertyMethod(MethodTable * pMT, LPCUTF8 pszName, EnumPropertyMethods Method, FM_Flags flags) -{ - CONTRACTL { - THROWS; - GC_TRIGGERS; - MODE_ANY; - PRECONDITION(Method < 2); - } CONTRACTL_END; - - // The format strings for the getter and setter. These must stay in synch with the - // EnumPropertyMethods enum defined in class.h - static const LPCUTF8 aFormatStrings[] = - { - "get_%s", - "set_%s" - }; - - CQuickBytes qbMethName; - size_t len = strlen(pszName) + strlen(aFormatStrings[Method]) + 1; - LPUTF8 strMethName = (LPUTF8) qbMethName.AllocThrows(len); - sprintf_s(strMethName, len, aFormatStrings[Method], pszName); - - return FindMethodByName(pMT, strMethName, flags); -} - //******************************************************************************* MethodDesc * MemberLoader::FindEventMethod(MethodTable * pMT, LPCUTF8 pszName, EnumEventMethods Method, FM_Flags flags) @@ -1404,7 +1368,7 @@ MemberLoader::FindEventMethod(MethodTable * pMT, LPCUTF8 pszName, EnumEventMetho } CONTRACTL_END; // The format strings for the getter and setter. These must stay in synch with the - // EnumPropertyMethods enum defined in class.h + // EnumEventMethods enum defined in memberload.h static const LPCUTF8 aFormatStrings[] = { "add_%s", diff --git a/src/coreclr/vm/memberload.h b/src/coreclr/vm/memberload.h index ceccb97b85381f..e32b04e3c88358 100644 --- a/src/coreclr/vm/memberload.h +++ b/src/coreclr/vm/memberload.h @@ -1,14 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: memberload.h -// - - -// - -// -// ============================================================================ #ifndef _MEMBERLOAD_H #define _MEMBERLOAD_H @@ -29,17 +20,6 @@ #include "methodtable.h" #include "typectxt.h" -// -// This enum represents the property methods that can be passed to FindPropertyMethod(). -// - -enum EnumPropertyMethods -{ - PropertyGet = 0, - PropertySet = 1, -}; - - // // This enum represents the event methods that can be passed to FindEventMethod(). // @@ -231,12 +211,6 @@ class MemberLoader LPCUTF8 pszName, FM_Flags flags = FM_Default); - static MethodDesc *FindPropertyMethod( - MethodTable * pMT, - LPCUTF8 pszName, - EnumPropertyMethods Method, - FM_Flags flags = FM_Default); - static MethodDesc *FindEventMethod( MethodTable * pMT, LPCUTF8 pszName, diff --git a/src/coreclr/vm/methodtable.h b/src/coreclr/vm/methodtable.h index f5f2088ad74b16..1b9cb0b77c851b 100644 --- a/src/coreclr/vm/methodtable.h +++ b/src/coreclr/vm/methodtable.h @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: methodtable.h -// #ifndef _METHODTABLE_H_ #define _METHODTABLE_H_ @@ -2207,8 +2204,6 @@ class MethodTable BOOL ValidateWithPossibleAV(); - BOOL IsClassPointerValid(); - static UINT32 GetOffsetOfFlags() { LIMITED_METHOD_CONTRACT; diff --git a/src/coreclr/vm/methodtable.inl b/src/coreclr/vm/methodtable.inl index df2990bd6515e4..54fe555bc7399f 100644 --- a/src/coreclr/vm/methodtable.inl +++ b/src/coreclr/vm/methodtable.inl @@ -1,14 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: methodtable.inl -// - - -// - -// -// ============================================================================ #ifndef _METHODTABLE_INL_ #define _METHODTABLE_INL_ @@ -71,25 +62,6 @@ inline Assembly * MethodTable::GetAssembly() return GetModule()->GetAssembly(); } -//========================================================================================== -inline BOOL MethodTable::IsClassPointerValid() -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - LowBits lowBits = union_getLowBits(m_pCanonMT); - if (lowBits == UNION_EECLASS) - { - return m_pEEClass != NULL; - } - else - { - // pointer to canonical MethodTable. - TADDR canonicalMethodTable = union_getPointer(m_pCanonMT); - return PTR_MethodTable(canonicalMethodTable)->m_pEEClass != NULL; - } -} - //========================================================================================== inline PTR_Module MethodTable::GetLoaderModule() { diff --git a/src/coreclr/vm/object.cpp b/src/coreclr/vm/object.cpp index 1e7796cf1c706b..f1dc20c95d5ec3 100644 --- a/src/coreclr/vm/object.cpp +++ b/src/coreclr/vm/object.cpp @@ -1,10 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// + // OBJECT.CPP // // Definitions of a CLR Object -// #include "common.h" @@ -427,35 +426,6 @@ void CopyValueClassArgUnchecked(ArgDestination *argDest, void* src, MethodTable CopyValueClassUnchecked(argDest->GetDestinationAddress(), src, pMT); } -// Initialize the value class argument to zeros -void InitValueClassArg(ArgDestination *argDest, MethodTable *pMT) -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_COOPERATIVE; - -#if defined(UNIX_AMD64_ABI) - - if (argDest->IsStructPassedInRegs()) - { - argDest->ZeroStructInRegisters(pMT->GetNumInstanceFieldBytes()); - return; - } - -#endif - -#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) - if (argDest->IsStructPassedInRegs()) - { - *(UINT64*)(argDest->GetStructGenRegDestinationAddress()) = 0; - *(UINT64*)(argDest->GetDestinationAddress()) = 0; - return; - } -#endif - - InitValueClass(argDest->GetDestinationAddress(), pMT); -} - #if defined (VERIFY_HEAP) #include "dbginterface.h" diff --git a/src/coreclr/vm/object.h b/src/coreclr/vm/object.h index acd7f720f8481f..923958a639714b 100644 --- a/src/coreclr/vm/object.h +++ b/src/coreclr/vm/object.h @@ -1,14 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// + // OBJECT.H // // Definitions of a CLR Object -// // See code:EEStartup#TableOfContents for overview - #ifndef _OBJECT_H_ #define _OBJECT_H_ @@ -415,9 +413,6 @@ inline void InitValueClass(void *dest, MethodTable *pMT) ZeroMemoryInGCHeap(dest, pMT->GetNumInstanceFieldBytes()); } -// Initialize value class argument -void InitValueClassArg(ArgDestination *argDest, MethodTable *pMT); - #define SetObjectReference(_d,_r) SetObjectReferenceUnchecked(_d, _r) #define CopyValueClass(_d,_s,_m) CopyValueClassUnchecked(_d,_s,_m) #define CopyValueClassArg(_d,_s,_m,_o) CopyValueClassArgUnchecked(_d,_s,_m,_o) diff --git a/src/coreclr/vm/olevariant.cpp b/src/coreclr/vm/olevariant.cpp index 2556ed94ed9433..0f5831b7fb40a0 100644 --- a/src/coreclr/vm/olevariant.cpp +++ b/src/coreclr/vm/olevariant.cpp @@ -1,11 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: OleVariant.cpp -// - -// - #include "common.h" @@ -14,7 +8,6 @@ #include "frames.h" #include "vars.hpp" #include "olevariant.h" -#include "comdatetime.h" #include "fieldmarshaler.h" #include "dllimport.h" @@ -1310,40 +1303,6 @@ void OleVariant::MarshalOleVariantForObjectUncommon(OBJECTREF * const & pObj, VA // Used by customer checked build to test validity of VARIANT -BOOL OleVariant::CheckVariant(VARIANT* pOle) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_ANY; - PRECONDITION(CheckPointer(pOle)); - } - CONTRACTL_END; - - BOOL bValidVariant = FALSE; - - // We need a try/catch here since VariantCopy could cause an AV if the VARIANT isn't valid. - EX_TRY - { - VARIANT pOleCopy; - SafeVariantInit(&pOleCopy); - - GCX_PREEMP(); - if (SUCCEEDED(VariantCopy(&pOleCopy, pOle))) - { - SafeVariantClear(&pOleCopy); - bValidVariant = TRUE; - } - } - EX_CATCH - { - } - EX_END_CATCH - - return bValidVariant; -} - HRESULT OleVariant::ClearAndInsertContentsIntoByrefRecordVariant(VARIANT* pOle, OBJECTREF* pObj) { CONTRACTL diff --git a/src/coreclr/vm/olevariant.h b/src/coreclr/vm/olevariant.h index 221c00350b212d..63bea064de7b05 100644 --- a/src/coreclr/vm/olevariant.h +++ b/src/coreclr/vm/olevariant.h @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: OleVariant.h -// #ifndef _H_OLEVARIANT_ #define _H_OLEVARIANT_ @@ -66,8 +63,6 @@ class OleVariant static BOOL IsValidArrayForSafeArrayElementType(BASEARRAYREF* pArrayRef, VARTYPE vtExpected); - static BOOL CheckVariant(VARIANT *pOle); - // Type conversion utilities static void ExtractContentsFromByrefVariant(VARIANT* pByrefVar, VARIANT* pDestVar); static void InsertContentsIntoByRefVariant(VARIANT* pSrcVar, VARIANT* pByrefVar); diff --git a/src/coreclr/vm/peimage.h b/src/coreclr/vm/peimage.h index dc9298d9bb20d5..8fb51faa4fb132 100644 --- a/src/coreclr/vm/peimage.h +++ b/src/coreclr/vm/peimage.h @@ -1,11 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -------------------------------------------------------------------------------- -// PEImage.h -// - -// -------------------------------------------------------------------------------- - #ifndef PEIMAGE_H_ #define PEIMAGE_H_ @@ -167,7 +161,6 @@ class PEImage final void GetPEKindAndMachine(DWORD* pdwKind, DWORD* pdwMachine); BOOL IsILOnly(); - BOOL IsReferenceAssembly(); BOOL IsComponentAssembly(); PTR_CVOID GetNativeManifestMetadata(COUNT_T* pSize = NULL); diff --git a/src/coreclr/vm/peimage.inl b/src/coreclr/vm/peimage.inl index 293bd7a7a81544..b329a98d81af3f 100644 --- a/src/coreclr/vm/peimage.inl +++ b/src/coreclr/vm/peimage.inl @@ -1,10 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -------------------------------------------------------------------------------- -// PEImage.inl -// - -// -------------------------------------------------------------------------------- #ifndef PEIMAGE_INL_ #define PEIMAGE_INL_ @@ -199,29 +194,6 @@ inline BOOL PEImage::IsOpened() return m_pLayouts[IMAGE_LOADED]!=NULL || m_pLayouts[IMAGE_FLAT] !=NULL; } - -inline BOOL PEImage::IsReferenceAssembly() -{ - CONTRACTL - { - PRECONDITION(HasCorHeader()); - } - CONTRACTL_END; - - IMDInternalImport* mdImport = this->GetMDImport(); - HRESULT hr = mdImport->GetCustomAttributeByName(TokenFromRid(1, mdtAssembly), - g_ReferenceAssemblyAttribute, - NULL, - NULL); - IfFailThrow(hr); - if (hr == S_OK) { - return TRUE; - } - _ASSERTE(hr == S_FALSE); - return FALSE; -} - - inline BOOL PEImage::HasHeaders() { WRAPPER_NO_CONTRACT; diff --git a/src/coreclr/vm/peimagelayout.h b/src/coreclr/vm/peimagelayout.h index 7fbfef61a474d7..d992ff47566d18 100644 --- a/src/coreclr/vm/peimagelayout.h +++ b/src/coreclr/vm/peimagelayout.h @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + // -------------------------------------------------------------------------------- // PEImageLayout.h -// - // -------------------------------------------------------------------------------- - #ifndef PEIMAGELAYOUT_H_ #define PEIMAGELAYOUT_H_ @@ -72,7 +70,6 @@ class PEImageLayout #endif PEImageLayout(); virtual ~PEImageLayout(); - static BOOL CompareBase(UPTR path, UPTR mapping); // Refcount above images. void AddRef(); @@ -338,4 +335,3 @@ class NativeImageLayout : public PEImageLayout }; #endif // PEIMAGELAYOUT_H_ - diff --git a/src/coreclr/vm/peimagelayout.inl b/src/coreclr/vm/peimagelayout.inl index f92530d9bd78a7..2db94fb5d95aff 100644 --- a/src/coreclr/vm/peimagelayout.inl +++ b/src/coreclr/vm/peimagelayout.inl @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// - #ifndef PEIMAGEVIEW_INL_ #define PEIMAGEVIEW_INL_ @@ -67,23 +65,6 @@ inline PEImageLayout::PEImageLayout() LIMITED_METHOD_CONTRACT; } -inline BOOL PEImageLayout::CompareBase(UPTR base, UPTR mapping) -{ - CONTRACTL - { - PRECONDITION(CheckPointer((PEImageLayout *)mapping)); - PRECONDITION(CheckPointer((PEImageLayout *)(base<<1),NULL_OK)); - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - if (base==0) //we were searching for 'Any' - return TRUE; - return ((PEImageLayout*)mapping)->GetBase()==((PEImageLayout*)(base<<1))->GetBase(); - -} - // ----------------------------------------------- // Forwarding methods — inline implementations // ----------------------------------------------- diff --git a/src/coreclr/vm/proftoeeinterfaceimpl.cpp b/src/coreclr/vm/proftoeeinterfaceimpl.cpp index b028b6c2a80f59..932b2a44509d53 100644 --- a/src/coreclr/vm/proftoeeinterfaceimpl.cpp +++ b/src/coreclr/vm/proftoeeinterfaceimpl.cpp @@ -1,14 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// + +// ====================================================================================== // FILE: ProfToEEInterfaceImpl.cpp // // This module implements the ICorProfilerInfo* interfaces, which allow the // Profiler to communicate with the EE. This allows the Profiler DLL to get // access to private EE data structures and other things that should never be // exported outside of the EE. -// - // // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! @@ -56,7 +55,6 @@ // NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // -// // #P2CLRRestrictionsOverview // // The public ICorProfilerInfo(N) functions below have different restrictions on when @@ -100,10 +98,6 @@ // * normally immutable or disallowed after attach, AND // * that the test plans to set after startup and / or by an attaching // profiler. -// -// - -// // ====================================================================================== #include "common.h" @@ -2641,24 +2635,6 @@ HRESULT ProfToEEInterfaceImpl::GetEventMask2(DWORD *pdwEventsLow, DWORD *pdwEven return S_OK; } -// static -void ProfToEEInterfaceImpl::MethodTableCallback(void* context, void* objectUNSAFE) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - // each callback identifies the address of a method table within the frozen object segment - // that pointer is an object ID by definition -- object references point to the method table - CDynArray< ObjectID >* objects = reinterpret_cast< CDynArray< ObjectID >* >(context); - - *objects->Append() = reinterpret_cast< ObjectID >(objectUNSAFE); -} - // static void ProfToEEInterfaceImpl::ObjectRefCallback(void* context, void* objectUNSAFE) { diff --git a/src/coreclr/vm/proftoeeinterfaceimpl.h b/src/coreclr/vm/proftoeeinterfaceimpl.h index e9ddd50a5fd064..8bc375570d1142 100644 --- a/src/coreclr/vm/proftoeeinterfaceimpl.h +++ b/src/coreclr/vm/proftoeeinterfaceimpl.h @@ -1,19 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// + +// ====================================================================================== // FILE: ProfToEEInterfaceImpl.h // // Declaration of class that implements the ICorProfilerInfo* interfaces, which allow the // Profiler to communicate with the EE. This allows the Profiler DLL to get // access to private EE data structures and other things that should never be exported // outside of the EE. -// - -// - // ====================================================================================== - #ifndef __PROFTOEEINTERFACEIMPL_H__ #define __PROFTOEEINTERFACEIMPL_H__ @@ -163,7 +159,6 @@ class ProfToEEInterfaceImpl : public ICorProfilerInfo15 // Internal Housekeeping - static void MethodTableCallback(void* context, void* methodTable); static void ObjectRefCallback(void* context, void* objectRefUNSAFE); ProfToEEInterfaceImpl(); @@ -804,5 +799,3 @@ class ProfToEEInterfaceImpl : public ICorProfilerInfo15 #endif // PROFILING_SUPPORTED #endif // __PROFTOEEINTERFACEIMPL_H__ - - diff --git a/src/coreclr/vm/qcallentrypoints.cpp b/src/coreclr/vm/qcallentrypoints.cpp index 11e954ef0d70d7..7c93058363ff4d 100644 --- a/src/coreclr/vm/qcallentrypoints.cpp +++ b/src/coreclr/vm/qcallentrypoints.cpp @@ -24,7 +24,6 @@ #include "comsynchronizable.h" #include "floatdouble.h" #include "floatsingle.h" -#include "comdatetime.h" #include "debugdebugger.h" #include "assemblynative.hpp" diff --git a/src/coreclr/vm/readytoruninfo.cpp b/src/coreclr/vm/readytoruninfo.cpp index b1ddad508370b0..ce4b342daed558 100644 --- a/src/coreclr/vm/readytoruninfo.cpp +++ b/src/coreclr/vm/readytoruninfo.cpp @@ -1,9 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + // =========================================================================== // File: ReadyToRunInfo.cpp -// - // // Runtime support for Ready to Run // =========================================================================== @@ -2421,25 +2420,6 @@ bool ReadyToRun_TypeGenericInfoMap::IsGeneric(mdTypeDef input, IMDInternalImport return !!((uint8_t)typeGenericInfo & (uint8_t)ReadyToRunTypeGenericInfo::GenericCountMask); } -HRESULT ReadyToRun_TypeGenericInfoMap::IsGenericNoThrow(mdTypeDef input, bool *pIsGeneric, IMDInternalImport* pImport) const -{ - bool foundResult; - bool result; - HRESULT hr; - ReadyToRunTypeGenericInfo typeGenericInfo = GetTypeGenericInfo(input, &foundResult); - if (!foundResult) - { - HENUMInternalHolder hEnumTyPars(pImport); - IfFailRet(hEnumTyPars.EnumInitNoThrow(mdtGenericParam, input)); - result = (pImport->EnumGetCount(&hEnumTyPars) != 0); - } - else - result = !!((uint8_t)typeGenericInfo & (uint8_t)ReadyToRunTypeGenericInfo::GenericCountMask); - - *pIsGeneric = result; - return S_OK; -} - uint32_t ReadyToRun_TypeGenericInfoMap::GetGenericArgumentCount(mdTypeDef input, IMDInternalImport* pImport) const { bool foundResult; diff --git a/src/coreclr/vm/readytoruninfo.h b/src/coreclr/vm/readytoruninfo.h index 237143e99c2797..469ca418252297 100644 --- a/src/coreclr/vm/readytoruninfo.h +++ b/src/coreclr/vm/readytoruninfo.h @@ -1,9 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + // =========================================================================== // File: ReadyToRunInfo.h -// - // // Runtime support for Ready to Run // =========================================================================== @@ -96,7 +95,6 @@ class ReadyToRun_TypeGenericInfoMap const static ReadyToRun_TypeGenericInfoMap EmptyInstance; - HRESULT IsGenericNoThrow(mdTypeDef input, bool *pIsGeneric, IMDInternalImport* pImport) const; HRESULT GetGenericArgumentCountNoThrow(mdTypeDef input, uint32_t *pCount, IMDInternalImport* pImport) const; bool IsGeneric(mdTypeDef input, IMDInternalImport* pImport) const; uint32_t GetGenericArgumentCount(mdTypeDef input, IMDInternalImport* pImport) const; diff --git a/src/coreclr/vm/siginfo.cpp b/src/coreclr/vm/siginfo.cpp index 3b28018011f23a..fc32bb3164643c 100644 --- a/src/coreclr/vm/siginfo.cpp +++ b/src/coreclr/vm/siginfo.cpp @@ -1,11 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// + // siginfo.cpp // // Signature parsing code -// - #include "common.h" @@ -5428,25 +5426,6 @@ CorElementType MetaSig::GetReturnTypeNormalized(TypeHandle * pthValueType) const return m_corNormalizedRetType; } -BOOL MetaSig::IsObjectRefReturnType() -{ - WRAPPER_NO_CONTRACT; - - switch (GetReturnTypeNormalized()) - { - case ELEMENT_TYPE_CLASS: - case ELEMENT_TYPE_SZARRAY: - case ELEMENT_TYPE_ARRAY: - case ELEMENT_TYPE_STRING: - case ELEMENT_TYPE_OBJECT: - case ELEMENT_TYPE_VAR: - return TRUE; - default: - break; - } - return FALSE; -} - CorElementType MetaSig::GetReturnType() const { WRAPPER_NO_CONTRACT; diff --git a/src/coreclr/vm/siginfo.hpp b/src/coreclr/vm/siginfo.hpp index c192a62b1bdef0..486c80e9dd04ca 100644 --- a/src/coreclr/vm/siginfo.hpp +++ b/src/coreclr/vm/siginfo.hpp @@ -1,9 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// siginfo.hpp -// - #ifndef _H_SIGINFO #define _H_SIGINFO @@ -833,10 +829,6 @@ class MetaSig } } // NextArgNormalized - // Tests if the return type is an object ref. Loads types - // if needed (though it shouldn't really need to) - BOOL IsObjectRefReturnType(); - //------------------------------------------------------------------------ // Compute element size from CorElementType and optional valuetype. //------------------------------------------------------------------------ diff --git a/src/coreclr/vm/staticallocationhelpers.inl b/src/coreclr/vm/staticallocationhelpers.inl deleted file mode 100644 index a9047ba8f87188..00000000000000 --- a/src/coreclr/vm/staticallocationhelpers.inl +++ /dev/null @@ -1,159 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// StaticAllocationHelpers.inl - -// - -// -// Helpers used to determine static offset allocation. -// -// -#ifndef StaticAllocationHelpers_INL -#define StaticAllocationHelpers_INL - -// Will return underlying type if it's an enum -// ELEMENT_TYPE_VALUETYPE if it is a non enum -// ELEMENT_TYPE_END if it doesn't know (we may not want to load other assemblies) -static CorElementType ParseMetadataForStaticsIsValueTypeEnum(Module * pModule, IMDInternalImport *pImport, mdToken tk) -{ - STANDARD_VM_CONTRACT; - - if (TypeFromToken(tk) != mdtTypeDef) - { - // At this point, we would have to load other assemblies. The only one we have guaranteed - // to be there is CoreLib. - return ELEMENT_TYPE_END; - } - - // The only condition we will be checking is that the parent of the type is System.Enum - // Rest of the checks will be handed by class loader, which will fail to load if it's malformed - // hence, no need to do all the checks here. - mdToken tkParent = 0; - DWORD dwParentAttr = 0; - - if (FAILED(pImport->GetTypeDefProps(tk, &dwParentAttr, &tkParent))) - { - return ELEMENT_TYPE_END; - } - - if (RidFromToken(tkParent) == 0) - { - return ELEMENT_TYPE_END; - } - - LPCSTR szName = NULL; - LPCSTR szNamespace = NULL; - - switch (TypeFromToken(tkParent)) - { - case mdtTypeDef: - if (FAILED(pImport->GetNameOfTypeDef(tkParent, &szName, &szNamespace))) - { - return ELEMENT_TYPE_END; - } - break; - case mdtTypeRef: - if (FAILED(pImport->GetNameOfTypeRef(tkParent, &szNamespace, &szName))) - { - return ELEMENT_TYPE_END; - } - break; - default: - return ELEMENT_TYPE_END; - } - - if (szName == NULL || szNamespace == NULL) - { - return ELEMENT_TYPE_END; - } - - // If it doesn't inherit from System.Enum, then it must be a value type - // Note that loader will not load malformed types so this check is enough - if (strcmp(szName,"Enum") != 0 || strcmp(szNamespace,"System") != 0) - { - return ELEMENT_TYPE_VALUETYPE; - } - - // OK, it's an enum; find its instance field and get its type - HENUMInternalHolder hEnum(pImport); - mdToken tkField; - hEnum.EnumInit(mdtFieldDef,tk); - while (pImport->EnumNext(&hEnum,&tkField)) - { - PCCOR_SIGNATURE pMemberSignature; - DWORD cMemberSignature; - - // Get the type of the static field. - DWORD dwMemberAttribs; - - IfFailThrow(pImport->GetFieldDefProps(tkField, &dwMemberAttribs)); - - if (!IsFdStatic(dwMemberAttribs)) - { - IfFailThrow(pImport->GetSigOfFieldDef(tkField, &cMemberSignature, &pMemberSignature)); - - IfFailThrow(validateTokenSig(tkField,pMemberSignature,cMemberSignature,dwMemberAttribs,pImport)); - - SigTypeContext typeContext; - MetaSig fsig(pMemberSignature, cMemberSignature, pModule, &typeContext, MetaSig::sigField); - CorElementType ElementType = fsig.NextArg(); - return ElementType; - } - } - - // no instance field found -- error! - return ELEMENT_TYPE_END; -} - -static BOOL GetStaticFieldElementTypeForFieldDef(Module * pModule, IMDInternalImport *pImport, mdToken field, CorElementType *pElementType, mdToken *ptkValueTypeToken, int *pkk) -{ - STANDARD_VM_CONTRACT; - - PCCOR_SIGNATURE pMemberSignature; - DWORD cMemberSignature; - DWORD dwMemberAttribs; - IfFailThrow(pImport->GetFieldDefProps(field, &dwMemberAttribs)); - - // Skip non-static and literal fields - if (!IsFdStatic(dwMemberAttribs) || IsFdLiteral(dwMemberAttribs)) - return TRUE; - - // We need to do an extra check to see if this field is ThreadStatic - HRESULT hr = pModule->GetCustomAttribute((mdToken)field, - WellKnownAttribute::ThreadStatic, - NULL, NULL); - IfFailThrow(hr); - - // Use one set of variables for regular statics, and the other set for thread statics - *pkk = (hr == S_OK) ? 1 : 0; - - - // Get the type of the static field. - IfFailThrow(pImport->GetSigOfFieldDef(field, &cMemberSignature, &pMemberSignature)); - IfFailThrow(validateTokenSig(field,pMemberSignature,cMemberSignature,dwMemberAttribs,pImport)); - - SigTypeContext typeContext; // this is an empty type context: is this right? Should we be explicitly excluding all generic types from this iteration? - MetaSig fsig(pMemberSignature, cMemberSignature, pModule, &typeContext, MetaSig::sigField); - CorElementType ElementType = fsig.NextArg(); - - if (ElementType == ELEMENT_TYPE_VALUETYPE) - { - // See if we can figure out what the value type is - Module *pTokenModule; - mdToken tk = fsig.GetArgProps().PeekValueTypeTokenClosed(pModule, &typeContext, &pTokenModule); - - *ptkValueTypeToken = tk; - - // As the current class is not generic, this should never happen, but if it did happen, we - // would have a problem. - if (pTokenModule != pModule) - { - ThrowHR(COR_E_BADIMAGEFORMAT, BFA_METADATA_CORRUPT); - } - - ElementType = ParseMetadataForStaticsIsValueTypeEnum(pModule, pImport, tk); - } - - *pElementType = ElementType; - return FALSE; -} -#endif // StaticAllocationHelpers_INL diff --git a/src/coreclr/vm/stdinterfaces.cpp b/src/coreclr/vm/stdinterfaces.cpp index b7959de9c874e1..e6bca87b5dcf6e 100644 --- a/src/coreclr/vm/stdinterfaces.cpp +++ b/src/coreclr/vm/stdinterfaces.cpp @@ -1,13 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + //--------------------------------------------------------------------------------- // stdinterfaces.cpp // // Defines various standard com interfaces - //--------------------------------------------------------------------------------- - #include "common.h" #include @@ -354,49 +353,6 @@ Unknown_ReleaseSpecial_Internal(IUnknown* pUnk) return cbRef; } // Unknown_Release - -HRESULT __stdcall -Unknown_QueryInterface_IErrorInfo_Simple(IUnknown* pUnk, REFIID riid, void** ppv) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_PREEMPTIVE; - PRECONDITION(CheckPointer(pUnk)); - PRECONDITION(IsInProcCCWTearOff(pUnk)); - PRECONDITION(CheckPointer(ppv, NULL_OK)); - } - CONTRACTL_END; - - HRESULT hr = S_OK; - - if (!ppv) - return E_POINTER; - *ppv = NULL; - - EX_TRY - { - hr = E_NOINTERFACE; - - _ASSERTE(!IsInnerUnknown(pUnk) && IsSimpleTearOff(pUnk)); - - SimpleComCallWrapper* pSimpleWrap = SimpleComCallWrapper::GetWrapperFromIP(pUnk); - - // we must not switch to cooperative GC mode here, so respond only to the - // two interfaces we always support - if (riid == IID_IUnknown || riid == IID_IErrorInfo) - { - *ppv = pUnk; - pSimpleWrap->AddRef(); - hr = S_OK; - } - } - EX_CATCH_HRESULT_NO_ERRORINFO(hr); - - return hr; -} // Unknown_QueryInterface_IErrorInfo_Simple - // --------------------------------------------------------------------------- ULONG __stdcall Unknown_ReleaseSpecial_IErrorInfo_Internal(IUnknown* pUnk) diff --git a/src/coreclr/vm/stdinterfaces_internal.h b/src/coreclr/vm/stdinterfaces_internal.h index f9e02b0a193a56..544e3309b1691d 100644 --- a/src/coreclr/vm/stdinterfaces_internal.h +++ b/src/coreclr/vm/stdinterfaces_internal.h @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - #ifndef _H_INTERNAL_STDINTERFACES #define _H_INTERNAL_STDINTERFACES @@ -13,8 +12,6 @@ // prototypes IUnknown methods HRESULT Unknown_QueryInterface_Internal ( ComCallWrapper* pWrap, IUnknown* pUnk, REFIID riid, void** ppv); -HRESULT __stdcall Unknown_QueryInterface_IErrorInfo_Simple ( - IUnknown* pUnk, REFIID riid, void** ppv); ULONG __stdcall Unknown_AddRef_Internal(IUnknown* pUnk); ULONG __stdcall Unknown_Release_Internal(IUnknown* pUnk); diff --git a/src/coreclr/vm/stubgen.cpp b/src/coreclr/vm/stubgen.cpp index 588b9167ee8018..49f8ff0b57d0ac 100644 --- a/src/coreclr/vm/stubgen.cpp +++ b/src/coreclr/vm/stubgen.cpp @@ -1,11 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: StubGen.cpp -// - -// - #include "common.h" #include @@ -393,26 +387,6 @@ ILCodeStream::ILInstrEnum ILCodeStream::LowerOpcode(ILInstrEnum instr, ILStubLin return instr; } -void ILStubLinker::PatchInstructionArgument(ILCodeLabel* pLabel, UINT_PTR uNewArg - DEBUG_ARG(UINT16 uExpectedInstruction)) -{ - LIMITED_METHOD_CONTRACT; - - UINT idx = pLabel->m_idxLabeledInstruction; - ILCodeStream* pLabelCodeStream = pLabel->m_pCodeStreamOfLabel; - ILInstruction* pLabelInstrBuffer = (ILInstruction*)pLabelCodeStream->m_pqbILInstructions->Ptr(); - - CONSISTENCY_CHECK(pLabelInstrBuffer[idx].uInstruction == ILCodeStream::CEE_CODE_LABEL); - CONSISTENCY_CHECK(pLabelInstrBuffer[idx].iStackDelta == 0); - - idx++; - - CONSISTENCY_CHECK(idx < pLabelCodeStream->m_uCurInstrIdx); - CONSISTENCY_CHECK(pLabelInstrBuffer[idx].uInstruction == uExpectedInstruction); - - pLabelInstrBuffer[idx].uArg = uNewArg; -} - ILCodeLabel::ILCodeLabel() { m_pNext = NULL; diff --git a/src/coreclr/vm/stubgen.h b/src/coreclr/vm/stubgen.h index 418c6f2b630cc9..abf2d6449ca02c 100644 --- a/src/coreclr/vm/stubgen.h +++ b/src/coreclr/vm/stubgen.h @@ -1,11 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// File: StubGen.h -// - -// - #ifndef __STUBGEN_H__ #define __STUBGEN_H__ @@ -736,9 +730,6 @@ class ILStubLinker UINT_PTR uArg; }; - static void PatchInstructionArgument(ILCodeLabel* pLabel, UINT_PTR uNewArg - DEBUG_ARG(UINT16 uExpectedInstruction)); - #ifdef _DEBUG bool IsInCodeStreamList(ILCodeStream* pcs); #endif // _DEBUG diff --git a/src/coreclr/vm/stubhelpers.cpp b/src/coreclr/vm/stubhelpers.cpp index c3026e913e8d8c..0a9f889a2ffa71 100644 --- a/src/coreclr/vm/stubhelpers.cpp +++ b/src/coreclr/vm/stubhelpers.cpp @@ -13,7 +13,6 @@ #include "fieldmarshaler.h" #include "comdelegate.h" #include "eventtrace.h" -#include "comdatetime.h" #include "gcheaputilities.h" #include "interoputil.h" #include "../debug/ee/debugger.h" diff --git a/src/coreclr/vm/stublink.cpp b/src/coreclr/vm/stublink.cpp index 36a2b18508912c..8bf1407bf1b8e8 100644 --- a/src/coreclr/vm/stublink.cpp +++ b/src/coreclr/vm/stublink.cpp @@ -1,10 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// stublink.cpp -// - - #include "common.h" @@ -221,49 +216,6 @@ VOID StubLinker::Emit32(uint32_t val) } } -//--------------------------------------------------------------- -// Append code bytes. -//--------------------------------------------------------------- -VOID StubLinker::Emit64(uint64_t val) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - CodeRun *pCodeRun = GetLastCodeRunIfAny(); - if (pCodeRun && (CODERUNSIZE - pCodeRun->m_numcodebytes) >= sizeof(val)) { - SET_UNALIGNED_64(pCodeRun->m_codebytes + pCodeRun->m_numcodebytes, val); - pCodeRun->m_numcodebytes += sizeof(val); - } else { - EmitBytes((BYTE*)&val, sizeof(val)); - } -} - -//--------------------------------------------------------------- -// Append pointer value. -//--------------------------------------------------------------- -VOID StubLinker::EmitPtr(const VOID *val) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - CodeRun *pCodeRun = GetLastCodeRunIfAny(); - if (pCodeRun && (CODERUNSIZE - pCodeRun->m_numcodebytes) >= sizeof(val)) { - SET_UNALIGNED_PTR(pCodeRun->m_codebytes + pCodeRun->m_numcodebytes, (UINT_PTR)val); - pCodeRun->m_numcodebytes += sizeof(val); - } else { - EmitBytes((BYTE*)&val, sizeof(val)); - } -} - - //--------------------------------------------------------------- // Create a new undefined label. Label must be assigned to a code // location using EmitLabel() prior to final linking. diff --git a/src/coreclr/vm/stublink.h b/src/coreclr/vm/stublink.h index 3b2a6419e48a47..0188f748f1fe0f 100644 --- a/src/coreclr/vm/stublink.h +++ b/src/coreclr/vm/stublink.h @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // STUBLINK.H -// - // // A StubLinker object provides a way to link several location-independent // code sources into one executable stub, resolving references, @@ -30,7 +28,6 @@ // StubLinker stublink; // Inner(); // -// // // Have to separate into inner function because VC++ forbids // // mixing __try & local objects in the same function. // void Inner() { @@ -40,8 +37,6 @@ // } COMPLUSCATCH { // } // } -// - // This file should only be included via the platform-specific cgencpu.h. @@ -115,8 +110,6 @@ class StubLinker VOID Emit8 (uint8_t u8); VOID Emit16(uint16_t u16); VOID Emit32(uint32_t u32); - VOID Emit64(uint64_t u64); - VOID EmitPtr(const VOID *pval); //--------------------------------------------------------------- // Append an instruction containing a reference to a label. diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index 27833c0b58dffe..7139b5327a1584 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -1,10 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// THREADS.CPP -// - #include "common.h" #include "CLREventBase.h" @@ -2925,38 +2921,6 @@ void Thread::OnThreadTerminate(BOOL holdingLock) } } -// Helper functions to check for duplicate handles. we only do this check if -// a waitfor multiple fails. -int __cdecl compareHandles( const void *arg1, const void *arg2 ) -{ - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - HANDLE h1 = *(HANDLE*)arg1; - HANDLE h2 = *(HANDLE*)arg2; - return (h1 == h2) ? 0 : ((h1 < h2) ? -1 : 1); -} - -BOOL CheckForDuplicateHandles(int countHandles, HANDLE *handles) -{ - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - qsort(handles,countHandles,sizeof(HANDLE),compareHandles); - for (int i=1; i < countHandles; i++) - { - if (handles[i-1] == handles[i]) - return TRUE; - } - return FALSE; -} - #ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT //-------------------------------------------------------------------- @@ -3449,25 +3413,6 @@ void Thread::SyncManagedExceptionState(bool fIsDebuggerThread) } } -void Thread::SetLastThrownObjectHandle(OBJECTHANDLE h) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_COOPERATIVE; - } - CONTRACTL_END; - - if (m_LastThrownObjectHandle != NULL && - !CLRException::IsPreallocatedExceptionHandle(m_LastThrownObjectHandle)) - { - DestroyHandle(m_LastThrownObjectHandle); - } - - m_LastThrownObjectHandle = h; -} - // // Create a duplicate handle of the current throwable and set the last thrown object to that. This ensures that the // last thrown object and the current throwable have handles that are in the same app domain. @@ -6342,30 +6287,6 @@ NOINLINE void Thread::OnIncrementCountOverflow(UINT32 *threadLocalCount, UINT64 InterlockedExchangeAdd64((LONGLONG *)overflowCount, (LONGLONG)UINT32_MAX + 1); } -UINT64 Thread::GetTotalCount(SIZE_T threadLocalCountOffset, UINT64 *overflowCount) -{ - CONTRACTL { - NOTHROW; - GC_TRIGGERS; - } - CONTRACTL_END; - - _ASSERTE(overflowCount != nullptr); - - // enumerate all threads, summing their local counts. - ThreadStoreLockHolder tsl; - - UINT64 total = GetOverflowCount(overflowCount); - - Thread *pThread = NULL; - while ((pThread = ThreadStore::GetAllThreadList(pThread, 0, 0)) != NULL) - { - total += *GetThreadLocalCountRef(pThread, threadLocalCountOffset); - } - - return total; -} - #if defined(FEATURE_MULTITHREADING) || defined(_DEBUG) DeadlockAwareLock::DeadlockAwareLock(const char *description) : m_pHoldingThread(NULL) diff --git a/src/coreclr/vm/threads.h b/src/coreclr/vm/threads.h index 80e8d5ff092898..7edf9c2a6a737c 100644 --- a/src/coreclr/vm/threads.h +++ b/src/coreclr/vm/threads.h @@ -1,11 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// // Currently represents a logical and physical CLR thread. Later, these concepts will be separated. -// - // // #SuspendingTheRuntime // @@ -103,7 +99,6 @@ // 'cooperates' to ensure that GCs can happen in a timely fashion. // // If you need to switch the GC mode of the current thread, look for the GCX_COOP() and GCX_PREEMP() macros. -// #ifndef __threads_h__ #define __threads_h__ @@ -2763,8 +2758,6 @@ class Thread void ClearThreadCurrNotification(); private: - void SetLastThrownObjectHandle(OBJECTHANDLE h); - ThreadExceptionState m_ExceptionState; private: @@ -2819,7 +2812,6 @@ class Thread private: #ifndef DACCESS_COMPILE -private: static UINT32 *GetThreadLocalCountRef(Thread *pThread, SIZE_T threadLocalCountOffset) { WRAPPER_NO_CONTRACT; @@ -2864,8 +2856,6 @@ class Thread } return InterlockedCompareExchange64((LONGLONG *)overflowCount, 0, 0); // prevent tearing } - - static UINT64 GetTotalCount(SIZE_T threadLocalCountOffset, UINT64 *overflowCount); #endif // !DACCESS_COMPILE public: @@ -3252,9 +3242,6 @@ class Thread #endif public: - // Is the current thread currently executing within a constrained execution region? - static BOOL IsExecutingWithinCer(); - #ifdef _DEBUG // when the thread is doing a stressing GC, some Crst violation could be ignored, by a non-elegant solution. private: diff --git a/src/coreclr/vm/threadsuspend.cpp b/src/coreclr/vm/threadsuspend.cpp index 5a9c0b4ff29deb..a61ed4828c01fe 100644 --- a/src/coreclr/vm/threadsuspend.cpp +++ b/src/coreclr/vm/threadsuspend.cpp @@ -1,13 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// // threadsuspend.CPP // // This file contains the implementation of thread suspension. The implementation of thread suspension // used to be spread through multiple places. That is why, many methods still live in their own homes // (class Thread, class ThreadStore, etc.). They should be eventually refactored into class ThreadSuspend. -// #include "common.h" #include "CLREventBase.h" @@ -815,51 +813,6 @@ StackWalkAction TAStackCrawlCallBack(CrawlFrame* pCf, void* data) return action; } -// Is the current thread currently executing within a constrained execution region? -BOOL Thread::IsExecutingWithinCer() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (!g_fEEStarted) - return FALSE; - - Thread *pThread = GetThread(); - StackCrawlContext sContext = { pThread, - StackCrawlContext::SCC_CheckWithinCer, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE}; - - pThread->StackWalkFrames(TAStackCrawlCallBack, &sContext); - -#ifdef STRESS_LOG - if (sContext.fWithinCer && StressLog::StressLogOn(~0u, 0)) - { - // If stress log is on, write info to stress log - StackCrawlContext sContext1 = { pThread, - StackCrawlContext::SCC_CheckWithinCer, - FALSE, - FALSE, - FALSE, - FALSE, - TRUE, - FALSE}; - - pThread->StackWalkFrames(TAStackCrawlCallBack, &sContext1); - } -#endif - - return sContext.fWithinCer; -} - #if defined(TARGET_AMD64) && defined(FEATURE_HIJACK) BOOL Thread::IsSafeToInjectThreadAbort(PTR_CONTEXT pContextToCheck) { diff --git a/src/coreclr/vm/tieredcompilation.h b/src/coreclr/vm/tieredcompilation.h index 09dacde317d20b..6dfdbc80eeebbe 100644 --- a/src/coreclr/vm/tieredcompilation.h +++ b/src/coreclr/vm/tieredcompilation.h @@ -1,9 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// =========================================================================== -// File: TieredCompilation.h -// -// =========================================================================== // Exceptions (OOM) // - On foreground threads, exceptions are propagated unless they can be handled without any compromise @@ -83,7 +79,6 @@ class TieredCompilationManager void ActivateCodeVersion(NativeCodeVersion nativeCodeVersion); public: HRESULT DeoptimizeMethod(Module* pModule, mdMethodDef methodDef); - HRESULT IsMethodDeoptimized(Module *pModule, mdMethodDef methodDef, BOOL *pResult); #ifndef DACCESS_COMPILE public: diff --git a/src/coreclr/vm/util.cpp b/src/coreclr/vm/util.cpp index 2ebf1210d4f086..725346ebab868e 100644 --- a/src/coreclr/vm/util.cpp +++ b/src/coreclr/vm/util.cpp @@ -1,10 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// =========================================================================== -// File: UTIL.CPP -// =========================================================================== - #include "common.h" #include "excep.h" #include "corhost.h" @@ -1524,23 +1520,6 @@ void DACNotify::DoModuleUnloadNotification(Module *ModulePtr) } } -void DACNotify::DoExceptionNotification(Thread* ThreadPtr) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_PREEMPTIVE; - } - CONTRACTL_END; - - if ((g_dacNotificationFlags & CLRDATA_NOTIFY_ON_EXCEPTION) != 0) - { - TADDR Args[2] = { EXCEPTION_NOTIFICATION, (TADDR) ThreadPtr}; - DACNotifyExceptionHelper(Args, 2); - } -} - void DACNotify::DoGCNotification(const GcEvtArgs& args) { CONTRACTL diff --git a/src/coreclr/vm/util.hpp b/src/coreclr/vm/util.hpp index c3756afa02b880..eba4c76a37e0f4 100644 --- a/src/coreclr/vm/util.hpp +++ b/src/coreclr/vm/util.hpp @@ -1,12 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// -// util.hpp -// +// util.hpp // // Miscellaneous useful functions -// #ifndef _H_UTIL #define _H_UTIL @@ -712,7 +709,6 @@ class DACNotify static void DoJITNotification(MethodDesc *MethodDescPtr, TADDR NativeCodeLocation); static void DoModuleLoadNotification(Module *Module); static void DoModuleUnloadNotification(Module *Module); - static void DoExceptionNotification(class Thread* ThreadPtr); static void DoGCNotification(const GcEvtArgs& evtargs); static void DoExceptionCatcherEnterNotification(MethodDesc *MethodDescPtr, DWORD nativeOffset); diff --git a/src/coreclr/vm/virtualcallstub.cpp b/src/coreclr/vm/virtualcallstub.cpp index c667d450c0c437..940c3440f455c2 100644 --- a/src/coreclr/vm/virtualcallstub.cpp +++ b/src/coreclr/vm/virtualcallstub.cpp @@ -4242,42 +4242,6 @@ BOOL VirtualCallStubManagerManager::DoTraceStub( return pMgr->DoTraceStub(stubStartAddress, trace); } -#ifndef DACCESS_COMPILE -#ifdef FEATURE_VIRTUAL_STUB_DISPATCH -///////////////////////////////////////////////////////////////////////////////////////////// -MethodDesc *VirtualCallStubManagerManager::Entry2MethodDesc( - PCODE stubStartAddress, - MethodTable *pMT) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - } - CONTRACTL_END - - if (pMT == NULL) - return NULL; - - StubCodeBlockKind sk = STUB_CODE_BLOCK_UNKNOWN; - - // Find the owning manager. - VirtualCallStubManager *pMgr = VirtualCallStubManager::FindStubManager(stubStartAddress, &sk); - if (pMgr == NULL) - return NULL; - - // Do the full resolve - DispatchToken token(VirtualCallStubManager::GetTokenFromStubQuick(pMgr, stubStartAddress, sk)); - - PCODE target = (PCODE)NULL; - // TODO: passing NULL as protectedObj here can lead to incorrect behavior for IDynamicInterfaceCastable objects - VirtualCallStubManager::Resolver(pMT, token, NULL, &target, TRUE /* throwOnConflict */); - - return NonVirtualEntry2MethodDesc(target); -} -#endif // FEATURE_VIRTUAL_STUB_DISPATCH -#endif - #ifdef DACCESS_COMPILE void VirtualCallStubManagerManager::DoEnumMemoryRegions(CLRDataEnumMemoryFlags flags) { diff --git a/src/coreclr/vm/virtualcallstub.h b/src/coreclr/vm/virtualcallstub.h index 9568a3544ff739..5363a04ce87400 100644 --- a/src/coreclr/vm/virtualcallstub.h +++ b/src/coreclr/vm/virtualcallstub.h @@ -1,11 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// +// ============================================================================ // File: VirtualCallStub.h // // See code:VirtualCallStubManager for details -// // ============================================================================ #ifndef _VIRTUAL_CALL_STUB_H @@ -779,8 +778,6 @@ class VirtualCallStubManagerManager : public StubManager virtual BOOL DoTraceStub(PCODE stubStartAddress, TraceDestination *trace); - static MethodDesc *Entry2MethodDesc(PCODE stubStartAddress, MethodTable *pMT); - #ifdef DACCESS_COMPILE virtual void DoEnumMemoryRegions(CLRDataEnumMemoryFlags flags); virtual LPCWSTR GetStubManagerName(PCODE addr) diff --git a/src/coreclr/vm/zapsig.cpp b/src/coreclr/vm/zapsig.cpp index bd5ae07cfea41e..163b0f20472246 100644 --- a/src/coreclr/vm/zapsig.cpp +++ b/src/coreclr/vm/zapsig.cpp @@ -1,17 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + // =========================================================================== // File: zapsig.cpp // -// // This module contains helper functions used to encode and manipulate // signatures for scenarios where runtime-specific signatures // including specific generic instantiations are persisted, // like Ready-To-Run decoding, and Multi-core JIT recording/playback -// // =========================================================================== - #include "common.h" #include "zapsig.h" #include "typedesc.h" @@ -538,25 +536,6 @@ BOOL ZapSig::GetSignatureForTypeHandle(TypeHandle handle, return TRUE; } -/*static*/ -BOOL ZapSig::CompareTypeHandleFieldToTypeHandle(TypeHandle *pTypeHnd, TypeHandle typeHnd2) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - PRECONDITION(CheckPointer(pTypeHnd)); - PRECONDITION(CheckPointer(typeHnd2)); - } - CONTRACTL_END - - // Ensure that the compiler won't fetch the value twice - SIZE_T fixup = VolatileLoadWithoutBarrier((SIZE_T *)pTypeHnd); - - return TypeHandle::FromTAddr(fixup) == typeHnd2; -} - #ifndef DACCESS_COMPILE ModuleBase *ZapSig::DecodeModuleFromIndex(Module *fromModule, DWORD index) diff --git a/src/coreclr/vm/zapsig.h b/src/coreclr/vm/zapsig.h index 31b0f4fab63dd7..9b674f64f4d8f5 100644 --- a/src/coreclr/vm/zapsig.h +++ b/src/coreclr/vm/zapsig.h @@ -2,17 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // --------------------------------------------------------------------------- -// zapsig.h -// --------------------------------------------------------------------------- -// // This module contains helper functions used to encode and manipulate // signatures for scenarios where runtime-specific signatures // including specific generic instantiations are persisted, // like Ready-To-Run decoding, and Multi-core JIT recording/playback -// // --------------------------------------------------------------------------- - #ifndef ZAPSIG_H #define ZAPSIG_H @@ -108,8 +103,6 @@ class ZapSig BOOL GetSignatureForTypeHandle(TypeHandle typeHandle, SigBuilder * pSigBuilder); - static BOOL CompareTypeHandleFieldToTypeHandle(TypeHandle *pTypeHnd, TypeHandle typeHnd2); - private: BOOL GetSignatureForTypeDesc(TypeDesc * desc, SigBuilder * pSigBuilder);