This repository was archived by the owner on Nov 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patherror.c
155 lines (139 loc) · 2.96 KB
/
error.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#include "vars.h"
#include "funs.h"
static int beenhere = 0;
#ifdef linux
struct sigcontext;
#endif
void chkstk PROTO((int, int, struct sigcontext *, char *));
void tracesignal(), traceerror(), tracefail(), failintr();
extern int traceflag;
void
sighandl(sig,code,scp,addr)
int sig, code;
struct sigcontext *scp;
char *addr;
{
if (debug)
fprintf(stderr, "sighandl\n");
if (sig == SIGINT) {
#if 0
cleansig();
failintr();
#else
finish(1);
#endif
}
chkstk(sig, code, scp, addr);
if (beenhere++) {
write(2, "Nested signal!\n", 15); /* be extra careful not to cause any more signals */
finish(1);
}
fprintf(stderr, "Signal: %s\n",
#if !defined(__ARM) && !defined(linux)
sig == SIGBUS ? "Bus error" :
#endif
sig == SIGSEGV ? "Segmentation fault" : "Illegal instruction");
if (traceflag)
tracesignal();
finish(1);
}
static void
Domsg(m, s)
char *m;
char *s;
{
if (beenhere++)
finish(1);
flushlow();
fprintf(stderr, "%s %s\n", m, s);
if (traceflag)
traceerror();
finish(1);
}
static void
Doerr(s)
char *s;
{
Domsg("Error in runtime system:", s);
}
void Eunimpl() { Doerr("unimplemented"); }
void EError() { Doerr("gettag"); }
void EErre() { Doerr("eval");}
void EErre_zap() { Domsg("Black hole detected in", "eval zap");}
void EErre_hole() { Domsg("Black hole detected in", "eval hole");}
void EErre_marked() { Doerr("eval marked");}
char line[100];
void EErre_moved(x) Int x; {
sprintf(line,"eval moved %lx\n",x); Doerr(line);
}
void EErrgc(x, str) Int x;char *str; {
#if 0
sprintf(line,"%s %lx\n",str,x); Doerr(line);
#else
extern char *tagname();
sprintf(line,"%s %lx = (%s)\n",str,x,tagname((PTR)x)); Doerr(line);
#endif
}
void EErre_gcret() { Doerr("eval gcret");}
void EErru() { Doerr("unwind");}
void EErrj() { Doerr("jfun");}
void EErrmk() { Doerr("mkapl");}
void EErrg() { Doerr("gettag");}
void ENolabel() { fprintf(stderr, "Jump to Nolabel: this cannot happen!\n"); finish(1);}
void EErrcm() { Doerr("callmethod");}
void Mrkerror() { Doerr("Genc on mrk node");}
void (*failhandler)() = 0;
char *failstring = "Fail:";
void
fail()
{
if (failhandler)
(*failhandler)();
/* If the handler returns we exit as usual. */
if (beenhere++ > 1) {
fprintf(stderr, "Too many nested calls to fail.\n");
finish(1);
}
flushlow();
fflush(stdout);
fprintf(stderr, failstring);
printtop(stderr);
fprintf(stderr, "\n");
if (traceflag)
tracefail();
finish(1);
}
void
gcerror(s, d)
char *s;
Int d;
{
flushlow();
fprintf(stderr, "\ngcerror %08x %d: %s\n",d,d,s);
finish(1);
}
void
noheapleft()
{
flushlow();
fprintf(stderr, "\nOut of heap space\n");
finish(1);
}
void
zapfail()
{
flushlow();
fprintf(stderr, "Severe problems with ZAPped node.\n");
/* if (tracefail)*/
traceerror();
finish(1);
}
void
forceerr()
{
flushlow();
fprintf(stderr, "Force on illegal node\n");
/* if (tracefail)*/
traceerror();
finish(1);
}