]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Add smartalloc function to print the owner of a buffer
authorEric Bollengier <eric@baculasystems.com>
Fri, 14 Dec 2018 16:08:19 +0000 (17:08 +0100)
committerKern Sibbald <kern@sibbald.com>
Mon, 8 Apr 2019 16:43:39 +0000 (18:43 +0200)
bacula/src/lib/smartall.c
bacula/src/lib/smartall.h

index 49a8c9fe8f032253a488937e210a9fc3afc645f9..afe5699436bdb7e6336f1ac877bfec36175a74fb 100644 (file)
@@ -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
index 49af5816278278660f6cc2906d3eaf876fda3474..b524610cbbec20d60ba7e5963cd2b90c4dd00cb9 100644 (file)
@@ -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)