From d15143e2ce156219ab43dee4e71d44f007df6692 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 6 Apr 2024 21:49:54 +0000 Subject: support malloc tracing and replay To test and provide reproducable behavior of different mallocs, provide an architecture-specific tracing mechanism to write trace files. Since these traces, they're compressed by gzip(1) by default to avoid filling up hard drives of long-lived daemons. The compressor can be replaced with zstd or bzip2 via "trace_compress:zstd" in the comma-delimited MWRAP environment. The new mwrap-trace-replay command is designed to run with either jemalloc or glibc malloc to replay trace files. It can read uncompressed output via stdin or compressed files via gzip/zstd/bzip2. This doesn't work reliably in multi-threaded code, but I have fragmentation problems in single-threaded code. --- lib/Devel/Mwrap/trace_struct.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/Devel/Mwrap/trace_struct.h (limited to 'lib/Devel/Mwrap/trace_struct.h') diff --git a/lib/Devel/Mwrap/trace_struct.h b/lib/Devel/Mwrap/trace_struct.h new file mode 100644 index 0000000..e5fe622 --- /dev/null +++ b/lib/Devel/Mwrap/trace_struct.h @@ -0,0 +1,34 @@ +enum tr_fn { + TR_FREE = 0, + TR_MEMALIGN = 1, + TR_MALLOC = 2, + TR_REALLOC = 3, + TR_CALLOC = 4, +}; +static const uintptr_t TR_MASK = 7; + +struct tr_memalign { + uintptr_t ret; + size_t alignment; + size_t size; +}; + +struct tr_free { + uintptr_t ptr; +}; + +struct tr_malloc { + uintptr_t ret; + size_t size; +}; + +struct tr_realloc { + uintptr_t ret; + uintptr_t ptr; + size_t size; +}; + +struct tr_calloc { + uintptr_t ret; + size_t size; +}; -- cgit v1.2.3-24-ge0c7