Commit a922f5ff authored by Philip Pronin's avatar Philip Pronin Committed by Facebook GitHub Bot

fix frame count reporting

Summary:
We're hiding internal frames during dump, but forget to adjust
the reported count, so the output looks clowny.

Reviewed By: luciang

Differential Revision: D32340094

fbshipit-source-id: 86a02c54178a03a83fa64c29faf6d82abfa45bf8
parent 11af35b6
......@@ -66,17 +66,20 @@ void printExceptionInfo(
} else {
out << "(unknown type)";
}
out << " (" << info.frames.size()
<< (info.frames.size() == 1 ? " frame" : " frames") << ")\n";
try {
size_t frameCount = info.frames.size();
// Skip our own internal frames
static constexpr size_t kInternalFramesNumber = 3;
if (frameCount > kInternalFramesNumber) {
// Skip our own internal frames.
size_t frameCount = info.frames.size();
if (frameCount <= kInternalFramesNumber) {
out << "\n";
return;
}
auto addresses = info.frames.data() + kInternalFramesNumber;
frameCount -= kInternalFramesNumber;
out << " (" << frameCount << (frameCount == 1 ? " frame" : " frames")
<< ")\n";
try {
std::vector<SymbolizedFrame> frames;
frames.resize(frameCount);
......@@ -88,7 +91,6 @@ void printExceptionInfo(
OStreamSymbolizePrinter osp(out, options);
osp.println(frames.data(), frameCount);
}
} catch (const std::exception& e) {
out << "\n !! caught " << folly::exceptionStr(e) << "\n";
} catch (...) {
......
......@@ -64,8 +64,7 @@ TEST(SmartExceptionTracer, EmptyExceptionWrapper) {
std::ostringstream ss;
ss << info;
ASSERT_TRUE(
ss.str().find("Exception type: (unknown type) (0 frames)") !=
std::string::npos);
ss.str().find("Exception type: (unknown type)") != std::string::npos);
}
TEST(SmartExceptionTracer, InvalidException) {
......@@ -77,8 +76,7 @@ TEST(SmartExceptionTracer, InvalidException) {
std::ostringstream ss;
ss << info;
ASSERT_TRUE(
ss.str().find("Exception type: (unknown type) (0 frames)") !=
std::string::npos);
ss.str().find("Exception type: (unknown type)") != std::string::npos);
}
}
......@@ -89,8 +87,7 @@ TEST(SmartExceptionTracer, UnthrownException) {
std::ostringstream ss;
ss << info;
ASSERT_TRUE(
ss.str().find("Exception type: std::runtime_error (0 frames)") !=
std::string::npos);
ss.str().find("Exception type: std::runtime_error") != std::string::npos);
}
namespace {
......
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