2 #include "CoreUtils/DebugUtils.h" 15 constexpr
auto boo = std::string::npos;
16 range_t libraryStr { boo, boo };
17 range_t addressStr { boo, boo };
18 range_t functionStr { boo, boo };
20 setAll(s, addressStr, libraryStr, functionStr, offsetStr);
26 size_t i = s.find(
'(');
27 if (i == boo)
return false;
33 libraryStr = { 0U, i };
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;
45 functionStr.second = i;
48 i = s.find_first_of(
"()", ++i);
49 if (i == boo)
return false;
58 functionStr.second = i;
63 i = s.find_first_of(
"([", ++i);
65 if (s[i] ==
'(')
continue;
66 addressStr.first = ++i;
68 i = s.find_first_of(
"(]", i);
69 if (s[i] ==
'(')
continue;
70 addressStr.second = i;
75 setAll(s, addressStr, libraryStr, functionStr, offsetStr);
85 std::istringstream sstr(s);
95 if (sstr.fail())
break;
97 if (sstr.fail())
offset = 0;
99 if (plus !=
'+')
break;
101 if (sstr.fail())
break;
115 # error("I am not on Linux nor on OSX. Hard to believe.") 135 std::istringstream sstr(
extract(s, addressStr));
141 auto offsetRange = offsetStr;
143 bool neg = (s[offsetRange.first] ==
'-');
144 std::istringstream sstr;
145 if (neg || (s[offsetRange.first] ==
'+')) ++offsetRange.first;
146 if (s.substr(offsetRange.first, 2) ==
"0x") {
147 offsetRange.first += 2;
150 sstr.str(
extract(s, offsetRange));
152 if (neg) offset = -
offset;
void * address
function address
bool ParseString(std::string const &s)
Returns whether the translation was complete (offset is optional!)
std::string libraryName
parsed library name
void demangleFunction()
Runs the demangler and stores the result.
std::pair< size_t, size_t > range_t
std::ptrdiff_t offset
instruction pointer offset
QTextStream & hex(QTextStream &s)
std::string original
string from the backtrace, unparsed
static bool emptyRange(range_t const &r)
Returns whether the range is empty or invalid.
std::string functionName
parsed function name, demangled
std::string mangledFunctionName
parsed function name, unprocessed
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.
QTextStream & dec(QTextStream &s)
static std::string extract(std::string const &s, range_t const &r)
Translates a range into a string.