|
|
1.1 root 1: #include "stdio.h"
2: #include "h00vars.h"
3: #include "h01errs.h"
4: #define HZ 60 /* interrupt frequency */
5:
6: backtrace(errnum)
7: long errnum;
8: {
9: register struct stack **mydp, *ap;
10: struct stack **dp, *disp[20];
11: register char *cp;
12: register long i;
13: long linum;
14:
15: fetchdp(&dp,&linum);
16: for (i=0; i<20; i++)
17: disp[i] = display[i];
18: if (errnum == EINTR)
19: fputs("\n\tInterrupted at \"",stderr);
20: else if (errnum == EHALT)
21: fputs("\n\tHalted at \"",stderr);
22: else
23: fputs("\n\tError at \"",stderr);
24: if (linum <= 0)
25: return;
26: mydp = dp;
27: for (;;){
28: ap = *mydp;
29: cp = &((ap)->entry)->name[0];
30: i = 8;
31: do
32: putc(*cp++,stderr);
33: while (--i && *cp != ' ');
34: i = linum - (((ap)->entry)->offset & 0177777);
35: fprintf(stderr,"\"+%1d near line %1d.\n",i,linum);
36: *mydp = (ap)->disp;
37: if (mydp <= &display[addrsze >> 2]){
38: for (i=0; i<20; i++)
39: display[i] = disp[i];
40: return;
41: }
42: mydp = (ap)->dp;
43: linum = (ap)->lino;
44: fputs("\tCalled by \"",stderr);
45: }
46: }
47:
48: stats()
49: {
50: struct {
51: long usr_time;
52: long sys_time;
53: long child_usr_time;
54: long child_sys_time;
55: } tbuf;
56: register double l;
57: register long count;
58:
59: if (nodump)
60: return(0);
61: times(&tbuf);
62: #ifdef profile
63: datafile = fopen(proffile,"r");
64: if (datafile != NULL) {
65: count = fread(&profdata,sizeof(profdata),1,datafile);
66: if (count != 1) {
67: for (count = 0; count < numops; count++)
68: profdata.counts[count] = 0.0;
69: profdata.runs = 0;
70: profdata.startdate = time(0);
71: profdata.usrtime = 0;
72: profdata.systime = 0;
73: profdata.stmts = 0;
74: }
75: for (count = 0; count < numops; count++)
76: profdata.counts[count] += profcnts[count];
77: profdata.runs += 1;
78: profdata.stmts += stcnt;
79: profdata.usrtime += tbuf.usr_time;
80: profdata.systime += tbuf.sys_time;
81: datafile = freopen(proffile,"w",datafile);
82: if (datafile != NULL) {
83: fwrite(&profdata,sizeof(profdata),1,datafile);
84: fclose(datafile);
85: }
86: }
87: #endif
88: l = tbuf.usr_time;
89: l = l / HZ;
90: fprintf(stderr,"\n%1ld statements executed in %04.2f seconds cpu time.\n",
91: stcnt,l);
92: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.