| 261 | } |
| 262 | |
| 263 | bool ParseTraceEvents(simdjson::dom::element& it, const std::string& curFileName) |
| 264 | { |
| 265 | if (!it.is_array()) |
| 266 | return false; |
| 267 | |
| 268 | NameToIndexMap nameToIndexLocal; |
| 269 | NameToIndex("", nameToIndexLocal); // make sure zero index is empty |
| 270 | BuildEvents fileEvents; |
| 271 | fileEvents.reserve(256); |
| 272 | for (simdjson::dom::element nit : it) |
| 273 | { |
| 274 | ParseEvent(nit, curFileName, fileEvents, nameToIndexLocal); |
| 275 | } |
| 276 | if (fileEvents.empty()) |
| 277 | return false; |
| 278 | |
| 279 | FindParentChildrenIndices(fileEvents); |
| 280 | if (fileEvents.back().parent.idx != -1) |
| 281 | { |
| 282 | printf("%sWARN: the last trace event should be root; was not in '%s'.%s\n", col::kRed, curFileName.c_str(), col::kReset); |
| 283 | return false; |
| 284 | } |
| 285 | |
| 286 | SanitizeEvents(fileEvents); |
| 287 | |
| 288 | AddEvents(fileEvents, nameToIndexLocal); |
| 289 | return true; |
| 290 | } |
| 291 | |
| 292 | static bool StrEqual(std::string_view a, const char* b) |
| 293 | { |
nothing calls this directly
no test coverage detected