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);
91 >> std::hex >>
address >> std::dec
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.")
122 std::string
const&
s,
129 libraryName = extract(s, libraryStr);
131 mangledFunctionName = extract(s, functionStr);
134 if (!emptyRange(addressStr)) {
135 std::istringstream sstr(extract(s, addressStr));
139 if (emptyRange(offsetStr))
offset = 0;
141 auto offsetRange = offsetStr;
142 if (!emptyRange(offsetRange)) {
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;
148 sstr.setf(std::ios::hex);
150 sstr.str(extract(s, offsetRange));
152 if (neg) offset = -
offset;
std::string original
String from the backtrace, unparsed.
then if[["$THISISATEST"==1]]
BEGIN_PROLOG TPC Trig offset(g4 rise time) ProjectToHeight
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
Functions to help debugging by instrumenting code.
then echo File list $list not found else cat $list while read file do echo $file sed s
std::string mangledFunctionName
Parsed function name, unprocessed.
std::ptrdiff_t offset
Instruction pointer offset.