From: Tudor Bosman Date: Mon, 10 Sep 2012 20:45:25 +0000 (-0700) Subject: Verbosify exception tracer dumps X-Git-Tag: v0.22.0~1186 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=6b4082ec2603c63cde2e33fb2c94e5a2ef9a8aa8;p=folly.git Verbosify exception tracer dumps Test Plan: by hand Reviewed By: philipp@fb.com FB internal diff: D570233 --- diff --git a/folly/experimental/exception_tracer/ExceptionTracer.cpp b/folly/experimental/exception_tracer/ExceptionTracer.cpp index 3e417d18..82e18639 100644 --- a/folly/experimental/exception_tracer/ExceptionTracer.cpp +++ b/folly/experimental/exception_tracer/ExceptionTracer.cpp @@ -44,18 +44,27 @@ namespace exception_tracer { std::ostream& operator<<(std::ostream& out, const ExceptionInfo& info) { out << "Exception type: "; if (info.type) { - out << folly::demangle(*info.type) << "\n"; + out << folly::demangle(*info.type); } else { - out << "(unknown type)\n"; + out << "(unknown type)"; } - Symbolizer symbolizer; - folly::StringPiece symbolName; - Dwarf::LocationInfo location; - for (auto ip : info.frames) { - // Symbolize the previous address because the IP might be in the - // next function, per glog/src/signalhandler.cc - symbolizer.symbolize(ip-1, symbolName, location); - Symbolizer::write(out, ip, symbolName, location); + out << " (" << info.frames.size() + << (info.frames.size() == 1 ? " frame" : " frames") + << ")\n"; + try { + Symbolizer symbolizer; + folly::StringPiece symbolName; + Dwarf::LocationInfo location; + for (auto ip : info.frames) { + // Symbolize the previous address because the IP might be in the + // next function, per glog/src/signalhandler.cc + symbolizer.symbolize(ip-1, symbolName, location); + Symbolizer::write(out, ip, symbolName, location); + } + } catch (const std::exception& e) { + out << "\n !! caught " << folly::exceptionStr(e) << "\n"; + } catch (...) { + out << "\n !!! caught unexpected exception\n"; } return out; } @@ -159,10 +168,11 @@ void dumpExceptionStack(const char* prefix) { if (exceptions.empty()) { return; } - LOG(ERROR) << prefix << ", exception stack follows\n"; + LOG(ERROR) << prefix << ", exception stack follows"; for (auto& exc : exceptions) { LOG(ERROR) << exc << "\n"; } + LOG(ERROR) << "exception stack complete"; } void terminateHandler() {