]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEV: gdb: add a memprofile decoder to the debug tools
authorWilly Tarreau <w@1wt.eu>
Wed, 16 Jul 2025 12:42:34 +0000 (14:42 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Jul 2025 13:33:33 +0000 (15:33 +0200)
"memprof_dump" will visit memprofile entries and dump them in a
synthetic format counting allocations/releases count/size, type
and calling address.

dev/gdb/memprof.dbg [new file with mode: 0644]

diff --git a/dev/gdb/memprof.dbg b/dev/gdb/memprof.dbg
new file mode 100644 (file)
index 0000000..8c6fd58
--- /dev/null
@@ -0,0 +1,19 @@
+# show non-null memprofile entries with method, alloc/free counts/tot and caller
+
+define memprof_dump
+  set $i = 0
+  set $meth={ "UNKN", "MALL", "CALL", "REAL", "STRD", "FREE", "P_AL", "P_FR", "STND", "VALL", "ALAL", "PALG", "MALG", "PVAL" }
+  while $i < sizeof(memprof_stats) / sizeof(memprof_stats[0])
+    if memprof_stats[$i].alloc_calls || memprof_stats[$i].free_calls
+      set $m = memprof_stats[$i].method
+      printf "m:%s ac:%u fc:%u at:%u ft:%u ", $meth[$m], \
+           memprof_stats[$i].alloc_calls, memprof_stats[$i].free_calls, \
+           memprof_stats[$i].alloc_tot, memprof_stats[$i].free_tot
+      output/a memprof_stats[$i].caller
+      printf "\n"
+    end
+    set $i = $i + 1
+  end
+end
+
+