This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
BUG: Integer floatifies? +PATCH: reading BIG integers with SMALL floats
[perl5.git] / deb.c
CommitLineData
a0d0e21e 1/* deb.c
79072805 2 *
1761cee5 3 * Copyright (c) 1991-2000, Larry Wall
79072805
LW
4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
7 *
a0d0e21e
LW
8 */
9
10/*
11 * "Didst thou think that the eyes of the White Tower were blind? Nay, I
12 * have seen more than thou knowest, Gray Fool." --Denethor
79072805
LW
13 */
14
15#include "EXTERN.h"
864dbfa3 16#define PERL_IN_DEB_C
79072805
LW
17#include "perl.h"
18
c5be433b
GS
19#if defined(PERL_IMPLICIT_CONTEXT)
20void
21Perl_deb_nocontext(const char *pat, ...)
22{
23#ifdef DEBUGGING
24 dTHX;
25 va_list args;
26 va_start(args, pat);
27 vdeb(pat, &args);
28 va_end(args);
29#endif /* DEBUGGING */
30}
31#endif
32
8990e307 33void
864dbfa3 34Perl_deb(pTHX_ const char *pat, ...)
79072805 35{
17c3b450 36#ifdef DEBUGGING
79072805 37 va_list args;
c5be433b
GS
38 va_start(args, pat);
39 vdeb(pat, &args);
40 va_end(args);
41#endif /* DEBUGGING */
42}
43
44void
45Perl_vdeb(pTHX_ const char *pat, va_list *args)
46{
47#ifdef DEBUGGING
48 dTHR;
79072805 49 register I32 i;
cc49e20b 50 char* file = CopFILE(PL_curcop);
79072805 51
11343788 52#ifdef USE_THREADS
b900a521
JH
53 PerlIO_printf(Perl_debug_log, "0x%"UVxf" (%s:%ld)\t",
54 PTR2UV(thr),
cc49e20b
GS
55 (file ? file : "<free>"),
56 (long)CopLINE(PL_curcop));
11343788 57#else
cc49e20b
GS
58 PerlIO_printf(Perl_debug_log, "(%s:%ld)\t", (file ? file : "<free>"),
59 (long)CopLINE(PL_curcop));
11343788 60#endif /* USE_THREADS */
c5be433b 61 (void) PerlIO_vprintf(Perl_debug_log, pat, *args);
17c3b450 62#endif /* DEBUGGING */
79072805 63}
79072805 64
79072805 65I32
864dbfa3 66Perl_debstackptrs(pTHX)
79072805 67{
17c3b450 68#ifdef DEBUGGING
11343788 69 dTHR;
b900a521
JH
70 PerlIO_printf(Perl_debug_log,
71 "%8"UVxf" %8"UVxf" %8"IVdf" %8"IVdf" %8"IVdf"\n",
72 PTR2UV(PL_curstack), PTR2UV(PL_stack_base),
73 (IV)*PL_markstack_ptr, (IV)(PL_stack_sp-PL_stack_base),
74 (IV)(PL_stack_max-PL_stack_base));
75 PerlIO_printf(Perl_debug_log,
76 "%8"UVxf" %8"UVxf" %8"UVuf" %8"UVuf" %8"UVuf"\n",
77 PTR2UV(PL_mainstack), PTR2UV(AvARRAY(PL_curstack)),
78 PTR2UV(PL_mainstack), PTR2UV(AvFILLp(PL_curstack)),
79 PTR2UV(AvMAX(PL_curstack)));
17c3b450 80#endif /* DEBUGGING */
79072805
LW
81 return 0;
82}
83
84I32
864dbfa3 85Perl_debstack(pTHX)
79072805 86{
17c3b450 87#ifdef DEBUGGING
11343788 88 dTHR;
3280af22 89 I32 top = PL_stack_sp - PL_stack_base;
a0d0e21e 90 register I32 i = top - 30;
ce2f7c3b 91 I32 *markscan = PL_markstack + PL_curstackinfo->si_markoff;
a0d0e21e
LW
92
93 if (i < 0)
94 i = 0;
95
3280af22 96 while (++markscan <= PL_markstack_ptr)
a0d0e21e
LW
97 if (*markscan >= i)
98 break;
79072805 99
11343788 100#ifdef USE_THREADS
b900a521
JH
101 PerlIO_printf(Perl_debug_log,
102 i ? "0x%"UVxf" => ... " : "0x%lx => ",
103 PTR2UV(thr));
11343788 104#else
760ac839 105 PerlIO_printf(Perl_debug_log, i ? " => ... " : " => ");
11343788 106#endif /* USE_THREADS */
3280af22 107 if (PL_stack_base[0] != &PL_sv_undef || PL_stack_sp < PL_stack_base)
760ac839 108 PerlIO_printf(Perl_debug_log, " [STACK UNDERFLOW!!!]\n");
a0d0e21e
LW
109 do {
110 ++i;
3280af22 111 if (markscan <= PL_markstack_ptr && *markscan < i) {
a0d0e21e
LW
112 do {
113 ++markscan;
760ac839 114 PerlIO_putc(Perl_debug_log, '*');
a0d0e21e 115 }
3280af22 116 while (markscan <= PL_markstack_ptr && *markscan < i);
760ac839 117 PerlIO_printf(Perl_debug_log, " ");
79072805 118 }
a0d0e21e
LW
119 if (i > top)
120 break;
3280af22 121 PerlIO_printf(Perl_debug_log, "%-4s ", SvPEEK(PL_stack_base[i]));
79072805 122 }
a0d0e21e 123 while (1);
760ac839 124 PerlIO_printf(Perl_debug_log, "\n");
17c3b450 125#endif /* DEBUGGING */
79072805
LW
126 return 0;
127}