-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.c
104 lines (87 loc) · 2.63 KB
/
debug.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
/* File: debug.c
Author: Douglas Jones, Dept. of Comp. Sci., U. of Iowa, Iowa City, IA 52242.
Date: July 26, 1995
Updates: Mats Engstrom, April 2020
Language: C (UNIX)
Purpose: PDP-8 emulator debugging tool
*/
#include <stdio.h>
#include "bus.h"
#include "ttyaccess.h"
#include "disasm.h"
/***********************************/
/* instruction frequency histogram */
/***********************************/
static int instructions[4096];
static int locations[32768];
/***********************************************/
/* Initialization used by CAF and reset switch */
/***********************************************/
void reset_debug(void) /* power-on initialize */
{
int i;
for (i=0; i<4096; i++) {
instructions[i] = 0;
}
for (i=0; i<32768; i++) {
locations[i] = 0;
}
}
/************************/
/* Accumulate histogram */
/************************/
void accumulate_debug(int p, int m, int ac, int lnk, int irq)
{
// static int prevp[16];
// static long int cnt=0;
instructions[m]++;
locations[p]++;
if (trace) {
// if (p==prevp[0] || p==prevp[1] || p==prevp[2]) {
// cnt++;
// } else {
fprintf(stderr,"[%04o] IRQ,DLY,IE=%d,%d,%d L/AC:%d/%04o MQ:%04o IR:%04o %s\r\n",pc,irq,(enab_rtf?0:1),enab,(lnk?1:0),ac,mq,m,ops[m]);
// if (cnt>0) {
// fprintf(stderr," [ %ld repeated instructions removed ]\r\n",cnt);
// cnt=0;
// }
// fprintf(stderr,"%o.%04o (%d) [%04o %04o %04o %04o %04o %04o %04o %04o] %05o:%04o %s\r\n",(lnk?1:0),ac,irq, memory[010],memory[011],memory[012],memory[013],memory[014],memory[015],memory[016],memory[017], p,m,ops[m]);
// fprintf(stderr,"%o.%04o (%d) %05o:%04o %s\r\n",(lnk?1:0),ac,irq,p,m,ops[m]);
// prevp[0]=prevp[1];
// prevp[1]=prevp[2];
// prevp[2]=p;
// }
}
if (bp_type[0]==1 && bp[0]==pc) run=0;
}
/************************/
/* Interface to console */
/************************/
void output_debug(void) /* show histogram */
{
// int i;
// char buf[80];
// sprintf( buf, "\r\nCumulative information since last report\r\n");
// ttyputs( buf );
// sprintf( buf, "\r\nInstructions that were fetched\r\n");
// ttyputs( buf );
// sprintf( buf, " Instruction: Frequency\r\n");
// ttyputs( buf );
// for (i=0; i<4096; i++) {
// if (instructions[i] > 0) {
// sprintf( buf, " %04o: /%6d\r\n", i, instructions[i]);
// ttyputs( buf );
// }
// }
// sprintf( buf, "\r\nLocations that were fetched from\r\n");
// ttyputs( buf );
// sprintf( buf, " Address: Frequency\r\n");
// ttyputs( buf );
// for (i=0; i<32768; i++) {
// if (locations[i] > 0) {
// sprintf( buf, " %04o: /%6d\r\n", i, locations[i]);
// ttyputs( buf );
// }
// }
reset_debug();
}