@@ -187,6 +187,24 @@ void EventMetadata::AddMetadata(EVENT_RECORD* eventRecord)
187
187
// If the metadata isn't found look it up using TDH. Then, look up each
188
188
// property in the metadata to obtain it's data pointer and size.
189
189
void 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)
190
208
{
191
209
// Look up stored metadata. If not found, look up metadata using TDH and
192
210
// cache it for future events.
@@ -207,7 +225,7 @@ void EventMetadata::GetEventData(EVENT_RECORD* eventRecord, EventDataDesc* desc,
207
225
ii = metadata_.emplace (key, std::vector<uint8_t >(sizeof (TRACE_EVENT_INFO), 0 )).first ;
208
226
assert (false );
209
227
}
210
- }
228
+ }
211
229
212
230
auto tei = (TRACE_EVENT_INFO*) ii->second .data ();
213
231
@@ -235,7 +253,7 @@ void EventMetadata::GetEventData(EVENT_RECORD* eventRecord, EventDataDesc* desc,
235
253
236
254
foundCount += 1 ;
237
255
if (foundCount == descCount) {
238
- return ;
256
+ return foundCount ;
239
257
}
240
258
}
241
259
}
@@ -244,8 +262,7 @@ void EventMetadata::GetEventData(EVENT_RECORD* eventRecord, EventDataDesc* desc,
244
262
offset += info.size_ * info.count_ ;
245
263
}
246
264
247
- assert (foundCount >= descCount - optionalCount);
248
- (void ) optionalCount;
265
+ return foundCount;
249
266
}
250
267
251
268
namespace {
0 commit comments