From 257b164e6efae6ce5d3046c1b7621df65836661b Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Wed, 31 May 2023 12:55:02 -0600 Subject: [PATCH] XXX util add thread to mem_log --- util.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/util.c b/util.c index c30588520f4d..3b1f60c755c3 100644 --- a/util.c +++ b/util.c @@ -4940,32 +4940,43 @@ S_mem_log_common(enum mem_log_type mlt, const UV n, MEM_LOG_TIME_FMT, MEM_LOG_TIME_ARG); PERL_UNUSED_RESULT(PerlLIO_write(fd, buf, len)); } +# ifdef USE_THREADS +# define ATHXf "%p: " +# define my_aTHX_ aTHX_ +# else +# define ATHXf +# define my_aTHX_ +# endif switch (mlt) { case MLT_ALLOC: len = my_snprintf(buf, sizeof(buf), - "alloc: %s:%d:%s: %" IVdf " %" UVuf + ATHXf "alloc: %s:%d:%s: %" IVdf " %" UVuf " %s = %" IVdf ": %" UVxf "\n", + my_aTHX_ filename, linenumber, funcname, n, typesize, type_name, n * typesize, PTR2UV(newalloc)); break; case MLT_REALLOC: len = my_snprintf(buf, sizeof(buf), - "realloc: %s:%d:%s: %" IVdf " %" UVuf + ATHXf "realloc: %s:%d:%s: %" IVdf " %" UVuf " %s = %" IVdf ": %" UVxf " -> %" UVxf "\n", + my_aTHX_ filename, linenumber, funcname, n, typesize, type_name, n * typesize, PTR2UV(oldalloc), PTR2UV(newalloc)); break; case MLT_FREE: len = my_snprintf(buf, sizeof(buf), - "free: %s:%d:%s: %" UVxf "\n", + ATHXf "free: %s:%d:%s: %" UVxf "\n", + my_aTHX_ filename, linenumber, funcname, PTR2UV(oldalloc)); break; case MLT_NEW_SV: case MLT_DEL_SV: len = my_snprintf(buf, sizeof(buf), - "%s_SV: %s:%d:%s: %" UVxf SV_LOG_SERIAL_FMT "\n", + ATHXf "%s_SV: %s:%d:%s: %" UVxf SV_LOG_SERIAL_FMT "\n", + my_aTHX_ mlt == MLT_NEW_SV ? "new" : "del", filename, linenumber, funcname, PTR2UV(sv) _SV_LOG_SERIAL_ARG(sv));