diff options
| author | Gregory Neil Shapiro <gshapiro@FreeBSD.org> | 2023-01-15 19:15:36 +0000 | 
|---|---|---|
| committer | Gregory Neil Shapiro <gshapiro@FreeBSD.org> | 2023-01-15 19:15:36 +0000 | 
| commit | 28fbd2825d216dafca4d991ad96d05b312f4f9a3 (patch) | |
| tree | 8b322391c58a9bd5ad56827bbb8fcf4cbd114917 /libsm/heap.c | |
| parent | 0694dcb04b81dfbd70ffe7384816863170a48b3e (diff) | |
Diffstat (limited to 'libsm/heap.c')
| -rw-r--r-- | libsm/heap.c | 27 | 
1 files changed, 22 insertions, 5 deletions
| diff --git a/libsm/heap.c b/libsm/heap.c index dd5e64b0bfdd..330739acef22 100644 --- a/libsm/heap.c +++ b/libsm/heap.c @@ -25,6 +25,13 @@ SM_RCSID("@(#)$Id: heap.c,v 1.52 2013-11-22 20:51:43 ca Exp $")  #include <sm/signal.h>  #include <sm/xtrap.h> +#if SM_HEAP_CHECK +# include <unistd.h> +# include <sm/types.h> +# include <sm/time.h> +# include <time.h> +#endif +  /* undef all macro versions of the "functions" so they can be specified here */  #undef sm_malloc  #undef sm_malloc_x @@ -458,7 +465,7 @@ sm_malloc_tagged_x(size, tag, num, group)  **	Parameters:  **		ptr -- pointer to register.  **		size -- size of requested memory. -**		tag -- tag for debugging. +**		tag -- tag for debugging (this is NOT copied!)  **		num -- additional value for debugging.  **		group -- heap group for debugging.  ** @@ -754,6 +761,9 @@ sm_heap_report(stream, verbosity)  {  	int i;  	unsigned long group0total, group1total, otherstotal, grandtotal; +	static char str[32] = "[1900-00-00/00:00:00] "; +	struct tm *tmp; +	time_t currt;  	if (!HEAP_CHECK || verbosity <= 0)  		return; @@ -804,11 +814,18 @@ sm_heap_report(stream, verbosity)  			hi = hi->hi_next;  		}  	} + +	currt = time((time_t *)0); +	tmp = localtime(&currt); +	snprintf(str, sizeof(str), "[%d-%02d-%02d/%02d:%02d:%02d] ", +		1900 + tmp->tm_year,	/* HACK */ +		tmp->tm_mon + 1, +		tmp->tm_mday, +		tmp->tm_hour, tmp->tm_min, tmp->tm_sec);  	sm_io_fprintf(stream, SM_TIME_DEFAULT, -		"heap max=%lu, total=%lu, ", -		(unsigned long) SmHeapMaxTotal, grandtotal); -	sm_io_fprintf(stream, SM_TIME_DEFAULT, -		"group 0=%lu, group 1=%lu, others=%lu\n", +		"pid=%ld time=%s\nheap max=%lu, total=%lu, group 0=%lu, group 1=%lu, others=%lu\n", +		(long) getpid(), str, +		(unsigned long) SmHeapMaxTotal, grandtotal,  		group0total, group1total, otherstotal);  	if (grandtotal != SmHeapTotal)  	{ | 
