From: Tudor Bosman Date: Thu, 16 Jan 2014 03:14:30 +0000 (-0800) Subject: stack_trace_test was broken in debug mode X-Git-Tag: v0.22.0~735 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8336eb31ed54bcd73eadd993a15f488bdeb96de8;p=folly.git stack_trace_test was broken in debug mode Summary: A function was getting inlined in opt mode but not in debug mode. Test Plan: ran test Reviewed By: philipp@fb.com FB internal diff: D1130949 @override-unit-failures test fix only --- diff --git a/folly/experimental/symbolizer/Symbolizer.h b/folly/experimental/symbolizer/Symbolizer.h index 0c87ed77..c9341f4f 100644 --- a/folly/experimental/symbolizer/Symbolizer.h +++ b/folly/experimental/symbolizer/Symbolizer.h @@ -74,13 +74,20 @@ bool fixFrameArray(FrameArray& fa, ssize_t n) { } } // namespace detail +// Always inline these functions; they don't do much, and unittests rely +// on them never showing up in a stack trace. template -bool getStackTrace(FrameArray& fa) { +inline bool getStackTrace(FrameArray& fa) __attribute__((always_inline)); + +template +inline bool getStackTrace(FrameArray& fa) { return detail::fixFrameArray(fa, getStackTrace(fa.addresses, N)); } +template +inline bool getStackTraceSafe(FrameArray& fa) __attribute__((always_inline)); template -bool getStackTraceSafe(FrameArray& fa) { +inline bool getStackTraceSafe(FrameArray& fa) { return detail::fixFrameArray(fa, getStackTraceSafe(fa.addresses, N)); } diff --git a/folly/experimental/symbolizer/test/StackTraceTest.cpp b/folly/experimental/symbolizer/test/StackTraceTest.cpp index 730e68ea..a7241256 100644 --- a/folly/experimental/symbolizer/test/StackTraceTest.cpp +++ b/folly/experimental/symbolizer/test/StackTraceTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2013 Facebook, Inc. + * Copyright 2014 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,19 @@ void verifyStackTraces() { CHECK_EQ(fa.frameCount, faSafe.frameCount); + if (VLOG_IS_ON(1)) { + Symbolizer symbolizer; + OStreamSymbolizePrinter printer(std::cerr, SymbolizePrinter::COLOR_IF_TTY); + + symbolizer.symbolize(fa); + VLOG(1) << "getStackTrace\n"; + printer.println(fa); + + symbolizer.symbolize(faSafe); + VLOG(1) << "getStackTraceSafe\n"; + printer.println(faSafe); + } + // Other than the top 2 frames (this one and getStackTrace / // getStackTraceSafe), the stack traces should be identical for (size_t i = 2; i < fa.frameCount; ++i) {