proxygen
folly::symbolizer::FDSymbolizePrinter Class Reference

#include <Symbolizer.h>

Inheritance diagram for folly::symbolizer::FDSymbolizePrinter:
folly::symbolizer::SymbolizePrinter

Public Member Functions

 FDSymbolizePrinter (int fd, int options=0, size_t bufferSize=0)
 
 ~FDSymbolizePrinter () override
 
virtual void flush () override
 
- Public Member Functions inherited from folly::symbolizer::SymbolizePrinter
void print (uintptr_t address, const SymbolizedFrame &frame)
 
void println (uintptr_t address, const SymbolizedFrame &frame)
 
void println (const uintptr_t *addresses, const SymbolizedFrame *frames, size_t frameCount)
 
void print (StringPiece sp)
 
template<size_t N>
void println (const FrameArray< N > &fa, size_t skip=0)
 
virtual ~SymbolizePrinter ()
 
void color (Color c)
 

Private Member Functions

void doPrint (StringPiece sp) override
 

Private Attributes

const int fd_
 
std::unique_ptr< IOBufbuffer_
 

Additional Inherited Members

- Public Types inherited from folly::symbolizer::SymbolizePrinter
enum  Options {
  NO_FILE_AND_LINE = 1 << 0, TERSE = 1 << 1, COLOR = 1 << 2, COLOR_IF_TTY = 1 << 3,
  NO_FRAME_ADDRESS = 1 << 4
}
 
enum  Color {
  DEFAULT, RED, GREEN, YELLOW,
  BLUE, CYAN, WHITE, PURPLE,
  NUM
}
 
- Protected Member Functions inherited from folly::symbolizer::SymbolizePrinter
 SymbolizePrinter (int options, bool isTty=false)
 
- Protected Attributes inherited from folly::symbolizer::SymbolizePrinter
const int options_
 
const bool isTty_
 

Detailed Description

Print a list of symbolized addresses to a file descriptor. Ignores errors. Async-signal-safe.

Definition at line 287 of file Symbolizer.h.

Constructor & Destructor Documentation

folly::symbolizer::FDSymbolizePrinter::FDSymbolizePrinter ( int  fd,
int  options = 0,
size_t  bufferSize = 0 
)
explicit

Definition at line 367 of file Symbolizer.cpp.

368  : SymbolizePrinter(options, isColorfulTty(options, fd)),
369  fd_(fd),
370  buffer_(bufferSize ? IOBuf::create(bufferSize) : nullptr) {}
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
std::unique_ptr< IOBuf > buffer_
Definition: Symbolizer.h:297
SymbolizePrinter(int options, bool isTty=false)
Definition: Symbolizer.h:248
folly::symbolizer::FDSymbolizePrinter::~FDSymbolizePrinter ( )
override

Definition at line 372 of file Symbolizer.cpp.

References flush().

372  {
373  flush();
374 }

Member Function Documentation

void folly::symbolizer::FDSymbolizePrinter::doPrint ( StringPiece  sp)
overrideprivatevirtual

Implements folly::symbolizer::SymbolizePrinter.

Definition at line 376 of file Symbolizer.cpp.

References buffer_, folly::Range< Iter >::data(), fd_, flush(), folly::Range< Iter >::size(), and folly::writeFull().

376  {
377  if (buffer_) {
378  if (sp.size() > buffer_->tailroom()) {
379  flush();
380  writeFull(fd_, sp.data(), sp.size());
381  } else {
382  memcpy(buffer_->writableTail(), sp.data(), sp.size());
383  buffer_->append(sp.size());
384  }
385  } else {
386  writeFull(fd_, sp.data(), sp.size());
387  }
388 }
std::unique_ptr< IOBuf > buffer_
Definition: Symbolizer.h:297
ssize_t writeFull(int fd, const void *buf, size_t count)
Definition: FileUtil.cpp:134
void folly::symbolizer::FDSymbolizePrinter::flush ( )
overridevirtual

If output buffered inside this class, send it to the output stream, so that any output done in other ways appears after this.

Reimplemented from folly::symbolizer::SymbolizePrinter.

Definition at line 390 of file Symbolizer.cpp.

References buffer_, fd_, and folly::writeFull().

Referenced by doPrint(), folly::symbolizer::SafeStackTracePrinter::flush(), and ~FDSymbolizePrinter().

390  {
391  if (buffer_ && !buffer_->empty()) {
392  writeFull(fd_, buffer_->data(), buffer_->length());
393  buffer_->clear();
394  }
395 }
std::unique_ptr< IOBuf > buffer_
Definition: Symbolizer.h:297
ssize_t writeFull(int fd, const void *buf, size_t count)
Definition: FileUtil.cpp:134

Member Data Documentation

std::unique_ptr<IOBuf> folly::symbolizer::FDSymbolizePrinter::buffer_
private

Definition at line 297 of file Symbolizer.h.

Referenced by doPrint(), and flush().

const int folly::symbolizer::FDSymbolizePrinter::fd_
private

Definition at line 296 of file Symbolizer.h.

Referenced by doPrint(), and flush().


The documentation for this class was generated from the following files: