Harden failure signal handler in the face of memory corruptions
[folly.git] / folly / experimental / symbolizer / Symbolizer.h
index 5595a53..5a87f90 100644 (file)
@@ -128,6 +128,24 @@ class Symbolizer {
   ElfCacheBase* cache_;
 };
 
   ElfCacheBase* cache_;
 };
 
+/**
+ * Format one address in the way it's usually printer by SymbolizePrinter.
+ * Async-signal-safe.
+ */
+class AddressFormatter {
+ public:
+  AddressFormatter();
+
+  /**
+   * Format the address. Returns an internal buffer.
+   */
+  StringPiece format(uintptr_t address);
+
+ private:
+  static constexpr char bufTemplate[] = "    @ 0000000000000000";
+  char buf_[sizeof(bufTemplate)];
+};
+
 /**
  * Print a list of symbolized addresses. Base class.
  */
 /**
  * Print a list of symbolized addresses. Base class.
  */