From: Eric Bollengier Date: Fri, 14 Dec 2018 16:08:19 +0000 (+0100) Subject: Add smartalloc function to print the owner of a buffer X-Git-Tag: Release-9.4.3~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63d571a0e5655da834a2b84a1c94a13cae075d39;p=thirdparty%2Fbacula.git Add smartalloc function to print the owner of a buffer --- diff --git a/bacula/src/lib/smartall.c b/bacula/src/lib/smartall.c index 49a8c9fe8..afe569943 100644 --- a/bacula/src/lib/smartall.c +++ b/bacula/src/lib/smartall.c @@ -161,6 +161,17 @@ void sm_new_owner(const char *fname, int lineno, char *buf) return; } +/* Print a debug message with the owner of a smartalloc buffer */ +void sm_get_owner(int64_t dbglvl, char *buf) +{ + /* Decrement to header */ + struct abufhead *h = (struct abufhead *) (buf - HEAD_SIZE); + Dmsg3(dbglvl, "%p from %s:%d\n", + buf + HEAD_SIZE, + NPRT(h->abfname), + h->ablineno); +} + /* SM_FREE -- Update free pool availability. FREE is never called except through this interface or by actuallyfree(). free(x) is defined to generate a call to this diff --git a/bacula/src/lib/smartall.h b/bacula/src/lib/smartall.h index 49af58162..b524610cb 100644 --- a/bacula/src/lib/smartall.h +++ b/bacula/src/lib/smartall.h @@ -49,7 +49,7 @@ extern void sm_free(const char *fname, int lineno, void *fp); extern void actuallyfree(void *cp), sm_dump(bool bufdump, bool in_use=false), sm_static(int mode); extern void sm_new_owner(const char *fname, int lineno, char *buf); - +extern void sm_get_owner(int64_t dbglvl, char *buf); #ifdef SMCHECK #define Dsm_check(lvl) if ((lvl)<=debug_level) sm_check(__FILE__, __LINE__, true) extern void sm_check(const char *fname, int lineno, bool bufdump); @@ -82,6 +82,7 @@ extern int sm_check_rtn(const char *fname, int lineno, bool bufdump); inline void sm_dump(int x, int y=0) {} /* with default arguments, we can't use a #define */ #define sm_static(x) #define sm_new_owner(a, b, c) +#define sm_get_owner(a,b) #define sm_malloc(f, l, n) malloc(n) #define sm_free(f, l, n) free(n) #define sm_check(f, l, fl)