17 Dec
2016
17 Dec
'16
4:23 p.m.
In
std::string name = f.name(); if (!name.empty()) { os << name; } else { os << f.address(); }
const std::size_t source_line = f.source_line(); if (source_line) { os << " at " << f.source_file() << ':' << source_line; }
which is perfectly reasonable code given the current interface, addr2line is called three times instead of just one. And in operator<< for a stacktrace of depth N, addr2line will be called 3*N times instead of one.
The same problem exists in the Windows backend, where the COM machinery is initialized/deinitialized on each call, and GetLineByOffset is called twice, each time discarding half of the result.