annotate debug.c @ 583:819921b76b4b

Use update_flags instead of individual set_flag calls in a few places
author Michael Pavone <pavone@retrodev.com>
date Fri, 07 Mar 2014 17:51:40 -0800
parents 624dd5106060
children f822d9216968
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
524
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include "debug.h"
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #include "blastem.h"
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 #include "68kinst.h"
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 #include <stdlib.h>
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 #include <string.h>
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6
525
62860044337d Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents: 524
diff changeset
7 static bp_def * breakpoints = NULL;
62860044337d Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents: 524
diff changeset
8 static bp_def * zbreakpoints = NULL;
62860044337d Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents: 524
diff changeset
9 static uint32_t bp_index = 0;
62860044337d Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents: 524
diff changeset
10 static uint32_t zbp_index = 0;
524
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 bp_def ** find_breakpoint(bp_def ** cur, uint32_t address)
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 while (*cur) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 if ((*cur)->address == address) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 cur = &((*cur)->next);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 return cur;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 bp_def ** find_breakpoint_idx(bp_def ** cur, uint32_t index)
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
25 while (*cur) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
26 if ((*cur)->index == index) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
27 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
28 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
29 cur = &((*cur)->next);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
30 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
31 return cur;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
32 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
33
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
34 disp_def * displays = NULL;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
35 disp_def * zdisplays = NULL;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
36 uint32_t disp_index = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
37 uint32_t zdisp_index = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
38
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
39 void add_display(disp_def ** head, uint32_t *index, char format_char, char * param)
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
40 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
41 disp_def * ndisp = malloc(sizeof(*ndisp));
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
42 ndisp->format_char = format_char;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
43 ndisp->param = strdup(param);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
44 ndisp->next = *head;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
45 ndisp->index = *index++;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
46 *head = ndisp;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
47 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
48
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
49 void remove_display(disp_def ** head, uint32_t index)
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
50 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
51 while (*head) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
52 if ((*head)->index == index) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
53 disp_def * del_disp = *head;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
54 *head = del_disp->next;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
55 free(del_disp->param);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
56 free(del_disp);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
57 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
58 head = &(*head)->next;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
59 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
60 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
61 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
62
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
63 char * find_param(char * buf)
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
64 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
65 for (; *buf; buf++) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
66 if (*buf == ' ') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
67 if (*(buf+1)) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
68 return buf+1;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
69 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
70 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
71 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
72 return NULL;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
73 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
74
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
75 void strip_nl(char * buf)
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
76 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
77 for(; *buf; buf++) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
78 if (*buf == '\n') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
79 *buf = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
80 return;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
81 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
82 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
83 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
84
565
9324f721efa6 Add a separate flag/define for disabling the Z80 at compile time to ease refactoring
Michael Pavone <pavone@retrodev.com>
parents: 548
diff changeset
85 #ifndef NO_Z80
548
a3afee2271ce Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents: 525
diff changeset
86
524
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
87 void zdebugger_print(z80_context * context, char format_char, char * param)
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
88 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
89 uint32_t value;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
90 char format[8];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
91 strcpy(format, "%s: %d\n");
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
92 switch (format_char)
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
93 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
94 case 'x':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
95 case 'X':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
96 case 'd':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
97 case 'c':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
98 format[5] = format_char;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
99 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
100 case '\0':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
101 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
102 default:
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
103 fprintf(stderr, "Unrecognized format character: %c\n", format_char);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
104 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
105 switch (param[0])
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
106 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
107 case 'a':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
108 if (param[1] == 'f') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
109 if(param[2] == '\'') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
110 value = context->alt_regs[Z80_A] << 8;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
111 value |= context->alt_flags[ZF_S] << 7;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
112 value |= context->alt_flags[ZF_Z] << 6;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
113 value |= context->alt_flags[ZF_H] << 4;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
114 value |= context->alt_flags[ZF_PV] << 2;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
115 value |= context->alt_flags[ZF_N] << 1;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
116 value |= context->alt_flags[ZF_C];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
117 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
118 value = context->regs[Z80_A] << 8;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
119 value |= context->flags[ZF_S] << 7;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
120 value |= context->flags[ZF_Z] << 6;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
121 value |= context->flags[ZF_H] << 4;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
122 value |= context->flags[ZF_PV] << 2;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
123 value |= context->flags[ZF_N] << 1;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
124 value |= context->flags[ZF_C];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
125 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
126 } else if(param[1] == '\'') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
127 value = context->alt_regs[Z80_A];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
128 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
129 value = context->regs[Z80_A];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
130 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
131 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
132 case 'b':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
133 if (param[1] == 'c') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
134 if(param[2] == '\'') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
135 value = context->alt_regs[Z80_B] << 8;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
136 value |= context->alt_regs[Z80_C];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
137 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
138 value = context->regs[Z80_B] << 8;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
139 value |= context->regs[Z80_C];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
140 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
141 } else if(param[1] == '\'') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
142 value = context->alt_regs[Z80_B];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
143 } else if(param[1] == 'a') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
144 value = context->bank_reg << 15;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
145 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
146 value = context->regs[Z80_B];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
147 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
148 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
149 case 'c':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
150 if(param[1] == '\'') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
151 value = context->alt_regs[Z80_C];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
152 } else if(param[1] == 'y') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
153 value = context->current_cycle;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
154 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
155 value = context->regs[Z80_C];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
156 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
157 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
158 case 'd':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
159 if (param[1] == 'e') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
160 if(param[2] == '\'') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
161 value = context->alt_regs[Z80_D] << 8;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
162 value |= context->alt_regs[Z80_E];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
163 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
164 value = context->regs[Z80_D] << 8;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
165 value |= context->regs[Z80_E];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
166 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
167 } else if(param[1] == '\'') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
168 value = context->alt_regs[Z80_D];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
169 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
170 value = context->regs[Z80_D];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
171 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
172 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
173 case 'e':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
174 if(param[1] == '\'') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
175 value = context->alt_regs[Z80_E];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
176 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
177 value = context->regs[Z80_E];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
178 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
179 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
180 case 'f':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
181 if(param[2] == '\'') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
182 value = context->alt_flags[ZF_S] << 7;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
183 value |= context->alt_flags[ZF_Z] << 6;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
184 value |= context->alt_flags[ZF_H] << 4;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
185 value |= context->alt_flags[ZF_PV] << 2;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
186 value |= context->alt_flags[ZF_N] << 1;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
187 value |= context->alt_flags[ZF_C];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
188 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
189 value = context->flags[ZF_S] << 7;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
190 value |= context->flags[ZF_Z] << 6;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
191 value |= context->flags[ZF_H] << 4;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
192 value |= context->flags[ZF_PV] << 2;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
193 value |= context->flags[ZF_N] << 1;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
194 value |= context->flags[ZF_C];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
195 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
196 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
197 case 'h':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
198 if (param[1] == 'l') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
199 if(param[2] == '\'') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
200 value = context->alt_regs[Z80_H] << 8;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
201 value |= context->alt_regs[Z80_L];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
202 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
203 value = context->regs[Z80_H] << 8;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
204 value |= context->regs[Z80_L];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
205 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
206 } else if(param[1] == '\'') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
207 value = context->alt_regs[Z80_H];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
208 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
209 value = context->regs[Z80_H];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
210 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
211 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
212 case 'l':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
213 if(param[1] == '\'') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
214 value = context->alt_regs[Z80_L];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
215 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
216 value = context->regs[Z80_L];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
217 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
218 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
219 case 'i':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
220 if(param[1] == 'x') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
221 if (param[2] == 'h') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
222 value = context->regs[Z80_IXH];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
223 } else if(param[2] == 'l') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
224 value = context->regs[Z80_IXL];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
225 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
226 value = context->regs[Z80_IXH] << 8;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
227 value |= context->regs[Z80_IXL];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
228 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
229 } else if(param[1] == 'y') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
230 if (param[2] == 'h') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
231 value = context->regs[Z80_IYH];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
232 } else if(param[2] == 'l') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
233 value = context->regs[Z80_IYL];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
234 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
235 value = context->regs[Z80_IYH] << 8;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
236 value |= context->regs[Z80_IYL];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
237 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
238 } else if(param[1] == 'n') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
239 value = context->int_cycle;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
240 } else if(param[1] == 'f' && param[2] == 'f' && param[3] == '1') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
241 value = context->iff1;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
242 } else if(param[1] == 'f' && param[2] == 'f' && param[3] == '2') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
243 value = context->iff2;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
244 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
245 value = context->im;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
246 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
247 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
248 case 's':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
249 if (param[1] == 'p') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
250 value = context->sp;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
251 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
252 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
253 case '0':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
254 if (param[1] == 'x') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
255 uint16_t p_addr = strtol(param+2, NULL, 16);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
256 if (p_addr < 0x4000) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
257 value = z80_ram[p_addr & 0x1FFF];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
258 } else if(p_addr >= 0x8000) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
259 uint32_t v_addr = context->bank_reg << 15;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
260 v_addr += p_addr & 0x7FFF;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
261 if (v_addr < 0x400000) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
262 value = cart[v_addr/2];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
263 } else if(v_addr > 0xE00000) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
264 value = ram[(v_addr & 0xFFFF)/2];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
265 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
266 if (v_addr & 1) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
267 value &= 0xFF;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
268 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
269 value >>= 8;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
270 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
271 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
272 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
273 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
274 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
275 printf(format, param, value);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
276 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
277
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
278 z80_context * zdebugger(z80_context * context, uint16_t address)
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
279 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
280 static char last_cmd[1024];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
281 char input_buf[1024];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
282 static uint16_t branch_t;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
283 static uint16_t branch_f;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
284 z80inst inst;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
285 //Check if this is a user set breakpoint, or just a temporary one
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
286 bp_def ** this_bp = find_breakpoint(&zbreakpoints, address);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
287 if (*this_bp) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
288 printf("Z80 Breakpoint %d hit\n", (*this_bp)->index);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
289 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
290 zremove_breakpoint(context, address);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
291 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
292 uint8_t * pc;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
293 if (address < 0x4000) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
294 pc = z80_ram + (address & 0x1FFF);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
295 } else if (address >= 0x8000) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
296 if (context->bank_reg < (0x400000 >> 15)) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
297 fprintf(stderr, "Entered Z80 debugger in banked memory address %X, which is not yet supported\n", address);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
298 exit(1);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
299 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
300 fprintf(stderr, "Entered Z80 debugger in banked memory address %X, but the bank is not pointed to a cartridge address\n", address);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
301 exit(1);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
302 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
303 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
304 fprintf(stderr, "Entered Z80 debugger at address %X\n", address);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
305 exit(1);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
306 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
307 for (disp_def * cur = zdisplays; cur; cur = cur->next) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
308 zdebugger_print(context, cur->format_char, cur->param);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
309 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
310 uint8_t * after_pc = z80_decode(pc, &inst);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
311 z80_disasm(&inst, input_buf, address);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
312 printf("%X:\t%s\n", address, input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
313 uint16_t after = address + (after_pc-pc);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
314 int debugging = 1;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
315 while(debugging) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
316 fputs(">", stdout);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
317 if (!fgets(input_buf, sizeof(input_buf), stdin)) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
318 fputs("fgets failed", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
319 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
320 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
321 strip_nl(input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
322 //hitting enter repeats last command
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
323 if (input_buf[0]) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
324 strcpy(last_cmd, input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
325 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
326 strcpy(input_buf, last_cmd);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
327 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
328 char * param;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
329 char format[8];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
330 uint32_t value;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
331 bp_def * new_bp;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
332 switch(input_buf[0])
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
333 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
334 case 'a':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
335 param = find_param(input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
336 if (!param) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
337 fputs("a command requires a parameter\n", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
338 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
339 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
340 value = strtol(param, NULL, 16);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
341 zinsert_breakpoint(context, value, (uint8_t *)zdebugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
342 debugging = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
343 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
344 case 'b':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
345 param = find_param(input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
346 if (!param) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
347 fputs("b command requires a parameter\n", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
348 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
349 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
350 value = strtol(param, NULL, 16);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
351 zinsert_breakpoint(context, value, (uint8_t *)zdebugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
352 new_bp = malloc(sizeof(bp_def));
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
353 new_bp->next = zbreakpoints;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
354 new_bp->address = value;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
355 new_bp->index = zbp_index++;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
356 zbreakpoints = new_bp;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
357 printf("Z80 Breakpoint %d set at %X\n", new_bp->index, value);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
358 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
359 case 'c':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
360 puts("Continuing");
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
361 debugging = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
362 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
363 case 'd':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
364 if (input_buf[1] == 'i') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
365 char format_char = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
366 for(int i = 2; input_buf[i] != 0 && input_buf[i] != ' '; i++) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
367 if (input_buf[i] == '/') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
368 format_char = input_buf[i+1];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
369 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
370 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
371 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
372 param = find_param(input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
373 if (!param) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
374 fputs("display command requires a parameter\n", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
375 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
376 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
377 zdebugger_print(context, format_char, param);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
378 add_display(&zdisplays, &zdisp_index, format_char, param);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
379 } else if (input_buf[1] == 'e' || input_buf[1] == ' ') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
380 param = find_param(input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
381 if (!param) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
382 fputs("delete command requires a parameter\n", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
383 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
384 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
385 if (param[0] >= '0' && param[0] <= '9') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
386 value = atoi(param);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
387 this_bp = find_breakpoint_idx(&zbreakpoints, value);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
388 if (!*this_bp) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
389 fprintf(stderr, "Breakpoint %d does not exist\n", value);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
390 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
391 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
392 new_bp = *this_bp;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
393 zremove_breakpoint(context, new_bp->address);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
394 *this_bp = new_bp->next;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
395 free(new_bp);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
396 } else if (param[0] == 'd') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
397 param = find_param(param);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
398 if (!param) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
399 fputs("delete display command requires a parameter\n", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
400 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
401 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
402 remove_display(&zdisplays, atoi(param));
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
403 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
404 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
405 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
406 case 'n':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
407 //TODO: Handle conditional branch instructions
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
408 if (inst.op == Z80_JP) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
409 if (inst.addr_mode == Z80_IMMED) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
410 after = inst.immed;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
411 } else if (inst.ea_reg == Z80_HL) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
412 after = context->regs[Z80_H] << 8 | context->regs[Z80_L];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
413 } else if (inst.ea_reg == Z80_IX) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
414 after = context->regs[Z80_IXH] << 8 | context->regs[Z80_IXL];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
415 } else if (inst.ea_reg == Z80_IY) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
416 after = context->regs[Z80_IYH] << 8 | context->regs[Z80_IYL];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
417 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
418 } else if(inst.op == Z80_JR) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
419 after += inst.immed;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
420 } else if(inst.op == Z80_RET) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
421 if (context->sp < 0x4000) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
422 after = z80_ram[context->sp & 0x1FFF] | z80_ram[(context->sp+1) & 0x1FFF] << 8;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
423 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
424 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
425 zinsert_breakpoint(context, after, (uint8_t *)zdebugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
426 debugging = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
427 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
428 case 'p':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
429 param = find_param(input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
430 if (!param) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
431 fputs("p command requires a parameter\n", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
432 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
433 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
434 zdebugger_print(context, input_buf[1] == '/' ? input_buf[2] : 0, param);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
435 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
436 case 'q':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
437 puts("Quitting");
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
438 exit(0);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
439 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
440 case 's': {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
441 param = find_param(input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
442 if (!param) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
443 fputs("s command requires a file name\n", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
444 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
445 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
446 FILE * f = fopen(param, "wb");
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
447 if (f) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
448 if(fwrite(z80_ram, 1, sizeof(z80_ram), f) != sizeof(z80_ram)) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
449 fputs("Error writing file\n", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
450 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
451 fclose(f);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
452 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
453 fprintf(stderr, "Could not open %s for writing\n", param);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
454 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
455 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
456 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
457 default:
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
458 fprintf(stderr, "Unrecognized debugger command %s\n", input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
459 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
460 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
461 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
462 return context;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
463 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
464
548
a3afee2271ce Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents: 525
diff changeset
465 #endif
a3afee2271ce Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents: 525
diff changeset
466
524
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
467 m68k_context * debugger(m68k_context * context, uint32_t address)
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
468 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
469 static char last_cmd[1024];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
470 char input_buf[1024];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
471 static uint32_t branch_t;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
472 static uint32_t branch_f;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
473 m68kinst inst;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
474 //probably not necessary, but let's play it safe
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
475 address &= 0xFFFFFF;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
476 if (address == branch_t) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
477 bp_def ** f_bp = find_breakpoint(&breakpoints, branch_f);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
478 if (!*f_bp) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
479 remove_breakpoint(context, branch_f);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
480 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
481 branch_t = branch_f = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
482 } else if(address == branch_f) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
483 bp_def ** t_bp = find_breakpoint(&breakpoints, branch_t);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
484 if (!*t_bp) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
485 remove_breakpoint(context, branch_t);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
486 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
487 branch_t = branch_f = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
488 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
489 //Check if this is a user set breakpoint, or just a temporary one
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
490 bp_def ** this_bp = find_breakpoint(&breakpoints, address);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
491 if (*this_bp) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
492 printf("68K Breakpoint %d hit\n", (*this_bp)->index);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
493 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
494 remove_breakpoint(context, address);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
495 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
496 uint16_t * pc;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
497 if (address < 0x400000) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
498 pc = cart + address/2;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
499 } else if(address > 0xE00000) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
500 pc = ram + (address & 0xFFFF)/2;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
501 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
502 fprintf(stderr, "Entered 68K debugger at address %X\n", address);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
503 exit(1);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
504 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
505 uint16_t * after_pc = m68k_decode(pc, &inst, address);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
506 m68k_disasm(&inst, input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
507 printf("%X: %s\n", address, input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
508 uint32_t after = address + (after_pc-pc)*2;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
509 int debugging = 1;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
510 while (debugging) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
511 fputs(">", stdout);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
512 if (!fgets(input_buf, sizeof(input_buf), stdin)) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
513 fputs("fgets failed", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
514 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
515 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
516 strip_nl(input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
517 //hitting enter repeats last command
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
518 if (input_buf[0]) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
519 strcpy(last_cmd, input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
520 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
521 strcpy(input_buf, last_cmd);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
522 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
523 char * param;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
524 char format[8];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
525 uint32_t value;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
526 bp_def * new_bp;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
527 switch(input_buf[0])
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
528 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
529 case 'c':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
530 puts("Continuing");
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
531 debugging = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
532 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
533 case 'b':
566
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
534 if (input_buf[1] == 't') {
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
535 uint32_t stack = context->aregs[7];
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
536 if (stack >= 0xE00000) {
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
537 stack &= 0xFFFF;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
538 uint8_t non_adr_count = 0;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
539 do {
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
540 uint32_t bt_address = ram[stack/2] << 16 | ram[stack/2+1];
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
541 bt_address = get_instruction_start(context->native_code_map, bt_address - 2);
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
542 if (bt_address) {
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
543 stack += 4;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
544 non_adr_count = 0;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
545 uint16_t *bt_pc = NULL;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
546 if (bt_address < 0x400000) {
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
547 bt_pc = cart + bt_address/2;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
548 } else if(bt_address > 0xE00000) {
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
549 bt_pc = ram + (bt_address & 0xFFFF)/2;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
550 }
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
551 m68k_decode(bt_pc, &inst, bt_address);
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
552 m68k_disasm(&inst, input_buf);
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
553 printf("%X: %s\n", bt_address, input_buf);
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
554 } else {
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
555 //non-return address value on stack can be word wide
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
556 stack += 2;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
557 non_adr_count++;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
558 }
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
559 stack &= 0xFFFF;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
560 } while (stack && non_adr_count < 6);
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
561 }
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
562 } else {
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
563 param = find_param(input_buf);
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
564 if (!param) {
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
565 fputs("b command requires a parameter\n", stderr);
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
566 break;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
567 }
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
568 value = strtol(param, NULL, 16);
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
569 insert_breakpoint(context, value, (uint8_t *)debugger);
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
570 new_bp = malloc(sizeof(bp_def));
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
571 new_bp->next = breakpoints;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
572 new_bp->address = value;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
573 new_bp->index = bp_index++;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
574 breakpoints = new_bp;
624dd5106060 Add backtrace (bt) command to 68K debugger
Michael Pavone <pavone@retrodev.com>
parents: 565
diff changeset
575 printf("68K Breakpoint %d set at %X\n", new_bp->index, value);
524
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
576 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
577 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
578 case 'a':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
579 param = find_param(input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
580 if (!param) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
581 fputs("a command requires a parameter\n", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
582 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
583 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
584 value = strtol(param, NULL, 16);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
585 insert_breakpoint(context, value, (uint8_t *)debugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
586 debugging = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
587 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
588 case 'd':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
589 param = find_param(input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
590 if (!param) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
591 fputs("d command requires a parameter\n", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
592 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
593 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
594 value = atoi(param);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
595 this_bp = find_breakpoint_idx(&breakpoints, value);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
596 if (!*this_bp) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
597 fprintf(stderr, "Breakpoint %d does not exist\n", value);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
598 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
599 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
600 new_bp = *this_bp;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
601 *this_bp = (*this_bp)->next;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
602 free(new_bp);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
603 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
604 case 'p':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
605 strcpy(format, "%s: %d\n");
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
606 if (input_buf[1] == '/') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
607 switch (input_buf[2])
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
608 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
609 case 'x':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
610 case 'X':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
611 case 'd':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
612 case 'c':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
613 format[5] = input_buf[2];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
614 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
615 default:
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
616 fprintf(stderr, "Unrecognized format character: %c\n", input_buf[2]);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
617 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
618 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
619 param = find_param(input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
620 if (!param) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
621 fputs("p command requires a parameter\n", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
622 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
623 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
624 if (param[0] == 'd' && param[1] >= '0' && param[1] <= '7') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
625 value = context->dregs[param[1]-'0'];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
626 } else if (param[0] == 'a' && param[1] >= '0' && param[1] <= '7') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
627 value = context->aregs[param[1]-'0'];
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
628 } else if (param[0] == 'S' && param[1] == 'R') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
629 value = (context->status << 8);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
630 for (int flag = 0; flag < 5; flag++) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
631 value |= context->flags[flag] << (4-flag);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
632 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
633 } else if(param[0] == 'c') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
634 value = context->current_cycle;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
635 } else if (param[0] == '0' && param[1] == 'x') {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
636 uint32_t p_addr = strtol(param+2, NULL, 16);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
637 value = read_dma_value(p_addr/2);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
638 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
639 fprintf(stderr, "Unrecognized parameter to p: %s\n", param);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
640 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
641 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
642 printf(format, param, value);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
643 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
644 case 'n':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
645 if (inst.op == M68K_RTS) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
646 after = (read_dma_value(context->aregs[7]/2) << 16) | read_dma_value(context->aregs[7]/2 + 1);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
647 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
648 after = (read_dma_value((context->aregs[7]+2)/2) << 16) | read_dma_value((context->aregs[7]+2)/2 + 1);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
649 } else if(m68k_is_noncall_branch(&inst)) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
650 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
651 branch_f = after;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
652 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
653 insert_breakpoint(context, branch_t, (uint8_t *)debugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
654 } else if(inst.op == M68K_DBCC) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
655 if ( inst.extra.cond == COND_FALSE) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
656 if (context->dregs[inst.dst.params.regs.pri] & 0xFFFF) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
657 after = m68k_branch_target(&inst, context->dregs, context->aregs);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
658 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
659 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
660 branch_t = after;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
661 branch_f = m68k_branch_target(&inst, context->dregs, context->aregs);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
662 insert_breakpoint(context, branch_f, (uint8_t *)debugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
663 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
664 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
665 after = m68k_branch_target(&inst, context->dregs, context->aregs);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
666 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
667 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
668 insert_breakpoint(context, after, (uint8_t *)debugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
669 debugging = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
670 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
671 case 'o':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
672 if (inst.op == M68K_RTS) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
673 after = (read_dma_value(context->aregs[7]/2) << 16) | read_dma_value(context->aregs[7]/2 + 1);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
674 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
675 after = (read_dma_value((context->aregs[7]+2)/2) << 16) | read_dma_value((context->aregs[7]+2)/2 + 1);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
676 } else if(m68k_is_noncall_branch(&inst)) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
677 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
678 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
679 if (branch_t < after) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
680 branch_t = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
681 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
682 branch_f = after;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
683 insert_breakpoint(context, branch_t, (uint8_t *)debugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
684 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
685 } else if(inst.op == M68K_DBCC) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
686 uint32_t target = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
687 if (target > after) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
688 if (inst.extra.cond == COND_FALSE) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
689 after = target;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
690 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
691 branch_f = target;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
692 branch_t = after;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
693 insert_breakpoint(context, branch_f, (uint8_t *)debugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
694 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
695 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
696 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
697 after = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
698 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
699 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
700 insert_breakpoint(context, after, (uint8_t *)debugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
701 debugging = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
702 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
703 case 's':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
704 if (inst.op == M68K_RTS) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
705 after = (read_dma_value(context->aregs[7]/2) << 16) | read_dma_value(context->aregs[7]/2 + 1);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
706 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
707 after = (read_dma_value((context->aregs[7]+2)/2) << 16) | read_dma_value((context->aregs[7]+2)/2 + 1);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
708 } else if(m68k_is_branch(&inst)) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
709 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
710 branch_f = after;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
711 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
712 insert_breakpoint(context, branch_t, (uint8_t *)debugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
713 } else if(inst.op == M68K_DBCC && inst.extra.cond != COND_FALSE) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
714 branch_t = after;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
715 branch_f = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
716 insert_breakpoint(context, branch_f, (uint8_t *)debugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
717 } else {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
718 after = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
719 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
720 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
721 insert_breakpoint(context, after, (uint8_t *)debugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
722 debugging = 0;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
723 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
724 case 'v': {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
725 genesis_context * gen = context->system;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
726 //VDP debug commands
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
727 switch(input_buf[1])
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
728 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
729 case 's':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
730 vdp_print_sprite_table(gen->vdp);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
731 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
732 case 'r':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
733 vdp_print_reg_explain(gen->vdp);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
734 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
735 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
736 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
737 }
565
9324f721efa6 Add a separate flag/define for disabling the Z80 at compile time to ease refactoring
Michael Pavone <pavone@retrodev.com>
parents: 548
diff changeset
738 #ifndef NO_Z80
524
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
739 case 'z': {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
740 genesis_context * gen = context->system;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
741 //Z80 debug commands
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
742 switch(input_buf[1])
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
743 {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
744 case 'b':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
745 param = find_param(input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
746 if (!param) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
747 fputs("zb command requires a parameter\n", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
748 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
749 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
750 value = strtol(param, NULL, 16);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
751 zinsert_breakpoint(gen->z80, value, (uint8_t *)zdebugger);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
752 new_bp = malloc(sizeof(bp_def));
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
753 new_bp->next = zbreakpoints;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
754 new_bp->address = value;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
755 new_bp->index = zbp_index++;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
756 zbreakpoints = new_bp;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
757 printf("Z80 Breakpoint %d set at %X\n", new_bp->index, value);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
758 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
759 case 'p':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
760 param = find_param(input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
761 if (!param) {
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
762 fputs("zp command requires a parameter\n", stderr);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
763 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
764 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
765 zdebugger_print(gen->z80, input_buf[2] == '/' ? input_buf[3] : 0, param);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
766 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
767 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
768 }
548
a3afee2271ce Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents: 525
diff changeset
769 #endif
524
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
770 case 'q':
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
771 puts("Quitting");
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
772 exit(0);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
773 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
774 default:
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
775 fprintf(stderr, "Unrecognized debugger command %s\n", input_buf);
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
776 break;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
777 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
778 }
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
779 return context;
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
780 }