[compiler-rt] 5759e3c - [scudo] Add mallopt to print stats to the log.
Christopher Ferris via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 16 13:34:55 PDT 2023
Author: Christopher Ferris
Date: 2023-06-16T13:34:45-07:00
New Revision: 5759e3ce6d03a8363779df2efea554a15ff61047
URL: https://github.com/llvm/llvm-project/commit/5759e3ce6d03a8363779df2efea554a15ff61047
DIFF: https://github.com/llvm/llvm-project/commit/5759e3ce6d03a8363779df2efea554a15ff61047.diff
LOG: [scudo] Add mallopt to print stats to the log.
Reviewed By: Chia-hungDuan
Differential Revision: https://reviews.llvm.org/D153094
Added:
Modified:
compiler-rt/lib/scudo/standalone/include/scudo/interface.h
compiler-rt/lib/scudo/standalone/wrappers_c.inc
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/include/scudo/interface.h b/compiler-rt/lib/scudo/standalone/include/scudo/interface.h
index 3c083ed7f9da2..6c0c521f8d82f 100644
--- a/compiler-rt/lib/scudo/standalone/include/scudo/interface.h
+++ b/compiler-rt/lib/scudo/standalone/include/scudo/interface.h
@@ -159,6 +159,11 @@ size_t __scudo_get_ring_buffer_size(void);
#define M_MEMTAG_TUNING_UAF 1
#endif
+// Print internal stats to the log.
+#ifndef M_LOG_STATS
+#define M_LOG_STATS -205
+#endif
+
} // extern "C"
#endif // SCUDO_INTERFACE_H_
diff --git a/compiler-rt/lib/scudo/standalone/wrappers_c.inc b/compiler-rt/lib/scudo/standalone/wrappers_c.inc
index 3e495eaa4a39e..2c8e382dba0b0 100644
--- a/compiler-rt/lib/scudo/standalone/wrappers_c.inc
+++ b/compiler-rt/lib/scudo/standalone/wrappers_c.inc
@@ -196,6 +196,9 @@ INTERFACE WEAK int SCUDO_PREFIX(mallopt)(int param, int value) {
} else if (param == M_PURGE_ALL) {
SCUDO_ALLOCATOR.releaseToOS(scudo::ReleaseToOS::ForceAll);
return 1;
+ } else if (param == M_LOG_STATS) {
+ SCUDO_ALLOCATOR.printStats();
+ return 1;
} else {
scudo::Option option;
switch (param) {
More information about the llvm-commits
mailing list