Skip to content

Commit

Permalink
remove some FOLLY_USE_SYMBOLIZER checks
Browse files Browse the repository at this point in the history
Summary: Refine some guards to be more precise.

Reviewed By: yfeldblum, luciang

Differential Revision: D23361317

fbshipit-source-id: 806d899890c990a840c4275fb1180e45a944715d
  • Loading branch information
chadaustin authored and facebook-github-bot committed Sep 18, 2020
1 parent 5c3b9d5 commit c5d1c45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
21 changes: 5 additions & 16 deletions folly/experimental/symbolizer/Symbolizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
#include <link.h>
#endif

#if defined(__linux__) && FOLLY_USE_SYMBOLIZER
static struct r_debug* get_r_debug() {
#if defined(__linux__) && FOLLY_HAVE_ELF && FOLLY_HAVE_DWARF
FOLLY_MAYBE_UNUSED static struct r_debug* get_r_debug() {
return &_r_debug;
}
#elif FOLLY_USE_SYMBOLIZER
#elif defined(__APPLE__)
extern struct r_debug _r_debug;
FOLLY_MAYBE_UNUSED static struct r_debug* get_r_debug() {
return &_r_debug;
Expand Down Expand Up @@ -292,8 +292,6 @@ void FastStackTracePrinter::flush() {

#endif // FOLLY_HAVE_ELF && FOLLY_HAVE_DWARF

#if FOLLY_USE_SYMBOLIZER

SafeStackTracePrinter::SafeStackTracePrinter(int fd)
: fd_(fd),
printer_(
Expand All @@ -308,7 +306,7 @@ void SafeStackTracePrinter::flush() {
}

void SafeStackTracePrinter::printSymbolizedStackTrace() {
#if FOLLY_HAVE_ELF
#if FOLLY_HAVE_ELF && FOLLY_HAVE_DWARF
// This function might run on an alternative stack allocated by
// UnsafeSelfAllocateStackTracePrinter. Capturing a stack from
// here is probably wrong.
Expand All @@ -326,14 +324,7 @@ void SafeStackTracePrinter::printSymbolizedStackTrace() {
// Leaving signalHandler on the stack for clarity, I think.
printer_.println(*addresses_, 2);
#else
// `backtrace_symbols_fd` from execinfo.h is not explicitly
// 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_);
printUnsymbolizedStackTrace();
#endif
}

Expand Down Expand Up @@ -467,7 +458,5 @@ void UnsafeSelfAllocateStackTracePrinter::printSymbolizedStackTrace() {

#endif // FOLLY_HAVE_SWAPCONTEXT

#endif // FOLLY_USE_SYMBOLIZER

} // namespace symbolizer
} // namespace folly
4 changes: 0 additions & 4 deletions folly/experimental/symbolizer/Symbolizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ class FastStackTracePrinter {

#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
* where you shouldn't allocate memory on the heap, and fsync()ing your file
Expand Down Expand Up @@ -262,7 +260,5 @@ class UnsafeSelfAllocateStackTracePrinter : public SafeStackTracePrinter {

#endif // FOLLY_HAVE_SWAPCONTEXT

#endif // FOLLY_USE_SYMBOLIZER

} // namespace symbolizer
} // namespace folly

0 comments on commit c5d1c45

Please sign in to comment.