summaryrefslogtreecommitdiff
path: root/malloc.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-06-20 07:43:48 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-06-20 07:43:48 +0000
commit066d1a89330dfaa74b5c19223bbd3a266ca4fab3 (patch)
tree408cb41be2302433d1e4e972f24e3c5f5c164c85 /malloc.c
parent22f7c9c9717fe07b508ba0e9958ef0592cdbbeef (diff)
downloadperl-066d1a89330dfaa74b5c19223bbd3a266ca4fab3.tar.gz
Show the source code location of an "assertion botch".
p4raw-id: //depot/perl@19832
Diffstat (limited to 'malloc.c')
-rw-r--r--malloc.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/malloc.c b/malloc.c
index d39927add0..0e6e6420a7 100644
--- a/malloc.c
+++ b/malloc.c
@@ -962,7 +962,7 @@ static char bucket_of[] =
static void morecore (register int bucket);
# if defined(DEBUGGING)
-static void botch (char *diag, char *s);
+static void botch (char *diag, char *s, char *file, int line);
# endif
static void add_to_chain (void *p, MEM_SIZE size, MEM_SIZE chip);
static void* get_from_chain (MEM_SIZE size);
@@ -1261,23 +1261,30 @@ write2(char *mess)
#ifdef DEBUGGING
#undef ASSERT
-#define ASSERT(p,diag) if (!(p)) botch(diag,STRINGIFY(p)); else
+#define ASSERT(p,diag) if (!(p)) botch(diag,STRINGIFY(p),__FILE__,__LINE__); else
static void
-botch(char *diag, char *s)
+botch(char *diag, char *s, char *file, int line)
{
if (!(PERL_MAYBE_ALIVE && PERL_GET_THX))
goto do_write;
else {
dTHX;
+ char linebuf[10];
if (PerlIO_printf(PerlIO_stderr(),
- "assertion botched (%s?): %s\n", diag, s) != 0) {
+ "assertion botched (%s?): %s%s %s:%d\n",
+ diag, s, file, line) != 0) {
do_write: /* Can be initializing interpreter */
write2("assertion botched (");
write2(diag);
write2("?): ");
write2(s);
- write2("\n");
+ write2(" (");
+ write2(file);
+ write2(":");
+ sprintf(linebuf, "%d", line);
+ write2(linebuf);
+ write2(")\n");
}
PerlProc_abort();
}