Harden failure signal handler in the face of memory corruptions
[folly.git] / folly / experimental / symbolizer / Symbolizer.h
index 5595a53b67994270c9588de1561899ee7b41db1f..5a87f90b6b689c9364e3e82ff0c0467468760f87 100644 (file)
@@ -128,6 +128,24 @@ class Symbolizer {
   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.
  */