This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.0 alpha 2
[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
40#ifdef I_VARARGS
41# include <varargs.h>
42#endif
43
44void deb_growlevel();
45
46# ifndef I_VARARGS
47/*VARARGS1*/
48void deb(pat,a1,a2,a3,a4,a5,a6,a7,a8)
49char *pat;
50{
51 register I32 i;
52
53 fprintf(stderr,"%-4ld",(long)curop->cop_line);
54 for (i=0; i<dlevel; i++)
55 fprintf(stderr,"%c%c ",debname[i],debdelim[i]);
56 fprintf(stderr,pat,a1,a2,a3,a4,a5,a6,a7,a8);
57}
58# else
59/*VARARGS1*/
60void deb(va_alist)
61va_dcl
62{
63 va_list args;
64 char *pat;
65 register I32 i;
66
67 va_start(args);
68 fprintf(stderr,"%-4ld",(long)curcop->cop_line);
69 for (i=0; i<dlevel; i++)
70 fprintf(stderr,"%c%c ",debname[i],debdelim[i]);
71
72 pat = va_arg(args, char *);
73 (void) vfprintf(stderr,pat,args);
74 va_end( args );
75}
76# endif
77
78void
79deb_growlevel()
80{
81 dlmax += 128;
82 Renew(debname, dlmax, char);
83 Renew(debdelim, dlmax, char);
84}
85
86I32
87debstackptrs()
88{
89 fprintf(stderr, "%8lx %8lx %8ld %8ld %8ld\n",
90 stack, stack_base, *markstack_ptr, stack_sp-stack_base, stack_max-stack_base);
91 fprintf(stderr, "%8lx %8lx %8ld %l8d %8ld\n",
92 mainstack, AvARRAY(stack), mainstack, AvFILL(stack), AvMAX(stack));
93 return 0;
94}
95
96I32
97debstack()
98{
99 register I32 i;
100 I32 markoff = markstack_ptr > markstack ? *markstack_ptr : -1;
101
102 fprintf(stderr, " =>");
103 if (stack_base[0] || stack_sp < stack_base)
104 fprintf(stderr, " [STACK UNDERFLOW!!!]\n");
105 for (i = 1; i <= 30; i++) {
106 if (stack_sp >= &stack_base[i])
107 {
108 fprintf(stderr, "\t%-4s%s%s", SvPEEK(stack_base[i]),
109 markoff == i ? " [" : "",
110 stack_sp == &stack_base[i] ?
111 (markoff == i ? "]" : " ]") : "");
112 }
113 }
114 fprintf(stderr, "\n");
115 return 0;
116}