namespace exception_tracer {
std::ostream& operator<<(std::ostream& out, const ExceptionInfo& info) {
+ printExceptionInfo(out, info, SymbolizePrinter::COLOR_IF_TTY);
+ return out;
+}
+
+void printExceptionInfo(
+ std::ostream& out,
+ const ExceptionInfo& info,
+ int options) {
out << "Exception type: ";
if (info.type) {
out << folly::demangle(*info.type);
Symbolizer symbolizer;
symbolizer.symbolize(addresses, frames.data(), frameCount);
- OStreamSymbolizePrinter osp(out, SymbolizePrinter::COLOR_IF_TTY);
+ OStreamSymbolizePrinter osp(out, options);
osp.println(addresses, frames.data(), frameCount);
}
} catch (const std::exception& e) {
} catch (...) {
out << "\n !!! caught unexpected exception\n";
}
- return out;
}
namespace {
std::vector<uintptr_t> frames; // front() is top of stack
};
+void printExceptionInfo(
+ std::ostream& out,
+ const ExceptionInfo& info,
+ int options);
std::ostream& operator<<(std::ostream& out, const ExceptionInfo& info);
/**
SCOPE_EXIT { color(Color::DEFAULT); };
- color(kAddressColor);
+ if (!(options_ & NO_FRAME_ADDRESS)) {
+ color(kAddressColor);
- AddressFormatter formatter;
- doPrint(formatter.format(address));
+ AddressFormatter formatter;
+ doPrint(formatter.format(address));
+ }
const char padBuf[] = " ";
folly::StringPiece pad(padBuf,
// Colorize output only if output is printed to a TTY (ANSI escape code)
COLOR_IF_TTY = 1 << 3,
+
+ // Skip frame address information
+ NO_FRAME_ADDRESS = 1 << 4,
};
// NOTE: enum values used as indexes in kColorMap.