Commit c5d1c45f authored by Chad Austin's avatar Chad Austin Committed by Facebook GitHub Bot

remove some FOLLY_USE_SYMBOLIZER checks

Summary: Refine some guards to be more precise.

Reviewed By: yfeldblum, luciang

Differential Revision: D23361317

fbshipit-source-id: 806d899890c990a840c4275fb1180e45a944715d
parent 5c3b9d59
...@@ -53,11 +53,11 @@ ...@@ -53,11 +53,11 @@
#include <link.h> #include <link.h>
#endif #endif
#if defined(__linux__) && FOLLY_USE_SYMBOLIZER #if defined(__linux__) && FOLLY_HAVE_ELF && FOLLY_HAVE_DWARF
static struct r_debug* get_r_debug() { FOLLY_MAYBE_UNUSED static struct r_debug* get_r_debug() {
return &_r_debug; return &_r_debug;
} }
#elif FOLLY_USE_SYMBOLIZER #elif defined(__APPLE__)
extern struct r_debug _r_debug; extern struct r_debug _r_debug;
FOLLY_MAYBE_UNUSED static struct r_debug* get_r_debug() { FOLLY_MAYBE_UNUSED static struct r_debug* get_r_debug() {
return &_r_debug; return &_r_debug;
...@@ -292,8 +292,6 @@ void FastStackTracePrinter::flush() { ...@@ -292,8 +292,6 @@ void FastStackTracePrinter::flush() {
#endif // FOLLY_HAVE_ELF && FOLLY_HAVE_DWARF #endif // FOLLY_HAVE_ELF && FOLLY_HAVE_DWARF
#if FOLLY_USE_SYMBOLIZER
SafeStackTracePrinter::SafeStackTracePrinter(int fd) SafeStackTracePrinter::SafeStackTracePrinter(int fd)
: fd_(fd), : fd_(fd),
printer_( printer_(
...@@ -308,7 +306,7 @@ void SafeStackTracePrinter::flush() { ...@@ -308,7 +306,7 @@ void SafeStackTracePrinter::flush() {
} }
void SafeStackTracePrinter::printSymbolizedStackTrace() { void SafeStackTracePrinter::printSymbolizedStackTrace() {
#if FOLLY_HAVE_ELF #if FOLLY_HAVE_ELF && FOLLY_HAVE_DWARF
// This function might run on an alternative stack allocated by // This function might run on an alternative stack allocated by
// UnsafeSelfAllocateStackTracePrinter. Capturing a stack from // UnsafeSelfAllocateStackTracePrinter. Capturing a stack from
// here is probably wrong. // here is probably wrong.
...@@ -326,14 +324,7 @@ void SafeStackTracePrinter::printSymbolizedStackTrace() { ...@@ -326,14 +324,7 @@ void SafeStackTracePrinter::printSymbolizedStackTrace() {
// Leaving signalHandler on the stack for clarity, I think. // Leaving signalHandler on the stack for clarity, I think.
printer_.println(*addresses_, 2); printer_.println(*addresses_, 2);
#else #else
// `backtrace_symbols_fd` from execinfo.h is not explicitly printUnsymbolizedStackTrace();
// documented on either macOS or Linux to be async-signal-safe, but
// the implementation in opensource.apple.com Libc-1353.60.8 appears
// safe.
::backtrace_symbols_fd(
reinterpret_cast<void**>(addresses_->addresses),
addresses_->frameCount,
fd_);
#endif #endif
} }
...@@ -467,7 +458,5 @@ void UnsafeSelfAllocateStackTracePrinter::printSymbolizedStackTrace() { ...@@ -467,7 +458,5 @@ void UnsafeSelfAllocateStackTracePrinter::printSymbolizedStackTrace() {
#endif // FOLLY_HAVE_SWAPCONTEXT #endif // FOLLY_HAVE_SWAPCONTEXT
#endif // FOLLY_USE_SYMBOLIZER
} // namespace symbolizer } // namespace symbolizer
} // namespace folly } // namespace folly
...@@ -191,8 +191,6 @@ class FastStackTracePrinter { ...@@ -191,8 +191,6 @@ class FastStackTracePrinter {
#endif // FOLLY_HAVE_ELF && FOLLY_HAVE_DWARF #endif // FOLLY_HAVE_ELF && FOLLY_HAVE_DWARF
#if FOLLY_USE_SYMBOLIZER
/** /**
* Use this class to print a stack trace from a signal handler, or other place * Use this class to print a stack trace from a signal handler, or other place
* where you shouldn't allocate memory on the heap, and fsync()ing your file * where you shouldn't allocate memory on the heap, and fsync()ing your file
...@@ -262,7 +260,5 @@ class UnsafeSelfAllocateStackTracePrinter : public SafeStackTracePrinter { ...@@ -262,7 +260,5 @@ class UnsafeSelfAllocateStackTracePrinter : public SafeStackTracePrinter {
#endif // FOLLY_HAVE_SWAPCONTEXT #endif // FOLLY_HAVE_SWAPCONTEXT
#endif // FOLLY_USE_SYMBOLIZER
} // namespace symbolizer } // namespace symbolizer
} // namespace folly } // namespace folly
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