Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Tweaks to existing BulkType event (#27516)
Browse files Browse the repository at this point in the history
- Enable specification of exact multi-dimensional array rank
- Tolerate scenarios where the name of the type is so large that it prevents generation of the BulkType event
  • Loading branch information
davidwrighton authored Nov 4, 2019
1 parent 5a381e7 commit fd418f6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/inc/eventtracebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ enum EtwTypeFlags
kEtwTypeFlagsFinalizable = 0x2,
kEtwTypeFlagsExternallyImplementedCOMObject = 0x4,
kEtwTypeFlagsArray = 0x8,
kEtwTypeFlagsArrayRankBit0 = 0x100,
kEtwTypeFlagsArrayRankBit1 = 0x200,
kEtwTypeFlagsArrayRankBit2 = 0x400,
kEtwTypeFlagsArrayRankBit3 = 0x800,
kEtwTypeFlagsArrayRankBit4 = 0x1000,
kEtwTypeFlagsArrayRankBit5 = 0x2000,

kEtwTypeFlagsArrayRankMask = 0x3F00,
kEtwTypeFlagsArrayRankShift = 8,
kEtwTypeFlagsArrayRankMax = kEtwTypeFlagsArrayRankMask >> kEtwTypeFlagsArrayRankShift
};

enum EtwThreadFlags
Expand Down
12 changes: 12 additions & 0 deletions src/vm/ClrEtwAll.man
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,12 @@
<map value="0x2" message="$(string.RuntimePublisher.TypeFlags.Finalizable)"/>
<map value="0x4" message="$(string.RuntimePublisher.TypeFlags.ExternallyImplementedCOMObject)"/>
<map value="0x8" message="$(string.RuntimePublisher.TypeFlags.Array)"/>
<map value="0x100" message="$(string.RuntimePublisher.TypeFlags.ArrayRankBit0)"/>
<map value="0x200" message="$(string.RuntimePublisher.TypeFlags.ArrayRankBit1)"/>
<map value="0x400" message="$(string.RuntimePublisher.TypeFlags.ArrayRankBit2)"/>
<map value="0x800" message="$(string.RuntimePublisher.TypeFlags.ArrayRankBit3)"/>
<map value="0x1000" message="$(string.RuntimePublisher.TypeFlags.ArrayRankBit4)"/>
<map value="0x2000" message="$(string.RuntimePublisher.TypeFlags.ArrayRankBit5)"/>
</bitMap>
<bitMap name="GCRootFlagsMap">
<map value="0x1" message="$(string.RuntimePublisher.GCRootFlags.Pinning)"/>
Expand Down Expand Up @@ -7012,6 +7018,12 @@
<string id="RuntimePublisher.TypeFlags.Finalizable" value="Finalizable"/>
<string id="RuntimePublisher.TypeFlags.ExternallyImplementedCOMObject" value="ExternallyImplementedCOMObject"/>
<string id="RuntimePublisher.TypeFlags.Array" value="Array"/>
<string id="RuntimePublisher.TypeFlags.ArrayRankBit0" value="ArrayRankBit0"/>
<string id="RuntimePublisher.TypeFlags.ArrayRankBit1" value="ArrayRankBit1"/>
<string id="RuntimePublisher.TypeFlags.ArrayRankBit2" value="ArrayRankBit2"/>
<string id="RuntimePublisher.TypeFlags.ArrayRankBit3" value="ArrayRankBit3"/>
<string id="RuntimePublisher.TypeFlags.ArrayRankBit4" value="ArrayRankBit4"/>
<string id="RuntimePublisher.TypeFlags.ArrayRankBit5" value="ArrayRankBit5"/>
<string id="RuntimePublisher.GCRootFlags.Pinning" value="Pinning"/>
<string id="RuntimePublisher.GCRootFlags.WeakRef" value="WeakRef"/>
<string id="RuntimePublisher.GCRootFlags.Interior" value="Interior"/>
Expand Down
29 changes: 24 additions & 5 deletions src/vm/eventtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,20 @@ int BulkTypeEventLogger::LogSingleType(TypeHandle th)
{
// Normal typedesc array
pVal->fixedSizedData.Flags |= kEtwTypeFlagsArray;

if (pVal->fixedSizedData.CorElementType == ELEMENT_TYPE_ARRAY)
{
// Multidimensional arrays set the rank bits, SzArrays do not set the rank bits
unsigned rank = th.AsArray()->GetRank();
if (rank < kEtwTypeFlagsArrayRankMax)
{
// Only ranks less than kEtwTypeFlagsArrayRankMax are supported.
// Fortunately kEtwTypeFlagsArrayRankMax should be greater than the
// number of ranks the type loader will support
rank <<= kEtwTypeFlagsArrayRankShift;
_ASSERTE((rank & kEtwTypeFlagsArrayRankMask) == rank);
pVal->fixedSizedData.Flags |= rank;
}
}
// Fetch TypeHandle of array elements
fSucceeded = FALSE;
EX_TRY
Expand Down Expand Up @@ -1895,10 +1908,16 @@ int BulkTypeEventLogger::LogSingleType(TypeHandle th)
int cbVal = pVal->GetByteCountInEvent();
if (cbVal > kMaxBytesTypeValues)
{
// This type is apparently so huge, it's too big to squeeze into an event, even
// if it were the only type batched in the whole event. Bail
_ASSERTE(!"Type too big to log via ETW");
return -1;
pVal->sName.Clear();
cbVal = pVal->GetByteCountInEvent();

if (cbVal > kMaxBytesTypeValues)
{
// This type is apparently so huge, it's too big to squeeze into an event, even
// if it were the only type batched in the whole event. Bail
_ASSERTE(!"Type too big to log via ETW");
return -1;
}
}

if (m_nBulkTypeValueByteCount + cbVal > kMaxBytesTypeValues)
Expand Down

0 comments on commit fd418f6

Please sign in to comment.