| 341 | } |
| 342 | |
| 343 | bool SymbolMappingLoader::LoadMapping(tinyxml2::XMLElement* mapping, SymbolMappings::Mapping& sym) |
| 344 | { |
| 345 | auto name = mapping->Attribute("Name"); |
| 346 | if (!name) { |
| 347 | ERR("Mapping must have a name"); |
| 348 | return false; |
| 349 | } |
| 350 | |
| 351 | sym.Name = name; |
| 352 | |
| 353 | auto scope = mapping->Attribute("Scope"); |
| 354 | if (scope == nullptr || strcmp(scope, "Text") == 0) { |
| 355 | sym.Scope = SymbolMappings::MatchScope::kText; |
| 356 | } else if (strcmp(scope, "Binary") == 0) { |
| 357 | sym.Scope = SymbolMappings::MatchScope::kBinary; |
| 358 | } else if (strcmp(scope, "Custom") == 0) { |
| 359 | sym.Scope = SymbolMappings::MatchScope::kCustom; |
| 360 | } else { |
| 361 | ERR("Mapping uses unsupported scope type: %s", scope); |
| 362 | return false; |
| 363 | } |
| 364 | |
| 365 | if (sym.Scope != SymbolMappings::MatchScope::kCustom) { |
| 366 | auto mod = mapping->Attribute("Module"); |
| 367 | if (mod == nullptr) { |
| 368 | mod = "Main"; |
| 369 | } |
| 370 | |
| 371 | auto moduleInfo = knownModules_.find(mod); |
| 372 | if (moduleInfo == knownModules_.end()) { |
| 373 | ERR("Mapping references unknown module: %s", mod); |
| 374 | return false; |
| 375 | } |
| 376 | |
| 377 | sym.Module = mod; |
| 378 | } else { |
| 379 | sym.Module = ""; |
| 380 | } |
| 381 | |
| 382 | if (mapping->BoolAttribute("Critical")) { |
| 383 | sym.Flag |= SymbolMappings::Mapping::kCritical; |
| 384 | } |
| 385 | |
| 386 | if (mapping->BoolAttribute("Deferred")) { |
| 387 | sym.Flag |= SymbolMappings::Mapping::kDeferred; |
| 388 | } |
| 389 | |
| 390 | if (mapping->BoolAttribute("AllowFail")) { |
| 391 | sym.Flag |= SymbolMappings::Mapping::kAllowFail; |
| 392 | } |
| 393 | |
| 394 | std::string pattern; |
| 395 | auto patternText = mapping->FirstChild(); |
| 396 | while (patternText) { |
| 397 | auto text = patternText->ToText(); |
| 398 | if (text) { |
| 399 | pattern += text->Value(); |
| 400 | } |
nothing calls this directly
no test coverage detected