Change 19832 by [EMAIL PROTECTED] on 2003/06/20 07:43:48
Show the source code location of an "assertion botch".
Affected files ...
... //depot/perl/malloc.c#98 edit
Differences ...
==== //depot/perl/malloc.c#98 (text) ====
Index: perl/malloc.c
--- perl/malloc.c#97~19831~ Fri Jun 20 00:31:11 2003
+++ perl/malloc.c Fri Jun 20 00:43:48 2003
@@ -962,7 +962,7 @@
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 @@
#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();
}
End of Patch.