improve error reporting

This commit is contained in:
tg 2008-11-12 06:14:26 +00:00
parent 364a7d116a
commit c6bcbc7bb0

View File

@ -1,6 +1,6 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/aalloc.c,v 1.15 2008/11/12 06:12:56 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/aalloc.c,v 1.16 2008/11/12 06:14:26 tg Exp $");
/* mksh integration of aalloc */
@ -121,7 +121,7 @@ static long pagesz;
size += extra; \
} while (/* CONSTCOND */ 0)
static void adelete_leak(PArea, PBlock);
static void adelete_leak(PArea, PBlock, const char *);
static PBlock check_bp(PArea, const char *, TCookie);
static TPtr *check_ptr(void *, PArea, PBlock *, const char *, const char *);
@ -279,7 +279,7 @@ track_check(void)
AALLOC_WARN("leaking empty area %p (%p %lu)", ap,
bp, (unsigned long)(bp->endp - (char *)bp));
} else
adelete_leak(ap, bp);
adelete_leak(ap, bp, "at exit");
free(bp);
track_next:
track = (PArea)ap->prev.pv;
@ -289,7 +289,7 @@ track_check(void)
#endif
static void
adelete_leak(PArea ap, PBlock bp)
adelete_leak(PArea ap, PBlock bp, const char *when)
{
TPtr *cp;
@ -297,10 +297,10 @@ adelete_leak(PArea ap, PBlock bp)
bp->last -= PVALIGN;
cp = *((void **)bp->last);
cp->iv ^= bp->cookie;
AALLOC_WARN("leaking %s pointer %p in area %p (%p %lu)",
AALLOC_WARN("leaking %s pointer %p in area %p (%p %lu) %s",
cp->pv == bp->last ? "valid" : "underflown",
(char *)cp + PVALIGN, ap, bp,
(unsigned long)(bp->endp - (char *)bp));
(unsigned long)(bp->endp - (char *)bp), when);
free(cp);
}
}
@ -316,7 +316,7 @@ adelete(PArea *pap)
/* ignore invalid areas */
if ((bp = check_bp(*pap, "adelete", 0)) != NULL) {
if (bp->last != (char *)&bp->storage)
adelete_leak(*pap, bp);
adelete_leak(*pap, bp, "in adelete");
free(bp);
}