Mercurial > repos > blastem
annotate debug.c @ 2274:bf1bb893f104
Properly ignore low bits of SP start address in disassembler
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 29 Dec 2022 22:44:35 -0800 |
parents | 6a07b13894f7 |
children | 0343f0d5add0 |
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" |
1103
22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents:
985
diff
changeset
|
2 #include "genesis.h" |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 #include "68kinst.h" |
2104
ff32a90260c9
Initial support for using debugger on sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2054
diff
changeset
|
4 #include "segacd.h" |
ff32a90260c9
Initial support for using debugger on sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2054
diff
changeset
|
5 #include "blastem.h" |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
6 #include "bindings.h" |
2177 | 7 #include <ctype.h> |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 #include <stdlib.h> |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 #include <string.h> |
745
daa31ee7d8cd
Get windows build compiling again post-merge
Michael Pavone <pavone@retrodev.com>
parents:
723
diff
changeset
|
10 #ifndef _WIN32 |
723
7178d750efbd
Process events while waiting for 68K debugger input. This prevents "not responsive" dialogs when sitting in the debugger
Michael Pavone <pavone@retrodev.com>
parents:
707
diff
changeset
|
11 #include <sys/select.h> |
745
daa31ee7d8cd
Get windows build compiling again post-merge
Michael Pavone <pavone@retrodev.com>
parents:
723
diff
changeset
|
12 #endif |
723
7178d750efbd
Process events while waiting for 68K debugger input. This prevents "not responsive" dialogs when sitting in the debugger
Michael Pavone <pavone@retrodev.com>
parents:
707
diff
changeset
|
13 #include "render.h" |
792
724bbec47f86
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
Michael Pavone <pavone@retrodev.com>
parents:
747
diff
changeset
|
14 #include "util.h" |
794
792be135d3af
Spawn a terminal for the debugger when needed if we are not already attached to one
Michael Pavone <pavone@retrodev.com>
parents:
792
diff
changeset
|
15 #include "terminal.h" |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1630
diff
changeset
|
16 #include "z80inst.h" |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
17 #ifndef NO_Z80 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
18 #include "sms.h" |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
19 #endif |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1630
diff
changeset
|
20 |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1630
diff
changeset
|
21 #ifdef NEW_CORE |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1630
diff
changeset
|
22 #define Z80_OPTS opts |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1630
diff
changeset
|
23 #else |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1630
diff
changeset
|
24 #define Z80_OPTS options |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1630
diff
changeset
|
25 #endif |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 |
2107
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
27 static debug_root roots[5]; |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
28 static uint32_t num_roots; |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
29 #define MAX_DEBUG_ROOTS (sizeof(roots)/sizeof(*roots)) |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
30 |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
31 debug_root *find_root(void *cpu) |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
32 { |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
33 for (uint32_t i = 0; i < num_roots; i++) |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
34 { |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
35 if (roots[i].cpu_context == cpu) { |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
36 return roots + i; |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
37 } |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
38 } |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
39 if (num_roots < MAX_DEBUG_ROOTS) { |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
40 num_roots++; |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
41 memset(roots + num_roots - 1, 0, sizeof(debug_root)); |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
42 roots[num_roots-1].cpu_context = cpu; |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
43 return roots + num_roots - 1; |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
44 } |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
45 return NULL; |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
46 } |
524
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 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
|
49 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 while (*cur) { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 if ((*cur)->address == address) { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 cur = &((*cur)->next); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 return cur; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 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
|
60 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 while (*cur) { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 if ((*cur)->index == index) { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 break; |
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 cur = &((*cur)->next); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 return cur; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
70 static const char *token_type_names[] = { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
71 "TOKEN_NONE", |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
72 "TOKEN_NUM", |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
73 "TOKEN_NAME", |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
74 "TOKEN_OPER", |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
75 "TOKEN_SIZE", |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
76 "TOKEN_LBRACKET", |
2171
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
77 "TOKEN_RBRACKET", |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
78 "TOKEN_LPAREN", |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
79 "TOKEN_RPAREN" |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
80 }; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
81 |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
82 static token parse_token(char *start, char **end) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
83 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
84 while(*start && isblank(*start) && *start != '\n' && *start != '\r') |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
85 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
86 ++start; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
87 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
88 if (!*start || *start == '\n' || *start == '\r') { |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
89 return (token){ |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
90 .type = TOKEN_NONE |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
91 }; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
92 *end = start; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
93 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
94 if (*start == '$' || (*start == '0' && start[1] == 'x')) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
95 return (token) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
96 .type = TOKEN_NUM, |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
97 .v = { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
98 .num = strtol(start + (*start == '$' ? 1 : 2), end, 16) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
99 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
100 }; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
101 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
102 if (isdigit(*start)) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
103 return (token) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
104 .type = TOKEN_NUM, |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
105 .v = { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
106 .num = strtol(start, end, 10) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
107 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
108 }; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
109 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
110 switch (*start) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
111 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
112 case '+': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
113 case '-': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
114 case '*': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
115 case '/': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
116 case '&': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
117 case '|': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
118 case '^': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
119 case '~': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
120 case '=': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
121 case '!': |
2191
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
122 case '>': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
123 case '<': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
124 if ((*start == '!' || *start == '>' || *start == '<') && start[1] == '=') { |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
125 *end = start + 2; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
126 return (token) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
127 .type = TOKEN_OPER, |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
128 .v = { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
129 .op = {*start, start[1], 0} |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
130 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
131 }; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
132 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
133 *end = start + 1; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
134 return (token) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
135 .type = TOKEN_OPER, |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
136 .v = { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
137 .op = {*start, 0} |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
138 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
139 }; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
140 case '.': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
141 *end = start + 2; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
142 return (token) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
143 .type = TOKEN_SIZE, |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
144 .v = { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
145 .op = {start[1], 0} |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
146 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
147 }; |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
148 case '[': |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
149 *end = start + 1; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
150 return (token) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
151 .type = TOKEN_LBRACKET |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
152 }; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
153 case ']': |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
154 *end = start + 1; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
155 return (token) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
156 .type = TOKEN_RBRACKET |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
157 }; |
2171
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
158 case '(': |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
159 *end = start + 1; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
160 return (token) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
161 .type = TOKEN_LPAREN |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
162 }; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
163 case ')': |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
164 *end = start + 1; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
165 return (token) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
166 .type = TOKEN_RPAREN |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
167 }; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
168 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
169 *end = start + 1; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
170 while (**end && !isspace(**end)) |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
171 { |
2172
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
172 uint8_t done = 0; |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
173 switch (**end) |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
174 { |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
175 case '+': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
176 case '-': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
177 case '*': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
178 case '/': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
179 case '&': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
180 case '|': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
181 case '^': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
182 case '~': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
183 case '=': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
184 case '!': |
2191
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
185 case '>': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
186 case '<': |
2172
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
187 case '.': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
188 done = 1; |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
189 break; |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
190 } |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
191 if (done) { |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
192 break; |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
193 } |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
194 |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
195 ++*end; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
196 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
197 char *name = malloc(*end - start + 1); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
198 memcpy(name, start, *end - start); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
199 name[*end-start] = 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
200 return (token) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
201 .type = TOKEN_NAME, |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
202 .v = { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
203 .str = name |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
204 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
205 }; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
206 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
207 |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
208 static void free_expr(expr *e) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
209 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
210 if (!e) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
211 return; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
212 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
213 free_expr(e->left); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
214 free_expr(e->right); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
215 if (e->op.type == TOKEN_NAME) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
216 free(e->op.v.str); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
217 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
218 free(e); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
219 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
220 |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
221 static expr *parse_scalar_or_muldiv(char *start, char **end); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
222 static expr *parse_expression(char *start, char **end); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
223 |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
224 static expr *parse_scalar(char *start, char **end) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
225 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
226 char *after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
227 token first = parse_token(start, &after_first); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
228 if (!first.type) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
229 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
230 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
231 if (first.type == TOKEN_SIZE) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
232 fprintf(stderr, "Unexpected TOKEN_SIZE '.%s'\n", first.v.op); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
233 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
234 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
235 if (first.type == TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
236 expr *target = parse_scalar(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
237 if (!target) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
238 fprintf(stderr, "Unary expression %s needs value\n", first.v.op); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
239 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
240 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
241 expr *ret = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
242 ret->type = EXPR_UNARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
243 ret->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
244 ret->left = target; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
245 *end = after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
246 return ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
247 } |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
248 if (first.type == TOKEN_LBRACKET) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
249 expr *ret = calloc(1, sizeof(expr)); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
250 ret->type = EXPR_MEM; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
251 ret->left = parse_expression(after_first, end); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
252 if (!ret->left) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
253 fprintf(stderr, "Expression expected after `[`\n"); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
254 free(ret); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
255 return NULL; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
256 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
257 token rbrack = parse_token(*end, end); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
258 if (rbrack.type != TOKEN_RBRACKET) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
259 fprintf(stderr, "Missing closing `]`"); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
260 free_expr(ret); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
261 return NULL; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
262 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
263 char *after_size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
264 token size = parse_token(*end, &after_size); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
265 if (size.type == TOKEN_SIZE) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
266 *end = after_size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
267 ret->op = size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
268 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
269 return ret; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
270 } |
2171
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
271 if (first.type == TOKEN_LPAREN) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
272 expr *ret = parse_expression(after_first, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
273 if (!ret) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
274 fprintf(stderr, "Expression expected after `(`\n"); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
275 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
276 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
277 token rparen = parse_token(*end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
278 if (rparen.type != TOKEN_RPAREN) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
279 fprintf(stderr, "Missing closing `)`"); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
280 free_expr(ret); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
281 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
282 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
283 return ret; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
284 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
285 if (first.type != TOKEN_NUM && first.type != TOKEN_NAME) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
286 fprintf(stderr, "Unexpected token %s\n", token_type_names[first.type]); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
287 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
288 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
289 token second = parse_token(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
290 if (second.type != TOKEN_SIZE) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
291 expr *ret = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
292 ret->type = EXPR_SCALAR; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
293 ret->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
294 *end = after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
295 return ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
296 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
297 expr *ret = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
298 ret->type = EXPR_SIZE; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
299 ret->left = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
300 ret->left->type = EXPR_SCALAR; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
301 ret->left->op = second; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
302 ret->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
303 return ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
304 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
305 |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
306 static expr *maybe_binary(expr *left, char *start, char **end) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
307 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
308 char *after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
309 token first = parse_token(start, &after_first); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
310 if (first.type != TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
311 *end = start; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
312 return left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
313 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
314 expr *bin = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
315 bin->left = left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
316 bin->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
317 bin->type = EXPR_BINARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
318 switch (first.v.op[0]) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
319 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
320 case '*': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
321 case '/': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
322 case '&': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
323 case '|': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
324 case '^': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
325 bin->right = parse_scalar(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
326 return maybe_binary(bin, *end, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
327 case '+': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
328 case '-': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
329 bin->right = parse_scalar_or_muldiv(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
330 return maybe_binary(bin, *end, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
331 case '=': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
332 case '!': |
2191
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
333 case '>': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
334 case '<': |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
335 bin->right = parse_expression(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
336 return bin; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
337 default: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
338 bin->left = NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
339 free(bin); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
340 return left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
341 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
342 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
343 |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
344 static expr *maybe_muldiv(expr *left, char *start, char **end) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
345 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
346 char *after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
347 token first = parse_token(start, &after_first); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
348 if (first.type != TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
349 *end = start; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
350 return left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
351 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
352 expr *bin = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
353 bin->left = left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
354 bin->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
355 bin->type = EXPR_BINARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
356 switch (first.v.op[0]) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
357 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
358 case '*': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
359 case '/': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
360 case '&': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
361 case '|': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
362 case '^': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
363 bin->right = parse_scalar(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
364 return maybe_binary(bin, *end, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
365 default: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
366 bin->left = NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
367 free(bin); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
368 return left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
369 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
370 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
371 |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
372 static expr *parse_scalar_or_muldiv(char *start, char **end) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
373 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
374 char *after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
375 token first = parse_token(start, &after_first); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
376 if (!first.type) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
377 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
378 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
379 if (first.type == TOKEN_SIZE) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
380 fprintf(stderr, "Unexpected TOKEN_SIZE '.%s'\n", first.v.op); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
381 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
382 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
383 if (first.type == TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
384 expr *target = parse_scalar(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
385 if (!target) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
386 fprintf(stderr, "Unary expression %s needs value\n", first.v.op); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
387 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
388 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
389 expr *ret = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
390 ret->type = EXPR_UNARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
391 ret->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
392 ret->left = target; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
393 return ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
394 } |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
395 if (first.type == TOKEN_LBRACKET) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
396 expr *ret = calloc(1, sizeof(expr)); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
397 ret->type = EXPR_MEM; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
398 ret->left = parse_expression(after_first, end); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
399 if (!ret->left) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
400 fprintf(stderr, "Expression expected after `[`\n"); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
401 free(ret); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
402 return NULL; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
403 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
404 token rbrack = parse_token(*end, end); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
405 if (rbrack.type != TOKEN_RBRACKET) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
406 fprintf(stderr, "Missing closing `]`"); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
407 free_expr(ret); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
408 return NULL; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
409 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
410 char *after_size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
411 token size = parse_token(*end, &after_size); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
412 if (size.type == TOKEN_SIZE) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
413 *end = after_size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
414 ret->op = size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
415 } |
2171
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
416 return maybe_muldiv(ret, *end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
417 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
418 if (first.type == TOKEN_LPAREN) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
419 expr *ret = parse_expression(after_first, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
420 if (!ret) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
421 fprintf(stderr, "Expression expected after `(`\n"); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
422 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
423 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
424 token rparen = parse_token(*end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
425 if (rparen.type != TOKEN_RPAREN) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
426 fprintf(stderr, "Missing closing `)`"); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
427 free_expr(ret); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
428 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
429 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
430 return maybe_muldiv(ret, *end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
431 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
432 if (first.type != TOKEN_NUM && first.type != TOKEN_NAME) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
433 fprintf(stderr, "Unexpected token %s\n", token_type_names[first.type]); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
434 return NULL; |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
435 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
436 char *after_second; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
437 token second = parse_token(after_first, &after_second); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
438 if (second.type == TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
439 expr *ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
440 expr *bin = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
441 bin->type = EXPR_BINARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
442 bin->left = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
443 bin->left->type = EXPR_SCALAR; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
444 bin->left->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
445 bin->op = second; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
446 switch (second.v.op[0]) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
447 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
448 case '*': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
449 case '/': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
450 case '&': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
451 case '|': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
452 case '^': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
453 bin->right = parse_scalar(after_second, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
454 return maybe_muldiv(bin, *end, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
455 case '+': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
456 case '-': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
457 case '=': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
458 case '!': |
2191
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
459 case '>': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
460 case '<': |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
461 ret = bin->left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
462 bin->left = NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
463 free_expr(bin); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
464 return ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
465 default: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
466 fprintf(stderr, "%s is not a valid binary operator\n", second.v.op); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
467 free(bin->left); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
468 free(bin); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
469 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
470 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
471 } else if (second.type == TOKEN_SIZE) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
472 expr *value = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
473 value->type = EXPR_SIZE; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
474 value->op = second; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
475 value->left = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
476 value->left->type = EXPR_SCALAR; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
477 value->left->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
478 return maybe_muldiv(value, after_second, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
479 } else { |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
480 expr *ret = calloc(1, sizeof(expr)); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
481 ret->type = EXPR_SCALAR; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
482 ret->op = first; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
483 *end = after_first; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
484 return ret; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
485 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
486 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
487 |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
488 static expr *parse_expression(char *start, char **end) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
489 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
490 char *after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
491 token first = parse_token(start, &after_first); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
492 if (!first.type) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
493 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
494 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
495 if (first.type == TOKEN_SIZE) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
496 fprintf(stderr, "Unexpected TOKEN_SIZE '.%s'\n", first.v.op); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
497 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
498 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
499 if (first.type == TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
500 expr *target = parse_scalar(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
501 if (!target) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
502 fprintf(stderr, "Unary expression %s needs value\n", first.v.op); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
503 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
504 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
505 expr *ret = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
506 ret->type = EXPR_UNARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
507 ret->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
508 ret->left = target; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
509 return ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
510 } |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
511 if (first.type == TOKEN_LBRACKET) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
512 expr *ret = calloc(1, sizeof(expr)); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
513 ret->type = EXPR_MEM; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
514 ret->left = parse_expression(after_first, end); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
515 if (!ret->left) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
516 fprintf(stderr, "Expression expected after `[`\n"); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
517 free(ret); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
518 return NULL; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
519 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
520 token rbrack = parse_token(*end, end); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
521 if (rbrack.type != TOKEN_RBRACKET) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
522 fprintf(stderr, "Missing closing `]`"); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
523 free_expr(ret); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
524 return NULL; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
525 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
526 char *after_size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
527 token size = parse_token(*end, &after_size); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
528 if (size.type == TOKEN_SIZE) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
529 *end = after_size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
530 ret->op = size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
531 } |
2171
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
532 return maybe_binary(ret, *end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
533 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
534 if (first.type == TOKEN_LPAREN) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
535 expr *ret = parse_expression(after_first, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
536 if (!ret) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
537 fprintf(stderr, "Expression expected after `(`\n"); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
538 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
539 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
540 token rparen = parse_token(*end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
541 if (rparen.type != TOKEN_RPAREN) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
542 fprintf(stderr, "Missing closing `)`"); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
543 free_expr(ret); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
544 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
545 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
546 return maybe_binary(ret, *end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
547 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
548 if (first.type != TOKEN_NUM && first.type != TOKEN_NAME) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
549 fprintf(stderr, "Unexpected token %s\n", token_type_names[first.type]); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
550 return NULL; |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
551 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
552 char *after_second; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
553 token second = parse_token(after_first, &after_second); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
554 if (second.type == TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
555 expr *bin = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
556 bin->type = EXPR_BINARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
557 bin->left = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
558 bin->left->type = EXPR_SCALAR; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
559 bin->left->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
560 bin->op = second; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
561 switch (second.v.op[0]) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
562 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
563 case '*': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
564 case '/': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
565 case '&': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
566 case '|': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
567 case '^': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
568 bin->right = parse_scalar(after_second, end); |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
569 if (!bin->right) { |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
570 fprintf(stderr, "Expected expression to the right of %s\n", second.v.op); |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
571 free_expr(bin); |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
572 return NULL; |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
573 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
574 return maybe_binary(bin, *end, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
575 case '+': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
576 case '-': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
577 bin->right = parse_scalar_or_muldiv(after_second, end); |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
578 if (!bin->right) { |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
579 fprintf(stderr, "Expected expression to the right of %s\n", second.v.op); |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
580 free_expr(bin); |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
581 return NULL; |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
582 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
583 return maybe_binary(bin, *end, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
584 case '=': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
585 case '!': |
2191
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
586 case '>': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
587 case '<': |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
588 bin->right = parse_expression(after_second, end); |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
589 if (!bin->right) { |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
590 fprintf(stderr, "Expected expression to the right of %s\n", second.v.op); |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
591 free_expr(bin); |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
592 return NULL; |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
593 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
594 return bin; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
595 default: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
596 fprintf(stderr, "%s is not a valid binary operator\n", second.v.op); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
597 free(bin->left); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
598 free(bin); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
599 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
600 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
601 } else if (second.type == TOKEN_SIZE) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
602 expr *value = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
603 value->type = EXPR_SIZE; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
604 value->op = second; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
605 value->left = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
606 value->left->type = EXPR_SCALAR; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
607 value->left->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
608 return maybe_binary(value, after_second, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
609 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
610 if (second.type == TOKEN_NAME) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
611 free(second.v.str); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
612 } |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
613 expr *ret = calloc(1, sizeof(expr)); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
614 ret->type = EXPR_SCALAR; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
615 ret->op = first; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
616 *end = after_first; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
617 return ret; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
618 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
619 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
620 |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
621 uint8_t eval_expr(debug_root *root, expr *e, uint32_t *out) |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
622 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
623 uint32_t right; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
624 switch(e->type) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
625 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
626 case EXPR_SCALAR: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
627 if (e->op.type == TOKEN_NAME) { |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
628 if (root->resolve(root, e->op.v.str, out)) { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
629 return 1; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
630 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
631 tern_val v; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
632 if (tern_find(root->symbols, e->op.v.str, &v)) { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
633 *out = v.intval; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
634 return 1; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
635 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
636 return 0; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
637 } else { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
638 *out = e->op.v.num; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
639 return 1; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
640 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
641 case EXPR_UNARY: |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
642 if (!eval_expr(root, e->left, out)) { |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
643 return 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
644 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
645 switch (e->op.v.op[0]) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
646 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
647 case '!': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
648 *out = !*out; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
649 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
650 case '~': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
651 *out = ~*out; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
652 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
653 case '-': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
654 *out = -*out; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
655 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
656 default: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
657 return 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
658 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
659 return 1; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
660 case EXPR_BINARY: |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
661 if (!eval_expr(root, e->left, out) || !eval_expr(root, e->right, &right)) { |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
662 return 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
663 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
664 switch (e->op.v.op[0]) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
665 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
666 case '+': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
667 *out += right; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
668 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
669 case '-': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
670 *out -= right; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
671 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
672 case '*': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
673 *out *= right; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
674 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
675 case '/': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
676 *out /= right; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
677 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
678 case '&': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
679 *out &= right; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
680 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
681 case '|': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
682 *out |= right; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
683 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
684 case '^': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
685 *out ^= right; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
686 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
687 case '=': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
688 *out = *out == right; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
689 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
690 case '!': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
691 *out = *out != right; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
692 break; |
2191
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
693 case '>': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
694 *out = e->op.v.op[1] ? *out >= right : *out > right; |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
695 break; |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
696 case '<': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
697 *out = e->op.v.op[1] ? *out <= right : *out < right; |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
698 break; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
699 default: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
700 return 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
701 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
702 return 1; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
703 case EXPR_SIZE: |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
704 if (!eval_expr(root, e->left, out)) { |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
705 return 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
706 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
707 switch (e->op.v.op[0]) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
708 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
709 case 'b': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
710 *out &= 0xFF; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
711 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
712 case 'w': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
713 *out &= 0xFFFF; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
714 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
715 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
716 return 1; |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
717 case EXPR_MEM: |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
718 if (!eval_expr(root, e->left, out)) { |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
719 return 0; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
720 } |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
721 return root->read_mem(root, out, e->op.v.op[0]); |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
722 default: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
723 return 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
724 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
725 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
726 |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
727 char * find_param(char * buf) |
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 for (; *buf; buf++) { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
730 if (*buf == ' ') { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
731 if (*(buf+1)) { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
732 return buf+1; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
733 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
734 } |
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 return NULL; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
737 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
738 |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
739 void strip_nl(char * buf) |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
740 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
741 for(; *buf; buf++) { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
742 if (*buf == '\n') { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
743 *buf = 0; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
744 return; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
745 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
746 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
747 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
748 |
1965
3a46ff899fa6
More correct implementation of byte printing in builtin debugger. Fix GDB debugger to use helper in backend.c for reading bytes
Michael Pavone <pavone@retrodev.com>
parents:
1963
diff
changeset
|
749 static uint8_t m68k_read_byte(uint32_t address, m68k_context *context) |
3a46ff899fa6
More correct implementation of byte printing in builtin debugger. Fix GDB debugger to use helper in backend.c for reading bytes
Michael Pavone <pavone@retrodev.com>
parents:
1963
diff
changeset
|
750 { |
3a46ff899fa6
More correct implementation of byte printing in builtin debugger. Fix GDB debugger to use helper in backend.c for reading bytes
Michael Pavone <pavone@retrodev.com>
parents:
1963
diff
changeset
|
751 //TODO: share this implementation with GDB debugger |
3a46ff899fa6
More correct implementation of byte printing in builtin debugger. Fix GDB debugger to use helper in backend.c for reading bytes
Michael Pavone <pavone@retrodev.com>
parents:
1963
diff
changeset
|
752 return read_byte(address, (void **)context->mem_pointers, &context->options->gen, context); |
3a46ff899fa6
More correct implementation of byte printing in builtin debugger. Fix GDB debugger to use helper in backend.c for reading bytes
Michael Pavone <pavone@retrodev.com>
parents:
1963
diff
changeset
|
753 } |
3a46ff899fa6
More correct implementation of byte printing in builtin debugger. Fix GDB debugger to use helper in backend.c for reading bytes
Michael Pavone <pavone@retrodev.com>
parents:
1963
diff
changeset
|
754 |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
755 static uint16_t m68k_read_word(uint32_t address, m68k_context *context) |
1313
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1312
diff
changeset
|
756 { |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1312
diff
changeset
|
757 return read_word(address, (void **)context->mem_pointers, &context->options->gen, context); |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1312
diff
changeset
|
758 } |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1312
diff
changeset
|
759 |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
760 static uint32_t m68k_read_long(uint32_t address, m68k_context *context) |
1313
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1312
diff
changeset
|
761 { |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1312
diff
changeset
|
762 return m68k_read_word(address, context) << 16 | m68k_read_word(address + 2, context); |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1312
diff
changeset
|
763 } |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1312
diff
changeset
|
764 |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
765 static uint8_t read_m68k(debug_root *root, uint32_t *out, char size) |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
766 { |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
767 m68k_context *context = root->cpu_context; |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
768 if (size == 'b') { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
769 *out = m68k_read_byte(*out, context); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
770 } else if (size == 'l') { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
771 if (*out & 1) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
772 fprintf(stderr, "Longword access to odd addresses (%X) is not allowed\n", *out); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
773 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
774 } |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
775 *out = m68k_read_long(*out, context); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
776 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
777 if (*out & 1) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
778 fprintf(stderr, "Wword access to odd addresses (%X) is not allowed\n", *out); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
779 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
780 } |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
781 *out = m68k_read_word(*out, context); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
782 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
783 return 1; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
784 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
785 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
786 static uint8_t write_m68k(debug_root *root, uint32_t address, uint32_t value, char size) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
787 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
788 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
789 if (size == 'b') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
790 write_byte(address, value, (void **)context->mem_pointers, &context->options->gen, context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
791 } else if (size == 'l') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
792 if (address & 1) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
793 fprintf(stderr, "Longword access to odd addresses (%X) is not allowed\n", address); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
794 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
795 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
796 write_word(address, value >> 16, (void **)context->mem_pointers, &context->options->gen, context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
797 write_word(address + 2, value, (void **)context->mem_pointers, &context->options->gen, context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
798 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
799 if (address & 1) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
800 fprintf(stderr, "Wword access to odd addresses (%X) is not allowed\n", address); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
801 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
802 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
803 write_word(address, value, (void **)context->mem_pointers, &context->options->gen, context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
804 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
805 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
806 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
807 |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
808 static uint8_t resolve_m68k(debug_root *root, const char *name, uint32_t *out) |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
809 { |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
810 m68k_context *context = root->cpu_context; |
2174
eff7bedfc838
Restore ability to print PC in debugger. Make 68K register names case insensitive. Add usp and ssp registers
Michael Pavone <pavone@retrodev.com>
parents:
2173
diff
changeset
|
811 if ((name[0] == 'd' || name[0] == 'D') && name[1] >= '0' && name[1] <= '7' && !name[2]) { |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
812 *out = context->dregs[name[1]-'0']; |
2174
eff7bedfc838
Restore ability to print PC in debugger. Make 68K register names case insensitive. Add usp and ssp registers
Michael Pavone <pavone@retrodev.com>
parents:
2173
diff
changeset
|
813 } else if ((name[0] == 'a' || name[0] == 'A') && name[1] >= '0' && name[1] <= '7' && !name[2]) { |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
814 *out = context->aregs[name[1]-'0']; |
2174
eff7bedfc838
Restore ability to print PC in debugger. Make 68K register names case insensitive. Add usp and ssp registers
Michael Pavone <pavone@retrodev.com>
parents:
2173
diff
changeset
|
815 } else if (!strcasecmp(name, "sr")) { |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
816 *out = context->status << 8; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
817 for (int flag = 0; flag < 5; flag++) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
818 *out |= context->flags[flag] << (4-flag); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
819 } |
2174
eff7bedfc838
Restore ability to print PC in debugger. Make 68K register names case insensitive. Add usp and ssp registers
Michael Pavone <pavone@retrodev.com>
parents:
2173
diff
changeset
|
820 } else if(!strcasecmp(name, "cycle")) { |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
821 *out = context->current_cycle; |
2174
eff7bedfc838
Restore ability to print PC in debugger. Make 68K register names case insensitive. Add usp and ssp registers
Michael Pavone <pavone@retrodev.com>
parents:
2173
diff
changeset
|
822 } else if (!strcasecmp(name, "pc")) { |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
823 *out = root->address; |
2174
eff7bedfc838
Restore ability to print PC in debugger. Make 68K register names case insensitive. Add usp and ssp registers
Michael Pavone <pavone@retrodev.com>
parents:
2173
diff
changeset
|
824 } else if (!strcasecmp(name, "usp")) { |
eff7bedfc838
Restore ability to print PC in debugger. Make 68K register names case insensitive. Add usp and ssp registers
Michael Pavone <pavone@retrodev.com>
parents:
2173
diff
changeset
|
825 *out = context->status & 0x20 ? context->aregs[8] : context->aregs[7]; |
eff7bedfc838
Restore ability to print PC in debugger. Make 68K register names case insensitive. Add usp and ssp registers
Michael Pavone <pavone@retrodev.com>
parents:
2173
diff
changeset
|
826 } else if (!strcasecmp(name, "ssp")) { |
eff7bedfc838
Restore ability to print PC in debugger. Make 68K register names case insensitive. Add usp and ssp registers
Michael Pavone <pavone@retrodev.com>
parents:
2173
diff
changeset
|
827 *out = context->status & 0x20 ? context->aregs[7] : context->aregs[8]; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
828 } else { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
829 return 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
830 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
831 return 1; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
832 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
833 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
834 static uint8_t set_m68k(debug_root *root, const char *name, uint32_t value) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
835 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
836 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
837 if ((name[0] == 'd' || name[0] == 'D') && name[1] >= '0' && name[1] <= '7' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
838 context->dregs[name[1]-'0'] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
839 } else if ((name[0] == 'a' || name[0] == 'A') && name[1] >= '0' && name[1] <= '7' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
840 context->aregs[name[1]-'0'] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
841 } else if (!strcasecmp(name, "sr")) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
842 context->status = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
843 for (int flag = 0; flag < 5; flag++) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
844 context->flags[flag] = (value & (1 << (4 - flag))) != 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
845 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
846 } else if (!strcasecmp(name, "usp")) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
847 context->aregs[context->status & 0x20 ? 8 : 7] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
848 } else if (!strcasecmp(name, "ssp")) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
849 context->aregs[context->status & 0x20 ? 7 : 8] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
850 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
851 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
852 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
853 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
854 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
855 |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
856 static uint8_t resolve_genesis(debug_root *root, const char *name, uint32_t *out) |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
857 { |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
858 if (resolve_m68k(root, name, out)) { |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
859 return 1; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
860 } |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
861 m68k_context *m68k = root->cpu_context; |
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
862 genesis_context *gen = m68k->system; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
863 if (!strcmp(name, "f") || !strcmp(name, "frame")) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
864 *out = gen->vdp->frame; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
865 return 1; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
866 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
867 return 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
868 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
869 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
870 void ambiguous_iter(char *key, tern_val val, uint8_t valtype, void *data) |
829
cc05444a4a4e
WIP debugger improvements. Partial support for display command in 68K debugger. Minor refactor to support commands on a breakpoint.
Michael Pavone <pavone@retrodev.com>
parents:
794
diff
changeset
|
871 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
872 char *prefix = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
873 char * full = alloc_concat(prefix, key); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
874 fprintf(stderr, "\t%s\n", full); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
875 free(full); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
876 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
877 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
878 uint8_t parse_command(debug_root *root, char *text, parsed_command *out) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
879 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
880 char *cur = text; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
881 while (*cur && *cur != '/' && !isspace(*cur)) |
829
cc05444a4a4e
WIP debugger improvements. Partial support for display command in 68K debugger. Minor refactor to support commands on a breakpoint.
Michael Pavone <pavone@retrodev.com>
parents:
794
diff
changeset
|
882 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
883 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
884 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
885 char *name = malloc(cur - text + 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
886 memcpy(name, text, cur - text); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
887 name[cur-text] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
888 uint8_t ret = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
889 tern_node *prefix_res = tern_find_prefix(root->commands, name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
890 command_def *def = tern_find_ptr(prefix_res, ""); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
891 if (!def) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
892 tern_node *node = prefix_res; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
893 while (node) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
894 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
895 if (node->left || node->right) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
896 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
897 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
898 if (node->el) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
899 node = node->straight.next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
900 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
901 def = node->straight.value.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
902 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
903 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
904 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
905 if (!def && prefix_res) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
906 fprintf(stderr, "%s is ambiguous. Matching commands:\n", name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
907 tern_foreach(prefix_res, ambiguous_iter, name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
908 goto cleanup_name; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
909 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
910 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
911 if (!def) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
912 fprintf(stderr, "%s is not a recognized command\n", name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
913 goto cleanup_name; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
914 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
915 char *format = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
916 if (*cur == '/') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
917 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
918 text = cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
919 while (*cur && !isspace(*cur)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
920 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
921 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
922 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
923 format = malloc(cur - text + 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
924 memcpy(format, text, cur - text); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
925 format[cur - text] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
926 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
927 int num_args = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
928 command_arg *args = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
929 if (*cur && *cur != '\n') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
930 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
931 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
932 text = cur; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
933 if (def->raw_args) { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
934 while (*cur && *cur != '\n') |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
935 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
936 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
937 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
938 char *raw_param = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
939 if (cur != text) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
940 raw_param = malloc(cur - text + 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
941 memcpy(raw_param, text, cur - text); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
942 raw_param[cur - text] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
943 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
944 out->raw = raw_param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
945 out->args = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
946 out->num_args = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
947 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
948 int arg_storage = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
949 if (def->max_args > 0) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
950 arg_storage = def->max_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
951 } else if (def->max_args) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
952 arg_storage = def->min_args > 0 ? 2 * def->min_args : 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
953 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
954 if (arg_storage) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
955 args = calloc(arg_storage, sizeof(command_arg)); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
956 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
957 while (*text && *text != '\n') |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
958 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
959 char *after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
960 expr *e = parse_expression(text, &after); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
961 if (e) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
962 if (num_args == arg_storage) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
963 if (def->max_args >= 0) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
964 free_expr(e); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
965 fprintf(stderr, "Command %s takes a max of %d arguments, but at least %d provided\n", name, def->max_args, def->max_args+1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
966 goto cleanup_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
967 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
968 arg_storage *= 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
969 args = realloc(args, arg_storage * sizeof(command_arg)); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
970 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
971 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
972 args[num_args].parsed = e; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
973 args[num_args].raw = malloc(after - text + 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
974 memcpy(args[num_args].raw, text, after - text); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
975 args[num_args++].raw[after - text] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
976 text = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
977 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
978 goto cleanup_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
979 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
980 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
981 if (num_args < def->min_args) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
982 fprintf(stderr, "Command %s requires at least %d arguments, but only %d provided\n", name, def->min_args, num_args); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
983 goto cleanup_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
984 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
985 out->raw = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
986 out->args = args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
987 out->num_args = num_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
988 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
989 out->def = def; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
990 out->format = format; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
991 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
992 ret = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
993 cleanup_args: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
994 if (!ret) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
995 for (int i = 0; i < num_args; i++) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
996 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
997 free_expr(args[i].parsed); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
998 free(args[i].raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
999 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1000 free(args); |
829
cc05444a4a4e
WIP debugger improvements. Partial support for display command in 68K debugger. Minor refactor to support commands on a breakpoint.
Michael Pavone <pavone@retrodev.com>
parents:
794
diff
changeset
|
1001 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1002 cleanup_name: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1003 free(name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1004 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1005 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1006 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1007 static void free_parsed_command(parsed_command *cmd); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1008 static void free_command_block(command_block *block) |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1009 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1010 for (int i = 0; i < block->num_commands; i++) |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1011 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1012 free_parsed_command(block->commands + i); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1013 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1014 free(block->commands); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1015 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1016 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1017 static void free_parsed_command(parsed_command *cmd) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1018 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1019 free(cmd->format); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1020 free(cmd->raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1021 for (int i = 0; i < cmd->num_args; i++) |
2173
894c7873a2b1
Consume all expressions in debugger print command
Michael Pavone <pavone@retrodev.com>
parents:
2172
diff
changeset
|
1022 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1023 free(cmd->args[i].raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1024 free_expr(cmd->args[i].parsed); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1025 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1026 free_command_block(&cmd->block); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1027 free_command_block(&cmd->else_block); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1028 free(cmd->args); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1029 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1030 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1031 enum { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1032 READ_FAILED = 0, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1033 NORMAL, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1034 EMPTY, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1035 ELSE, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1036 END |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1037 }; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1038 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1039 static uint8_t read_parse_command(debug_root *root, parsed_command *out, int indent_level) |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1040 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1041 ++indent_level; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1042 for (int i = 0; i < indent_level; i++) |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1043 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1044 putchar('>'); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1045 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1046 putchar(' '); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1047 fflush(stdout); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1048 #ifdef _WIN32 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1049 #define wait 0 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1050 #else |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1051 int wait = 1; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1052 fd_set read_fds; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1053 FD_ZERO(&read_fds); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1054 struct timeval timeout; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1055 #endif |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1056 do { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1057 process_events(); |
2252
6a07b13894f7
Fix input processing while waiting for console input in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2216
diff
changeset
|
1058 render_update_display(); |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1059 #ifndef _WIN32 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1060 timeout.tv_sec = 0; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1061 timeout.tv_usec = 16667; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1062 FD_SET(fileno(stdin), &read_fds); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1063 if(select(fileno(stdin) + 1, &read_fds, NULL, NULL, &timeout) >= 1) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1064 wait = 0; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1065 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1066 #endif |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1067 } while (wait); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1068 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1069 char input_buf[1024]; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1070 if (!fgets(input_buf, sizeof(input_buf), stdin)) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1071 fputs("fgets failed", stderr); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1072 return READ_FAILED; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1073 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1074 char *stripped = strip_ws(input_buf); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1075 if (!stripped[0]) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1076 return EMPTY; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1077 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1078 if (indent_level > 1) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1079 if (!strcmp(stripped, "else")) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1080 return ELSE; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1081 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1082 if (!strcmp(stripped, "end")) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1083 return END; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1084 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1085 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1086 if (parse_command(root, input_buf, out)) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1087 if (!out->def->has_block) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1088 return NORMAL; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1089 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1090 int command_storage = 4; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1091 command_block *block = &out->block; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1092 block->commands = calloc(command_storage, sizeof(parsed_command)); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1093 block->num_commands = 0; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1094 for (;;) |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1095 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1096 if (block->num_commands == command_storage) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1097 command_storage *= 2; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1098 block->commands = realloc(block->commands, command_storage * sizeof(parsed_command)); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1099 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1100 switch (read_parse_command(root, block->commands + block->num_commands, indent_level)) |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1101 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1102 case READ_FAILED: |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1103 return READ_FAILED; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1104 case NORMAL: |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1105 block->num_commands++; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1106 break; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1107 case END: |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1108 return NORMAL; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1109 case ELSE: |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1110 if (block == &out->else_block) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1111 fprintf(stderr, "Too many else blocks for command %s\n", out->def->names[0]); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1112 return READ_FAILED; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1113 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1114 if (!out->def->accepts_else) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1115 fprintf(stderr, "Command %s does not take an else block\n", out->def->names[0]); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1116 return READ_FAILED; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1117 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1118 block = &out->else_block; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1119 block->commands = calloc(command_storage, sizeof(parsed_command)); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1120 block->num_commands = 0; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1121 break; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1122 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1123 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1124 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1125 return READ_FAILED; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1126 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1127 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1128 static uint8_t run_command(debug_root *root, parsed_command *cmd) |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1129 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1130 if (!cmd->def->raw_args && !cmd->def->skip_eval) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1131 for (int i = 0; i < cmd->num_args; i++) |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1132 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1133 if (!eval_expr(root, cmd->args[i].parsed, &cmd->args[i].value)) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1134 fprintf(stderr, "Failed to eval %s\n", cmd->args[i].raw); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1135 return 1; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1136 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1137 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1138 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1139 return cmd->def->impl(root, cmd); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1140 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1141 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1142 static void debugger_repl(debug_root *root) |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1143 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1144 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1145 int debugging = 1; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1146 parsed_command cmds[2] = {0}; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1147 int cur = 0; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1148 uint8_t has_last = 0; |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1149 if (root->last_cmd.def) { |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1150 memcpy(cmds + 1, &root->last_cmd, sizeof(root->last_cmd)); |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1151 has_last = 1; |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1152 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1153 while(debugging) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1154 switch (read_parse_command(root, cmds + cur, 0)) |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1155 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1156 case NORMAL: |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1157 debugging = run_command(root, cmds + cur); |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1158 cur = !cur; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1159 if (debugging && has_last) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1160 free_parsed_command(cmds + cur); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1161 memset(cmds + cur, 0, sizeof(cmds[cur])); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1162 } |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1163 has_last = 1; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1164 break; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1165 case EMPTY: |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1166 if (has_last) { |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1167 debugging = run_command(root, cmds + !cur); |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1168 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1169 break; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1170 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1171 } |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1172 if (has_last) { |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1173 memcpy(&root->last_cmd, cmds + !cur, sizeof(root->last_cmd)); |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1174 } else { |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1175 free_parsed_command(cmds + !cur); |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1176 } |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1177 free_parsed_command(cmds + cur); |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1178 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1179 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1180 static uint8_t cmd_quit(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1181 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1182 exit(0); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1183 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1184 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1185 typedef struct { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1186 size_t num_commands; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1187 size_t longest_command; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1188 } help_state; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1189 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1190 static void help_first_pass(char *key, tern_val val, uint8_t valtype, void *data) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1191 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1192 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1193 if (def->visited) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1194 return; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1195 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1196 def->visited = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1197 help_state *state = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1198 state->num_commands++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1199 size_t len = strlen(def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1200 if (len > state->longest_command) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1201 state->longest_command = len; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1202 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1203 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1204 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1205 static void help_reset_visited(char *key, tern_val val, uint8_t valtype, void *data) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1206 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1207 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1208 def->visited = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1209 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1210 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1211 static void help_second_pass(char *key, tern_val val, uint8_t valtype, void *data) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1212 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1213 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1214 if (def->visited) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1215 return; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1216 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1217 def->visited = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1218 help_state *state = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1219 size_t len = strlen(def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1220 printf(" %s", def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1221 while (len < state->longest_command) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1222 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1223 len++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1224 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1225 int remaining = 80 - state->longest_command - 5; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1226 const char *extra_desc = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1227 if (strlen(def->desc) <= remaining) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1228 printf(" - %s\n", def->desc); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1229 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1230 char split[76]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1231 int split_point = remaining; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1232 while (split_point > 0 && !isspace(def->desc[split_point])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1233 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1234 --split_point; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1235 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1236 if (!split_point) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1237 split_point = remaining; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1238 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1239 memcpy(split, def->desc, split_point); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1240 extra_desc = def->desc + split_point + 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1241 split[split_point] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1242 printf(" - %s\n", split); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1243 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1244 if (def->names[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1245 fputs(" Aliases: ", stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1246 len = strlen(" Aliases: "); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1247 const char **name = def->names + 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1248 uint8_t first = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1249 while (*name) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1250 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1251 if (first) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1252 first = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1253 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1254 putchar(','); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1255 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1256 len += 2; |
1312
9ab3f6781202
Allow adding .w or .b to select just the low word or byte of a register in a 68K debugger print command
Michael Pavone <pavone@retrodev.com>
parents:
1311
diff
changeset
|
1257 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1258 fputs(*name, stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1259 len += strlen(*name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1260 ++name; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1261 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1262 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1263 len = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1264 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1265 if (extra_desc) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1266 while (len < state->longest_command + 5) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1267 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1268 len++; |
829
cc05444a4a4e
WIP debugger improvements. Partial support for display command in 68K debugger. Minor refactor to support commands on a breakpoint.
Michael Pavone <pavone@retrodev.com>
parents:
794
diff
changeset
|
1269 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1270 fputs(extra_desc, stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1271 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1272 putchar('\n'); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1273 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1274 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1275 static uint8_t cmd_help(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1276 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1277 help_state state = {0,0}; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1278 tern_foreach(root->commands, help_first_pass, &state); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1279 tern_foreach(root->commands, help_reset_visited, &state); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1280 tern_foreach(root->commands, help_second_pass, &state); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1281 tern_foreach(root->commands, help_reset_visited, &state); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1282 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1283 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1284 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1285 static uint8_t cmd_continue(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1286 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1287 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1288 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1289 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1290 static void make_format_str(char *format_str, char *format) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1291 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1292 strcpy(format_str, "%s: %d\n"); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1293 if (format) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1294 switch (format[0]) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1295 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1296 case 'x': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1297 case 'X': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1298 case 'd': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1299 case 'c': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1300 case 's': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1301 format_str[5] = format[0]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1302 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1303 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1304 fprintf(stderr, "Unrecognized format character: %c\n", format[0]); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1305 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1306 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1307 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1308 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1309 static void do_print(debug_root *root, char *format_str, char *raw, uint32_t value) |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1310 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1311 if (format_str[5] == 's') { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1312 char tmp[128]; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1313 int j; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1314 uint32_t addr = value; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1315 for (j = 0; j < sizeof(tmp)-1; j++, addr++) |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1316 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1317 uint32_t tmp_addr = addr; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1318 root->read_mem(root, &tmp_addr, 'b'); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1319 char c = tmp_addr; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1320 if (c < 0x20 || c > 0x7F) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1321 break; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1322 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1323 tmp[j] = c; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1324 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1325 tmp[j] = 0; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1326 printf(format_str, raw, tmp); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1327 } else { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1328 printf(format_str, raw, value); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1329 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1330 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1331 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1332 static uint8_t cmd_print(debug_root *root, parsed_command *cmd) |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1333 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1334 char format_str[8]; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1335 make_format_str(format_str, cmd->format); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1336 for (int i = 0; i < cmd->num_args; i++) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1337 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1338 do_print(root, format_str, cmd->args[i].raw, cmd->args[i].value); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1339 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1340 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1341 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1342 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1343 static uint8_t cmd_printf(debug_root *root, parsed_command *cmd) |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1344 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1345 char *param = cmd->raw; |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1346 if (!param) { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1347 fputs("printf requires at least one parameter\n", stderr); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1348 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1349 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1350 while (isblank(*param)) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1351 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1352 ++param; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1353 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1354 if (*param != '"') { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1355 fprintf(stderr, "First parameter to printf must be a string, found '%s'\n", param); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1356 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1357 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1358 ++param; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1359 char *fmt = strdup(param); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1360 char *cur = param, *out = fmt; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1361 while (*cur && *cur != '"') |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1362 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1363 if (*cur == '\\') { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1364 switch (cur[1]) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1365 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1366 case 't': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1367 *(out++) = '\t'; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1368 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1369 case 'n': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1370 *(out++) = '\n'; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1371 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1372 case 'r': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1373 *(out++) = '\r'; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1374 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1375 case '\\': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1376 *(out++) = '\\'; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1377 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1378 default: |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1379 fprintf(stderr, "Unsupported escape character %c in string %s\n", cur[1], fmt); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1380 free(fmt); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1381 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1382 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1383 cur += 2; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1384 } else { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1385 *(out++) = *(cur++); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1386 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1387 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1388 *out = 0; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1389 ++cur; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1390 param = cur; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1391 cur = fmt; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1392 char format_str[3] = {'%', 'd', 0}; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1393 while (*cur) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1394 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1395 if (*cur == '%') { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1396 switch(cur[1]) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1397 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1398 case 'x': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1399 case 'X': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1400 case 'c': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1401 case 'd': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1402 case 's': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1403 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1404 default: |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1405 fprintf(stderr, "Unsupported format character %c\n", cur[1]); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1406 free(fmt); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1407 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1408 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1409 format_str[1] = cur[1]; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1410 expr *arg = parse_expression(param, ¶m); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1411 if (!arg) { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1412 free(fmt); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1413 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1414 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1415 uint32_t val; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1416 if (!eval_expr(root, arg, &val)) { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1417 free(fmt); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1418 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1419 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1420 if (cur[1] == 's') { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1421 char tmp[128]; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1422 int j; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1423 for (j = 0; j < sizeof(tmp)-1; j++, val++) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1424 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1425 uint32_t addr = val; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1426 root->read_mem(root, &addr, 'b'); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1427 char c = addr; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1428 if (c < 0x20 || c > 0x7F) { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1429 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1430 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1431 tmp[j] = c; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1432 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1433 tmp[j] = 0; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1434 printf(format_str, tmp); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1435 } else { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1436 printf(format_str, val); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1437 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1438 cur += 2; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1439 } else { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1440 putchar(*cur); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1441 ++cur; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1442 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1443 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1444 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1445 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1446 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1447 static uint8_t cmd_display(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1448 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1449 cmd_print(root, cmd); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1450 disp_def *ndisp = calloc(1, sizeof(*ndisp)); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1451 ndisp->next = root->displays; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1452 ndisp->index = root->disp_index++; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1453 ndisp->format = cmd->format ? strdup(cmd->format) : NULL; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1454 ndisp->num_args = cmd->num_args; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1455 ndisp->args = cmd->args; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1456 cmd->args = NULL; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1457 cmd->num_args = 0; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1458 root->displays = ndisp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1459 printf("Added display %d\n", ndisp->index); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1460 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1461 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1462 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1463 static uint8_t cmd_delete_display(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1464 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1465 disp_def **cur = &root->displays; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1466 while (*cur) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1467 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1468 if ((*cur)->index == cmd->args[0].value) { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1469 disp_def *del_disp = *cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1470 *cur = del_disp->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1471 free(del_disp->format); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1472 for (int i = 0; i < del_disp->num_args; i++) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1473 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1474 free(del_disp->args[i].raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1475 free_expr(del_disp->args[i].parsed); |
2173
894c7873a2b1
Consume all expressions in debugger print command
Michael Pavone <pavone@retrodev.com>
parents:
2172
diff
changeset
|
1476 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1477 free(del_disp->args); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1478 free(del_disp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1479 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1480 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1481 cur = &(*cur)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1482 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1483 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1484 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1485 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1486 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1487 static uint8_t cmd_softreset(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1488 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1489 if (current_system->soft_reset) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1490 current_system->soft_reset(current_system); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1491 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1492 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1493 fputs("Current system does not support soft reset", stderr); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1494 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1495 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1496 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1497 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1498 static uint8_t cmd_command(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1499 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1500 bp_def **target = find_breakpoint_idx(&root->breakpoints, cmd->args[0].value); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1501 if (!target) { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1502 fprintf(stderr, "Breakpoint %d does not exist!\n", cmd->args[0].value); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1503 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1504 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1505 for (uint32_t i = 0; i < (*target)->num_commands; i++) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1506 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1507 free_parsed_command((*target)->commands + i); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1508 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1509 free((*target)->commands); |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1510 (*target)->commands = cmd->block.commands; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1511 (*target)->num_commands = cmd->block.num_commands; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1512 cmd->block.commands = NULL; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1513 cmd->block.num_commands = 0; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1514 return 1; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1515 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1516 |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1517 static uint8_t execute_block(debug_root *root, command_block * block) |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1518 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1519 uint8_t debugging = 1; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1520 for (int i = 0; i < block->num_commands; i++) |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1521 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1522 debugging = run_command(root, block->commands + i) && debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1523 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1524 return debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1525 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1526 |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1527 static uint8_t cmd_if(debug_root *root, parsed_command *cmd) |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1528 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1529 return execute_block(root, cmd->args[0].value ? &cmd->block : &cmd->else_block); |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1530 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1531 |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1532 static uint8_t cmd_while(debug_root *root, parsed_command *cmd) |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1533 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1534 if (!cmd->args[0].value) { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1535 return execute_block(root, &cmd->else_block); |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1536 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1537 int debugging = 1; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1538 do { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1539 debugging = execute_block(root, &cmd->block) && debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1540 if (!eval_expr(root, cmd->args[0].parsed, &cmd->args[0].value)) { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1541 fprintf(stderr, "Failed to eval %s\n", cmd->args[0].raw); |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1542 return 1; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1543 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1544 } while (cmd->args[0].value); |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1545 return debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1546 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1547 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1548 const char *expr_type_names[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1549 "EXPR_NONE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1550 "EXPR_SCALAR", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1551 "EXPR_UNARY", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1552 "EXPR_BINARY", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1553 "EXPR_SIZE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1554 "EXPR_MEM" |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1555 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1556 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1557 static uint8_t cmd_set(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1558 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1559 char *name = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1560 char size = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1561 uint32_t address; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1562 switch (cmd->args[0].parsed->type) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1563 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1564 case EXPR_SCALAR: |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1565 if (cmd->args[0].parsed->op.type == TOKEN_NAME) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1566 name = cmd->args[0].parsed->op.v.str; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1567 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1568 fputs("First argument to set must be a name or memory expression, not a number", stderr); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1569 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1570 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1571 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1572 case EXPR_SIZE: |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1573 size = cmd->args[0].parsed->op.v.op[0]; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1574 if (cmd->args[0].parsed->left->op.type == TOKEN_NAME) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1575 name = cmd->args[0].parsed->left->op.v.str; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1576 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1577 fputs("First argument to set must be a name or memory expression, not a number", stderr); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1578 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1579 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1580 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1581 case EXPR_MEM: |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1582 size = cmd->args[0].parsed->op.v.op[0]; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1583 if (!eval_expr(root, cmd->args[0].parsed->left, &address)) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1584 fprintf(stderr, "Failed to eval %s\n", cmd->args[0].raw); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1585 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1586 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1587 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1588 default: |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1589 fprintf(stderr, "First argument to set must be a name or memory expression, got %s\n", expr_type_names[cmd->args[0].parsed->type]); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1590 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1591 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1592 if (!eval_expr(root, cmd->args[1].parsed, &cmd->args[1].value)) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1593 fprintf(stderr, "Failed to eval %s\n", cmd->args[1].raw); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1594 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1595 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1596 uint32_t value = cmd->args[1].value; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1597 if (name && size && size != 'l') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1598 uint32_t old; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1599 if (!root->resolve(root, name, &old)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1600 fprintf(stderr, "Failed to eval %s\n", name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1601 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1602 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1603 if (size == 'b') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1604 old &= 0xFFFFFF00; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1605 value &= 0xFF; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1606 value |= old; |
1314
ae932ca28282
Allow a .l suffix to a memory print command to allow fetching and printing a longword
Michael Pavone <pavone@retrodev.com>
parents:
1313
diff
changeset
|
1607 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1608 old &= 0xFFFF0000; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1609 value &= 0xFFFF; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1610 value |= old; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1611 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1612 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1613 if (name) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1614 if (!root->set(root, name, value)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1615 fprintf(stderr, "Failed to set %s\n", name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1616 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1617 } else if (!root->write_mem(root, address, value, size)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1618 fprintf(stderr, "Failed to write to address %X\n", address); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1619 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1620 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1621 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1622 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1623 static uint8_t cmd_frames(debug_root *root, parsed_command *cmd) |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
1624 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1625 current_system->enter_debugger_frames = cmd->args[0].value; |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
1626 return 0; |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
1627 } |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
1628 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1629 static uint8_t cmd_bindup(debug_root *root, parsed_command *cmd) |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1630 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1631 if (!bind_up(cmd->raw)) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1632 fprintf(stderr, "%s is not a valid binding name\n", cmd->raw); |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1633 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1634 return 1; |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1635 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1636 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1637 static uint8_t cmd_binddown(debug_root *root, parsed_command *cmd) |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1638 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1639 if (!bind_down(cmd->raw)) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1640 fprintf(stderr, "%s is not a valid binding name\n", cmd->raw); |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1641 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1642 return 1; |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1643 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1644 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1645 static uint8_t cmd_condition(debug_root *root, parsed_command *cmd) |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1646 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1647 if (!eval_expr(root, cmd->args[0].parsed, &cmd->args[0].value)) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1648 fprintf(stderr, "Failed to evaluate breakpoint number: %s\n", cmd->args[0].raw); |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1649 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1650 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1651 bp_def **target = find_breakpoint_idx(&root->breakpoints, cmd->args[0].value); |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1652 if (!*target) { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1653 fprintf(stderr, "Failed to find breakpoint %u\n", cmd->args[0].value); |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1654 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1655 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1656 free_expr((*target)->condition); |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1657 if (cmd->num_args > 1 && cmd->args[1].parsed) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1658 (*target)->condition = cmd->args[1].parsed; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1659 cmd->args[1].parsed = NULL; |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1660 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1661 (*target)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1662 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1663 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1664 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1665 |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1666 static void symbol_max_len(char *key, tern_val val, uint8_t valtype, void *data) |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1667 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1668 size_t *max_len = data; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1669 size_t len = strlen(key); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1670 if (len > *max_len) { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1671 *max_len = len; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1672 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1673 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1674 |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1675 static void print_symbol(char *key, tern_val val, uint8_t valtype, void *data) |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1676 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1677 size_t *padding = data; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1678 size_t len = strlen(key); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1679 fputs(key, stdout); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1680 while (len < *padding) |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1681 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1682 putchar(' '); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1683 len++; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1684 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1685 printf("%X\n", (uint32_t)val.intval); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1686 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1687 |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1688 static uint8_t cmd_symbols(debug_root *root, parsed_command *cmd) |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1689 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1690 char *filename = cmd->raw ? strip_ws(cmd->raw) : NULL; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1691 if (filename && *filename) { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1692 FILE *f = fopen(filename, "r"); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1693 if (!f) { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1694 fprintf(stderr, "Failed to open %s for reading\n", filename); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1695 return 1; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1696 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1697 char linebuf[1024]; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1698 while (fgets(linebuf, sizeof(linebuf), f)) |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1699 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1700 char *line = strip_ws(linebuf); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1701 if (*line) { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1702 char *end; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1703 uint32_t address = strtol(line, &end, 16); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1704 if (end != line) { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1705 if (*end == '=') { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1706 char *name = strip_ws(end + 1); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1707 add_label(root->disasm, name, address); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1708 root->symbols = tern_insert_int(root->symbols, name, address); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1709 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1710 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1711 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1712 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1713 } else { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1714 size_t max_len = 0; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1715 tern_foreach(root->symbols, symbol_max_len, &max_len); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1716 max_len += 2; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1717 tern_foreach(root->symbols, print_symbol, &max_len); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1718 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1719 return 1; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1720 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1721 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1722 static uint8_t cmd_delete_m68k(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1723 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1724 bp_def **this_bp = find_breakpoint_idx(&root->breakpoints, cmd->args[0].value); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1725 if (!*this_bp) { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1726 fprintf(stderr, "Breakpoint %d does not exist\n", cmd->args[0].value); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1727 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1728 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1729 bp_def *tmp = *this_bp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1730 remove_breakpoint(root->cpu_context, tmp->address); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1731 *this_bp = (*this_bp)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1732 if (tmp->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1733 for (uint32_t i = 0; i < tmp->num_commands; i++) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1734 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1735 free_parsed_command(tmp->commands + i); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1736 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1737 free(tmp->commands); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1738 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1739 free(tmp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1740 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1741 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1742 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1743 static uint8_t cmd_breakpoint_m68k(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1744 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1745 insert_breakpoint(root->cpu_context, cmd->args[0].value, debugger); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1746 bp_def *new_bp = calloc(1, sizeof(bp_def)); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1747 new_bp->next = root->breakpoints; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1748 new_bp->address = cmd->args[0].value; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1749 new_bp->index = root->bp_index++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1750 root->breakpoints = new_bp; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1751 printf("68K Breakpoint %d set at %X\n", new_bp->index, cmd->args[0].value); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1752 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1753 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1754 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1755 static uint8_t cmd_advance_m68k(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1756 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1757 insert_breakpoint(root->cpu_context, cmd->args[0].value, debugger); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1758 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1759 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1760 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1761 static uint8_t cmd_step_m68k(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1762 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1763 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1764 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1765 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1766 if (inst->op == M68K_RTS) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1767 after = m68k_read_long(context->aregs[7], context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1768 } else if (inst->op == M68K_RTE || inst->op == M68K_RTR) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1769 after = m68k_read_long(context->aregs[7] + 2, context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1770 } else if(m68k_is_branch(inst)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1771 if (inst->op == M68K_BCC && inst->extra.cond != COND_TRUE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1772 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1773 root->branch_t = m68k_branch_target(inst, context->dregs, context->aregs) & 0xFFFFFF; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1774 insert_breakpoint(context, root->branch_t, debugger); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1775 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1776 if (inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1777 if (context->dregs[inst->dst.params.regs.pri] & 0xFFFF) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1778 after = m68k_branch_target(inst, context->dregs, context->aregs); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1779 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1780 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1781 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1782 root->branch_f = m68k_branch_target(inst, context->dregs, context->aregs); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1783 insert_breakpoint(context, root->branch_f, debugger); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1784 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1785 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1786 after = m68k_branch_target(inst, context->dregs, context->aregs) & 0xFFFFFF; |
1314
ae932ca28282
Allow a .l suffix to a memory print command to allow fetching and printing a longword
Michael Pavone <pavone@retrodev.com>
parents:
1313
diff
changeset
|
1787 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1788 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1789 insert_breakpoint(root->cpu_context, after, debugger); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1790 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1791 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1792 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1793 static uint8_t cmd_over_m68k(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1794 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1795 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1796 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1797 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1798 if (inst->op == M68K_RTS) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1799 after = m68k_read_long(context->aregs[7], context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1800 } else if (inst->op == M68K_RTE || inst->op == M68K_RTR) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1801 after = m68k_read_long(context->aregs[7] + 2, context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1802 } else if(m68k_is_noncall_branch(inst)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1803 if (inst->op == M68K_BCC && inst->extra.cond != COND_TRUE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1804 root->branch_t = m68k_branch_target(inst, context->dregs, context->aregs) & 0xFFFFFF; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1805 if (root->branch_t < after) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1806 root->branch_t = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1807 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1808 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1809 insert_breakpoint(context, root->branch_t, debugger); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1810 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1811 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1812 uint32_t target = m68k_branch_target(inst, context->dregs, context->aregs) & 0xFFFFFF; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1813 if (target > after) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1814 if (inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1815 after = target; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1816 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1817 root->branch_f = target; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1818 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1819 insert_breakpoint(context, root->branch_f, debugger); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1820 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1821 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1822 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1823 after = m68k_branch_target(inst, context->dregs, context->aregs) & 0xFFFFFF; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1824 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1825 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1826 insert_breakpoint(root->cpu_context, after, debugger); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1827 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1828 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1829 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1830 static uint8_t cmd_next_m68k(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1831 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1832 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1833 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1834 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1835 if (inst->op == M68K_RTS) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1836 after = m68k_read_long(context->aregs[7], context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1837 } else if (inst->op == M68K_RTE || inst->op == M68K_RTR) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1838 after = m68k_read_long(context->aregs[7] + 2, context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1839 } else if(m68k_is_noncall_branch(inst)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1840 if (inst->op == M68K_BCC && inst->extra.cond != COND_TRUE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1841 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1842 root->branch_t = m68k_branch_target(inst, context->dregs, context->aregs); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1843 insert_breakpoint(context, root->branch_t, debugger); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1844 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1845 if ( inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1846 if (context->dregs[inst->dst.params.regs.pri] & 0xFFFF) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1847 after = m68k_branch_target(inst, context->dregs, context->aregs); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1848 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1849 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1850 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1851 root->branch_f = m68k_branch_target(inst, context->dregs, context->aregs); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1852 insert_breakpoint(context, root->branch_f, debugger); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1853 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1854 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1855 after = m68k_branch_target(inst, context->dregs, context->aregs) & 0xFFFFFF; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1856 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1857 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1858 insert_breakpoint(root->cpu_context, after, debugger); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1859 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1860 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1861 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1862 static uint8_t cmd_backtrace_m68k(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1863 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1864 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1865 uint32_t stack = context->aregs[7]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1866 uint8_t non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1867 do { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1868 uint32_t bt_address = m68k_instruction_fetch(stack, context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1869 bt_address = get_instruction_start(context->options, bt_address - 2); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1870 if (bt_address) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1871 stack += 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1872 non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1873 m68kinst inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1874 char buf[128]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1875 m68k_decode(m68k_instruction_fetch, context, &inst, bt_address); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1876 m68k_disasm(&inst, buf); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1877 printf("%X: %s\n", bt_address, buf); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1878 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1879 //non-return address value on stack can be word wide |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1880 stack += 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1881 non_adr_count++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1882 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1883 //TODO: Make sure we don't wander into an invalid memory region |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1884 } while (stack && non_adr_count < 6); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1885 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1886 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1887 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1888 static uint8_t cmd_disassemble_m68k(debug_root *root, parsed_command *cmd) |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1889 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1890 m68k_context *context = root->cpu_context; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1891 uint32_t address = root->address; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1892 if (cmd->num_args) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1893 address = cmd->args[0].value; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1894 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1895 char disasm_buf[1024]; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1896 m68kinst inst; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1897 do { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1898 label_def *def = find_label(root->disasm, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1899 if (def) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1900 for (uint32_t i = 0; i < def->num_labels; i++) |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1901 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1902 printf("%s:\n", def->labels[i]); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1903 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1904 } |
2252
6a07b13894f7
Fix input processing while waiting for console input in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2216
diff
changeset
|
1905 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1906 address = m68k_decode(m68k_instruction_fetch, context, &inst, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1907 m68k_disasm_labels(&inst, disasm_buf, root->disasm); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1908 printf("\t%s\n", disasm_buf); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1909 } while(!m68k_is_terminal(&inst)); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1910 return 1; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1911 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1912 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1913 static uint8_t cmd_vdp_sprites(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1914 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1915 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1916 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1917 vdp_print_sprite_table(gen->vdp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1918 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1919 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1920 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1921 static uint8_t cmd_vdp_regs(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1922 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1923 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1924 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1925 vdp_print_reg_explain(gen->vdp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1926 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1927 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1928 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1929 static uint8_t cmd_ym_channel(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1930 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1931 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1932 genesis_context * gen = context->system; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1933 if (cmd->num_args) { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1934 ym_print_channel_info(gen->ym, cmd->args[0].value - 1); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1935 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1936 for (int i = 0; i < 6; i++) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1937 ym_print_channel_info(gen->ym, i); |
1314
ae932ca28282
Allow a .l suffix to a memory print command to allow fetching and printing a longword
Michael Pavone <pavone@retrodev.com>
parents:
1313
diff
changeset
|
1938 } |
2173
894c7873a2b1
Consume all expressions in debugger print command
Michael Pavone <pavone@retrodev.com>
parents:
2172
diff
changeset
|
1939 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1940 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1941 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1942 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1943 static uint8_t cmd_ym_timer(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1944 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1945 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1946 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1947 ym_print_timer_info(gen->ym); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1948 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1949 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1950 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1951 static uint8_t cmd_sub(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1952 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1953 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1954 while (param && *param && isblank(*param)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1955 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1956 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1957 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1958 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1959 genesis_context *gen = m68k->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1960 segacd_context *cd = gen->expansion; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1961 if (param && *param && !isspace(*param)) { |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1962 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1963 debug_root *sub_root = find_m68k_root(cd->m68k); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1964 if (!sub_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1965 fputs("Failed to get debug root for Sub CPU\n", stderr); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1966 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1967 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1968 if (!parse_command(sub_root, param, &cmd)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1969 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1970 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1971 uint8_t ret = run_command(sub_root, &cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1972 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1973 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1974 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1975 cd->enter_debugger = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1976 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1977 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1978 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1979 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1980 static uint8_t cmd_main(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1981 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1982 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1983 while (param && *param && isblank(*param)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1984 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1985 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1986 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1987 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1988 segacd_context *cd = m68k->system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
1989 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1990 if (param && *param && !isspace(*param)) { |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1991 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1992 debug_root *main_root = find_m68k_root(cd->genesis->m68k); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1993 if (!main_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1994 fputs("Failed to get debug root for Main CPU\n", stderr); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1995 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1996 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1997 if (!parse_command(main_root, param, &cmd)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1998 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1999 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2000 uint8_t ret = run_command(main_root, &cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2001 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2002 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2003 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2004 cd->genesis->header.enter_debugger = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2005 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2006 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2007 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2008 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2009 static uint8_t cmd_gen_z80(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2010 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2011 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2012 while (param && *param && isblank(*param)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2013 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2014 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2015 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2016 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2017 genesis_context *gen = m68k->system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
2018 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2019 if (param && *param && !isspace(*param)) { |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2020 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2021 debug_root *z80_root = find_z80_root(gen->z80); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2022 if (!z80_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2023 fputs("Failed to get debug root for Z80\n", stderr); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2024 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2025 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2026 if (!parse_command(z80_root, param, &cmd)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2027 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2028 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2029 uint8_t ret = run_command(z80_root, &cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2030 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2031 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2032 } else { |
2184
408fb8a7e990
Implement argumentless variant of z80 debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2183
diff
changeset
|
2033 gen->enter_z80_debugger = 1; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2034 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2035 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2036 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2037 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2038 command_def common_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2039 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2040 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2041 "quit", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2042 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2043 .usage = "quit", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2044 .desc = "Quit BlastEm", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2045 .impl = cmd_quit, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2046 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2047 .max_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2048 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2049 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2050 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2051 "help", "?", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2052 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2053 .usage = "help", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2054 .desc = "Print a list of available commands for the current debug context", |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2055 .impl = cmd_help, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2056 .min_args = 0, |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2057 .max_args = 1, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2058 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2059 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2060 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2061 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2062 "continue", "c", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2063 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2064 .usage = "continue", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2065 .desc = "Resume execution", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2066 .impl = cmd_continue, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2067 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2068 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2069 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2070 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2071 .names = (const char *[]){ |
2189
6b33ce6bc740
Add an explicit p alias for the print command now that printf prevents use of it as an implicit alias
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
2072 "print", "p", NULL |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2073 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2074 .usage = "print[/FORMAT] EXPRESSION...", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2075 .desc = "Print one or more expressions using the optional format character", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2076 .impl = cmd_print, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2077 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2078 .max_args = -1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2079 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2080 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2081 .names = (const char *[]){ |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2082 "printf", NULL |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2083 }, |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2084 .usage = "printf FORMAT EXPRESSION...", |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2085 .desc = "Print a string with C-style formatting specifiers replaced with the value of the remaining arguments", |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2086 .impl = cmd_printf, |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2087 .min_args = 1, |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2088 .max_args = -1, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2089 .raw_args = 1 |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2090 }, |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2091 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2092 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2093 "softreset", "sr", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2094 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2095 .usage = "softreset", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2096 .desc = "Perform a soft-reset for the current system", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2097 .impl = cmd_softreset, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2098 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2099 .max_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2100 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2101 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2102 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2103 "display", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2104 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2105 .usage = "display[/FORMAT] EXPRESSION...", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2106 .desc = "Print one or more expressions every time the debugger is entered", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2107 .impl = cmd_display, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2108 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2109 .max_args = -1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2110 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2111 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2112 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2113 "deletedisplay", "dd", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2114 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2115 .usage = "deletedisplay DISPLAYNUM", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2116 .desc = "Remove expressions added with the `display` command", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2117 .impl = cmd_delete_display, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2118 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2119 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2120 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2121 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2122 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2123 "commands", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2124 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2125 .usage = "command BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2126 .desc = "Set a list of debugger commands to be executed when the given breakpoint is hit", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2127 .impl = cmd_command, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2128 .min_args = 1, |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2129 .max_args = 1, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2130 .has_block = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2131 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2132 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2133 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2134 "set", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2135 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2136 .usage = "set MEM|NAME VALUE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2137 .desc = "Set a register, symbol or memory location to the result of evaluating VALUE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2138 .impl = cmd_set, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2139 .min_args = 2, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2140 .max_args = 2, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2141 .skip_eval = 1 |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2142 }, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2143 { |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2144 .names = (const char *[]){ |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2145 "frames", NULL |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2146 }, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2147 .usage = "frames EXPRESSION", |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2148 .desc = "Resume execution for EXPRESSION video frames", |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2149 .impl = cmd_frames, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2150 .min_args = 1, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2151 .max_args = 1 |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2152 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2153 { |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2154 .names = (const char *[]){ |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2155 "bindup", NULL |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2156 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2157 .usage = "bindup NAME", |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2158 .desc = "Simulate a keyup for binding NAME", |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2159 .impl = cmd_bindup, |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2160 .min_args = 1, |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2161 .max_args = 1, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2162 .raw_args = 1 |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2163 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2164 { |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2165 .names = (const char *[]){ |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2166 "binddown", NULL |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2167 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2168 .usage = "bindown NAME", |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2169 .desc = "Simulate a keydown for binding NAME", |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2170 .impl = cmd_binddown, |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2171 .min_args = 1, |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2172 .max_args = 1, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2173 .raw_args = 1 |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2174 }, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2175 { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2176 .names = (const char *[]){ |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2177 "condition", NULL |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2178 }, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2179 .usage = "condition BREAKPOINT [EXPRESSION]", |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2180 .desc = "Makes breakpoint BREAKPOINT conditional on the value of EXPRESSION or removes a condition if EXPRESSION is omitted", |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2181 .impl = cmd_condition, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2182 .min_args = 1, |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2183 .max_args = 2, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2184 .skip_eval = 1 |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2185 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2186 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2187 .names = (const char *[]){ |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2188 "if", NULL |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2189 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2190 .usage = "if CONDITION", |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2191 .desc = "If the condition is true, the following block is executed. Otherwise the else block is executed if present", |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2192 .impl = cmd_if, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2193 .min_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2194 .max_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2195 .has_block = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2196 .accepts_else = 1 |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2197 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2198 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2199 .names = (const char *[]){ |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2200 "while", NULL |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2201 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2202 .usage = "while CONDITION", |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2203 .desc = "The following block is executed repeatedly until the condition is false. If the condition is false at the start, the else block is executed if present", |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2204 .impl = cmd_while, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2205 .min_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2206 .max_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2207 .has_block = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2208 .accepts_else = 1 |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2209 }, |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2210 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2211 .names = (const char *[]){ |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2212 "symbols", NULL |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2213 }, |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2214 .usage = "symbols [FILENAME]", |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2215 .desc = "Loads a list of symbols from the file indicated by FILENAME or lists currently loaded symbols if FILENAME is omitted", |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2216 .impl = cmd_symbols, |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2217 .min_args = 0, |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2218 .max_args = 1, |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2219 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2220 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2221 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2222 #define NUM_COMMON (sizeof(common_commands)/sizeof(*common_commands)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2223 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2224 command_def m68k_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2225 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2226 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2227 "breakpoint", "b", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2228 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2229 .usage = "breakpoint ADDRESSS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2230 .desc = "Set a breakpoint at ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2231 .impl = cmd_breakpoint_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2232 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2233 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2234 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2235 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2236 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2237 "advance", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2238 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2239 .usage = "advance ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2240 .desc = "Advance to ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2241 .impl = cmd_advance_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2242 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2243 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2244 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2245 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2246 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2247 "step", "s", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2248 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2249 .usage = "step", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2250 .desc = "Advance to the next instruction, stepping into subroutines", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2251 .impl = cmd_step_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2252 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2253 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2254 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2255 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2256 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2257 "over", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2258 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2259 .usage = "over", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2260 .desc = "Advance to the next instruction, ignoring branches to lower addresses", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2261 .impl = cmd_over_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2262 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2263 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2264 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2265 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2266 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2267 "next", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2268 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2269 .usage = "next", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2270 .desc = "Advance to the next instruction", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2271 .impl = cmd_next_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2272 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2273 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2274 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2275 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2276 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2277 "backtrace", "bt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2278 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2279 .usage = "backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2280 .desc = "Print a backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2281 .impl = cmd_backtrace_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2282 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2283 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2284 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2285 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2286 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2287 "delete", "d", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2288 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2289 .usage = "delete BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2290 .desc = "Remove breakpoint identified by BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2291 .impl = cmd_delete_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2292 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2293 .max_args = 1 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2294 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2295 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2296 .names = (const char *[]){ |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2297 "disassemble", "disasm", NULL |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2298 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2299 .usage = "disassemble [ADDRESS]", |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2300 .desc = "Disassemble code starting at ADDRESS if provided or the current address if not", |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2301 .impl = cmd_disassemble_m68k, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2302 .min_args = 0, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2303 .max_args = 1 |
2112
3abb64bd0da6
Add support for printing strings in 68K debugger
Michael Pavone <pavone@retrodev.com>
parents:
2107
diff
changeset
|
2304 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2305 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2306 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2307 #define NUM_68K (sizeof(m68k_commands)/sizeof(*m68k_commands)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2308 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2309 command_def genesis_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2310 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2311 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2312 "vdpsprites", "vs", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2313 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2314 .usage = "vdpsprites", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2315 .desc = "Print the VDP sprite table", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2316 .impl = cmd_vdp_sprites, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2317 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2318 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2319 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2320 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2321 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2322 "vdpsregs", "vr", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2323 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2324 .usage = "vdpregs", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2325 .desc = "Print VDP register values with a short description", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2326 .impl = cmd_vdp_regs, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2327 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2328 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2329 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2330 #ifndef NO_Z80 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2331 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2332 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2333 "z80", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2334 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2335 .usage = "z80 [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2336 .desc = "Run a Z80 debugger command or switch to Z80 context when no command is given", |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2337 .impl = cmd_gen_z80, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2338 .min_args = 0, |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2339 .max_args = -1, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2340 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2341 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2342 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2343 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2344 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2345 "ymchannel", "yc", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2346 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2347 .usage = "ymchannel [CHANNEL]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2348 .desc = "Print YM-2612 channel and operator params. Limited to CHANNEL if specified", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2349 .impl = cmd_ym_channel, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2350 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2351 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2352 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2353 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2354 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2355 "ymtimer", "yt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2356 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2357 .usage = "ymtimer", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2358 .desc = "Print YM-2612 timer info", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2359 .impl = cmd_ym_timer, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2360 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2361 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2362 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2363 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2364 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2365 #define NUM_GENESIS (sizeof(genesis_commands)/sizeof(*genesis_commands)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2366 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2367 command_def scd_main_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2368 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2369 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2370 "subcpu", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2371 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2372 .usage = "subcpu [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2373 .desc = "Run a Sub-CPU debugger command or switch to Sub-CPU context when no command is given", |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2374 .impl = cmd_sub, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2375 .min_args = 0, |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2376 .max_args = -1, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2377 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2378 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2379 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2380 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2381 #define NUM_SCD_MAIN (sizeof(scd_main_commands)/sizeof(*scd_main_commands)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2382 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2383 command_def scd_sub_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2384 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2385 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2386 "maincpu", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2387 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2388 .usage = "maincpu [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2389 .desc = "Run a Main-CPU debugger command or switch to Main-CPU context when no command is given", |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2390 .impl = cmd_main, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2391 .min_args = 0, |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2392 .max_args = -1, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2393 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2394 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2395 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2396 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2397 #define NUM_SCD_SUB (sizeof(scd_main_commands)/sizeof(*scd_main_commands)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2398 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2399 #ifndef NO_Z80 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2400 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2401 static uint8_t cmd_delete_z80(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2402 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2403 bp_def **this_bp = find_breakpoint_idx(&root->breakpoints, cmd->args[0].value); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2404 if (!*this_bp) { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2405 fprintf(stderr, "Breakpoint %d does not exist\n", cmd->args[0].value); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2406 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2407 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2408 bp_def *tmp = *this_bp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2409 zremove_breakpoint(root->cpu_context, tmp->address); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2410 *this_bp = (*this_bp)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2411 if (tmp->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2412 for (uint32_t i = 0; i < tmp->num_commands; i++) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2413 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2414 free_parsed_command(tmp->commands + i); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2415 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2416 free(tmp->commands); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2417 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2418 free(tmp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2419 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2420 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2421 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2422 static uint8_t cmd_breakpoint_z80(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2423 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2424 zinsert_breakpoint(root->cpu_context, cmd->args[0].value, (uint8_t *)zdebugger); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2425 bp_def *new_bp = calloc(1, sizeof(bp_def)); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2426 new_bp->next = root->breakpoints; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2427 new_bp->address = cmd->args[0].value; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2428 new_bp->index = root->bp_index++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2429 root->breakpoints = new_bp; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2430 printf("Z80 Breakpoint %d set at %X\n", new_bp->index, cmd->args[0].value); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2431 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2432 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2433 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2434 static uint8_t cmd_advance_z80(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2435 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2436 zinsert_breakpoint(root->cpu_context, cmd->args[0].value, (uint8_t *)zdebugger); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2437 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2438 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2439 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2440 static uint8_t cmd_step_z80(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2441 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2442 z80inst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2443 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2444 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2445 //TODO: handle conditional branches |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2446 if (inst->op == Z80_JP || inst->op == Z80_CALL || inst->op == Z80_RST) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2447 if (inst->addr_mode == Z80_IMMED) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2448 after = inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2449 } else if (inst->ea_reg == Z80_HL) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2450 #ifndef NEW_CORE |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2451 after = context->regs[Z80_H] << 8 | context->regs[Z80_L]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2452 } else if (inst->ea_reg == Z80_IX) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2453 after = context->regs[Z80_IXH] << 8 | context->regs[Z80_IXL]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2454 } else if (inst->ea_reg == Z80_IY) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2455 after = context->regs[Z80_IYH] << 8 | context->regs[Z80_IYL]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2456 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2457 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2458 } else if(inst->op == Z80_JR) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2459 after += inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2460 } else if(inst->op == Z80_RET) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2461 uint8_t *sp = get_native_pointer(context->sp, (void **)context->mem_pointers, &context->Z80_OPTS->gen); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2462 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2463 after = *sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2464 sp = get_native_pointer((context->sp + 1) & 0xFFFF, (void **)context->mem_pointers, &context->Z80_OPTS->gen); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2465 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2466 after |= *sp << 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2467 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2468 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2469 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2470 zinsert_breakpoint(context, after, (uint8_t *)zdebugger); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2471 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2472 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2473 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2474 static uint8_t cmd_over_z80(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2475 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2476 fputs("not implemented yet\n", stderr); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2477 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2478 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2479 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2480 static uint8_t cmd_next_z80(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2481 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2482 z80inst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2483 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2484 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2485 //TODO: handle conditional branches |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2486 if (inst->op == Z80_JP) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2487 if (inst->addr_mode == Z80_IMMED) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2488 after = inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2489 } else if (inst->ea_reg == Z80_HL) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2490 #ifndef NEW_CORE |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2491 after = context->regs[Z80_H] << 8 | context->regs[Z80_L]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2492 } else if (inst->ea_reg == Z80_IX) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2493 after = context->regs[Z80_IXH] << 8 | context->regs[Z80_IXL]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2494 } else if (inst->ea_reg == Z80_IY) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2495 after = context->regs[Z80_IYH] << 8 | context->regs[Z80_IYL]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2496 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2497 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2498 } else if(inst->op == Z80_JR) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2499 after += inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2500 } else if(inst->op == Z80_RET) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2501 uint8_t *sp = get_native_pointer(context->sp, (void **)context->mem_pointers, &context->Z80_OPTS->gen); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2502 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2503 after = *sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2504 sp = get_native_pointer((context->sp + 1) & 0xFFFF, (void **)context->mem_pointers, &context->Z80_OPTS->gen); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2505 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2506 after |= *sp << 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2507 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2508 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2509 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2510 zinsert_breakpoint(context, after, (uint8_t *)zdebugger); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2511 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2512 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2513 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2514 static uint8_t cmd_backtrace_z80(debug_root *root, parsed_command *cmd) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2515 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2516 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2517 uint32_t stack = context->sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2518 uint8_t non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2519 do { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2520 uint32_t bt_address = stack; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2521 if (!root->read_mem(root, &bt_address, 'w')) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2522 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2523 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2524 bt_address = z80_get_instruction_start(context, bt_address - 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2525 if (bt_address != 0xFEEDFEED) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2526 stack += 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2527 non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2528 z80inst inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2529 char buf[128]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2530 uint8_t *pc = get_native_pointer(bt_address, (void **)context->mem_pointers, &context->Z80_OPTS->gen); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2531 z80_decode(pc, &inst); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2532 z80_disasm(&inst, buf, bt_address); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2533 printf("%X: %s\n", bt_address, buf); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2534 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2535 //non-return address value on stack can be byte wide |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2536 stack++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2537 non_adr_count++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2538 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2539 //TODO: Make sure we don't wander into an invalid memory region |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2540 } while (stack && non_adr_count < 6); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2541 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2542 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2543 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2544 static uint8_t cmd_disassemble_z80(debug_root *root, parsed_command *cmd) |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2545 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2546 z80_context *context = root->cpu_context; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2547 uint32_t address = root->address; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2548 if (cmd->num_args) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2549 address = cmd->args[0].value; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2550 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2551 char disasm_buf[1024]; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2552 z80inst inst; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2553 do { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2554 label_def *def = find_label(root->disasm, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2555 if (def) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2556 for (uint32_t i = 0; i < def->num_labels; i++) |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2557 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2558 printf("%s:\n", def->labels[i]); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2559 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2560 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2561 uint8_t *pc = get_native_pointer(address, (void **)context->mem_pointers, &context->Z80_OPTS->gen); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2562 uint8_t *after = z80_decode(pc, &inst); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2563 z80_disasm(&inst, disasm_buf, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2564 address += after - pc; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2565 printf("\t%s\n", disasm_buf); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2566 } while(!z80_is_terminal(&inst)); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2567 return 1; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2568 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2569 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2570 static uint8_t cmd_gen_m68k(debug_root *root, parsed_command *cmd) |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2571 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2572 char *param = cmd->raw; |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2573 while (param && *param && isblank(*param)) |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2574 { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2575 ++param; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2576 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2577 genesis_context *gen = (genesis_context *)current_system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
2578 |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2579 if (param && *param && !isspace(*param)) { |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2580 parsed_command cmd = {0}; |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2581 debug_root *m68k_root = find_m68k_root(gen->m68k); |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2582 if (!m68k_root) { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2583 fputs("Failed to get debug root for M68K\n", stderr); |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2584 return 1; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2585 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2586 if (!parse_command(m68k_root, param, &cmd)) { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2587 return 1; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2588 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2589 uint8_t ret = run_command(m68k_root, &cmd); |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2590 free_parsed_command(&cmd); |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2591 return ret; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2592 } else { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2593 gen->header.enter_debugger = 1; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2594 return 0; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2595 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2596 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2597 |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2598 static uint8_t cmd_vdp_sprites_sms(debug_root *root, parsed_command *cmd) |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2599 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2600 z80_context *context = root->cpu_context; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2601 sms_context * sms = context->system; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2602 vdp_print_sprite_table(sms->vdp); |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2603 return 1; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2604 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2605 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2606 static uint8_t cmd_vdp_regs_sms(debug_root *root, parsed_command *cmd) |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2607 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2608 z80_context *context = root->cpu_context; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2609 sms_context * sms = context->system; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2610 vdp_print_reg_explain(sms->vdp); |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2611 return 1; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2612 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2613 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2614 command_def z80_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2615 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2616 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2617 "breakpoint", "b", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2618 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2619 .usage = "breakpoint ADDRESSS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2620 .desc = "Set a breakpoint at ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2621 .impl = cmd_breakpoint_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2622 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2623 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2624 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2625 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2626 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2627 "advance", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2628 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2629 .usage = "advance ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2630 .desc = "Advance to ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2631 .impl = cmd_advance_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2632 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2633 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2634 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2635 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2636 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2637 "step", "s", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2638 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2639 .usage = "step", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2640 .desc = "Advance to the next instruction, stepping into subroutines", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2641 .impl = cmd_step_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2642 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2643 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2644 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2645 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2646 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2647 "over", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2648 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2649 .usage = "over", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2650 .desc = "Advance to the next instruction, ignoring branches to lower addresses", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2651 .impl = cmd_over_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2652 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2653 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2654 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2655 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2656 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2657 "next", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2658 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2659 .usage = "next", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2660 .desc = "Advance to the next instruction", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2661 .impl = cmd_next_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2662 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2663 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2664 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2665 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2666 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2667 "backtrace", "bt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2668 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2669 .usage = "backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2670 .desc = "Print a backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2671 .impl = cmd_backtrace_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2672 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2673 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2674 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2675 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2676 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2677 "delete", "d", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2678 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2679 .usage = "delete BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2680 .desc = "Remove breakpoint identified by BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2681 .impl = cmd_delete_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2682 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2683 .max_args = 1 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2684 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2685 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2686 .names = (const char *[]){ |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2687 "disassemble", "disasm", NULL |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2688 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2689 .usage = "disassemble [ADDRESS]", |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2690 .desc = "Disassemble code starting at ADDRESS if provided or the current address if not", |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2691 .impl = cmd_disassemble_z80, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2692 .min_args = 0, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2693 .max_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2694 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2695 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2696 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2697 #define NUM_Z80 (sizeof(z80_commands)/sizeof(*z80_commands)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2698 |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2699 command_def gen_z80_commands[] = { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2700 { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2701 .names = (const char *[]){ |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2702 "m68k", NULL |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2703 }, |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2704 .usage = "m68k [COMMAND]", |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2705 .desc = "Run a M68K debugger command or switch to M68K context when no command is given", |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2706 .impl = cmd_gen_m68k, |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2707 .min_args = 0, |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2708 .max_args = -1, |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2709 .raw_args = 1 |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2710 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2711 }; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2712 |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2713 #define NUM_GEN_Z80 (sizeof(gen_z80_commands)/sizeof(*gen_z80_commands)) |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2714 |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2715 command_def sms_commands[] = { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2716 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2717 .names = (const char *[]){ |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2718 "vdpsprites", "vs", NULL |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2719 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2720 .usage = "vdpsprites", |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2721 .desc = "Print the VDP sprite table", |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2722 .impl = cmd_vdp_sprites_sms, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2723 .min_args = 0, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2724 .max_args = 0 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2725 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2726 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2727 .names = (const char *[]){ |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2728 "vdpsregs", "vr", NULL |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2729 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2730 .usage = "vdpregs", |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2731 .desc = "Print VDP register values with a short description", |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2732 .impl = cmd_vdp_regs_sms, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2733 .min_args = 0, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2734 .max_args = 0 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2735 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2736 }; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2737 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2738 #define NUM_SMS (sizeof(sms_commands)/sizeof(*sms_commands)) |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2739 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2740 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2741 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2742 void add_commands(debug_root *root, command_def *defs, uint32_t num_commands) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2743 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2744 for (uint32_t i = 0; i < num_commands; i++) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2745 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2746 for (int j = 0; defs[i].names[j]; j++) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2747 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2748 root->commands = tern_insert_ptr(root->commands, defs[i].names[j], defs + i); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2749 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2750 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2751 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2752 |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2753 static void symbol_map(char *key, tern_val val, uint8_t valtype, void *data) |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2754 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2755 debug_root *root = data; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2756 label_def *label = val.ptrval; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2757 for (uint32_t i = 0; i < label->num_labels; i++) |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2758 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2759 root->symbols = tern_insert_int(root->symbols, label->labels[i], label->full_address); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2760 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2761 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2762 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2763 debug_root *find_m68k_root(m68k_context *context) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2764 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2765 debug_root *root = find_root(context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2766 if (root && !root->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2767 add_commands(root, common_commands, NUM_COMMON); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2768 add_commands(root, m68k_commands, NUM_68K); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2769 root->read_mem = read_m68k; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2770 root->write_mem = write_m68k; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2771 root->set = set_m68k; |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2772 root->disasm = create_68000_disasm(); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2773 switch (current_system->type) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2774 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2775 case SYSTEM_GENESIS: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2776 case SYSTEM_SEGACD: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2777 //check if this is the main CPU |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2778 if (context->system == current_system) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2779 root->resolve = resolve_genesis; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2780 add_commands(root, genesis_commands, NUM_GENESIS); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2781 if (current_system->type == SYSTEM_SEGACD) { |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2782 add_segacd_maincpu_labels(root->disasm); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2783 add_commands(root, scd_main_commands, NUM_SCD_MAIN); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2784 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2785 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2786 } else { |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2787 add_segacd_subcpu_labels(root->disasm); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2788 add_commands(root, scd_sub_commands, NUM_SCD_SUB); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2789 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2790 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2791 root->resolve = resolve_m68k; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2792 } |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2793 tern_foreach(root->disasm->labels, symbol_map, root); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2794 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2795 return root; |
829
cc05444a4a4e
WIP debugger improvements. Partial support for display command in 68K debugger. Minor refactor to support commands on a breakpoint.
Michael Pavone <pavone@retrodev.com>
parents:
794
diff
changeset
|
2796 } |
cc05444a4a4e
WIP debugger improvements. Partial support for display command in 68K debugger. Minor refactor to support commands on a breakpoint.
Michael Pavone <pavone@retrodev.com>
parents:
794
diff
changeset
|
2797 |
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
|
2798 #ifndef NO_Z80 |
548
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
2799 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2800 static uint8_t read_z80(debug_root *root, uint32_t *out, char size) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2801 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2802 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2803 uint32_t address = *out; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2804 *out = read_byte(address, (void **)context->mem_pointers, &context->options->gen, context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2805 if (size == 'w') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2806 *out |= read_byte(address + 1, (void **)context->mem_pointers, &context->options->gen, context) << 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2807 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2808 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2809 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2810 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2811 static uint8_t write_z80(debug_root *root, uint32_t address, uint32_t value, char size) |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2812 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2813 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2814 write_byte(address, value, (void **)context->mem_pointers, &context->options->gen, context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2815 if (size == 'w') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2816 write_byte(address + 1, value >> 8, (void **)context->mem_pointers, &context->options->gen, context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2817 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2818 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2819 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2820 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2821 static uint8_t resolve_z80(debug_root *root, const char *name, uint32_t *out) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2822 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2823 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2824 switch (tolower(name[0])) |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2825 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2826 case 'a': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2827 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2828 *out = context->regs[Z80_A]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2829 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2830 *out = context->alt_regs[Z80_A]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2831 } else if (tolower(name[1]) == 'f') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2832 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2833 *out = context->regs[Z80_A] << 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2834 *out |= context->flags[ZF_S] << 7; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2835 *out |= context->flags[ZF_Z] << 6; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2836 *out |= context->flags[ZF_H] << 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2837 *out |= context->flags[ZF_PV] << 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2838 *out |= context->flags[ZF_N] << 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2839 *out |= context->flags[ZF_C]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2840 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2841 *out = context->alt_regs[Z80_A] << 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2842 *out |= context->alt_flags[ZF_S] << 7; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2843 *out |= context->alt_flags[ZF_Z] << 6; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2844 *out |= context->alt_flags[ZF_H] << 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2845 *out |= context->alt_flags[ZF_PV] << 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2846 *out |= context->alt_flags[ZF_N] << 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2847 *out |= context->alt_flags[ZF_C]; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2848 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2849 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2850 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2851 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2852 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2853 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2854 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2855 case 'b': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2856 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2857 *out = context->regs[Z80_B]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2858 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2859 *out = context->alt_regs[Z80_B]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2860 } else if (tolower(name[1]) == 'c') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2861 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2862 *out = context->regs[Z80_B] << 8 | context->regs[Z80_C]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2863 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2864 *out = context->alt_regs[Z80_B] << 8 | context->alt_regs[Z80_C]; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2865 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2866 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2867 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2868 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2869 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2870 case 'c': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2871 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2872 *out = context->regs[Z80_C]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2873 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2874 *out = context->alt_regs[Z80_C]; |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2875 } else if (!strcmp(name + 1, "ycle")) { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2876 *out = context->current_cycle; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2877 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2878 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2879 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2880 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2881 case 'd': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2882 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2883 *out = context->regs[Z80_D]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2884 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2885 *out = context->alt_regs[Z80_D]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2886 } else if (tolower(name[1]) == 'e') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2887 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2888 *out = context->regs[Z80_D] << 8 | context->regs[Z80_E]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2889 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2890 *out = context->alt_regs[Z80_D] << 8 | context->alt_regs[Z80_E]; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2891 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2892 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2893 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2894 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2895 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2896 case 'e': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2897 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2898 *out = context->regs[Z80_E]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2899 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2900 *out = context->alt_regs[Z80_E]; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2901 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2902 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2903 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2904 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2905 case 'f': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2906 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2907 *out = context->flags[ZF_S] << 7; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2908 *out |= context->flags[ZF_Z] << 6; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2909 *out |= context->flags[ZF_H] << 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2910 *out |= context->flags[ZF_PV] << 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2911 *out |= context->flags[ZF_N] << 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2912 *out |= context->flags[ZF_C]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2913 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2914 *out = context->alt_flags[ZF_S] << 7; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2915 *out |= context->alt_flags[ZF_Z] << 6; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2916 *out |= context->alt_flags[ZF_H] << 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2917 *out |= context->alt_flags[ZF_PV] << 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2918 *out |= context->alt_flags[ZF_N] << 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2919 *out |= context->alt_flags[ZF_C]; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2920 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2921 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2922 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2923 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2924 case 'h': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2925 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2926 *out = context->regs[Z80_H]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2927 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2928 *out = context->alt_regs[Z80_H]; |
2208
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
2929 } else if (tolower(name[1]) == 'l') { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2930 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2931 *out = context->regs[Z80_H] << 8 | context->regs[Z80_L]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2932 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2933 *out = context->alt_regs[Z80_H] << 8 | context->alt_regs[Z80_L]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2934 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2935 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2936 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2937 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2938 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2939 case 'i': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2940 switch (tolower(name[1])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2941 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2942 case 0: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2943 *out = context->regs[Z80_I]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2944 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2945 case 'f': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2946 if (name[2] != 'f' || name[3] < '1' || name[4]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2947 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2948 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2949 if (name[3] == '1') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2950 *out = context->iff1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2951 } else if (name[3] == '2') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2952 *out = context->iff2; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2953 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2954 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2955 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2956 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2957 case 'm': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2958 if (name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2959 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2960 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2961 *out = context->im; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2962 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2963 case 'n': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2964 if (strcasecmp(name +2, "t_cycle")) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2965 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2966 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2967 *out = context->int_cycle; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2968 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2969 case 'r': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2970 if (name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2971 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2972 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2973 *out = context->regs[Z80_I] << 8 | context->regs[Z80_R]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2974 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2975 case 'x': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2976 switch (tolower(name[2])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2977 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2978 case 0: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2979 *out = context->regs[Z80_IXH] << 8 | context->regs[Z80_IXL]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2980 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2981 case 'h': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2982 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2983 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2984 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2985 *out = context->regs[Z80_IXH]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2986 case 'l': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2987 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2988 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2989 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2990 *out = context->regs[Z80_IXL]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2991 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2992 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2993 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2994 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2995 case 'y': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2996 switch (tolower(name[2])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2997 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2998 case 0: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2999 *out = context->regs[Z80_IYH] << 8 | context->regs[Z80_IYL]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3000 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3001 case 'h': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3002 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3003 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3004 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3005 *out = context->regs[Z80_IYH]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3006 case 'l': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3007 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3008 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3009 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3010 *out = context->regs[Z80_IYL]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3011 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3012 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3013 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3014 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3015 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3016 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3017 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3018 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3019 case 'l': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3020 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3021 *out = context->regs[Z80_L]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3022 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3023 *out = context->alt_regs[Z80_L]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3024 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3025 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3026 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3027 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3028 case 'p': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3029 if (tolower(name[1]) != 'c' || name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3030 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3031 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3032 *out = root->address; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3033 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3034 case 'r': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3035 if (name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3036 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3037 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3038 *out = context->regs[Z80_R]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3039 case 's': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3040 if (tolower(name[1]) != 'p' || name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3041 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3042 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3043 *out = context->sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3044 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3045 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3046 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3047 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3048 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3049 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3050 |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3051 static uint8_t resolve_sms(debug_root *root, const char *name, uint32_t *out) |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3052 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3053 if (resolve_z80(root, name, out)) { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3054 return 1; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3055 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3056 z80_context *z80 = root->cpu_context; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3057 sms_context *sms = z80->system; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3058 if (!strcmp(name, "f") || !strcmp(name, "frame")) { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3059 *out = sms->vdp->frame; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3060 return 1; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3061 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3062 return 0; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3063 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3064 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3065 static uint8_t set_z80(debug_root *root, const char *name, uint32_t value) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3066 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3067 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3068 switch (tolower(name[0])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3069 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3070 case 'a': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3071 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3072 context->regs[Z80_A] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3073 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3074 context->alt_regs[Z80_A] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3075 } else if (tolower(name[1]) == 'f') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3076 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3077 context->regs[Z80_A] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3078 context->flags[ZF_S] = value >> 7 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3079 context->flags[ZF_Z] = value >> 6 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3080 context->flags[ZF_H] = value >> 4 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3081 context->flags[ZF_PV] = value >> 2 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3082 context->flags[ZF_N] = value >> 1 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3083 context->flags[ZF_C] = value & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3084 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3085 context->alt_regs[Z80_A] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3086 context->alt_flags[ZF_S] = value >> 7 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3087 context->alt_flags[ZF_Z] = value >> 6 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3088 context->alt_flags[ZF_H] = value >> 4 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3089 context->alt_flags[ZF_PV] = value >> 2 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3090 context->alt_flags[ZF_N] = value >> 1 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3091 context->alt_flags[ZF_C] = value & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3092 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3093 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3094 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3095 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3096 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3097 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3098 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3099 case 'b': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3100 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3101 context->regs[Z80_B] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3102 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3103 context->alt_regs[Z80_B] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3104 } else if (tolower(name[1]) == 'c') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3105 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3106 context->regs[Z80_B] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3107 context->regs[Z80_C] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3108 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3109 context->alt_regs[Z80_B] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3110 context->alt_regs[Z80_C] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3111 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3112 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3113 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3114 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3115 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3116 case 'c': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3117 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3118 context->regs[Z80_C] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3119 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3120 context->alt_regs[Z80_C] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3121 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3122 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3123 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3124 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3125 case 'd': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3126 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3127 context->regs[Z80_D] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3128 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3129 context->alt_regs[Z80_D] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3130 } else if (tolower(name[1]) == 'e') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3131 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3132 context->regs[Z80_D] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3133 context->regs[Z80_E] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3134 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3135 context->alt_regs[Z80_D] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3136 context->alt_regs[Z80_E] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3137 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3138 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3139 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3140 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3141 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3142 case 'e': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3143 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3144 context->regs[Z80_E] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3145 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3146 context->alt_regs[Z80_E] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3147 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3148 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3149 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3150 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3151 case 'f': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3152 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3153 context->flags[ZF_S] = value >> 7 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3154 context->flags[ZF_Z] = value >> 6 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3155 context->flags[ZF_H] = value >> 4 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3156 context->flags[ZF_PV] = value >> 2 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3157 context->flags[ZF_N] = value >> 1 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3158 context->flags[ZF_C] = value & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3159 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3160 context->alt_flags[ZF_S] = value >> 7 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3161 context->alt_flags[ZF_Z] = value >> 6 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3162 context->alt_flags[ZF_H] = value >> 4 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3163 context->alt_flags[ZF_PV] = value >> 2 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3164 context->alt_flags[ZF_N] = value >> 1 & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3165 context->alt_flags[ZF_C] = value & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3166 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3167 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3168 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3169 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3170 case 'h': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3171 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3172 context->regs[Z80_H] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3173 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3174 context->alt_regs[Z80_H] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3175 } else if (tolower(name[1]) == 'e') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3176 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3177 context->regs[Z80_H] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3178 context->regs[Z80_L] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3179 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3180 context->alt_regs[Z80_H] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3181 context->alt_regs[Z80_L] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3182 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3183 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3184 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3185 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3186 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3187 case 'i': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3188 switch (tolower(name[1])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3189 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3190 case 0: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3191 context->regs[Z80_I] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3192 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3193 case 'f': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3194 if (name[2] != 'f' || name[3] < '1' || name[4]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3195 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3196 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3197 if (name[3] == '1') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3198 context->iff1 = value != 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3199 } else if (name[3] == '2') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3200 context->iff2 = value != 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3201 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3202 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3203 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3204 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3205 case 'm': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3206 if (name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3207 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3208 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3209 context->im = value & 3; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3210 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3211 case 'r': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3212 if (name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3213 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3214 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3215 context->regs[Z80_I] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3216 context->regs[Z80_R] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3217 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3218 case 'x': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3219 switch (tolower(name[2])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3220 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3221 case 0: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3222 context->regs[Z80_IXH] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3223 context->regs[Z80_IXL] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3224 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3225 case 'h': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3226 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3227 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3228 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3229 context->regs[Z80_IXH] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3230 case 'l': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3231 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3232 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3233 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3234 context->regs[Z80_IXL] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3235 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3236 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3237 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3238 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3239 case 'y': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3240 switch (tolower(name[2])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3241 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3242 case 0: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3243 context->regs[Z80_IYH] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3244 context->regs[Z80_IYL] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3245 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3246 case 'h': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3247 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3248 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3249 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3250 context->regs[Z80_IYH] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3251 case 'l': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3252 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3253 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3254 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3255 context->regs[Z80_IYL] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3256 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3257 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3258 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3259 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3260 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3261 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3262 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3263 break; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3264 case 'l': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3265 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3266 context->regs[Z80_L] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3267 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3268 context->alt_regs[Z80_L] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3269 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3270 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3271 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3272 break; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3273 case 'r': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3274 if (name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3275 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3276 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3277 context->regs[Z80_R] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3278 case 's': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3279 if (tolower(name[1]) != 'p' || name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3280 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3281 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3282 context->sp = value; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3283 break; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3284 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3285 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3286 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3287 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3288 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3289 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3290 debug_root *find_z80_root(z80_context *context) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3291 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3292 debug_root *root = find_root(context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3293 if (root && !root->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3294 add_commands(root, common_commands, NUM_COMMON); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3295 add_commands(root, z80_commands, NUM_Z80); |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3296 switch (current_system->type) |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3297 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3298 case SYSTEM_GENESIS: |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3299 case SYSTEM_SEGACD: |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
3300 add_commands(root, gen_z80_commands, NUM_GEN_Z80); |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3301 root->resolve = resolve_z80; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3302 break; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3303 case SYSTEM_SMS: |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3304 root->resolve = resolve_sms; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3305 add_commands(root, sms_commands, NUM_SMS); |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3306 break; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3307 default: |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3308 root->resolve = resolve_z80; |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
3309 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3310 root->read_mem = read_z80; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3311 root->write_mem = write_z80; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3312 root->set = set_z80; |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3313 root->disasm = create_z80_disasm(); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3314 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3315 return root; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3316 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3317 |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3318 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
|
3319 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3320 static char last_cmd[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3321 char input_buf[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3322 z80inst inst; |
1103
22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents:
985
diff
changeset
|
3323 genesis_context *system = context->system; |
794
792be135d3af
Spawn a terminal for the debugger when needed if we are not already attached to one
Michael Pavone <pavone@retrodev.com>
parents:
792
diff
changeset
|
3324 init_terminal(); |
2180
b87658ba3b94
Fix bug in Z80 debugger for SMS mode post-refactor
Michael Pavone <pavone@retrodev.com>
parents:
2179
diff
changeset
|
3325 debug_root *root = find_z80_root(context); |
2107
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3326 if (!root) { |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3327 return context; |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3328 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3329 root->address = address; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3330 //Check if this is a user set breakpoint, or just a temporary one |
2107
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3331 bp_def ** this_bp = find_breakpoint(&root->breakpoints, address); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3332 if (*this_bp) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3333 if ((*this_bp)->condition) { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3334 uint32_t condres; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3335 if (eval_expr(root, (*this_bp)->condition, &condres)) { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3336 if (!condres) { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3337 return context; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3338 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3339 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3340 fprintf(stderr, "Failed to eval condition for Z80 breakpoint %u\n", (*this_bp)->index); |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3341 free_expr((*this_bp)->condition); |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3342 (*this_bp)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3343 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3344 } |
2208
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3345 int debugging = 1; |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3346 for (uint32_t i = 0; debugging && i < (*this_bp)->num_commands; i++) |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3347 { |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3348 debugging = run_command(root, (*this_bp)->commands + i); |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3349 } |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3350 if (debugging) { |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3351 printf("Z80 Breakpoint %d hit\n", (*this_bp)->index); |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3352 } else { |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3353 return context; |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3354 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3355 } else { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3356 zremove_breakpoint(context, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3357 } |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1630
diff
changeset
|
3358 uint8_t * pc = get_native_pointer(address, (void **)context->mem_pointers, &context->Z80_OPTS->gen); |
1129
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
1111
diff
changeset
|
3359 if (!pc) { |
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
1111
diff
changeset
|
3360 fatal_error("Failed to get native pointer on entering Z80 debugger at address %X\n", address); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3361 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3362 uint8_t * after_pc = z80_decode(pc, &inst); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3363 uint16_t after = address + (after_pc-pc); |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3364 root->after = after; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3365 root->inst = &inst; |
2107
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3366 for (disp_def * cur = root->displays; cur; cur = cur->next) { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3367 char format_str[8]; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3368 make_format_str(format_str, cur->format); |
2183
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3369 for (int i = 0; i < cur->num_args; i++) |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3370 { |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3371 eval_expr(root, cur->args[i].parsed, &cur->args[i].value); |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3372 do_print(root, format_str, cur->args[i].raw, cur->args[i].value); |
2183
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3373 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3374 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3375 |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3376 z80_disasm(&inst, input_buf, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3377 printf("%X:\t%s\n", address, input_buf); |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3378 debugger_repl(root); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3379 return context; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3380 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3381 |
548
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
3382 #endif |
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
3383 |
1329
85a90964b557
Fix interaction between 68K debugger and instruction retranslation due to self modifying code or bank switching
Michael Pavone <pavone@retrodev.com>
parents:
1314
diff
changeset
|
3384 void debugger(m68k_context * context, uint32_t address) |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3385 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3386 static char last_cmd[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3387 char input_buf[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3388 m68kinst inst; |
830
5a3ac6093ea2
Add support for executing a list of debugger commands when a breakpoint is hit
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
3389 |
794
792be135d3af
Spawn a terminal for the debugger when needed if we are not already attached to one
Michael Pavone <pavone@retrodev.com>
parents:
792
diff
changeset
|
3390 init_terminal(); |
830
5a3ac6093ea2
Add support for executing a list of debugger commands when a breakpoint is hit
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
3391 |
2054
8ee7ecbf3f21
Implement enough of Sega CD gate array and Sub CPU to pass Sik's Mode 1 test ROM
Michael Pavone <pavone@retrodev.com>
parents:
1965
diff
changeset
|
3392 context->options->sync_components(context, 0); |
2104
ff32a90260c9
Initial support for using debugger on sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2054
diff
changeset
|
3393 if (context->system == current_system) { |
ff32a90260c9
Initial support for using debugger on sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2054
diff
changeset
|
3394 genesis_context *gen = context->system; |
ff32a90260c9
Initial support for using debugger on sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2054
diff
changeset
|
3395 vdp_force_update_framebuffer(gen->vdp); |
ff32a90260c9
Initial support for using debugger on sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2054
diff
changeset
|
3396 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3397 debug_root *root = find_m68k_root(context); |
2107
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3398 if (!root) { |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3399 return; |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3400 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3401 //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
|
3402 address &= 0xFFFFFF; |
2107
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3403 if (address == root->branch_t) { |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3404 bp_def ** f_bp = find_breakpoint(&root->breakpoints, root->branch_f); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3405 if (!*f_bp) { |
2107
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3406 remove_breakpoint(context, root->branch_f); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3407 } |
2107
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3408 root->branch_t = root->branch_f = 0; |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3409 } else if(address == root->branch_f) { |
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3410 bp_def ** t_bp = find_breakpoint(&root->breakpoints, root->branch_t); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3411 if (!*t_bp) { |
2107
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3412 remove_breakpoint(context, root->branch_t); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3413 } |
2107
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3414 root->branch_t = root->branch_f = 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3415 } |
849
1416c4261d5b
Fix some debug commands that got broken when I added support for the command command
Michael Pavone <pavone@retrodev.com>
parents:
831
diff
changeset
|
3416 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3417 root->address = address; |
830
5a3ac6093ea2
Add support for executing a list of debugger commands when a breakpoint is hit
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
3418 int debugging = 1; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3419 //Check if this is a user set breakpoint, or just a temporary one |
2107
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3420 bp_def ** this_bp = find_breakpoint(&root->breakpoints, address); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3421 if (*this_bp) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3422 if ((*this_bp)->condition) { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3423 uint32_t condres; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3424 if (eval_expr(root, (*this_bp)->condition, &condres)) { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3425 if (!condres) { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3426 return; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3427 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3428 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3429 fprintf(stderr, "Failed to eval condition for M68K breakpoint %u\n", (*this_bp)->index); |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3430 free_expr((*this_bp)->condition); |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3431 (*this_bp)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3432 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3433 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3434 for (uint32_t i = 0; debugging && i < (*this_bp)->num_commands; i++) |
830
5a3ac6093ea2
Add support for executing a list of debugger commands when a breakpoint is hit
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
3435 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3436 debugging = run_command(root, (*this_bp)->commands + i); |
830
5a3ac6093ea2
Add support for executing a list of debugger commands when a breakpoint is hit
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
3437 } |
5a3ac6093ea2
Add support for executing a list of debugger commands when a breakpoint is hit
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
3438 if (debugging) { |
5a3ac6093ea2
Add support for executing a list of debugger commands when a breakpoint is hit
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
3439 printf("68K Breakpoint %d hit\n", (*this_bp)->index); |
5a3ac6093ea2
Add support for executing a list of debugger commands when a breakpoint is hit
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
3440 } else { |
1329
85a90964b557
Fix interaction between 68K debugger and instruction retranslation due to self modifying code or bank switching
Michael Pavone <pavone@retrodev.com>
parents:
1314
diff
changeset
|
3441 return; |
830
5a3ac6093ea2
Add support for executing a list of debugger commands when a breakpoint is hit
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
3442 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3443 } else { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3444 remove_breakpoint(context, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3445 } |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3446 uint32_t after = m68k_decode(m68k_instruction_fetch, context, &inst, address); |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3447 root->after = after; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3448 root->inst = &inst; |
2107
f80c6111e1ae
Move some debugger state to a per-CPU structure. Add m command for returning to main CPU from sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2104
diff
changeset
|
3449 for (disp_def * cur = root->displays; cur; cur = cur->next) { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3450 char format_str[8]; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3451 make_format_str(format_str, cur->format); |
2183
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3452 for (int i = 0; i < cur->num_args; i++) |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3453 { |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3454 eval_expr(root, cur->args[i].parsed, &cur->args[i].value); |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3455 do_print(root, format_str, cur->args[i].raw, cur->args[i].value); |
2183
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3456 } |
829
cc05444a4a4e
WIP debugger improvements. Partial support for display command in 68K debugger. Minor refactor to support commands on a breakpoint.
Michael Pavone <pavone@retrodev.com>
parents:
794
diff
changeset
|
3457 } |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3458 m68k_disasm_labels(&inst, input_buf, root->disasm); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3459 printf("%X: %s\n", address, input_buf); |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3460 debugger_repl(root); |
1329
85a90964b557
Fix interaction between 68K debugger and instruction retranslation due to self modifying code or bank switching
Michael Pavone <pavone@retrodev.com>
parents:
1314
diff
changeset
|
3461 return; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3462 } |