summaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
authorDavid Wrighton <davidwr@microsoft.com>2019-04-03 15:54:05 -0700
committerGitHub <noreply@github.com>2019-04-03 15:54:05 -0700
commitd3e39bc2f81e3dbf9e4b96347f62b49d8700336c (patch)
tree78b72499a0f38e9dbf6ae4d6d24c77779ac543dc /src/debug
parenta7dd6192530dec1d424c359233a1b92f559fa92a (diff)
downloadcoreclr-d3e39bc2f81e3dbf9e4b96347f62b49d8700336c.tar.gz
coreclr-d3e39bc2f81e3dbf9e4b96347f62b49d8700336c.tar.bz2
coreclr-d3e39bc2f81e3dbf9e4b96347f62b49d8700336c.zip
Remove ADID and ADIndex from CoreCLR (#23588)
- Remove concept of AppDomain from object api in VM - Various infrastructure around entering/leaving appdomains is removed - Add small implementation of GetAppDomain for use by DAC (to match existing behavior) - Simplify finalizer thread operations - Eliminate AppDomain::Terminate - Remove use of ADID from stresslog - Remove thread enter/leave tracking from AppDomain - Remove unused asm constants across all architectures - Re-order header inclusion order to put gcenv.h before handletable - Remove retail only sync block code involving appdomain index
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/daccess/daccess.cpp21
-rw-r--r--src/debug/daccess/dacdbiimpl.cpp2
-rw-r--r--src/debug/daccess/request.cpp9
-rw-r--r--src/debug/daccess/task.cpp15
-rw-r--r--src/debug/ee/dactable.cpp8
-rw-r--r--src/debug/ee/debugger.cpp52
-rw-r--r--src/debug/ee/debugger.h1
-rw-r--r--src/debug/ee/funceval.cpp27
-rw-r--r--src/debug/inc/dbgappdomain.h2
9 files changed, 36 insertions, 101 deletions
diff --git a/src/debug/daccess/daccess.cpp b/src/debug/daccess/daccess.cpp
index 237a9b67da..0d1dc56e03 100644
--- a/src/debug/daccess/daccess.cpp
+++ b/src/debug/daccess/daccess.cpp
@@ -3829,18 +3829,15 @@ ClrDataAccess::GetAppDomainByUniqueID(
EX_TRY
{
- AppDomainIterator iter(FALSE);
-
- status = E_INVALIDARG;
- while (iter.Next())
+ if (uniqueID != DefaultADID)
{
- if (iter.GetDomain()->GetId().m_dwId == uniqueID)
- {
- *appDomain = new (nothrow)
- ClrDataAppDomain(this, iter.GetDomain());
- status = *appDomain ? S_OK : E_OUTOFMEMORY;
- break;
- }
+ status = E_INVALIDARG;
+ }
+ else
+ {
+ *appDomain = new (nothrow)
+ ClrDataAppDomain(this, AppDomain::GetCurrentDomain());
+ status = *appDomain ? S_OK : E_OUTOFMEMORY;
}
}
EX_CATCH
@@ -8105,7 +8102,7 @@ bool DacHandleWalker::FetchMoreHandles(HANDLESCANPROC callback)
if (mask & 1)
{
dac_handle_table *pTable = hTable;
- PTR_AppDomain pDomain = SystemDomain::GetAppDomainAtIndex(ADIndex(pTable->uADIndex));
+ PTR_AppDomain pDomain = AppDomain::GetCurrentDomain();
param.AppDomain = TO_CDADDR(pDomain.GetAddr());
param.Type = handleType;
diff --git a/src/debug/daccess/dacdbiimpl.cpp b/src/debug/daccess/dacdbiimpl.cpp
index a68a50d51e..2941714a75 100644
--- a/src/debug/daccess/dacdbiimpl.cpp
+++ b/src/debug/daccess/dacdbiimpl.cpp
@@ -570,7 +570,7 @@ ULONG DacDbiInterfaceImpl::GetAppDomainId(VMPTR_AppDomain vmAppDomain)
else
{
AppDomain * pAppDomain = vmAppDomain.GetDacPtr();
- return pAppDomain->GetId().m_dwId;
+ return DefaultADID;
}
}
diff --git a/src/debug/daccess/request.cpp b/src/debug/daccess/request.cpp
index 167069ac39..2365fdf959 100644
--- a/src/debug/daccess/request.cpp
+++ b/src/debug/daccess/request.cpp
@@ -2320,7 +2320,7 @@ ClrDataAccess::GetAppDomainData(CLRDATA_ADDRESS addr, struct DacpAppDomainData *
offsetof(AppDomain, m_sDomainLocalBlock);
appdomainData->pDomainLocalModules = PTR_CDADDR(pAppDomain->m_sDomainLocalBlock.m_pModuleSlots);
- appdomainData->dwId = pAppDomain->GetId().m_dwId;
+ appdomainData->dwId = DefaultADID;
appdomainData->appDomainStage = (DacpAppDomainDataStage)pAppDomain->m_Stage.Load();
if (pAppDomain->IsActive())
{
@@ -3580,12 +3580,7 @@ ClrDataAccess::GetSyncBlockData(unsigned int SBNumber, struct DacpSyncBlockData
pSyncBlockData->MonitorHeld = pBlock->m_Monitor.GetMonitorHeldStateVolatile();
pSyncBlockData->Recursion = pBlock->m_Monitor.GetRecursionLevel();
pSyncBlockData->HoldingThread = HOST_CDADDR(pBlock->m_Monitor.GetHoldingThread());
-
- if (pBlock->GetAppDomainIndex().m_dwIndex)
- {
- pSyncBlockData->appDomainPtr = PTR_HOST_TO_TADDR(
- SystemDomain::TestGetAppDomainAtIndex(pBlock->GetAppDomainIndex()));
- }
+ pSyncBlockData->appDomainPtr = PTR_HOST_TO_TADDR(AppDomain::GetCurrentDomain());
// TODO: Microsoft, implement the wait list
pSyncBlockData->AdditionalThreadCount = 0;
diff --git a/src/debug/daccess/task.cpp b/src/debug/daccess/task.cpp
index d7d8ba5a84..6667c48c3e 100644
--- a/src/debug/daccess/task.cpp
+++ b/src/debug/daccess/task.cpp
@@ -854,19 +854,8 @@ ClrDataAppDomain::GetUniqueID(
DAC_ENTER_SUB(m_dac);
- EX_TRY
- {
- *id = m_appDomain->GetId().m_dwId;
- status = S_OK;
- }
- EX_CATCH
- {
- if (!DacExceptionFilter(GET_EXCEPTION(), m_dac, &status))
- {
- EX_RETHROW;
- }
- }
- EX_END_CATCH(SwallowAllExceptions)
+ *id = DefaultADID;
+ status = S_OK;
DAC_LEAVE();
return status;
diff --git a/src/debug/ee/dactable.cpp b/src/debug/ee/dactable.cpp
index dbe64827fa..2f60124906 100644
--- a/src/debug/ee/dactable.cpp
+++ b/src/debug/ee/dactable.cpp
@@ -13,10 +13,6 @@
#include "stdafx.h"
#include <daccess.h>
-// This header include will need to be rmeoved as part of GitHub#12170.
-// The only reason it's here now is that this file references the GC-private
-// variable g_HandleTableMap.
-#include "../../gc/objecthandle.h"
#include "../../vm/virtualcallstub.h"
#include "../../vm/win32threadpool.h"
#include "../../vm/hillclimbing.h"
@@ -26,6 +22,10 @@
#include "../../vm/gcenv.h"
#include "../../vm/ecall.h"
#include "../../vm/rcwwalker.h"
+// This header include will need to be rmeoved as part of GitHub#12170.
+// The only reason it's here now is that this file references the GC-private
+// variable g_HandleTableMap.
+#include "../../gc/objecthandle.h"
#ifdef DEBUGGING_SUPPORTED
diff --git a/src/debug/ee/debugger.cpp b/src/debug/ee/debugger.cpp
index cb083c3214..f2d2f06105 100644
--- a/src/debug/ee/debugger.cpp
+++ b/src/debug/ee/debugger.cpp
@@ -1411,22 +1411,6 @@ DebuggerEval::DebuggerEval(CONTEXT * pContext, DebuggerIPCE_FuncEvalInfo * pEval
// AppDomain ID which is safe to use after the AD is unloaded. It's only safe to
// use the DebuggerModule* after we've verified the ADID is still valid (i.e. by entering that domain).
m_debuggerModule = g_pDebugger->LookupOrCreateModule(pEvalInfo->vmDomainFile);
-
- if (m_debuggerModule == NULL)
- {
- // We have no associated code.
- _ASSERTE((m_evalType == DB_IPCE_FET_NEW_STRING) || (m_evalType == DB_IPCE_FET_NEW_ARRAY));
-
- // We'll just do the creation in whatever domain the thread is already in.
- // It's conceivable that we might want to allow the caller to specify a specific domain, but
- // ICorDebug provides the debugger with no was to specify the domain.
- m_appDomainId = m_thread->GetDomain()->GetId();
- }
- else
- {
- m_appDomainId = m_debuggerModule->GetAppDomain()->GetId();
- }
-
m_funcEvalKey = pEvalInfo->funcEvalKey;
m_argCount = pEvalInfo->argCount;
m_targetCodeAddr = NULL;
@@ -9357,8 +9341,8 @@ void Debugger::SendCreateAppDomainEvent(AppDomain * pRuntimeAppDomain)
return;
}
- STRESS_LOG2(LF_CORDB, LL_INFO10000, "D::SCADE: AppDomain creation:%#08x, %#08x\n",
- pRuntimeAppDomain, pRuntimeAppDomain->GetId().m_dwId);
+ STRESS_LOG1(LF_CORDB, LL_INFO10000, "D::SCADE: AppDomain creation:%#08x\n",
+ pRuntimeAppDomain);
@@ -9412,8 +9396,8 @@ void Debugger::SendExitAppDomainEvent(AppDomain* pRuntimeAppDomain)
LOG((LF_CORDB, LL_INFO100, "D::EAD: Exit AppDomain 0x%08x.\n",
pRuntimeAppDomain));
- STRESS_LOG3(LF_CORDB, LL_INFO10000, "D::EAD: AppDomain exit:%#08x, %#08x, %#08x\n",
- pRuntimeAppDomain, pRuntimeAppDomain->GetId().m_dwId, CORDebuggerAttached());
+ STRESS_LOG2(LF_CORDB, LL_INFO10000, "D::EAD: AppDomain exit:%#08x, %#08x\n",
+ pRuntimeAppDomain, CORDebuggerAttached());
Thread *thread = g_pEEInterface->GetThread();
// Prevent other Runtime threads from handling events.
@@ -10403,7 +10387,6 @@ void Debugger::FuncEvalComplete(Thread* pThread, DebuggerEval *pDE)
//
AppDomain *pDomain = pThread->GetDomain();
AppDomain *pResultDomain = ((pDE->m_debuggerModule == NULL) ? pDomain : pDE->m_debuggerModule->GetAppDomain());
- _ASSERTE( pResultDomain->GetId() == pDE->m_appDomainId );
// Send a func eval complete event to the Right Side.
DebuggerIPCEvent* ipce = m_pRCThread->GetIPCEventSendBuffer();
@@ -11099,9 +11082,7 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
if(fValid)
{
// Get the appdomain
- IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
- ADIndex appDomainIndex = ADIndex((DWORD)(SIZE_T)(mgr->GetHandleContext(objectHandle)));
- pAppDomain = SystemDomain::GetAppDomainAtIndex(appDomainIndex);
+ pAppDomain = AppDomain::GetCurrentDomain();
_ASSERTE(pAppDomain != NULL);
}
@@ -14745,12 +14726,11 @@ HRESULT Debugger::AddAppDomainToIPC(AppDomain *pAppDomain)
HRESULT hr = S_OK;
LPCWSTR szName = NULL;
- LOG((LF_CORDB, LL_INFO100, "D::AADTIPC: Executing AADTIPC for AppDomain 0x%08x (0x%x).\n",
- pAppDomain,
- pAppDomain->GetId().m_dwId));
+ LOG((LF_CORDB, LL_INFO100, "D::AADTIPC: Executing AADTIPC for AppDomain 0x%08x.\n",
+ pAppDomain));
- STRESS_LOG2(LF_CORDB, LL_INFO10000, "D::AADTIPC: AddAppDomainToIPC:%#08x, %#08x\n",
- pAppDomain, pAppDomain->GetId().m_dwId);
+ STRESS_LOG1(LF_CORDB, LL_INFO10000, "D::AADTIPC: AddAppDomainToIPC:%#08x\n",
+ pAppDomain);
@@ -14790,9 +14770,6 @@ HRESULT Debugger::AddAppDomainToIPC(AppDomain *pAppDomain)
goto LErrExit;
}
- // copy the ID
- pAppDomainInfo->m_id = pAppDomain->GetId().m_dwId;
-
// Now set the AppDomainName.
/*
@@ -14845,9 +14822,8 @@ HRESULT Debugger::RemoveAppDomainFromIPC (AppDomain *pAppDomain)
HRESULT hr = E_FAIL;
- LOG((LF_CORDB, LL_INFO100, "D::RADFIPC: Executing RADFIPC for AppDomain 0x%08x (0x%x).\n",
- pAppDomain,
- pAppDomain->GetId().m_dwId));
+ LOG((LF_CORDB, LL_INFO100, "D::RADFIPC: Executing RADFIPC for AppDomain 0x%08x.\n",
+ pAppDomain));
// if none of the slots are occupied, then simply return.
if (m_pAppDomainCB->m_iNumOfUsedSlots == 0)
@@ -14989,7 +14965,7 @@ HRESULT Debugger::IterateAppDomainsForPdbs()
while (pADInfo)
{
- STRESS_LOG3(LF_CORDB, LL_INFO100, "Iterating over domain %#08x AD:%#08x %ls\n", pADInfo->m_pAppDomain->GetId().m_dwId, pADInfo->m_pAppDomain, pADInfo->m_szAppDomainName);
+ STRESS_LOG2(LF_CORDB, LL_INFO100, "Iterating over domain AD:%#08x %ls\n", pADInfo->m_pAppDomain, pADInfo->m_szAppDomainName);
AppDomain::AssemblyIterator i;
i = pADInfo->m_pAppDomain->IterateAssembliesEx((AssemblyIterationFlags)(kIncludeLoaded | kIncludeLoading | kIncludeExecution));
@@ -15635,7 +15611,7 @@ HRESULT Debugger::SetReference(void *objectRefAddress,
OBJECTREF *dst = (OBJECTREF*)objectRefAddress;
OBJECTREF src = *((OBJECTREF*)&newReference);
- SetObjectReferenceUnchecked(dst, src);
+ SetObjectReference(dst, src);
}
else
{
@@ -15674,7 +15650,7 @@ HRESULT Debugger::SetValueClass(void *oldData, void *newData, DebuggerIPCE_Basic
return CORDBG_E_CLASS_NOT_LOADED;
// Update the value class.
- CopyValueClassUnchecked(oldData, newData, th.GetMethodTable());
+ CopyValueClass(oldData, newData, th.GetMethodTable());
// Free the buffer that is holding the new data. This is a buffer that was created in response to a GET_BUFFER
// message, so we release it with ReleaseRemoteBuffer.
diff --git a/src/debug/ee/debugger.h b/src/debug/ee/debugger.h
index 3d3118e85e..8386a227eb 100644
--- a/src/debug/ee/debugger.h
+++ b/src/debug/ee/debugger.h
@@ -3429,7 +3429,6 @@ public:
DebuggerIPCE_FuncEvalType m_evalType;
mdMethodDef m_methodToken;
mdTypeDef m_classToken;
- ADID m_appDomainId; // Safe even if AD unloaded
PTR_DebuggerModule m_debuggerModule; // Only valid if AD is still around
RSPTR_CORDBEVAL m_funcEvalKey;
bool m_successful; // Did the eval complete successfully
diff --git a/src/debug/ee/funceval.cpp b/src/debug/ee/funceval.cpp
index 0bcfa93dc8..2dbea0e487 100644
--- a/src/debug/ee/funceval.cpp
+++ b/src/debug/ee/funceval.cpp
@@ -980,7 +980,7 @@ static void GetFuncEvalArgValue(DebuggerEval *pDE,
if (size <= sizeof(ARG_SLOT))
{
// Its not ByRef, so we need to copy the value class onto the ARG_SLOT.
- CopyValueClassUnchecked(ArgSlotEndianessFixup(pArgument, sizeof(LPVOID)), pData, o1->GetMethodTable());
+ CopyValueClass(ArgSlotEndianessFixup(pArgument, sizeof(LPVOID)), pData, o1->GetMethodTable());
}
else
{
@@ -2774,16 +2774,14 @@ void UnpackFuncEvalResult(DebuggerEval *pDE,
// box the object
CopyValueClass(retObject->GetData(),
pRetBuff,
- RetValueType.GetMethodTable(),
- retObject->GetAppDomain());
+ RetValueType.GetMethodTable());
}
else
{
// box the primitive returned, retObject is a true nullable for nullabes, It will be Normalized later
CopyValueClass(retObject->GetData(),
pDE->m_result,
- RetValueType.GetMethodTable(),
- retObject->GetAppDomain());
+ RetValueType.GetMethodTable());
}
pDE->m_result[0] = ObjToArgSlot(retObject);
@@ -3434,8 +3432,6 @@ static void GCProtectArgsAndDoNormalFuncEval(DebuggerEval *pDE,
// invalid due to an AD unload.
// All normal func evals should have an AppDomain specified.
//
- _ASSERTE( pDE->m_appDomainId.m_dwId != 0 );
- ENTER_DOMAIN_ID( pDE->m_appDomainId );
// Wrap everything in a EX_TRY so we catch any exceptions that could be thrown.
// Note that we don't let any thrown exceptions cross the AppDomain boundary because we don't
@@ -3464,9 +3460,6 @@ static void GCProtectArgsAndDoNormalFuncEval(DebuggerEval *pDE,
// the funceval. If a ThreadAbort occurred other than for a funcEval abort, we'll re-throw it manually.
EX_END_CATCH(SwallowAllExceptions);
- // Restore context
- END_DOMAIN_TRANSITION;
-
protectValueClassFrame.Pop();
CleanUpTemporaryVariables(protectValueClassFrame.GetValueClassInfoList());
@@ -3490,14 +3483,6 @@ void FuncEvalHijackRealWorker(DebuggerEval *pDE, Thread* pThread, FuncEvalFrame*
return;
}
- // The method may be in a different AD than the thread.
- // The RS already verified that all of the arguments are in the same appdomain as the function
- // (because we can't verify it here).
- // Note that this is exception safe, so we are guarenteed to be in the correct AppDomain when
- // we leave this method.
- // Before this, we can't safely use the DebuggerModule* since the domain may have been unloaded.
- ENTER_DOMAIN_ID( pDE->m_appDomainId );
-
OBJECTREF newObj = NULL;
GCPROTECT_BEGIN(newObj);
@@ -3671,12 +3656,6 @@ void FuncEvalHijackRealWorker(DebuggerEval *pDE, Thread* pThread, FuncEvalFrame*
EX_END_CATCH(SwallowAllExceptions);
GCPROTECT_END();
-
- //
- // Restore context
- //
- END_DOMAIN_TRANSITION;
-
}
//
diff --git a/src/debug/inc/dbgappdomain.h b/src/debug/inc/dbgappdomain.h
index 91d024be70..14f7773c29 100644
--- a/src/debug/inc/dbgappdomain.h
+++ b/src/debug/inc/dbgappdomain.h
@@ -13,7 +13,7 @@ class AppDomain;
// All pointers are for the left side, and we do not own any of the memory
struct AppDomainInfo
{
- ULONG m_id; // unique identifier
+ DWORD m_id = 0; // UNUSED, only present to maintain the shape of this structure
int m_iNameLengthInBytes;
LPCWSTR m_szAppDomainName;
AppDomain *m_pAppDomain; // only used by LS