Commit edf8f25a authored by Dmitry Pleshkov's avatar Dmitry Pleshkov Committed by Facebook Github Bot 1

Allow usage of Symbolizer options for ExceptionStats printing

Summary: For exceptions aggregation conveniece

Reviewed By: philippv

Differential Revision: D3128132

fb-gh-sync-id: 48c72df364228c1d2c8f29161c2b85c131b4fea8
fbshipit-source-id: 48c72df364228c1d2c8f29161c2b85c131b4fea8
parent b50d0563
...@@ -44,6 +44,14 @@ namespace folly { ...@@ -44,6 +44,14 @@ namespace folly {
namespace exception_tracer { namespace exception_tracer {
std::ostream& operator<<(std::ostream& out, const ExceptionInfo& info) { 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: "; out << "Exception type: ";
if (info.type) { if (info.type) {
out << folly::demangle(*info.type); out << folly::demangle(*info.type);
...@@ -68,7 +76,7 @@ std::ostream& operator<<(std::ostream& out, const ExceptionInfo& info) { ...@@ -68,7 +76,7 @@ std::ostream& operator<<(std::ostream& out, const ExceptionInfo& info) {
Symbolizer symbolizer; Symbolizer symbolizer;
symbolizer.symbolize(addresses, frames.data(), frameCount); symbolizer.symbolize(addresses, frames.data(), frameCount);
OStreamSymbolizePrinter osp(out, SymbolizePrinter::COLOR_IF_TTY); OStreamSymbolizePrinter osp(out, options);
osp.println(addresses, frames.data(), frameCount); osp.println(addresses, frames.data(), frameCount);
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
...@@ -76,7 +84,6 @@ std::ostream& operator<<(std::ostream& out, const ExceptionInfo& info) { ...@@ -76,7 +84,6 @@ std::ostream& operator<<(std::ostream& out, const ExceptionInfo& info) {
} catch (...) { } catch (...) {
out << "\n !!! caught unexpected exception\n"; out << "\n !!! caught unexpected exception\n";
} }
return out;
} }
namespace { namespace {
......
...@@ -35,6 +35,10 @@ struct ExceptionInfo { ...@@ -35,6 +35,10 @@ struct ExceptionInfo {
std::vector<uintptr_t> frames; // front() is top of stack 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); std::ostream& operator<<(std::ostream& out, const ExceptionInfo& info);
/** /**
......
...@@ -345,10 +345,12 @@ void SymbolizePrinter::print(uintptr_t address, const SymbolizedFrame& frame) { ...@@ -345,10 +345,12 @@ void SymbolizePrinter::print(uintptr_t address, const SymbolizedFrame& frame) {
SCOPE_EXIT { color(Color::DEFAULT); }; SCOPE_EXIT { color(Color::DEFAULT); };
color(kAddressColor); if (!(options_ & NO_FRAME_ADDRESS)) {
color(kAddressColor);
AddressFormatter formatter; AddressFormatter formatter;
doPrint(formatter.format(address)); doPrint(formatter.format(address));
}
const char padBuf[] = " "; const char padBuf[] = " ";
folly::StringPiece pad(padBuf, folly::StringPiece pad(padBuf,
......
...@@ -203,6 +203,9 @@ class SymbolizePrinter { ...@@ -203,6 +203,9 @@ class SymbolizePrinter {
// Colorize output only if output is printed to a TTY (ANSI escape code) // Colorize output only if output is printed to a TTY (ANSI escape code)
COLOR_IF_TTY = 1 << 3, COLOR_IF_TTY = 1 << 3,
// Skip frame address information
NO_FRAME_ADDRESS = 1 << 4,
}; };
// NOTE: enum values used as indexes in kColorMap. // NOTE: enum values used as indexes in kColorMap.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment