Mercurial > repos > blastem
annotate debug.c @ 2354:a773b8f09292
Remove old refresh hack that is causing VDPFifoTesting to have a failed test
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 19 Oct 2023 23:27:57 -0700 |
parents | 0343f0d5add0 |
children | 344c6a3fe8a8 |
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(); |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2252
diff
changeset
|
1058 #ifndef IS_LIB |
2252
6a07b13894f7
Fix input processing while waiting for console input in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2216
diff
changeset
|
1059 render_update_display(); |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2252
diff
changeset
|
1060 #endif |
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
|
1061 #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
|
1062 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
|
1063 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
|
1064 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
|
1065 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
|
1066 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
|
1067 } |
e17d99c96c89
Make blocks an 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 #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
|
1069 } 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
|
1070 |
e17d99c96c89
Make blocks an 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 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
|
1072 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
|
1073 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
|
1074 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
|
1075 } |
e17d99c96c89
Make blocks an 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 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
|
1077 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
|
1078 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
|
1079 } |
e17d99c96c89
Make blocks an 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 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
|
1081 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
|
1082 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
|
1083 } |
e17d99c96c89
Make blocks an 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 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
|
1085 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
|
1086 } |
e17d99c96c89
Make blocks an 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 } |
e17d99c96c89
Make blocks an 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 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
|
1089 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
|
1090 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
|
1091 } |
e17d99c96c89
Make blocks an 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 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
|
1093 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
|
1094 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
|
1095 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
|
1096 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
|
1097 { |
e17d99c96c89
Make blocks an 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 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
|
1099 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
|
1100 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
|
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 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
|
1103 { |
e17d99c96c89
Make blocks an 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 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
|
1105 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
|
1106 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
|
1107 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
|
1108 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
|
1109 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
|
1110 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
|
1111 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
|
1112 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
|
1113 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
|
1114 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
|
1115 } |
e17d99c96c89
Make blocks an 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 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
|
1117 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
|
1118 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
|
1119 } |
e17d99c96c89
Make blocks an 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 = &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
|
1121 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
|
1122 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
|
1123 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
|
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 } |
e17d99c96c89
Make blocks an 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 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
|
1128 } |
e17d99c96c89
Make blocks an 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 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
|
1131 { |
e17d99c96c89
Make blocks an 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 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
|
1133 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
|
1134 { |
e17d99c96c89
Make blocks an 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 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
|
1136 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
|
1137 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
|
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 } |
e17d99c96c89
Make blocks an 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 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
|
1142 } |
e17d99c96c89
Make blocks an 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 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
|
1145 { |
e17d99c96c89
Make blocks an 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 |
e17d99c96c89
Make blocks an 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 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
|
1148 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
|
1149 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
|
1150 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
|
1151 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
|
1152 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
|
1153 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
|
1154 } |
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
|
1155 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
|
1156 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
|
1157 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1158 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
|
1159 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
|
1160 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
|
1161 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
|
1162 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
|
1163 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
|
1164 } |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1165 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
|
1166 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
|
1167 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
|
1168 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
|
1169 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
|
1170 } |
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
|
1171 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
|
1172 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1173 } |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1174 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
|
1175 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
|
1176 } else { |
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); |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1178 } |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
1179 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
|
1180 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1181 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
1182 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
|
1183 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1184 exit(0); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1185 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1186 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1187 typedef struct { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1188 size_t num_commands; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1189 size_t longest_command; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1190 } help_state; |
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 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
|
1193 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1194 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1195 if (def->visited) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1196 return; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1197 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1198 def->visited = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1199 help_state *state = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1200 state->num_commands++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1201 size_t len = strlen(def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1202 if (len > state->longest_command) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1203 state->longest_command = len; |
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 } |
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 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
|
1208 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1209 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1210 def->visited = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1211 } |
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 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
|
1214 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1215 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1216 if (def->visited) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1217 return; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1218 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1219 def->visited = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1220 help_state *state = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1221 size_t len = strlen(def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1222 printf(" %s", def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1223 while (len < state->longest_command) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1224 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1225 len++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1226 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1227 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
|
1228 const char *extra_desc = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1229 if (strlen(def->desc) <= remaining) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1230 printf(" - %s\n", def->desc); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1231 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1232 char split[76]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1233 int split_point = remaining; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1234 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
|
1235 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1236 --split_point; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1237 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1238 if (!split_point) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1239 split_point = remaining; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1240 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1241 memcpy(split, def->desc, split_point); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1242 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
|
1243 split[split_point] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1244 printf(" - %s\n", split); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1245 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1246 if (def->names[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1247 fputs(" Aliases: ", stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1248 len = strlen(" Aliases: "); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1249 const char **name = def->names + 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1250 uint8_t first = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1251 while (*name) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1252 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1253 if (first) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1254 first = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1255 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1256 putchar(','); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1257 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1258 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
|
1259 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1260 fputs(*name, stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1261 len += strlen(*name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1262 ++name; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1263 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1264 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1265 len = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1266 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1267 if (extra_desc) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1268 while (len < state->longest_command + 5) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1269 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1270 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
|
1271 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1272 fputs(extra_desc, stdout); |
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 putchar('\n'); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1275 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1276 |
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
|
1277 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
|
1278 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1279 help_state state = {0,0}; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1280 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
|
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 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
|
1283 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
|
1284 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1285 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1286 |
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
|
1287 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
|
1288 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1289 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1290 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1291 |
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
|
1292 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
|
1293 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1294 strcpy(format_str, "%s: %d\n"); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1295 if (format) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1296 switch (format[0]) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1297 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1298 case 'x': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1299 case 'X': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1300 case 'd': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1301 case 'c': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1302 case 's': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1303 format_str[5] = format[0]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1304 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1305 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1306 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
|
1307 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1308 } |
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
|
1309 } |
e17d99c96c89
Make blocks an 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 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
|
1312 { |
e17d99c96c89
Make blocks an 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 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
|
1314 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
|
1315 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
|
1316 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
|
1317 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
|
1318 { |
e17d99c96c89
Make blocks an 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 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
|
1320 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
|
1321 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
|
1322 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
|
1323 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
|
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] = 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
|
1326 } |
e17d99c96c89
Make blocks an 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 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
|
1328 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
|
1329 } 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
|
1330 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
|
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 } |
e17d99c96c89
Make blocks an 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 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
|
1335 { |
e17d99c96c89
Make blocks an 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 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
|
1337 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
|
1338 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
|
1339 { |
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
|
1340 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
|
1341 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1342 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1343 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
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 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
|
1346 { |
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
|
1347 char *param = cmd->raw; |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1348 if (!param) { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1349 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
|
1350 return 1; |
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 while (isblank(*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 ++param; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1355 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1356 if (*param != '"') { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1357 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
|
1358 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1359 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1360 ++param; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1361 char *fmt = strdup(param); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1362 char *cur = param, *out = fmt; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1363 while (*cur && *cur != '"') |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1364 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1365 if (*cur == '\\') { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1366 switch (cur[1]) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1367 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1368 case 't': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1369 *(out++) = '\t'; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1370 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1371 case 'n': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1372 *(out++) = '\n'; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1373 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1374 case 'r': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1375 *(out++) = '\r'; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1376 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1377 case '\\': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1378 *(out++) = '\\'; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1379 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1380 default: |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1381 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
|
1382 free(fmt); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1383 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1384 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1385 cur += 2; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1386 } else { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1387 *(out++) = *(cur++); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1388 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1389 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1390 *out = 0; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1391 ++cur; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1392 param = cur; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1393 cur = fmt; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1394 char format_str[3] = {'%', 'd', 0}; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1395 while (*cur) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1396 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1397 if (*cur == '%') { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1398 switch(cur[1]) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1399 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1400 case 'x': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1401 case 'X': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1402 case 'c': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1403 case 'd': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1404 case 's': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1405 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1406 default: |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1407 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
|
1408 free(fmt); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1409 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1410 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1411 format_str[1] = cur[1]; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1412 expr *arg = parse_expression(param, ¶m); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1413 if (!arg) { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1414 free(fmt); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1415 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1416 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1417 uint32_t val; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1418 if (!eval_expr(root, arg, &val)) { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1419 free(fmt); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1420 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1421 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1422 if (cur[1] == 's') { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1423 char tmp[128]; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1424 int j; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1425 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
|
1426 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1427 uint32_t addr = val; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1428 root->read_mem(root, &addr, 'b'); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1429 char c = addr; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1430 if (c < 0x20 || c > 0x7F) { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1431 break; |
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] = c; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1434 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1435 tmp[j] = 0; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1436 printf(format_str, tmp); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1437 } else { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1438 printf(format_str, val); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1439 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1440 cur += 2; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1441 } else { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1442 putchar(*cur); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1443 ++cur; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1444 } |
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 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
1447 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
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 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
|
1450 { |
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
|
1451 cmd_print(root, cmd); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1452 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
|
1453 ndisp->next = root->displays; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1454 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
|
1455 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
|
1456 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
|
1457 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
|
1458 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
|
1459 cmd->num_args = 0; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1460 root->displays = ndisp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1461 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
|
1462 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1463 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1464 |
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
|
1465 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
|
1466 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1467 disp_def **cur = &root->displays; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1468 while (*cur) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1469 { |
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
|
1470 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
|
1471 disp_def *del_disp = *cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1472 *cur = del_disp->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1473 free(del_disp->format); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1474 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
|
1475 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1476 free(del_disp->args[i].raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1477 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
|
1478 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1479 free(del_disp->args); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1480 free(del_disp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1481 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1482 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1483 cur = &(*cur)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1484 } |
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 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1487 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1488 |
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
|
1489 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
|
1490 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1491 if (current_system->soft_reset) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1492 current_system->soft_reset(current_system); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1493 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1494 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1495 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
|
1496 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1497 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1498 } |
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 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
|
1501 { |
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 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
|
1503 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
|
1504 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
|
1505 return 1; |
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 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
|
1508 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1509 free_parsed_command((*target)->commands + i); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1510 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1511 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
|
1512 (*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
|
1513 (*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
|
1514 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
|
1515 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
|
1516 return 1; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1517 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1518 |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1519 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
|
1520 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1521 uint8_t debugging = 1; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1522 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
|
1523 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1524 debugging = run_command(root, block->commands + i) && 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 return debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1527 } |
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 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
|
1530 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1531 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
|
1532 } |
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 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
|
1535 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1536 if (!cmd->args[0].value) { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1537 return execute_block(root, &cmd->else_block); |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1538 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1539 int debugging = 1; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1540 do { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1541 debugging = execute_block(root, &cmd->block) && debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1542 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
|
1543 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
|
1544 return 1; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1545 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1546 } while (cmd->args[0].value); |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1547 return debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1548 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
1549 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1550 const char *expr_type_names[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1551 "EXPR_NONE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1552 "EXPR_SCALAR", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1553 "EXPR_UNARY", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1554 "EXPR_BINARY", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1555 "EXPR_SIZE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1556 "EXPR_MEM" |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1557 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1558 |
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
|
1559 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
|
1560 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1561 char *name = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1562 char size = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1563 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
|
1564 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
|
1565 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1566 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
|
1567 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
|
1568 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
|
1569 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1570 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
|
1571 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1572 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1573 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1574 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
|
1575 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
|
1576 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
|
1577 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
|
1578 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1579 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
|
1580 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1581 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1582 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1583 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
|
1584 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
|
1585 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
|
1586 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
|
1587 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1588 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1589 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1590 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
|
1591 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
|
1592 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1593 } |
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
|
1594 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
|
1595 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
|
1596 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1597 } |
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
|
1598 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
|
1599 if (name && size && size != 'l') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1600 uint32_t old; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1601 if (!root->resolve(root, name, &old)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1602 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
|
1603 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1604 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1605 if (size == 'b') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1606 old &= 0xFFFFFF00; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1607 value &= 0xFF; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1608 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
|
1609 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1610 old &= 0xFFFF0000; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1611 value &= 0xFFFF; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1612 value |= old; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1613 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1614 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1615 if (name) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1616 if (!root->set(root, name, value)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1617 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
|
1618 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1619 } 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
|
1620 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
|
1621 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1622 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1623 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
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 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
|
1626 { |
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
|
1627 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
|
1628 return 0; |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
1629 } |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
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 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
|
1632 { |
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
|
1633 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
|
1634 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
|
1635 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1636 return 1; |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1637 } |
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 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
|
1640 { |
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
|
1641 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
|
1642 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
|
1643 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1644 return 1; |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
1645 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
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 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
|
1648 { |
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
|
1649 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
|
1650 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
|
1651 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1652 } |
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 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
|
1654 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
|
1655 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
|
1656 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1657 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1658 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
|
1659 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
|
1660 (*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
|
1661 cmd->args[1].parsed = NULL; |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1662 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1663 (*target)->condition = NULL; |
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 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1666 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
1667 |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1668 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
|
1669 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1670 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
|
1671 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
|
1672 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
|
1673 *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
|
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 } |
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 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
|
1678 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1679 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
|
1680 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
|
1681 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
|
1682 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
|
1683 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1684 putchar(' '); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1685 len++; |
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 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
|
1688 } |
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 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
|
1691 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1692 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
|
1693 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
|
1694 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
|
1695 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
|
1696 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
|
1697 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
|
1698 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1699 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
|
1700 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
|
1701 { |
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 *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
|
1703 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
|
1704 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
|
1705 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
|
1706 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
|
1707 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
|
1708 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
|
1709 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
|
1710 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
|
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 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1714 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1715 } else { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1716 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
|
1717 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
|
1718 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
|
1719 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
|
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 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
|
1722 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
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 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
|
1725 { |
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 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
|
1727 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
|
1728 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
|
1729 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1730 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1731 bp_def *tmp = *this_bp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1732 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
|
1733 *this_bp = (*this_bp)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1734 if (tmp->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1735 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
|
1736 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1737 free_parsed_command(tmp->commands + i); |
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->commands); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1740 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1741 free(tmp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1742 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1743 } |
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 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
|
1746 { |
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
|
1747 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
|
1748 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
|
1749 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
|
1750 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
|
1751 new_bp->index = root->bp_index++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1752 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
|
1753 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
|
1754 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1755 } |
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 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
|
1758 { |
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
|
1759 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
|
1760 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1761 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1762 |
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
|
1763 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
|
1764 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1765 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1766 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1767 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1768 if (inst->op == M68K_RTS) { |
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], context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1770 } 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
|
1771 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
|
1772 } else if(m68k_is_branch(inst)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1773 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
|
1774 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1775 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
|
1776 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
|
1777 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1778 if (inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1779 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
|
1780 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
|
1781 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1782 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1783 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1784 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
|
1785 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
|
1786 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1787 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1788 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
|
1789 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1790 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1791 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
|
1792 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1793 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1794 |
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
|
1795 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
|
1796 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1797 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1798 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1799 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1800 if (inst->op == M68K_RTS) { |
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], context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1802 } 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
|
1803 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
|
1804 } 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
|
1805 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
|
1806 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
|
1807 if (root->branch_t < after) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1808 root->branch_t = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1809 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1810 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1811 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
|
1812 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1813 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1814 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
|
1815 if (target > after) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1816 if (inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1817 after = target; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1818 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1819 root->branch_f = target; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1820 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1821 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
|
1822 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1823 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1824 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1825 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
|
1826 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1827 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1828 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
|
1829 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1830 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1831 |
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
|
1832 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
|
1833 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1834 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1835 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1836 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1837 if (inst->op == M68K_RTS) { |
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], context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1839 } 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
|
1840 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
|
1841 } 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
|
1842 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
|
1843 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1844 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
|
1845 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
|
1846 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1847 if ( inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1848 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
|
1849 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
|
1850 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1851 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1852 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1853 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
|
1854 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
|
1855 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1856 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1857 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
|
1858 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1859 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1860 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
|
1861 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1862 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1863 |
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
|
1864 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
|
1865 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1866 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1867 uint32_t stack = context->aregs[7]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1868 uint8_t non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1869 do { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1870 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
|
1871 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
|
1872 if (bt_address) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1873 stack += 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1874 non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1875 m68kinst inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1876 char buf[128]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1877 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
|
1878 m68k_disasm(&inst, buf); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1879 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
|
1880 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1881 //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
|
1882 stack += 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1883 non_adr_count++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1884 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1885 //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
|
1886 } while (stack && non_adr_count < 6); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1887 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1888 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1889 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1890 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
|
1891 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1892 m68k_context *context = root->cpu_context; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1893 uint32_t address = root->address; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1894 if (cmd->num_args) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1895 address = cmd->args[0].value; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1896 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1897 char disasm_buf[1024]; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1898 m68kinst inst; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1899 do { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1900 label_def *def = find_label(root->disasm, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1901 if (def) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1902 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
|
1903 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1904 printf("%s:\n", def->labels[i]); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1905 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1906 } |
2252
6a07b13894f7
Fix input processing while waiting for console input in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2216
diff
changeset
|
1907 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1908 address = m68k_decode(m68k_instruction_fetch, context, &inst, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1909 m68k_disasm_labels(&inst, disasm_buf, root->disasm); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1910 printf("\t%s\n", disasm_buf); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1911 } while(!m68k_is_terminal(&inst)); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1912 return 1; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1913 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
1914 |
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
|
1915 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
|
1916 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1917 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1918 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1919 vdp_print_sprite_table(gen->vdp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1920 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1921 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1922 |
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
|
1923 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
|
1924 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1925 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1926 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1927 vdp_print_reg_explain(gen->vdp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1928 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1929 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1930 |
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
|
1931 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
|
1932 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1933 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1934 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
|
1935 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
|
1936 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
|
1937 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1938 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
|
1939 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
|
1940 } |
2173
894c7873a2b1
Consume all expressions in debugger print command
Michael Pavone <pavone@retrodev.com>
parents:
2172
diff
changeset
|
1941 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1942 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1943 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1944 |
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
|
1945 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
|
1946 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1947 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1948 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1949 ym_print_timer_info(gen->ym); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1950 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1951 } |
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 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
|
1954 { |
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
|
1955 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1956 while (param && *param && isblank(*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 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1959 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1960 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1961 genesis_context *gen = m68k->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1962 segacd_context *cd = gen->expansion; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1963 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
|
1964 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1965 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
|
1966 if (!sub_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1967 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
|
1968 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1969 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1970 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
|
1971 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1972 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1973 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
|
1974 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1975 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1976 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1977 cd->enter_debugger = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1978 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1979 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1980 } |
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 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
|
1983 { |
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
|
1984 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1985 while (param && *param && isblank(*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 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1988 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1989 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1990 segacd_context *cd = m68k->system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
1991 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1992 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
|
1993 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1994 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
|
1995 if (!main_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1996 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
|
1997 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1998 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1999 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
|
2000 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2001 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2002 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
|
2003 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2004 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2005 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2006 cd->genesis->header.enter_debugger = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2007 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2008 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2009 } |
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 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
|
2012 { |
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
|
2013 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2014 while (param && *param && isblank(*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 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2017 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2018 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2019 genesis_context *gen = m68k->system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
2020 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2021 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
|
2022 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2023 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
|
2024 if (!z80_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2025 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
|
2026 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2027 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2028 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
|
2029 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2030 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2031 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
|
2032 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2033 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2034 } else { |
2184
408fb8a7e990
Implement argumentless variant of z80 debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2183
diff
changeset
|
2035 gen->enter_z80_debugger = 1; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2036 return 0; |
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 } |
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 command_def common_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2041 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2042 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2043 "quit", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2044 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2045 .usage = "quit", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2046 .desc = "Quit BlastEm", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2047 .impl = cmd_quit, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2048 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2049 .max_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2050 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2051 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2052 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2053 "help", "?", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2054 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2055 .usage = "help", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2056 .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
|
2057 .impl = cmd_help, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2058 .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
|
2059 .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
|
2060 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2061 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2062 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2063 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2064 "continue", "c", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2065 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2066 .usage = "continue", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2067 .desc = "Resume execution", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2068 .impl = cmd_continue, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2069 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2070 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2071 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2072 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2073 .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
|
2074 "print", "p", NULL |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2075 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2076 .usage = "print[/FORMAT] EXPRESSION...", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2077 .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
|
2078 .impl = cmd_print, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2079 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2080 .max_args = -1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2081 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2082 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2083 .names = (const char *[]){ |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2084 "printf", NULL |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2085 }, |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2086 .usage = "printf FORMAT EXPRESSION...", |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2087 .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
|
2088 .impl = cmd_printf, |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2089 .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
|
2090 .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
|
2091 .raw_args = 1 |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2092 }, |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2093 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2094 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2095 "softreset", "sr", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2096 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2097 .usage = "softreset", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2098 .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
|
2099 .impl = cmd_softreset, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2100 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2101 .max_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2102 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2103 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2104 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2105 "display", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2106 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2107 .usage = "display[/FORMAT] EXPRESSION...", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2108 .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
|
2109 .impl = cmd_display, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2110 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2111 .max_args = -1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2112 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2113 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2114 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2115 "deletedisplay", "dd", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2116 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2117 .usage = "deletedisplay DISPLAYNUM", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2118 .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
|
2119 .impl = cmd_delete_display, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2120 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2121 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2122 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2123 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2124 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2125 "commands", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2126 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2127 .usage = "command BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2128 .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
|
2129 .impl = cmd_command, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2130 .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
|
2131 .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
|
2132 .has_block = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2133 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2134 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2135 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2136 "set", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2137 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2138 .usage = "set MEM|NAME VALUE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2139 .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
|
2140 .impl = cmd_set, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2141 .min_args = 2, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2142 .max_args = 2, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2143 .skip_eval = 1 |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2144 }, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2145 { |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2146 .names = (const char *[]){ |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2147 "frames", NULL |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2148 }, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2149 .usage = "frames EXPRESSION", |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2150 .desc = "Resume execution for EXPRESSION video frames", |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2151 .impl = cmd_frames, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2152 .min_args = 1, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2153 .max_args = 1 |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2154 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2155 { |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2156 .names = (const char *[]){ |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2157 "bindup", NULL |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2158 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2159 .usage = "bindup NAME", |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2160 .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
|
2161 .impl = cmd_bindup, |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2162 .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
|
2163 .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
|
2164 .raw_args = 1 |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2165 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2166 { |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2167 .names = (const char *[]){ |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2168 "binddown", NULL |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2169 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2170 .usage = "bindown NAME", |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2171 .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
|
2172 .impl = cmd_binddown, |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
2173 .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
|
2174 .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
|
2175 .raw_args = 1 |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2176 }, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2177 { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2178 .names = (const char *[]){ |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2179 "condition", NULL |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2180 }, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2181 .usage = "condition BREAKPOINT [EXPRESSION]", |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2182 .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
|
2183 .impl = cmd_condition, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
2184 .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
|
2185 .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
|
2186 .skip_eval = 1 |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2187 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2188 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2189 .names = (const char *[]){ |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2190 "if", NULL |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2191 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2192 .usage = "if CONDITION", |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2193 .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
|
2194 .impl = cmd_if, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2195 .min_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2196 .max_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2197 .has_block = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2198 .accepts_else = 1 |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2199 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2200 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2201 .names = (const char *[]){ |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2202 "while", NULL |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2203 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2204 .usage = "while CONDITION", |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2205 .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
|
2206 .impl = cmd_while, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2207 .min_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2208 .max_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2209 .has_block = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2210 .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
|
2211 }, |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2212 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2213 .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
|
2214 "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
|
2215 }, |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2216 .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
|
2217 .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
|
2218 .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
|
2219 .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
|
2220 .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
|
2221 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2222 } |
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 #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
|
2225 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2226 command_def m68k_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2227 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2228 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2229 "breakpoint", "b", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2230 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2231 .usage = "breakpoint ADDRESSS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2232 .desc = "Set a breakpoint at ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2233 .impl = cmd_breakpoint_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2234 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2235 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2236 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2237 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2238 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2239 "advance", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2240 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2241 .usage = "advance ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2242 .desc = "Advance to ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2243 .impl = cmd_advance_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2244 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2245 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2246 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2247 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2248 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2249 "step", "s", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2250 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2251 .usage = "step", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2252 .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
|
2253 .impl = cmd_step_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2254 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2255 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2256 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2257 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2258 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2259 "over", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2260 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2261 .usage = "over", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2262 .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
|
2263 .impl = cmd_over_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2264 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2265 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2266 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2267 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2268 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2269 "next", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2270 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2271 .usage = "next", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2272 .desc = "Advance to the next instruction", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2273 .impl = cmd_next_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2274 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2275 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2276 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2277 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2278 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2279 "backtrace", "bt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2280 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2281 .usage = "backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2282 .desc = "Print a backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2283 .impl = cmd_backtrace_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2284 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2285 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2286 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2287 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2288 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2289 "delete", "d", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2290 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2291 .usage = "delete BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2292 .desc = "Remove breakpoint identified by BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2293 .impl = cmd_delete_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2294 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2295 .max_args = 1 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2296 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2297 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2298 .names = (const char *[]){ |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2299 "disassemble", "disasm", NULL |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2300 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2301 .usage = "disassemble [ADDRESS]", |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2302 .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
|
2303 .impl = cmd_disassemble_m68k, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2304 .min_args = 0, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2305 .max_args = 1 |
2112
3abb64bd0da6
Add support for printing strings in 68K debugger
Michael Pavone <pavone@retrodev.com>
parents:
2107
diff
changeset
|
2306 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2307 }; |
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 #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
|
2310 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2311 command_def genesis_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2312 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2313 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2314 "vdpsprites", "vs", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2315 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2316 .usage = "vdpsprites", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2317 .desc = "Print the VDP sprite table", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2318 .impl = cmd_vdp_sprites, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2319 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2320 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2321 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2322 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2323 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2324 "vdpsregs", "vr", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2325 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2326 .usage = "vdpregs", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2327 .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
|
2328 .impl = cmd_vdp_regs, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2329 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2330 .max_args = 0 |
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 #ifndef NO_Z80 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2333 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2334 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2335 "z80", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2336 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2337 .usage = "z80 [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2338 .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
|
2339 .impl = cmd_gen_z80, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2340 .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
|
2341 .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
|
2342 .raw_args = 1 |
2178
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 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2345 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2346 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2347 "ymchannel", "yc", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2348 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2349 .usage = "ymchannel [CHANNEL]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2350 .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
|
2351 .impl = cmd_ym_channel, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2352 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2353 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2354 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2355 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2356 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2357 "ymtimer", "yt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2358 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2359 .usage = "ymtimer", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2360 .desc = "Print YM-2612 timer info", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2361 .impl = cmd_ym_timer, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2362 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2363 .max_args = 0 |
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 }; |
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 #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
|
2368 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2369 command_def scd_main_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2370 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2371 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2372 "subcpu", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2373 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2374 .usage = "subcpu [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2375 .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
|
2376 .impl = cmd_sub, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2377 .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
|
2378 .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
|
2379 .raw_args = 1 |
2178
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 }; |
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 #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
|
2384 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2385 command_def scd_sub_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2386 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2387 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2388 "maincpu", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2389 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2390 .usage = "maincpu [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2391 .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
|
2392 .impl = cmd_main, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2393 .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
|
2394 .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
|
2395 .raw_args = 1 |
2178
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 }; |
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 #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
|
2400 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2401 #ifndef NO_Z80 |
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 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
|
2404 { |
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 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
|
2406 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
|
2407 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
|
2408 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2409 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2410 bp_def *tmp = *this_bp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2411 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
|
2412 *this_bp = (*this_bp)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2413 if (tmp->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2414 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
|
2415 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2416 free_parsed_command(tmp->commands + i); |
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->commands); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2419 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2420 free(tmp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2421 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2422 } |
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 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
|
2425 { |
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
|
2426 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
|
2427 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
|
2428 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
|
2429 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
|
2430 new_bp->index = root->bp_index++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2431 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
|
2432 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
|
2433 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2434 } |
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 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
|
2437 { |
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
|
2438 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
|
2439 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2440 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2441 |
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
|
2442 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
|
2443 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2444 z80inst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2445 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2446 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2447 //TODO: handle conditional branches |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2448 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
|
2449 if (inst->addr_mode == Z80_IMMED) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2450 after = inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2451 } 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
|
2452 #ifndef NEW_CORE |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2453 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
|
2454 } 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
|
2455 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
|
2456 } 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
|
2457 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
|
2458 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2459 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2460 } else if(inst->op == Z80_JR) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2461 after += inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2462 } else if(inst->op == Z80_RET) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2463 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
|
2464 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2465 after = *sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2466 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
|
2467 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2468 after |= *sp << 8; |
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 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2471 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2472 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
|
2473 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2474 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2475 |
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
|
2476 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
|
2477 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2478 fputs("not implemented yet\n", stderr); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2479 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2480 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2481 |
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
|
2482 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
|
2483 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2484 z80inst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2485 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2486 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2487 //TODO: handle conditional branches |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2488 if (inst->op == Z80_JP) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2489 if (inst->addr_mode == Z80_IMMED) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2490 after = inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2491 } 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
|
2492 #ifndef NEW_CORE |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2493 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
|
2494 } 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
|
2495 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
|
2496 } 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
|
2497 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
|
2498 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2499 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2500 } else if(inst->op == Z80_JR) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2501 after += inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2502 } else if(inst->op == Z80_RET) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2503 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
|
2504 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2505 after = *sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2506 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
|
2507 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2508 after |= *sp << 8; |
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 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2511 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2512 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
|
2513 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2514 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2515 |
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
|
2516 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
|
2517 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2518 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2519 uint32_t stack = context->sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2520 uint8_t non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2521 do { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2522 uint32_t bt_address = stack; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2523 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
|
2524 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2525 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2526 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
|
2527 if (bt_address != 0xFEEDFEED) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2528 stack += 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2529 non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2530 z80inst inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2531 char buf[128]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2532 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
|
2533 z80_decode(pc, &inst); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2534 z80_disasm(&inst, buf, bt_address); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2535 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
|
2536 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2537 //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
|
2538 stack++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2539 non_adr_count++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2540 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2541 //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
|
2542 } while (stack && non_adr_count < 6); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2543 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2544 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2545 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2546 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
|
2547 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2548 z80_context *context = root->cpu_context; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2549 uint32_t address = root->address; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2550 if (cmd->num_args) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2551 address = cmd->args[0].value; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2552 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2553 char disasm_buf[1024]; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2554 z80inst inst; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2555 do { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2556 label_def *def = find_label(root->disasm, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2557 if (def) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2558 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
|
2559 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2560 printf("%s:\n", def->labels[i]); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2561 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2562 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2563 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
|
2564 uint8_t *after = z80_decode(pc, &inst); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2565 z80_disasm(&inst, disasm_buf, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2566 address += after - pc; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2567 printf("\t%s\n", disasm_buf); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2568 } while(!z80_is_terminal(&inst)); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2569 return 1; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2570 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
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 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
|
2573 { |
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
|
2574 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
|
2575 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
|
2576 { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2577 ++param; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2578 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2579 genesis_context *gen = (genesis_context *)current_system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
2580 |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2581 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
|
2582 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
|
2583 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
|
2584 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
|
2585 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
|
2586 return 1; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2587 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2588 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
|
2589 return 1; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2590 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2591 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
|
2592 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
|
2593 return ret; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2594 } else { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2595 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
|
2596 return 0; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2597 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2598 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2599 |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2600 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
|
2601 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2602 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
|
2603 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
|
2604 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
|
2605 return 1; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2606 } |
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 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
|
2609 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2610 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
|
2611 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
|
2612 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
|
2613 return 1; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2614 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2615 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2616 command_def z80_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2617 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2618 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2619 "breakpoint", "b", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2620 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2621 .usage = "breakpoint ADDRESSS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2622 .desc = "Set a breakpoint at ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2623 .impl = cmd_breakpoint_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2624 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2625 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2626 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2627 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2628 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2629 "advance", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2630 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2631 .usage = "advance ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2632 .desc = "Advance to ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2633 .impl = cmd_advance_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2634 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2635 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2636 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2637 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2638 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2639 "step", "s", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2640 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2641 .usage = "step", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2642 .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
|
2643 .impl = cmd_step_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2644 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2645 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2646 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2647 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2648 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2649 "over", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2650 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2651 .usage = "over", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2652 .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
|
2653 .impl = cmd_over_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2654 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2655 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2656 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2657 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2658 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2659 "next", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2660 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2661 .usage = "next", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2662 .desc = "Advance to the next instruction", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2663 .impl = cmd_next_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2664 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2665 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2666 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2667 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2668 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2669 "backtrace", "bt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2670 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2671 .usage = "backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2672 .desc = "Print a backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2673 .impl = cmd_backtrace_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2674 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2675 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2676 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2677 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2678 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2679 "delete", "d", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2680 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2681 .usage = "delete BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2682 .desc = "Remove breakpoint identified by BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2683 .impl = cmd_delete_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2684 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2685 .max_args = 1 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2686 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2687 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2688 .names = (const char *[]){ |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2689 "disassemble", "disasm", NULL |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2690 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2691 .usage = "disassemble [ADDRESS]", |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2692 .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
|
2693 .impl = cmd_disassemble_z80, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2694 .min_args = 0, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
2695 .max_args = 1 |
2178
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 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2698 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2699 #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
|
2700 |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2701 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
|
2702 { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2703 .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
|
2704 "m68k", NULL |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2705 }, |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2706 .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
|
2707 .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
|
2708 .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
|
2709 .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
|
2710 .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
|
2711 .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
|
2712 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2713 }; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2714 |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
2715 #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
|
2716 |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2717 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
|
2718 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2719 .names = (const char *[]){ |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2720 "vdpsprites", "vs", NULL |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2721 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2722 .usage = "vdpsprites", |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2723 .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
|
2724 .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
|
2725 .min_args = 0, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2726 .max_args = 0 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2727 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2728 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2729 .names = (const char *[]){ |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2730 "vdpsregs", "vr", NULL |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2731 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2732 .usage = "vdpregs", |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2733 .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
|
2734 .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
|
2735 .min_args = 0, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2736 .max_args = 0 |
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 }; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2739 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
2740 #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
|
2741 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2742 #endif |
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 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
|
2745 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2746 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
|
2747 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2748 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
|
2749 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2750 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
|
2751 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2752 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2753 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2754 |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2755 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
|
2756 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2757 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
|
2758 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
|
2759 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
|
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 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
|
2762 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2763 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2764 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2765 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
|
2766 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2767 debug_root *root = find_root(context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2768 if (root && !root->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2769 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
|
2770 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
|
2771 root->read_mem = read_m68k; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2772 root->write_mem = write_m68k; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2773 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
|
2774 root->disasm = create_68000_disasm(); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2775 switch (current_system->type) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2776 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2777 case SYSTEM_GENESIS: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2778 case SYSTEM_SEGACD: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2779 //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
|
2780 if (context->system == current_system) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2781 root->resolve = resolve_genesis; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2782 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
|
2783 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
|
2784 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
|
2785 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
|
2786 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2787 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2788 } 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
|
2789 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
|
2790 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
|
2791 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2792 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2793 root->resolve = resolve_m68k; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2794 } |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
2795 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
|
2796 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2797 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
|
2798 } |
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
|
2799 |
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
|
2800 #ifndef NO_Z80 |
548
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
2801 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2802 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
|
2803 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2804 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2805 uint32_t address = *out; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2806 *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
|
2807 if (size == 'w') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2808 *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
|
2809 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2810 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2811 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2812 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2813 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
|
2814 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2815 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2816 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
|
2817 if (size == 'w') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2818 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
|
2819 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2820 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2821 } |
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 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
|
2824 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2825 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2826 switch (tolower(name[0])) |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2827 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2828 case 'a': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2829 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2830 *out = context->regs[Z80_A]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2831 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2832 *out = context->alt_regs[Z80_A]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2833 } else if (tolower(name[1]) == 'f') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2834 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2835 *out = context->regs[Z80_A] << 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2836 *out |= context->flags[ZF_S] << 7; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2837 *out |= context->flags[ZF_Z] << 6; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2838 *out |= context->flags[ZF_H] << 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2839 *out |= context->flags[ZF_PV] << 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2840 *out |= context->flags[ZF_N] << 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2841 *out |= context->flags[ZF_C]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2842 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2843 *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
|
2844 *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
|
2845 *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
|
2846 *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
|
2847 *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
|
2848 *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
|
2849 *out |= context->alt_flags[ZF_C]; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2850 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2851 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2852 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2853 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2854 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2855 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2856 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2857 case 'b': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2858 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2859 *out = context->regs[Z80_B]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2860 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2861 *out = context->alt_regs[Z80_B]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2862 } else if (tolower(name[1]) == 'c') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2863 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2864 *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
|
2865 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2866 *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
|
2867 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2868 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2869 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2870 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2871 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2872 case 'c': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2873 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2874 *out = context->regs[Z80_C]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2875 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2876 *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
|
2877 } 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
|
2878 *out = context->current_cycle; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2879 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2880 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2881 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2882 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2883 case 'd': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2884 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2885 *out = context->regs[Z80_D]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2886 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2887 *out = context->alt_regs[Z80_D]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2888 } else if (tolower(name[1]) == 'e') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2889 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2890 *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
|
2891 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2892 *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
|
2893 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2894 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2895 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2896 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2897 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2898 case 'e': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2899 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2900 *out = context->regs[Z80_E]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2901 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2902 *out = context->alt_regs[Z80_E]; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2903 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2904 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2905 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2906 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2907 case 'f': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2908 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2909 *out = context->flags[ZF_S] << 7; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2910 *out |= context->flags[ZF_Z] << 6; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2911 *out |= context->flags[ZF_H] << 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2912 *out |= context->flags[ZF_PV] << 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2913 *out |= context->flags[ZF_N] << 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2914 *out |= context->flags[ZF_C]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2915 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2916 *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
|
2917 *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
|
2918 *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
|
2919 *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
|
2920 *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
|
2921 *out |= context->alt_flags[ZF_C]; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2922 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2923 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2924 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2925 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2926 case 'h': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2927 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2928 *out = context->regs[Z80_H]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2929 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2930 *out = context->alt_regs[Z80_H]; |
2208
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
2931 } 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
|
2932 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2933 *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
|
2934 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2935 *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
|
2936 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2937 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2938 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2939 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2940 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2941 case 'i': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2942 switch (tolower(name[1])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2943 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2944 case 0: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2945 *out = context->regs[Z80_I]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2946 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2947 case 'f': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2948 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
|
2949 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2950 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2951 if (name[3] == '1') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2952 *out = context->iff1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2953 } else if (name[3] == '2') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2954 *out = context->iff2; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2955 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2956 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2957 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2958 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2959 case 'm': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2960 if (name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2961 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2962 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2963 *out = context->im; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2964 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2965 case 'n': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2966 if (strcasecmp(name +2, "t_cycle")) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2967 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2968 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2969 *out = context->int_cycle; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2970 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2971 case 'r': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2972 if (name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2973 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2974 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2975 *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
|
2976 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2977 case 'x': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2978 switch (tolower(name[2])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2979 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2980 case 0: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2981 *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
|
2982 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2983 case 'h': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2984 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2985 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2986 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2987 *out = context->regs[Z80_IXH]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2988 case 'l': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2989 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2990 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2991 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2992 *out = context->regs[Z80_IXL]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2993 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2994 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2995 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2996 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2997 case 'y': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2998 switch (tolower(name[2])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2999 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3000 case 0: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3001 *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
|
3002 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3003 case 'h': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3004 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3005 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3006 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3007 *out = context->regs[Z80_IYH]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3008 case 'l': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3009 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3010 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3011 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3012 *out = context->regs[Z80_IYL]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3013 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3014 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3015 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3016 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3017 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3018 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3019 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3020 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3021 case 'l': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3022 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3023 *out = context->regs[Z80_L]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3024 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3025 *out = context->alt_regs[Z80_L]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3026 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3027 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3028 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3029 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3030 case 'p': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3031 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
|
3032 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3033 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3034 *out = root->address; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3035 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3036 case 'r': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3037 if (name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3038 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3039 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3040 *out = context->regs[Z80_R]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3041 case 's': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3042 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
|
3043 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3044 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3045 *out = context->sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3046 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3047 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3048 return 0; |
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 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3051 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3052 |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3053 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
|
3054 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3055 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
|
3056 return 1; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3057 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3058 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
|
3059 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
|
3060 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
|
3061 *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
|
3062 return 1; |
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 return 0; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3065 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3066 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3067 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
|
3068 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3069 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3070 switch (tolower(name[0])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3071 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3072 case 'a': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3073 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3074 context->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 (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3076 context->alt_regs[Z80_A] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3077 } else if (tolower(name[1]) == 'f') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3078 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3079 context->regs[Z80_A] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3080 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
|
3081 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
|
3082 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
|
3083 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
|
3084 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
|
3085 context->flags[ZF_C] = value & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3086 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3087 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
|
3088 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
|
3089 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
|
3090 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
|
3091 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
|
3092 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
|
3093 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
|
3094 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3095 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3096 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3097 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3098 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3099 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3100 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3101 case 'b': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3102 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3103 context->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 (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3105 context->alt_regs[Z80_B] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3106 } else if (tolower(name[1]) == 'c') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3107 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3108 context->regs[Z80_B] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3109 context->regs[Z80_C] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3110 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3111 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
|
3112 context->alt_regs[Z80_C] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3113 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3114 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3115 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3116 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3117 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3118 case 'c': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3119 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3120 context->regs[Z80_C] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3121 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3122 context->alt_regs[Z80_C] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3123 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3124 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3125 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3126 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3127 case 'd': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3128 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3129 context->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 (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3131 context->alt_regs[Z80_D] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3132 } else if (tolower(name[1]) == 'e') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3133 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3134 context->regs[Z80_D] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3135 context->regs[Z80_E] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3136 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3137 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
|
3138 context->alt_regs[Z80_E] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3139 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3140 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3141 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3142 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3143 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3144 case 'e': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3145 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3146 context->regs[Z80_E] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3147 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3148 context->alt_regs[Z80_E] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3149 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3150 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3151 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3152 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3153 case 'f': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3154 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3155 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
|
3156 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
|
3157 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
|
3158 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
|
3159 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
|
3160 context->flags[ZF_C] = value & 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3161 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3162 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
|
3163 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
|
3164 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
|
3165 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
|
3166 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
|
3167 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
|
3168 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3169 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3170 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3171 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3172 case 'h': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3173 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3174 context->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 (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3176 context->alt_regs[Z80_H] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3177 } else if (tolower(name[1]) == 'e') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3178 if (!name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3179 context->regs[Z80_H] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3180 context->regs[Z80_L] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3181 } else if (name[2] == '\'' && !name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3182 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
|
3183 context->alt_regs[Z80_L] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3184 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3185 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3186 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3187 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3188 break; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3189 case 'i': |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3190 switch (tolower(name[1])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3191 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3192 case 0: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3193 context->regs[Z80_I] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3194 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3195 case 'f': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3196 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
|
3197 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3198 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3199 if (name[3] == '1') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3200 context->iff1 = value != 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3201 } else if (name[3] == '2') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3202 context->iff2 = value != 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3203 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3204 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3205 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3206 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3207 case 'm': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3208 if (name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3209 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3210 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3211 context->im = value & 3; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3212 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3213 case 'r': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3214 if (name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3215 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3216 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3217 context->regs[Z80_I] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3218 context->regs[Z80_R] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3219 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3220 case 'x': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3221 switch (tolower(name[2])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3222 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3223 case 0: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3224 context->regs[Z80_IXH] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3225 context->regs[Z80_IXL] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3226 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3227 case 'h': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3228 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3229 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3230 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3231 context->regs[Z80_IXH] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3232 case 'l': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3233 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3234 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3235 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3236 context->regs[Z80_IXL] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3237 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3238 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3239 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3240 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3241 case 'y': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3242 switch (tolower(name[2])) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3243 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3244 case 0: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3245 context->regs[Z80_IYH] = value >> 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3246 context->regs[Z80_IYL] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3247 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3248 case 'h': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3249 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3250 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3251 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3252 context->regs[Z80_IYH] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3253 case 'l': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3254 if (name[3]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3255 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3256 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3257 context->regs[Z80_IYL] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3258 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3259 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3260 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3261 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3262 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3263 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3264 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3265 break; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3266 case 'l': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3267 if (!name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3268 context->regs[Z80_L] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3269 } else if (name[1] == '\'' && !name[2]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3270 context->alt_regs[Z80_L] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3271 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3272 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3273 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3274 break; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3275 case 'r': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3276 if (name[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3277 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3278 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3279 context->regs[Z80_R] = value; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3280 case 's': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3281 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
|
3282 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3283 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3284 context->sp = value; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3285 break; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3286 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3287 return 0; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3288 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3289 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3290 } |
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 *find_z80_root(z80_context *context) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3293 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3294 debug_root *root = find_root(context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3295 if (root && !root->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3296 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
|
3297 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
|
3298 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
|
3299 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3300 case SYSTEM_GENESIS: |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3301 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
|
3302 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
|
3303 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
|
3304 break; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3305 case SYSTEM_SMS: |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3306 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
|
3307 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
|
3308 break; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3309 default: |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
3310 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
|
3311 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3312 root->read_mem = read_z80; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3313 root->write_mem = write_z80; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3314 root->set = set_z80; |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3315 root->disasm = create_z80_disasm(); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3316 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3317 return root; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3318 } |
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 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
|
3321 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3322 static char last_cmd[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3323 char input_buf[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3324 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
|
3325 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
|
3326 init_terminal(); |
2180
b87658ba3b94
Fix bug in Z80 debugger for SMS mode post-refactor
Michael Pavone <pavone@retrodev.com>
parents:
2179
diff
changeset
|
3327 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
|
3328 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
|
3329 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
|
3330 } |
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
|
3331 root->address = address; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3332 //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
|
3333 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
|
3334 if (*this_bp) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3335 if ((*this_bp)->condition) { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3336 uint32_t condres; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3337 if (eval_expr(root, (*this_bp)->condition, &condres)) { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3338 if (!condres) { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3339 return context; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3340 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3341 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3342 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
|
3343 free_expr((*this_bp)->condition); |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3344 (*this_bp)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3345 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3346 } |
2208
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3347 int debugging = 1; |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3348 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
|
3349 { |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3350 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
|
3351 } |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3352 if (debugging) { |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3353 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
|
3354 } else { |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3355 return context; |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
3356 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3357 } else { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3358 zremove_breakpoint(context, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3359 } |
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
|
3360 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
|
3361 if (!pc) { |
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
1111
diff
changeset
|
3362 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
|
3363 } |
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
|
3364 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
|
3365 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
|
3366 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
|
3367 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
|
3368 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
|
3369 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
|
3370 make_format_str(format_str, cur->format); |
2183
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3371 for (int i = 0; i < cur->num_args; i++) |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3372 { |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3373 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
|
3374 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
|
3375 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3376 } |
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
|
3377 |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3378 z80_disasm(&inst, input_buf, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3379 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
|
3380 debugger_repl(root); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3381 return context; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3382 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3383 |
548
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
3384 #endif |
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
3385 |
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
|
3386 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
|
3387 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3388 static char last_cmd[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3389 char input_buf[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3390 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
|
3391 |
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
|
3392 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
|
3393 |
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
|
3394 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
|
3395 if (context->system == current_system) { |
ff32a90260c9
Initial support for using debugger on sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2054
diff
changeset
|
3396 genesis_context *gen = context->system; |
ff32a90260c9
Initial support for using debugger on sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2054
diff
changeset
|
3397 vdp_force_update_framebuffer(gen->vdp); |
ff32a90260c9
Initial support for using debugger on sub CPU
Michael Pavone <pavone@retrodev.com>
parents:
2054
diff
changeset
|
3398 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3399 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
|
3400 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
|
3401 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
|
3402 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3403 //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
|
3404 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
|
3405 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
|
3406 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
|
3407 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
|
3408 remove_breakpoint(context, root->branch_f); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3409 } |
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
|
3410 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
|
3411 } 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
|
3412 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
|
3413 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
|
3414 remove_breakpoint(context, root->branch_t); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3415 } |
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
|
3416 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
|
3417 } |
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
|
3418 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3419 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
|
3420 int debugging = 1; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3421 //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
|
3422 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
|
3423 if (*this_bp) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3424 if ((*this_bp)->condition) { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3425 uint32_t condres; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3426 if (eval_expr(root, (*this_bp)->condition, &condres)) { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3427 if (!condres) { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3428 return; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3429 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3430 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3431 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
|
3432 free_expr((*this_bp)->condition); |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3433 (*this_bp)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3434 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3435 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3436 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
|
3437 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3438 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
|
3439 } |
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 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
|
3441 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
|
3442 } 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
|
3443 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
|
3444 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3445 } else { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3446 remove_breakpoint(context, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3447 } |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3448 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
|
3449 root->after = after; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3450 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
|
3451 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
|
3452 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
|
3453 make_format_str(format_str, cur->format); |
2183
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3454 for (int i = 0; i < cur->num_args; i++) |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3455 { |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
3456 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
|
3457 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
|
3458 } |
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
|
3459 } |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3460 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
|
3461 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
|
3462 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
|
3463 return; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3464 } |