From: Jarkko Hietaniemi Date: Fri, 20 Jun 2003 07:43:48 +0000 (+0000) Subject: Show the source code location of an "assertion botch". X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=066d1a89330dfaa74b5c19223bbd3a266ca4fab3;p=p5sagit%2Fp5-mst-13.2.git Show the source code location of an "assertion botch". p4raw-id: //depot/perl@19832 --- diff --git a/malloc.c b/malloc.c index d39927a..0e6e642 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(); }