Skip to content
This repository
Browse code

Verbosify exception tracer dumps

Test Plan: by hand

Reviewed By: philipp@fb.com

FB internal diff: D570233
  • Loading branch information...
commit 6b4082ec2603c63cde2e33fb2c94e5a2ef9a8aa8 1 parent 78ee280
tudor tudor authored jdelong committed

Showing 1 changed file with 21 additions and 11 deletions. Show diff stats Hide diff stats

  1. +21 11 folly/experimental/exception_tracer/ExceptionTracer.cpp
32 folly/experimental/exception_tracer/ExceptionTracer.cpp
@@ -44,18 +44,27 @@ namespace exception_tracer {
44 44 std::ostream& operator<<(std::ostream& out, const ExceptionInfo& info) {
45 45 out << "Exception type: ";
46 46 if (info.type) {
47   - out << folly::demangle(*info.type) << "\n";
  47 + out << folly::demangle(*info.type);
48 48 } else {
49   - out << "(unknown type)\n";
  49 + out << "(unknown type)";
50 50 }
51   - Symbolizer symbolizer;
52   - folly::StringPiece symbolName;
53   - Dwarf::LocationInfo location;
54   - for (auto ip : info.frames) {
55   - // Symbolize the previous address because the IP might be in the
56   - // next function, per glog/src/signalhandler.cc
57   - symbolizer.symbolize(ip-1, symbolName, location);
58   - Symbolizer::write(out, ip, symbolName, location);
  51 + out << " (" << info.frames.size()
  52 + << (info.frames.size() == 1 ? " frame" : " frames")
  53 + << ")\n";
  54 + try {
  55 + Symbolizer symbolizer;
  56 + folly::StringPiece symbolName;
  57 + Dwarf::LocationInfo location;
  58 + for (auto ip : info.frames) {
  59 + // Symbolize the previous address because the IP might be in the
  60 + // next function, per glog/src/signalhandler.cc
  61 + symbolizer.symbolize(ip-1, symbolName, location);
  62 + Symbolizer::write(out, ip, symbolName, location);
  63 + }
  64 + } catch (const std::exception& e) {
  65 + out << "\n !! caught " << folly::exceptionStr(e) << "\n";
  66 + } catch (...) {
  67 + out << "\n !!! caught unexpected exception\n";
59 68 }
60 69 return out;
61 70 }
@@ -159,10 +168,11 @@ void dumpExceptionStack(const char* prefix) {
159 168 if (exceptions.empty()) {
160 169 return;
161 170 }
162   - LOG(ERROR) << prefix << ", exception stack follows\n";
  171 + LOG(ERROR) << prefix << ", exception stack follows";
163 172 for (auto& exc : exceptions) {
164 173 LOG(ERROR) << exc << "\n";
165 174 }
  175 + LOG(ERROR) << "exception stack complete";
166 176 }
167 177
168 178 void terminateHandler() {

0 comments on commit 6b4082e

Please sign in to comment.
Something went wrong with that request. Please try again.