| 237 | } |
| 238 | |
| 239 | std::optional<int> GetOffsetAttribute(tinyxml2::XMLElement* ele, Pattern const& pattern, char const* name) |
| 240 | { |
| 241 | char const* value{ nullptr }; |
| 242 | auto e = ele->QueryStringAttribute(name, &value); |
| 243 | if (e != tinyxml2::XML_SUCCESS) { |
| 244 | return {}; |
| 245 | } |
| 246 | |
| 247 | if (*value == '@') { |
| 248 | auto offset = pattern.GetAnchor(value + 1); |
| 249 | if (!offset) { |
| 250 | ERR("Invalid anchor reference in XML attribute '%s': '%s'", name, value); |
| 251 | return {}; |
| 252 | } else { |
| 253 | return (int)*offset; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | std::size_t readSize{ 0 }; |
| 258 | int parsed; |
| 259 | try { |
| 260 | parsed = std::stoi(value, &readSize, 0); |
| 261 | } catch (std::exception const& e) { |
| 262 | ERR("Invalid offset value in XML attribute '%s': '%s' (%s)", name, value, e.what()); |
| 263 | return {}; |
| 264 | } |
| 265 | |
| 266 | if (readSize != strlen(value)) { |
| 267 | ERR("Invalid offset value in XML attribute '%s': '%s' (garbage found at end of string)", name, value); |
| 268 | } |
| 269 | |
| 270 | return parsed; |
| 271 | } |
| 272 | |
| 273 | void SymbolMappingLoader::AddKnownModule(std::string const& name) |
| 274 | { |
no test coverage detected