Add getmnt() to nosuid checking.
[p5sagit/p5-mst-13.2.git] / deb.c
1 /*    deb.c
2  *
3  *    Copyright (c) 1991-1999, Larry Wall
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  *
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
13  */
14
15 #include "EXTERN.h"
16 #define PERL_IN_DEB_C
17 #include "perl.h"
18
19 #if defined(PERL_IMPLICIT_CONTEXT)
20 void
21 Perl_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
33 void
34 Perl_deb(pTHX_ const char *pat, ...)
35 {
36 #ifdef DEBUGGING
37     va_list args;
38     va_start(args, pat);
39     vdeb(pat, &args);
40     va_end(args);
41 #endif /* DEBUGGING */
42 }
43
44 void
45 Perl_vdeb(pTHX_ const char *pat, va_list *args)
46 {
47 #ifdef DEBUGGING
48     dTHR;
49     register I32 i;
50     GV* gv = PL_curcop->cop_filegv;
51
52 #ifdef USE_THREADS
53     PerlIO_printf(Perl_debug_log, "0x%"UVxf" (%s:%ld)\t",
54                   PTR2UV(thr),
55                   SvTYPE(gv) == SVt_PVGV ? SvPVX(GvSV(gv)) : "<free>",
56                   (long)PL_curcop->cop_line);
57 #else
58     PerlIO_printf(Perl_debug_log, "(%s:%ld)\t",
59         SvTYPE(gv) == SVt_PVGV ? SvPVX(GvSV(gv)) : "<free>",
60         (long)PL_curcop->cop_line);
61 #endif /* USE_THREADS */
62     for (i=0; i<PL_dlevel; i++)
63         PerlIO_printf(Perl_debug_log, "%c%c ",PL_debname[i],PL_debdelim[i]);
64     (void) PerlIO_vprintf(Perl_debug_log, pat, *args);
65 #endif /* DEBUGGING */
66 }
67
68 void
69 Perl_deb_growlevel(pTHX)
70 {
71 #ifdef DEBUGGING
72     PL_dlmax += 128;
73     Renew(PL_debname, PL_dlmax, char);
74     Renew(PL_debdelim, PL_dlmax, char);
75 #endif /* DEBUGGING */
76 }
77
78 I32
79 Perl_debstackptrs(pTHX)
80 {
81 #ifdef DEBUGGING
82     dTHR;
83     PerlIO_printf(Perl_debug_log,
84                   "%8"UVxf" %8"UVxf" %8"IVdf" %8"IVdf" %8"IVdf"\n",
85                   PTR2UV(PL_curstack), PTR2UV(PL_stack_base),
86                   (IV)*PL_markstack_ptr, (IV)(PL_stack_sp-PL_stack_base),
87                   (IV)(PL_stack_max-PL_stack_base));
88     PerlIO_printf(Perl_debug_log,
89                   "%8"UVxf" %8"UVxf" %8"UVuf" %8"UVuf" %8"UVuf"\n",
90                   PTR2UV(PL_mainstack), PTR2UV(AvARRAY(PL_curstack)),
91                   PTR2UV(PL_mainstack), PTR2UV(AvFILLp(PL_curstack)),
92                   PTR2UV(AvMAX(PL_curstack)));
93 #endif /* DEBUGGING */
94     return 0;
95 }
96
97 I32
98 Perl_debstack(pTHX)
99 {
100 #ifdef DEBUGGING
101     dTHR;
102     I32 top = PL_stack_sp - PL_stack_base;
103     register I32 i = top - 30;
104     I32 *markscan = PL_curstackinfo->si_markbase;
105
106     if (i < 0)
107         i = 0;
108     
109     while (++markscan <= PL_markstack_ptr)
110         if (*markscan >= i)
111             break;
112
113 #ifdef USE_THREADS
114     PerlIO_printf(Perl_debug_log,
115                   i ? "0x%"UVxf"    =>  ...  " : "0x%lx    =>  ",
116                   PTR2UV(thr));
117 #else
118     PerlIO_printf(Perl_debug_log, i ? "    =>  ...  " : "    =>  ");
119 #endif /* USE_THREADS */
120     if (PL_stack_base[0] != &PL_sv_undef || PL_stack_sp < PL_stack_base)
121         PerlIO_printf(Perl_debug_log, " [STACK UNDERFLOW!!!]\n");
122     do {
123         ++i;
124         if (markscan <= PL_markstack_ptr && *markscan < i) {
125             do {
126                 ++markscan;
127                 PerlIO_putc(Perl_debug_log, '*');
128             }
129             while (markscan <= PL_markstack_ptr && *markscan < i);
130             PerlIO_printf(Perl_debug_log, "  ");
131         }
132         if (i > top)
133             break;
134         PerlIO_printf(Perl_debug_log, "%-4s  ", SvPEEK(PL_stack_base[i]));
135     }
136     while (1);
137     PerlIO_printf(Perl_debug_log, "\n");
138 #endif /* DEBUGGING */
139     return 0;
140 }