[compiler-rt] [scudo] Add `__scudo_get_info` symbol to export stats to a buffer. (PR #130273)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 2 06:32:20 PDT 2025


================
@@ -35,6 +35,23 @@ __attribute__((weak)) void __scudo_realloc_deallocate_hook(void *old_ptr);
 
 void __scudo_print_stats(void);
 
+// Reports all allocators configuration and general statistics as a null
+// terminated text string.
+#ifndef M_INFO_TOPIC_STATS
+#define M_INFO_TOPIC_STATS 1
+#endif
+
+// Reports fragmentation statistics of the primary allocation as a null
+// terminated text string.
+#ifndef M_INFO_TOPIC_FRAGMENTATION
+#define M_INFO_TOPIC_FRAGMENTATION 2
+#endif
+
+// Writes allocator statistics to the buffer, truncating to the specified size
+// if necessary. Returns the full report size (before truncation) for buffer
+// sizing purpose, or zero if the topic is not supported.
+size_t __scudo_get_info(uint32_t topic, void *buffer, size_t size);
----------------
piwicode wrote:

Yes, I want to allow for future topic additions without altering the binary interface. This approach enables us to experiment with new topics and validate their usefulness before formally documenting them. It also provides a graceful way to deprecate topics without breaking existing callers or cluttering the symbol table.

https://github.com/llvm/llvm-project/pull/130273


More information about the llvm-commits mailing list