mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-29 13:28:14 +00:00
Theoretically fancier reference count history printer (needs more work)
This commit is contained in:
parent
e0de25c53b
commit
0ae2319345
@ -55,6 +55,11 @@ unsigned long dmalloc_cutoff_generation;
|
|||||||
#if defined (DEBUG_RC_HISTORY)
|
#if defined (DEBUG_RC_HISTORY)
|
||||||
struct rc_history_entry rc_history [RC_HISTORY_MAX];
|
struct rc_history_entry rc_history [RC_HISTORY_MAX];
|
||||||
int rc_history_index;
|
int rc_history_index;
|
||||||
|
int rc_history_count;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (DEBUG_RC_HISTORY)
|
||||||
|
static void print_rc_hist_entry (int);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
VOIDPTR dmalloc (size, file, line)
|
VOIDPTR dmalloc (size, file, line)
|
||||||
@ -119,6 +124,7 @@ VOIDPTR dmalloc (size, file, line)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
rc_register (file, line, 0, foo + DMDOFFSET, 1);
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,6 +185,7 @@ void dfree (ptr, file, line)
|
|||||||
ptr = bar;
|
ptr = bar;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
rc_register (file, line, 0, (unsigned char *)ptr + DMDOFFSET, 0);
|
||||||
free (ptr);
|
free (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,9 +287,41 @@ void dmalloc_dump_outstanding ()
|
|||||||
#if defined (DEBUG_MEMORY_LEAKAGE)
|
#if defined (DEBUG_MEMORY_LEAKAGE)
|
||||||
/* Don't count data that's actually on a free list
|
/* Don't count data that's actually on a free list
|
||||||
somewhere. */
|
somewhere. */
|
||||||
if (dp -> file)
|
if (dp -> file) {
|
||||||
log_info (" %s(%d): %d",
|
#if defined (DEBUG_RC_HISTORY)
|
||||||
dp -> file, dp -> line, dp -> size);
|
/* If we have the info, see if this is actually
|
||||||
|
new garbage. */
|
||||||
|
if (rc_history_count < RC_HISTORY_MAX) {
|
||||||
|
int i, printit = 0, inhistory = 0, prefcnt = 0;
|
||||||
|
i = rc_history_index - rc_history_count;
|
||||||
|
if (i < 0)
|
||||||
|
i += RC_HISTORY_MAX;
|
||||||
|
do {
|
||||||
|
if (rc_history [i].addr == dp + 1) {
|
||||||
|
if (rc_history [i].refcnt == 1 &&
|
||||||
|
prefcnt == 0 && !printit) {
|
||||||
|
printit = 1;
|
||||||
|
inhistory = 1;
|
||||||
|
log_info (" %s(%d): %d",
|
||||||
|
dp -> file,
|
||||||
|
dp -> line,
|
||||||
|
dp -> size);
|
||||||
|
}
|
||||||
|
prefcnt = rc_history [i].refcnt;
|
||||||
|
if (printit)
|
||||||
|
print_rc_hist_entry (i);
|
||||||
|
}
|
||||||
|
if (++i == RC_HISTORY_MAX)
|
||||||
|
i = 0;
|
||||||
|
} while (i != rc_history_index);
|
||||||
|
if (!inhistory)
|
||||||
|
log_info (" %s(%d): %d", dp -> file,
|
||||||
|
dp -> line, dp -> size);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
log_info (" %s(%d): %d",
|
||||||
|
dp -> file, dp -> line, dp -> size);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (dmalloc_list)
|
if (dmalloc_list)
|
||||||
@ -291,21 +330,37 @@ void dmalloc_dump_outstanding ()
|
|||||||
#endif /* DEBUG_MEMORY_LEAKAGE || DEBUG_MALLOC_POOL */
|
#endif /* DEBUG_MEMORY_LEAKAGE || DEBUG_MALLOC_POOL */
|
||||||
|
|
||||||
#if defined (DEBUG_RC_HISTORY)
|
#if defined (DEBUG_RC_HISTORY)
|
||||||
|
static void print_rc_hist_entry (int i)
|
||||||
|
{
|
||||||
|
log_info (" referenced by %s(%d)[%lx]: addr = %lx refcnt = %x",
|
||||||
|
rc_history [i].file, rc_history [i].line,
|
||||||
|
(unsigned long)rc_history [i].reference,
|
||||||
|
(unsigned long)rc_history [i].addr,
|
||||||
|
rc_history [i].refcnt);
|
||||||
|
}
|
||||||
|
|
||||||
void dump_rc_history ()
|
void dump_rc_history ()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = rc_history_index;
|
i = rc_history_index;
|
||||||
do {
|
if (!rc_history [i].file)
|
||||||
log_info (" referenced by %s(%d)[%lx]: addr = %lx refcnt = %x",
|
i = 0;
|
||||||
rc_history [i].file, rc_history [i].line,
|
else if (rc_history_count < RC_HISTORY_MAX) {
|
||||||
(unsigned long)rc_history [i].reference,
|
i -= rc_history_count;
|
||||||
(unsigned long)rc_history [i].addr,
|
if (i < 0)
|
||||||
rc_history [i].refcnt);
|
i += RC_HISTORY_MAX;
|
||||||
|
}
|
||||||
|
rc_history_count = 0;
|
||||||
|
|
||||||
|
while (rc_history [i].file) {
|
||||||
|
print_rc_hist_entry (i);
|
||||||
++i;
|
++i;
|
||||||
if (i == RC_HISTORY_MAX)
|
if (i == RC_HISTORY_MAX)
|
||||||
i = 0;
|
i = 0;
|
||||||
} while (i != rc_history_index && rc_history [i].file);
|
if (i == rc_history_index)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user