Skip to content

Commit 1ccc750

Browse files
author
Max Charlamb
committed
wip
1 parent b0c2d75 commit 1ccc750

File tree

5 files changed

+92
-0
lines changed

5 files changed

+92
-0
lines changed

src/coreclr/debug/runtimeinfo/datadescriptor.h

+14
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,22 @@ CDAC_TYPE_END(ProbeExtensionResult)
282282
CDAC_TYPE_BEGIN(AppDomain)
283283
CDAC_TYPE_INDETERMINATE(AppDomain)
284284
CDAC_TYPE_FIELD(AppDomain, /*pointer*/, RootAssembly, cdac_data<AppDomain>::RootAssembly)
285+
CDAC_TYPE_FIELD(AppDomain, /*DomainAssemblyList*/, DomainAssemblyList, cdac_data<AppDomain>::DomainAssemblyList)
285286
CDAC_TYPE_END(AppDomain)
286287

288+
CDAC_TYPE_BEGIN(ArrayListBase)
289+
CDAC_TYPE_INDETERMINATE(ArrayListBase)
290+
CDAC_TYPE_FIELD(ArrayListBase, /*uint32*/, Count, cdac_data<ArrayListBase>::Count)
291+
CDAC_TYPE_FIELD(ArrayListBase, /*pointer*/, FirstBlock, cdac_data<ArrayListBase>::FirstBlock)
292+
CDAC_TYPE_END(ArrayListBase)
293+
294+
CDAC_TYPE_BEGIN(ArrayListBlock)
295+
CDAC_TYPE_INDETERMINATE(ArrayListBlock)
296+
CDAC_TYPE_FIELD(ArrayListBlock, /*pointer*/, Next, cdac_data<ArrayListBlock>::Next)
297+
CDAC_TYPE_FIELD(ArrayListBlock, /*uint32*/, Size, cdac_data<ArrayListBlock>::Size)
298+
CDAC_TYPE_FIELD(ArrayListBlock, /*pointer*/, ArrayStart, cdac_data<ArrayListBlock>::ArrayStart)
299+
CDAC_TYPE_END(ArrayListBlock)
300+
287301
// RuntimeTypeSystem
288302

289303
CDAC_TYPE_BEGIN(MethodTable)

src/coreclr/inc/arraylist.h

+18
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class ArrayListBase
5353
(*PTR_DWORD(addr + offsetof(ArrayListBlock, m_blockSize)) * sizeof(void*));
5454
}
5555
#endif
56+
friend struct ::cdac_data<ArrayListBlock>;
5657
};
5758
typedef SPTR(ArrayListBlock) PTR_ArrayListBlock;
5859

@@ -263,6 +264,23 @@ class ArrayListBase
263264
return BlockIterator((ArrayListBlock *) &m_firstBlock, m_count);
264265
}
265266

267+
friend struct ::cdac_data<ArrayListBase>;
268+
friend struct ::cdac_data<ArrayListBlock>;
269+
};
270+
271+
template<>
272+
struct cdac_data<ArrayListBase>
273+
{
274+
static constexpr size_t Count = offsetof(ArrayListBase, m_count);
275+
static constexpr size_t FirstBlock = offsetof(ArrayListBase, m_firstBlock);
276+
};
277+
278+
template<>
279+
struct cdac_data<ArrayListBase::ArrayListBlock>
280+
{
281+
static constexpr size_t Next = offsetof(ArrayListBase::ArrayListBlock, m_next);
282+
static constexpr size_t Size = offsetof(ArrayListBase::ArrayListBlock, m_blockSize);
283+
static constexpr size_t ArrayStart = offsetof(ArrayListBase::ArrayListBlock, m_array);
266284
};
267285

268286
class ArrayList : public ArrayListBase

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ILoader.cs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public interface ILoader : IContract
3838

3939
ModuleHandle GetModuleHandle(TargetPointer modulePointer) => throw new NotImplementedException();
4040

41+
List<TargetPointer> GetAssemblies(TargetPointer appDomain) => throw new NotImplementedException();
4142
TargetPointer GetRootAssembly() => throw new NotImplementedException();
4243
TargetPointer GetAssembly(ModuleHandle handle) => throw new NotImplementedException();
4344
TargetPointer GetPEAssembly(ModuleHandle handle) => throw new NotImplementedException();

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/DataType.cs

+3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ public enum DataType
9696
MethodImpl,
9797
NativeCodeSlot,
9898
GCCoverageInfo,
99+
ArrayListBase,
100+
ArrayListBlock,
101+
99102
TransitionBlock,
100103
DebuggerEval,
101104
CalleeSavedRegisters,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.using System;
3+
4+
using System.Collections.Generic;
5+
6+
namespace Microsoft.Diagnostics.DataContractReader.Data;
7+
8+
internal sealed class ArrayListBase : IData<ArrayListBase>
9+
{
10+
static ArrayListBase IData<ArrayListBase>.Create(Target target, TargetPointer address) => new ArrayListBase(target, address);
11+
public ArrayListBase(Target target, TargetPointer address)
12+
{
13+
Target.TypeInfo type = target.GetTypeInfo(DataType.ArrayListBase);
14+
15+
Count = target.Read<uint>(address + (ulong)type.Fields[nameof(Count)].Offset);
16+
FirstBlock = address + (ulong)type.Fields[nameof(FirstBlock)].Offset;
17+
18+
TargetPointer next = FirstBlock;
19+
while (next != TargetPointer.Null)
20+
{
21+
ArrayListBlock block = target.ProcessedData.GetOrAdd<ArrayListBlock>(next);
22+
Blocks.Add(block);
23+
next = block.Next;
24+
}
25+
}
26+
27+
public uint Count { get; init; }
28+
public TargetPointer FirstBlock { get; init; }
29+
30+
public List<ArrayListBlock> Blocks { get; init; } = [];
31+
public List<TargetPointer> Elements { get; init; } = [];
32+
33+
internal sealed class ArrayListBlock : IData<ArrayListBlock>
34+
{
35+
static ArrayListBlock IData<ArrayListBlock>.Create(Target target, TargetPointer address) => new ArrayListBlock(target, address);
36+
public ArrayListBlock(Target target, TargetPointer address)
37+
{
38+
Target.TypeInfo type = target.GetTypeInfo(DataType.ArrayListBlock);
39+
40+
Next = target.ReadPointer(address + (ulong)type.Fields[nameof(Next)].Offset);
41+
Size = target.Read<uint>(address + (ulong)type.Fields[nameof(Size)].Offset);
42+
ArrayStart = address + (ulong)type.Fields[nameof(ArrayStart)].Offset;
43+
44+
for (ulong i = 0; i < Size; i++)
45+
{
46+
Elements.Add(target.ReadPointer(ArrayStart + (i * (ulong)target.PointerSize)));
47+
}
48+
}
49+
50+
public TargetPointer Next { get; init; }
51+
public uint Size { get; init; }
52+
public TargetPointer ArrayStart { get; init; }
53+
54+
public List<TargetPointer> Elements { get; init; } = [];
55+
}
56+
}

0 commit comments

Comments
 (0)