This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.0 alpha 9
[perl5.git] / deb.c
CommitLineData
79072805
LW
1/* $RCSfile: op.c,v $$Revision: 4.1 $$Date: 92/08/07 17:19:16 $
2 *
3 * Copyright (c) 1991, 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 * $Log: op.c,v $
9 * Revision 4.1 92/08/07 17:19:16 lwall
10 * Stage 6 Snapshot
11 *
12 * Revision 4.0.1.5 92/06/08 12:00:39 lwall
13 * patch20: the switch optimizer didn't do anything in subroutines
14 * patch20: removed implicit int declarations on funcions
15 *
16 * Revision 4.0.1.4 91/11/11 16:29:33 lwall
17 * patch19: do {$foo ne "bar";} returned wrong value
18 * patch19: some earlier patches weren't propagated to alternate 286 code
19 *
20 * Revision 4.0.1.3 91/11/05 16:07:43 lwall
21 * patch11: random cleanup
22 * patch11: "foo\0" eq "foo" was sometimes optimized to true
23 * patch11: foreach on null list could spring memory leak
24 *
25 * Revision 4.0.1.2 91/06/07 10:26:45 lwall
26 * patch4: new copyright notice
27 * patch4: made some allowances for "semi-standard" C
28 *
29 * Revision 4.0.1.1 91/04/11 17:36:16 lwall
30 * patch1: you may now use "die" and "caller" in a signal handler
31 *
32 * Revision 4.0 91/03/20 01:04:18 lwall
33 * 4.0 baseline.
34 *
35 */
36
37#include "EXTERN.h"
38#include "perl.h"
39
79072805
LW
40void deb_growlevel();
41
8990e307
LW
42#if !defined(STANDARD_C) && !defined(I_VARARGS)
43
44/*
45 * Fallback on the old hackers way of doing varargs
46 */
47
79072805 48/*VARARGS1*/
8990e307
LW
49void
50deb(pat,a1,a2,a3,a4,a5,a6,a7,a8)
51 char *pat;
79072805
LW
52{
53 register I32 i;
54
8990e307
LW
55 fprintf(stderr,"(%s:%ld)\t",
56 SvPVX(GvSV(curcop->cop_filegv)),(long)curcop->cop_line);
79072805
LW
57 for (i=0; i<dlevel; i++)
58 fprintf(stderr,"%c%c ",debname[i],debdelim[i]);
59 fprintf(stderr,pat,a1,a2,a3,a4,a5,a6,a7,a8);
60}
8990e307
LW
61
62#else /* !defined(STANDARD_C) && !defined(I_VARARGS) */
63
64# ifdef STANDARD_C
65void
66deb(char *pat, ...)
79072805
LW
67# else
68/*VARARGS1*/
8990e307
LW
69void
70deb(pat, va_alist)
71 char *pat;
72 va_dcl
73# endif
79072805
LW
74{
75 va_list args;
79072805
LW
76 register I32 i;
77
8990e307
LW
78 fprintf(stderr,"(%s:%ld)\t",
79 SvPVX(GvSV(curcop->cop_filegv)),(long)curcop->cop_line);
79072805
LW
80 for (i=0; i<dlevel; i++)
81 fprintf(stderr,"%c%c ",debname[i],debdelim[i]);
82
8990e307
LW
83# if STANDARD_C
84 va_start(args, pat);
85# else
86 va_start(args);
87# endif
79072805
LW
88 (void) vfprintf(stderr,pat,args);
89 va_end( args );
90}
8990e307 91#endif /* !defined(STANDARD_C) && !defined(I_VARARGS) */
79072805
LW
92
93void
94deb_growlevel()
95{
96 dlmax += 128;
97 Renew(debname, dlmax, char);
98 Renew(debdelim, dlmax, char);
99}
100
101I32
102debstackptrs()
103{
104 fprintf(stderr, "%8lx %8lx %8ld %8ld %8ld\n",
105 stack, stack_base, *markstack_ptr, stack_sp-stack_base, stack_max-stack_base);
106 fprintf(stderr, "%8lx %8lx %8ld %l8d %8ld\n",
107 mainstack, AvARRAY(stack), mainstack, AvFILL(stack), AvMAX(stack));
108 return 0;
109}
110
111I32
112debstack()
113{
114 register I32 i;
115 I32 markoff = markstack_ptr > markstack ? *markstack_ptr : -1;
116
117 fprintf(stderr, " =>");
118 if (stack_base[0] || stack_sp < stack_base)
119 fprintf(stderr, " [STACK UNDERFLOW!!!]\n");
120 for (i = 1; i <= 30; i++) {
121 if (stack_sp >= &stack_base[i])
122 {
123 fprintf(stderr, "\t%-4s%s%s", SvPEEK(stack_base[i]),
124 markoff == i ? " [" : "",
125 stack_sp == &stack_base[i] ?
126 (markoff == i ? "]" : " ]") : "");
127 }
128 }
129 fprintf(stderr, "\n");
130 return 0;
131}