| 10 | |
| 11 | namespace FEX::VolatileMetadata { |
| 12 | fextl::unordered_map<fextl::string, ExtendedVolatileMetadata> ParseExtendedVolatileMetadata(std::string_view ListOfDescriptors) { |
| 13 | // Parsing: `<module>;<address begin>-<address-end>,<more addresses>;<instruction offset to force TSO>:` |
| 14 | if (ListOfDescriptors.empty()) { |
| 15 | return {}; |
| 16 | } |
| 17 | |
| 18 | fextl::unordered_map<fextl::string, ExtendedVolatileMetadata> ExtendedMetaData {}; |
| 19 | |
| 20 | auto to_string_view = [](auto rng) { |
| 21 | return std::string_view(&*rng.begin(), ranges::distance(rng)); |
| 22 | }; |
| 23 | for (auto module_config : ranges::views::split(ListOfDescriptors, ':') | ranges::views::transform(to_string_view)) { |
| 24 | if (module_config.empty()) { |
| 25 | continue; |
| 26 | } |
| 27 | |
| 28 | auto sections = ranges::views::split(module_config, ';') | ranges::views::transform(to_string_view); |
| 29 | auto section = ranges::begin(sections); |
| 30 | const auto sections_end = ranges::end(sections); |
| 31 | |
| 32 | // Module name handling |
| 33 | std::string_view section_str = *section; |
| 34 | if (section_str.empty()) { |
| 35 | continue; |
| 36 | } |
| 37 | |
| 38 | auto current_module = ExtendedMetaData |
| 39 | .insert_or_assign(fextl::string(section_str), |
| 40 | ExtendedVolatileMetadata { |
| 41 | .ModuleTSODisabled = true, |
| 42 | }) |
| 43 | .first; |
| 44 | ++section; |
| 45 | |
| 46 | // Address range handling |
| 47 | if (section != sections_end) { |
| 48 | std::string_view section_str = *section; |
| 49 | if (section_str.empty()) { |
| 50 | continue; |
| 51 | } |
| 52 | |
| 53 | current_module->second.ModuleTSODisabled = false; |
| 54 | |
| 55 | // Walk all the address ranges provided. |
| 56 | for (auto tso_region_view : ranges::views::split(section_str, ',') | ranges::views::transform(to_string_view)) { |
| 57 | if (tso_region_view.empty()) { |
| 58 | continue; |
| 59 | } |
| 60 | |
| 61 | uint64_t begin {}, end {}; |
| 62 | char* str_end; |
| 63 | begin = std::strtoull(tso_region_view.data(), &str_end, 16); |
| 64 | LOGMAN_THROW_A_FMT(tso_region_view.data() != str_end, "Couldn't parse begin {}", tso_region_view); |
| 65 | |
| 66 | // Skip `-` separator. |
| 67 | ++str_end; |
| 68 | |
| 69 | LOGMAN_THROW_A_FMT(str_end != tso_region_view.end(), "Couldn't parse end {}", tso_region_view); |
no test coverage detected