15 constexpr
auto boo = std::string::npos;
20 setAll(s, addressStr, libraryStr, functionStr, offsetStr);
26 size_t i = s.find(
'(');
27 if (i == boo)
return false;
34 addressStr = {boo, boo};
35 functionStr = {boo, boo};
36 offsetStr = {boo, boo};
38 functionStr.first = ++i;
40 i = s.find_first_of(
"(+-)", i);
41 if (i == boo)
return false;
46 functionStr.second = i;
49 i = s.find_first_of(
"()", ++i);
50 if (i == boo)
return false;
53 case ')': offsetStr.second = i;
break;
56 case ')': functionStr.second = i;
break;
60 i = s.find_first_of(
"([", ++i);
62 if (s[i] ==
'(')
continue;
63 addressStr.first = ++i;
65 i = s.find_first_of(
"(]", i);
66 if (s[i] ==
'(')
continue;
67 addressStr.second = i;
72 setAll(s, addressStr, libraryStr, functionStr, offsetStr);
82 std::istringstream sstr(s);
88 if (sstr.fail())
break;
93 if (plus !=
'+')
break;
95 if (sstr.fail())
break;
109 #error("I am not on Linux nor on OSX. Hard to believe.") 127 std::istringstream sstr(
extract(s, addressStr));
134 auto offsetRange = offsetStr;
136 bool neg = (s[offsetRange.first] ==
'-');
137 std::istringstream sstr;
138 if (neg || (s[offsetRange.first] ==
'+')) ++offsetRange.first;
139 if (s.substr(offsetRange.first, 2) ==
"0x") {
140 offsetRange.first += 2;
141 sstr.setf(std::ios::hex);
143 sstr.str(
extract(s, offsetRange));
145 if (neg) offset = -
offset;
std::string original
String from the backtrace, unparsed.
static std::string extract(std::string const &s, range_t const &r)
Translates a range into a string.
std::string functionName
Parsed function name, demangled.
std::string libraryName
Parsed library name.
void setAll(std::string const &s, range_t addressStr, range_t libraryStr, range_t functionStr, range_t offsetStr)
Fills the information from an original string and parsed ranges.
void * address
Function address.
void demangleFunction()
Runs the demangler and stores the result.
bool ParseString(std::string const &s)
Returns whether the translation was complete (offset is optional!).
std::pair< size_t, size_t > range_t
static bool emptyRange(range_t const &r)
Returns whether the range is empty or invalid.
Functions to help debugging by instrumenting code.
std::string mangledFunctionName
Parsed function name, unprocessed.
std::ptrdiff_t offset
Instruction pointer offset.