@@ -187,6 +187,24 @@ void EventMetadata::AddMetadata(EVENT_RECORD* eventRecord)
187187// If the metadata isn't found look it up using TDH. Then, look up each
188188// property in the metadata to obtain it's data pointer and size.
189189void EventMetadata::GetEventData (EVENT_RECORD* eventRecord, EventDataDesc* desc, uint32_t descCount, uint32_t optionalCount /* =0*/ )
190+ {
191+ [[maybe_unused]] auto foundCount = GetEventDataWithCount (eventRecord, desc, descCount);
192+ assert (foundCount >= descCount - optionalCount);
193+ (void )optionalCount;
194+ }
195+
196+ // Some events have been evolving over time but not incrementing the version number. As an example DXGI::SwapChain::Start.
197+ // Use this version of GetEventData when a data param might be available based on the version of the event
198+ // being processed. Be sure to check the returned event cound to ensure the expected number of descriptions have
199+ // been found.
200+ void EventMetadata::GetEventData (EVENT_RECORD* eventRecord, EventDataDesc* desc, uint32_t * descCount)
201+ {
202+ auto foundCount = GetEventDataWithCount (eventRecord, desc, *descCount);
203+ *descCount = foundCount;
204+ return ;
205+ }
206+
207+ uint32_t EventMetadata::GetEventDataWithCount (EVENT_RECORD* eventRecord, EventDataDesc* desc, uint32_t descCount)
190208{
191209 // Look up stored metadata. If not found, look up metadata using TDH and
192210 // cache it for future events.
@@ -207,7 +225,7 @@ void EventMetadata::GetEventData(EVENT_RECORD* eventRecord, EventDataDesc* desc,
207225 ii = metadata_.emplace (key, std::vector<uint8_t >(sizeof (TRACE_EVENT_INFO), 0 )).first ;
208226 assert (false );
209227 }
210- }
228+ }
211229
212230 auto tei = (TRACE_EVENT_INFO*) ii->second .data ();
213231
@@ -235,7 +253,7 @@ void EventMetadata::GetEventData(EVENT_RECORD* eventRecord, EventDataDesc* desc,
235253
236254 foundCount += 1 ;
237255 if (foundCount == descCount) {
238- return ;
256+ return foundCount ;
239257 }
240258 }
241259 }
@@ -244,8 +262,7 @@ void EventMetadata::GetEventData(EVENT_RECORD* eventRecord, EventDataDesc* desc,
244262 offset += info.size_ * info.count_ ;
245263 }
246264
247- assert (foundCount >= descCount - optionalCount);
248- (void ) optionalCount;
265+ return foundCount;
249266}
250267
251268namespace {
0 commit comments