proxygen
|
#include <Symbolizer.h>
Public Member Functions | |
SafeStackTracePrinter (size_t minSignalSafeElfCacheSize=kDefaultMinSignalSafeElfCacheSize, int fd=STDERR_FILENO) | |
virtual | ~SafeStackTracePrinter () |
FOLLY_NOINLINE void | printStackTrace (bool symbolize) |
void | print (StringPiece sp) |
void | flush () |
Static Public Attributes | |
static constexpr size_t | kDefaultMinSignalSafeElfCacheSize = 500 |
Protected Member Functions | |
virtual void | printSymbolizedStackTrace () |
Private Attributes | |
int | fd_ |
SignalSafeElfCache | elfCache_ |
FDSymbolizePrinter | printer_ |
std::unique_ptr< FrameArray< kMaxStackTraceDepth > > | addresses_ |
Static Private Attributes | |
static constexpr size_t | kMaxStackTraceDepth = 100 |
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 descriptor is more important than performance.
Make sure to create one of these on startup, not in the signal handler, as the constructor allocates on the heap, whereas the other methods don't. Best practice is to just leak this object, rather than worry about destruction order.
These methods aren't thread safe, so if you could have signals on multiple threads at the same time, you need to do your own locking to ensure you don't call these methods from multiple threads. They are signal safe, however.
Definition at line 351 of file Symbolizer.h.
|
explicit |
Definition at line 409 of file Symbolizer.cpp.
|
inlinevirtual |
void folly::symbolizer::SafeStackTracePrinter::flush | ( | ) |
Definition at line 420 of file Symbolizer.cpp.
References fd_, folly::symbolizer::FDSymbolizePrinter::flush(), folly::fsyncNoInt(), and printer_.
Referenced by printStackTrace().
|
inline |
Definition at line 371 of file Symbolizer.h.
Referenced by printStackTrace().
void folly::symbolizer::SafeStackTracePrinter::printStackTrace | ( | bool | symbolize | ) |
Only allocates on the stack and is signal-safe but not thread-safe. Don't call printStackTrace() on the same StackTracePrinter object from multiple threads at the same time.
This is NOINLINE to make sure it shows up in the stack we grab, which makes it easy to skip printing it.
Definition at line 443 of file Symbolizer.cpp.
References addresses_, flush(), folly::symbolizer::AddressFormatter::format(), folly::symbolizer::getStackTraceSafe(), i, print(), printSymbolizedStackTrace(), and SCOPE_EXIT.
|
protectedvirtual |
Reimplemented in folly::symbolizer::UnsafeSelfAllocateStackTracePrinter.
Definition at line 425 of file Symbolizer.cpp.
References addresses_, elfCache_, folly::symbolizer::Dwarf::FULL, printer_, folly::symbolizer::SymbolizePrinter::println(), and folly::symbolizer::Symbolizer::symbolize().
Referenced by printStackTrace().
|
private |
Definition at line 387 of file Symbolizer.h.
Referenced by printStackTrace(), and printSymbolizedStackTrace().
|
private |
Definition at line 385 of file Symbolizer.h.
Referenced by printSymbolizedStackTrace().
|
private |
Definition at line 384 of file Symbolizer.h.
Referenced by flush().
|
static |
Definition at line 353 of file Symbolizer.h.
|
staticprivate |
Definition at line 382 of file Symbolizer.h.
|
private |
Definition at line 386 of file Symbolizer.h.
Referenced by flush(), and printSymbolizedStackTrace().