Skip to content

Commit d94ca57

Browse files
Remove usage of FEATURE_CORESYSTEM (#63850)
* Remove usage of FEATURE_CORESYSTEM from coreclr.
1 parent 26648d1 commit d94ca57

37 files changed

+72
-1326
lines changed

src/coreclr/clrdefinitions.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ endif(CLR_CMAKE_TARGET_WIN32)
9292

9393
add_definitions(-DFEATURE_BASICFREEZE)
9494
add_definitions(-DFEATURE_CORECLR)
95-
add_definitions(-DFEATURE_CORESYSTEM)
9695
if(FEATURE_DBGIPC)
9796
add_definitions(-DFEATURE_DBGIPC_TRANSPORT_DI)
9897
add_definitions(-DFEATURE_DBGIPC_TRANSPORT_VM)

src/coreclr/debug/daccess/daccess.cpp

Lines changed: 2 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -6542,61 +6542,6 @@ bool ClrDataAccess::GetILImageInfoFromNgenPEFile(PEAssembly *pPEAssembly,
65426542
return true;
65436543
}
65446544

6545-
#if defined(FEATURE_CORESYSTEM)
6546-
/* static */
6547-
// We extract "ni.dll from the NGEN image name to obtain the IL image name.
6548-
// In the end we add given ilExtension.
6549-
// This dependecy is based on Apollo installer behavior.
6550-
bool ClrDataAccess::GetILImageNameFromNgenImage( LPCWSTR ilExtension,
6551-
_Out_writes_(cchFilePath) LPWSTR wszFilePath,
6552-
const DWORD cchFilePath)
6553-
{
6554-
if (wszFilePath == NULL || cchFilePath == 0)
6555-
{
6556-
return false;
6557-
}
6558-
6559-
_wcslwr_s(wszFilePath, cchFilePath);
6560-
// Find the "ni.dll" extension.
6561-
// If none exists use NGEN image name.
6562-
//
6563-
const WCHAR* ngenExtension = W("ni.dll");
6564-
6565-
if (wcslen(ilExtension) <= wcslen(ngenExtension))
6566-
{
6567-
LPWSTR wszFileExtension = wcsstr(wszFilePath, ngenExtension);
6568-
if (wszFileExtension != 0)
6569-
{
6570-
LPWSTR wszNextFileExtension = wszFileExtension;
6571-
// Find last occurrence
6572-
do
6573-
{
6574-
wszFileExtension = wszNextFileExtension;
6575-
wszNextFileExtension = wcsstr(wszFileExtension + 1, ngenExtension);
6576-
} while (wszNextFileExtension != 0);
6577-
6578-
// Overwrite ni.dll with ilExtension
6579-
if (!memcpy_s(wszFileExtension,
6580-
wcslen(ngenExtension)*sizeof(WCHAR),
6581-
ilExtension,
6582-
wcslen(ilExtension)*sizeof(WCHAR)))
6583-
{
6584-
wszFileExtension[wcslen(ilExtension)] = '\0';
6585-
return true;
6586-
}
6587-
}
6588-
}
6589-
6590-
//Use ngen filename if there is no ".ni"
6591-
if (wcsstr(wszFilePath, W(".ni")) == 0)
6592-
{
6593-
return true;
6594-
}
6595-
6596-
return false;
6597-
}
6598-
#endif // FEATURE_CORESYSTEM
6599-
66006545
void *
66016546
ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly,
66026547
bool* isAlternate)
@@ -6705,7 +6650,6 @@ ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly,
67056650
goto ErrExit;
67066651
}
67076652

6708-
#if defined(FEATURE_CORESYSTEM)
67096653
const WCHAR* ilExtension = W("dll");
67106654
WCHAR ngenImageName[MAX_LONGPATH] = {0};
67116655
if (wcscpy_s(ngenImageName, ARRAY_SIZE(ngenImageName), uniPath) != 0)
@@ -6716,12 +6660,6 @@ ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly,
67166660
{
67176661
goto ErrExit;
67186662
}
6719-
// Transform NGEN image name into IL Image name
6720-
if (!GetILImageNameFromNgenImage(ilExtension, uniPath, ARRAY_SIZE(uniPath)))
6721-
{
6722-
goto ErrExit;
6723-
}
6724-
#endif//FEATURE_CORESYSTEM
67256663

67266664
// RVA size in ngen image and IL image is the same. Because the only
67276665
// different is in RVA. That is 4 bytes column fixed.
@@ -6943,11 +6881,6 @@ bool ClrDataAccess::TargetConsistencyAssertsEnabled()
69436881
return m_fEnableTargetConsistencyAsserts;
69446882
}
69456883

