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,29 +66,31 @@ void printExceptionInfo( ...@@ -66,29 +66,31 @@ void printExceptionInfo(
} else { } else {
out << "(unknown type)"; out << "(unknown type)";
} }
out << " (" << info.frames.size() static constexpr size_t kInternalFramesNumber = 3;
<< (info.frames.size() == 1 ? " frame" : " frames") << ")\n";
try {
size_t frameCount = info.frames.size();
// Skip our own internal frames // Skip our own internal frames.
static constexpr size_t kInternalFramesNumber = 3; size_t frameCount = info.frames.size();
if (frameCount > kInternalFramesNumber) { if (frameCount <= kInternalFramesNumber) {
auto addresses = info.frames.data() + kInternalFramesNumber; out << "\n";
frameCount -= kInternalFramesNumber; return;
}
auto addresses = info.frames.data() + kInternalFramesNumber;
frameCount -= kInternalFramesNumber;
std::vector<SymbolizedFrame> frames; out << " (" << frameCount << (frameCount == 1 ? " frame" : " frames")
frames.resize(frameCount); << ")\n";
try {
std::vector<SymbolizedFrame> frames;
frames.resize(frameCount);
Symbolizer symbolizer( Symbolizer symbolizer(
(options & SymbolizePrinter::NO_FILE_AND_LINE) (options & SymbolizePrinter::NO_FILE_AND_LINE)
? LocationInfoMode::DISABLED ? LocationInfoMode::DISABLED
: Symbolizer::kDefaultLocationInfoMode); : Symbolizer::kDefaultLocationInfoMode);
symbolizer.symbolize(addresses, frames.data(), frameCount); symbolizer.symbolize(addresses, frames.data(), frameCount);
OStreamSymbolizePrinter osp(out, options); OStreamSymbolizePrinter osp(out, options);
osp.println(frames.data(), frameCount); osp.println(frames.data(), frameCount);
}
} catch (const std::exception& e) { } catch (const std::exception& e) {
out << "\n !! caught " << folly::exceptionStr(e) << "\n"; out << "\n !! caught " << folly::exceptionStr(e) << "\n";
} catch (...) { } catch (...) {
......
...@@ -64,8 +64,7 @@ TEST(SmartExceptionTracer, EmptyExceptionWrapper) { ...@@ -64,8 +64,7 @@ TEST(SmartExceptionTracer, EmptyExceptionWrapper) {
std::ostringstream ss; std::ostringstream ss;
ss << info; ss << info;
ASSERT_TRUE( ASSERT_TRUE(
ss.str().find("Exception type: (unknown type) (0 frames)") != ss.str().find("Exception type: (unknown type)") != std::string::npos);
std::string::npos);
} }
TEST(SmartExceptionTracer, InvalidException) { TEST(SmartExceptionTracer, InvalidException) {
...@@ -77,8 +76,7 @@ TEST(SmartExceptionTracer, InvalidException) { ...@@ -77,8 +76,7 @@ TEST(SmartExceptionTracer, InvalidException) {
std::ostringstream ss; std::ostringstream ss;
ss << info; ss << info;
ASSERT_TRUE( ASSERT_TRUE(
ss.str().find("Exception type: (unknown type) (0 frames)") != ss.str().find("Exception type: (unknown type)") != std::string::npos);
std::string::npos);
} }
} }
...@@ -89,8 +87,7 @@ TEST(SmartExceptionTracer, UnthrownException) { ...@@ -89,8 +87,7 @@ TEST(SmartExceptionTracer, UnthrownException) {
std::ostringstream ss; std::ostringstream ss;
ss << info; ss << info;
ASSERT_TRUE( ASSERT_TRUE(
ss.str().find("Exception type: std::runtime_error (0 frames)") != ss.str().find("Exception type: std::runtime_error") != std::string::npos);
std::string::npos);
} }
namespace { 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