X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/0c2634fcd1d84b99d20ef77de231400d450a99dd..c39e6ab0a7545b7ae425e21f045aa689291b268e:/deb.c diff --git a/deb.c b/deb.c index 381fc52..6a5a21c 100644 --- a/deb.c +++ b/deb.c @@ -1,6 +1,6 @@ /* deb.c * - * Copyright (c) 1991-1994, Larry Wall + * Copyright (c) 1991-2002, Larry Wall * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -13,120 +13,114 @@ */ #include "EXTERN.h" +#define PERL_IN_DEB_C #include "perl.h" -#ifdef DEBUGGING -#if !defined(I_STDARG) && !defined(I_VARARGS) - -/* - * Fallback on the old hackers way of doing varargs - */ - -/*VARARGS1*/ +#if defined(PERL_IMPLICIT_CONTEXT) void -deb(pat,a1,a2,a3,a4,a5,a6,a7,a8) - char *pat; +Perl_deb_nocontext(const char *pat, ...) { - register I32 i; - GV* gv = curcop->cop_filegv; - - fprintf(Perl_debug_log,"(%s:%ld)\t", - SvTYPE(gv) == SVt_PVGV ? SvPVX(GvSV(gv)) : "", - (long)curcop->cop_line); - for (i=0; icop_filegv; - - fprintf(Perl_debug_log,"(%s:%ld)\t", - SvTYPE(gv) == SVt_PVGV ? SvPVX(GvSV(gv)) : "", - (long)curcop->cop_line); - for (i=0; i"), + (long)CopLINE(PL_curcop)); +#else + PerlIO_printf(Perl_debug_log, "(%s:%ld)\t", (file ? file : ""), + (long)CopLINE(PL_curcop)); +#endif /* USE_5005THREADS */ + (void) PerlIO_vprintf(Perl_debug_log, pat, *args); +#endif /* DEBUGGING */ } I32 -debstackptrs() +Perl_debstackptrs(pTHX) { - fprintf(Perl_debug_log, "%8lx %8lx %8ld %8ld %8ld\n", - (unsigned long)curstack, (unsigned long)stack_base, - (long)*markstack_ptr, (long)(stack_sp-stack_base), - (long)(stack_max-stack_base)); - fprintf(Perl_debug_log, "%8lx %8lx %8ld %8ld %8ld\n", - (unsigned long)mainstack, (unsigned long)AvARRAY(curstack), - (long)mainstack, (long)AvFILL(curstack), (long)AvMAX(curstack)); +#ifdef DEBUGGING + PerlIO_printf(Perl_debug_log, + "%8"UVxf" %8"UVxf" %8"IVdf" %8"IVdf" %8"IVdf"\n", + PTR2UV(PL_curstack), PTR2UV(PL_stack_base), + (IV)*PL_markstack_ptr, (IV)(PL_stack_sp-PL_stack_base), + (IV)(PL_stack_max-PL_stack_base)); + PerlIO_printf(Perl_debug_log, + "%8"UVxf" %8"UVxf" %8"UVuf" %8"UVuf" %8"UVuf"\n", + PTR2UV(PL_mainstack), PTR2UV(AvARRAY(PL_curstack)), + PTR2UV(PL_mainstack), PTR2UV(AvFILLp(PL_curstack)), + PTR2UV(AvMAX(PL_curstack))); +#endif /* DEBUGGING */ return 0; } I32 -debstack() +Perl_debstack(pTHX) { - I32 top = stack_sp - stack_base; +#ifndef SKIP_DEBUGGING + I32 top = PL_stack_sp - PL_stack_base; register I32 i = top - 30; - I32 *markscan = markstack; + I32 *markscan = PL_markstack + PL_curstackinfo->si_markoff; + + if (CopSTASH_eq(PL_curcop, PL_debstash) && !DEBUG_J_TEST_) + return 0; if (i < 0) i = 0; - while (++markscan <= markstack_ptr) + while (++markscan <= PL_markstack_ptr) if (*markscan >= i) break; - fprintf(Perl_debug_log, i ? " => ... " : " => "); - if (stack_base[0] != &sv_undef || stack_sp < stack_base) - fprintf(Perl_debug_log, " [STACK UNDERFLOW!!!]\n"); +#ifdef USE_5005THREADS + PerlIO_printf(Perl_debug_log, + i ? "0x%"UVxf" => ... " : "0x%lx => ", + PTR2UV(thr)); +#else + PerlIO_printf(Perl_debug_log, i ? " => ... " : " => "); +#endif /* USE_5005THREADS */ + if (PL_stack_base[0] != &PL_sv_undef || PL_stack_sp < PL_stack_base) + PerlIO_printf(Perl_debug_log, " [STACK UNDERFLOW!!!]\n"); do { ++i; - if (markscan <= markstack_ptr && *markscan < i) { + if (markscan <= PL_markstack_ptr && *markscan < i) { do { ++markscan; - putc('*', Perl_debug_log); + PerlIO_putc(Perl_debug_log, '*'); } - while (markscan <= markstack_ptr && *markscan < i); - fprintf(Perl_debug_log, " "); + while (markscan <= PL_markstack_ptr && *markscan < i); + PerlIO_printf(Perl_debug_log, " "); } if (i > top) break; - fprintf(Perl_debug_log, "%-4s ", SvPEEK(stack_base[i])); + PerlIO_printf(Perl_debug_log, "%-4s ", SvPEEK(PL_stack_base[i])); } while (1); - fprintf(Perl_debug_log, "\n"); + PerlIO_printf(Perl_debug_log, "\n"); +#endif /* SKIP_DEBUGGING */ return 0; } -#else -static int dummy; /* avoid totally empty deb.o file */ -#endif /* DEBUGGING */