6946-
#ifdef FEATURE_CORESYSTEM
6947-
#define ctime_s _ctime32_s
6948-
#define time_t __time32_t
6949-
#endif
6950-
69516884
//
69526885
// VerifyDlls - Validate that the mscorwks in the target matches this version of mscordacwks
69536886
// Only done on Windows and Mac builds at the moment.
@@ -7503,34 +7436,8 @@ BOOL OutOfProcessExceptionEventGetProcessIdAndThreadId(HANDLE hProcess, HANDLE h
75037436
*pPId = (DWORD)(SIZE_T)hProcess;
75047437
*pThreadId = (DWORD)(SIZE_T)hThread;
75057438
#else
7506-
#if !defined(FEATURE_CORESYSTEM)
7507-
HMODULE hKernel32 = WszGetModuleHandle(W("kernel32.dll"));
7508-
#else
7509-
HMODULE hKernel32 = WszGetModuleHandle(W("api-ms-win-core-processthreads-l1-1-1.dll"));
7510-
#endif
7511-
if (hKernel32 == NULL)
7512-
{
7513-
return FALSE;
7514-
}
7515-
7516-
typedef WINBASEAPI DWORD (WINAPI GET_PROCESSID_OF_THREAD)(HANDLE);
7517-
GET_PROCESSID_OF_THREAD * pGetProcessIdOfThread;
7518-
7519-
typedef WINBASEAPI DWORD (WINAPI GET_THREADID)(HANDLE);
7520-
GET_THREADID * pGetThreadId;
7521-
7522-
pGetProcessIdOfThread = (GET_PROCESSID_OF_THREAD *)GetProcAddress(hKernel32, "GetProcessIdOfThread");
7523-
pGetThreadId = (GET_THREADID *)GetProcAddress(hKernel32, "GetThreadId");
7524-
7525-
// OOP callbacks are used on Win7 or later. We should have having below two APIs available.
7526-
_ASSERTE((pGetProcessIdOfThread != NULL) && (pGetThreadId != NULL));
7527-
if ((pGetProcessIdOfThread == NULL) || (pGetThreadId == NULL))
7528-
{
7529-
return FALSE;
7530-
}
7531-
7532-
*pPId = (*pGetProcessIdOfThread)(hThread);
7533-
*pThreadId = (*pGetThreadId)(hThread);
7439+
*pPId = GetProcessIdOfThread(hThread);
7440+
*pThreadId = GetThreadId(hThread);
75347441
#endif // TARGET_UNIX
75357442
return TRUE;
75367443
}

src/coreclr/debug/daccess/dacimpl.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@
1414
#define __DACIMPL_H__
1515

1616
#include "gcinterface.dac.h"
17-
18-
#if defined(TARGET_ARM) || defined(FEATURE_CORESYSTEM) // @ARMTODO: STL breaks the build with current VC headers
1917
//---------------------------------------------------------------------------------------
2018
// Setting DAC_HASHTABLE tells the DAC to use the hand rolled hashtable for
2119
// storing code:DAC_INSTANCE . Otherwise, the DAC uses the STL unordered_map to.
2220

2321
#define DAC_HASHTABLE
24-
#endif // TARGET_ARM|| FEATURE_CORESYSTEM
2522

2623
#ifndef DAC_HASHTABLE
2724
#pragma push_macro("return")
@@ -1520,11 +1517,6 @@ class ClrDataAccess
15201517
DWORD &dwSize,
15211518
_Out_writes_(cchPath) LPWSTR wszPath,
15221519
const DWORD cchPath);
1523-
#if defined(FEATURE_CORESYSTEM)
1524-
static bool GetILImageNameFromNgenImage(LPCWSTR ilExtension,
1525-
_Out_writes_(cchFilePath) LPWSTR wszFilePath,
1526-
const DWORD cchFilePath);
1527-
#endif // FEATURE_CORESYSTEM
15281520
};
15291521

15301522
extern ClrDataAccess* g_dacImpl;

