Skip to content

Commit 959c2a7

Browse files
rcj1Rachel Jarvimax-charlamb
authored
GetAppDomainList cDAC implementation (#117515)
* adding GetAppDomainList cDAC API * cleanup * rebasing onto GetAssemblyModuleList Co-authored-by: Max Charlamb <[email protected]> --------- Co-authored-by: Rachel Jarvi <[email protected]> Co-authored-by: Max Charlamb <[email protected]>
1 parent e768358 commit 959c2a7

File tree

1 file changed

+39
-1
lines changed
  • src/native/managed/cdac/mscordaccore_universal/Legacy

1 file changed

+39
-1
lines changed

src/native/managed/cdac/mscordaccore_universal/Legacy/SOSDacImpl.cs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,45 @@ int ISOSDacInterface.GetAppDomainConfigFile(ClrDataAddress appDomain, int count,
113113
int ISOSDacInterface.GetAppDomainData(ClrDataAddress addr, void* data)
114114
=> _legacyImpl is not null ? _legacyImpl.GetAppDomainData(addr, data) : HResults.E_NOTIMPL;
115115
int ISOSDacInterface.GetAppDomainList(uint count, [In, MarshalUsing(CountElementName = "count"), Out] ClrDataAddress[] values, uint* pNeeded)
116-
=> _legacyImpl is not null ? _legacyImpl.GetAppDomainList(count, values, pNeeded) : HResults.E_NOTIMPL;
116+
{
117+
int hr = HResults.S_OK;
118+
try
119+
{
120+
uint i = 0;
121+
TargetPointer appDomainPointer = _target.ReadGlobalPointer(Constants.Globals.AppDomain);
122+
TargetPointer appDomain = _target.ReadPointer(appDomainPointer);
123+
124+
if (appDomain != TargetPointer.Null && values.Length > 0)
125+
{
126+
values[0] = appDomain.ToClrDataAddress(_target);
127+
i = 1;
128+
}
129+
130+
if (pNeeded is not null)
131+
{
132+
*pNeeded = i;
133+
}
134+
}
135+
catch (System.Exception ex)
136+
{
137+
hr = ex.HResult;
138+
}
139+
#if DEBUG
140+
if (_legacyImpl is not null)
141+
{
142+
ClrDataAddress[] valuesLocal = new ClrDataAddress[count];
143+
uint neededLocal;
144+
int hrLocal = _legacyImpl.GetAppDomainList(count, valuesLocal, &neededLocal);
145+
Debug.Assert(hrLocal == hr, $"cDAC: {hr:x}, DAC: {hrLocal:x}");
146+
Debug.Assert(pNeeded == null || *pNeeded == neededLocal);
147+
if (values is not null && values.Length > 0 && valuesLocal.Length > 0)
148+
{
149+
Debug.Assert(values[0] == valuesLocal[0], $"cDAC: {values[0]:x}, DAC: {valuesLocal[0]:x}");
150+
}
151+
}
152+
#endif
153+
return hr;
154+
}
117155
int ISOSDacInterface.GetAppDomainName(ClrDataAddress addr, uint count, char* name, uint* pNeeded)
118156
=> _legacyImpl is not null ? _legacyImpl.GetAppDomainName(addr, count, name, pNeeded) : HResults.E_NOTIMPL;
119157
int ISOSDacInterface.GetAppDomainStoreData(void* data)

0 commit comments

Comments
 (0)