src/coreclr/debug/di/cordb.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,6 @@
8484
//*****************************************************************************
8585
STDAPI CreateCordbObject(int iDebuggerVersion, IUnknown ** ppCordb)
8686
{
87-
#if !defined(FEATURE_DBGIPC_TRANSPORT_DI) && !defined(FEATURE_CORESYSTEM)
88-
// This API should not be called for Windows CoreCLR unless we are doing interop-debugging
89-
// (which is only supported internally). Use code:CoreCLRCreateCordbObject instead.
90-
if (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_DbgEnableMixedModeDebugging) == 0)
91-
{
92-
_ASSERTE(!"Deprecated entry point CreateCordbObject() is called on Windows CoreCLR\n");
93-
return E_NOTIMPL;
94-
}
95-
#endif // !defined(FEATURE_DBGIPC_TRANSPORT_DI) && !defined(FEATURE_CORESYSTEM)
96-
9787
if (ppCordb == NULL)
9888
{
9989
return E_INVALIDARG;

src/coreclr/debug/di/module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5169,8 +5169,8 @@ HRESULT CordbNativeCode::GetReturnValueLiveOffsetImpl(Instantiation *currentInst
51695169

51705170
int skipBytes = 0;
51715171

5172-
#if defined(TARGET_X86) && defined(FEATURE_CORESYSTEM)
5173-
// Skip nop sleds on x86 coresystem. The JIT adds these instructions as a security measure,
5172+
#if defined(PSEUDORANDOM_NOP_INSERTION)
5173+
// Skip nop sleds the JIT adds. These instructions as a security measure,
51745174
// and incorrectly reports to us the wrong offset of the call instruction.
51755175
const BYTE nop_opcode = 0x90;
51765176
while (fetched && nativeBuffer[0] == nop_opcode)

src/coreclr/debug/di/nativepipeline.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -146,28 +146,6 @@ class INativeEventPipeline
146146

147147
virtual BOOL TerminateProcess(UINT32 exitCode) = 0;
148148

149-
//
150-
// Resume any suspended threads in the currend process.
151-
// This decreases the suspend count of each thread by at most 1.
152-
// Call multiple times until it returns S_FALSE if you want to really ensure
153-
// all threads are running.
154-
//
155-
// Notes:
156-
// On Windows the OS may suspend threads when continuing a 2nd-chance exception.
157-
// Call this to get them resumed again. On other platforms this
158-
// will typically be a no-op, so I provide a default implementation to avoid
159-
// everyone having to override this.
160-
//
161-
// Return Value:
162-
// S_OK if at least one thread was resumed from a suspended state
163-
// S_FALSE if nothing was done
164-
// An error code indicating why we were not able to attempt this
165-
166-
virtual HRESULT EnsureThreadsRunning()
167-
{
168-
return S_FALSE;
169-
}
170-
171149
#ifdef TARGET_UNIX
172150
// Used by debugger side (RS) to cleanup the target (LS) named pipes
173151
// and semaphores when the debugger detects the debuggee process exited.

src/coreclr/debug/di/process.cpp

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,6 @@ IMDInternalImport * CordbProcess::LookupMetaDataFromDebugger(
414414

415415
WCHAR *mutableFilePath = (WCHAR *)filePath;
416416

417-
#if defined(FEATURE_CORESYSTEM)
418417
size_t pathLen = wcslen(mutableFilePath);
419418

420419
const WCHAR *nidll = W(".ni.dll");
@@ -429,7 +428,6 @@ IMDInternalImport * CordbProcess::LookupMetaDataFromDebugger(
429428
{
430429
wcscpy_s(mutableFilePath+pathLen-dllLen, dllLen, W(".exe"));
431430
}
432-
#endif//FEATURE_CORESYSTEM
433431

434432
ALLOW_DATATARGET_MISSING_MEMORY(
435433
pMDII = LookupMetaDataFromDebuggerForSingleFile(pModule, mutableFilePath, dwImageTimeStamp, dwImageSize);
@@ -7626,27 +7624,7 @@ HRESULT CordbProcess::GetRuntimeOffsets()
76267624

76277625

76287626
{
7629-
#if !defined FEATURE_CORESYSTEM
7630-
// kernel32!OpenThread does not exist on all platforms (missing on Win98).
7631-
// So we need to delay load it.
7632-
typedef HANDLE (WINAPI *FPOPENTHREAD)(DWORD dwDesiredAccess,
7633-
BOOL bInheritHandle,
7634-
DWORD dwThreadId);
7635-
7636-
7637-
7638-
HMODULE mod = WszGetModuleHandle(W("kernel32.dll"));
7639-
7640-
_ASSERTE(mod != NULL); // can't fail since Kernel32.dll is already loaded.
7641-
7642-
const FPOPENTHREAD pfnOpenThread = (FPOPENTHREAD)GetProcAddress(mod, "OpenThread");
7643-
7644-
if (pfnOpenThread != NULL)
7645-
{
7646-
m_hHelperThread = pfnOpenThread(SYNCHRONIZE, FALSE, dwHelperTid);
7647-
CONSISTENCY_CHECK_MSGF(m_hHelperThread != NULL, ("Failed to get helper-thread handle. tid=0x%x\n", dwHelperTid));
7648-
}
7649-
#elif TARGET_UNIX
7627+
#if TARGET_UNIX
76507628
m_hHelperThread = NULL; //RS is supposed to be able to live without a helper thread handle.
76517629
#else
76527630
m_hHelperThread = OpenThread(SYNCHRONIZE, FALSE, dwHelperTid);
@@ -7673,8 +7651,6 @@ HRESULT CordbProcess::GetRuntimeOffsets()
76737651
m_runtimeOffsets.m_excepNotForRuntimeBPAddr));
76747652
LOG((LF_CORDB, LL_INFO10000, " m_notifyRSOfSyncCompleteBPAddr= 0x%p\n",
76757653
m_runtimeOffsets.m_notifyRSOfSyncCompleteBPAddr));
7676-
LOG((LF_CORDB, LL_INFO10000, " m_raiseException= 0x%p\n",
7677-
m_runtimeOffsets.m_raiseExceptionAddr));
76787654
LOG((LF_CORDB, LL_INFO10000, " m_debuggerWordTLSIndex= 0x%08x\n",
76797655
m_runtimeOffsets.m_debuggerWordTLSIndex));
76807656
#endif // FEATURE_INTEROP_DEBUGGING
@@ -9819,27 +9795,22 @@ HRESULT CordbProcess::EnsureClrInstanceIdSet()
98199795
// If we didn't expect a specific CLR, then attempt to attach to any.
98209796
if (m_clrInstanceId == 0)
98219797
{
9822-
9823-
#ifdef FEATURE_CORESYSTEM
9798+
// The only case in which we were allowed to request the "default" CLR instance
9799+
// ID is when we're running in V2 mode. In V3, the client is required to pass
9800+
// a non-zero value to OpenVirtualProcess. Since V2 is no longer supported we
9801+
// no longer attempt to find it.
98249802
if(m_cordb->GetTargetCLR() != 0)
98259803
{
98269804
m_clrInstanceId = PTR_TO_CORDB_ADDRESS(m_cordb->GetTargetCLR());
98279805
return S_OK;
98289806
}
9829-
#endif
98309807

9831-
// The only case in which we're allowed to request the "default" CLR instance
9832-
// ID is when we're running in V2 mode. In V3, the client is required to pass
9833-
// a non-zero value to OpenVirtualProcess.
9808+
// In V3, the client is required to pass a non-zero value to OpenVirtualProcess.
9809+
// In V2 mode we should be setting target CLR up front but return an error
9810+
// if we haven't.
98349811
_ASSERTE(m_pShim != NULL);
9812+
return E_UNEXPECTED;
98359813

9836-
HRESULT hr = m_pShim->FindLoadedCLR(&m_clrInstanceId);
9837-
if (FAILED(hr))
9838-
{
9839-
// Couldn't find a loaded clr - no CLR instance ID yet
9840-
_ASSERTE(m_clrInstanceId == 0);
9841-
return hr;
9842-
}
98439814
}
98449815

98459816
// We've (now) got a valid CLR instance id
@@ -14910,26 +14881,6 @@ HRESULT CordbProcess::IsReadyForDetach()
1491014881
pAppDomain = m_appDomains.FindNext(&foundAppDomain);
1491114882
}
1491214883

14913-
// If we're using the shim, give a chance to early-out if the OS doesn't support detach
14914-
// so that the user can continue to debug in that case.
14915-
// Ideally we'd just rely on the failure from DebugActiveProcessStop, but by then it's too late
14916-
// to recover. This function is our only chance to distinguish between graceful detach failures
14917-
// and hard detach failures (after which the process object is neutered).
14918-
if (m_pShim != NULL)
14919-
{
14920-
#if !defined(FEATURE_CORESYSTEM) // CORESYSTEM TODO
14921-
HModuleHolder hKernel32;
14922-
hKernel32 = WszLoadLibrary(W("kernel32"));
14923-
if (hKernel32 == NULL)
14924-
return HRESULT_FROM_GetLastError();
14925-
typedef BOOL (*DebugActiveProcessStopSig) (DWORD);
14926-
DebugActiveProcessStopSig pDebugActiveProcessStop =
14927-
reinterpret_cast<DebugActiveProcessStopSig>(GetProcAddress(hKernel32, "DebugActiveProcessStop"));
14928-
if (pDebugActiveProcessStop == NULL)
14929-
return COR_E_PLATFORMNOTSUPPORTED;
14930-
#endif
14931-
}
14932-
1493314884
return S_OK;
1493414885
}
1493514886

0 commit comments

Comments
 (0)