Mercurial > repos > blastem
annotate debug.c @ 2414:dc05f1805921
Fix out of bound read from mode4_address_map in TMS modes
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 04 Jan 2024 23:31:54 -0800 |
parents | 64cf80e683aa |
children | 1978bd770023 |
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> |
2366
1e36d8a2633c
Add missing math.h include
Michael Pavone <pavone@retrodev.com>
parents:
2365
diff
changeset
|
8 #include <math.h> |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 #include <stdlib.h> |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 #include <string.h> |
745
daa31ee7d8cd
Get windows build compiling again post-merge
Michael Pavone <pavone@retrodev.com>
parents:
723
diff
changeset
|
11 #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
|
12 #include <sys/select.h> |
745
daa31ee7d8cd
Get windows build compiling again post-merge
Michael Pavone <pavone@retrodev.com>
parents:
723
diff
changeset
|
13 #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
|
14 #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
|
15 #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
|
16 #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
|
17 #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
|
18 #ifndef NO_Z80 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
19 #include "sms.h" |
2413
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
20 #include "coleco.h" |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
21 #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
|
22 |
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 #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
|
24 #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
|
25 #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
|
26 #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
|
27 #endif |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
29 static debug_func *funcs; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
30 static uint32_t num_funcs, func_storage; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
31 |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
32 static debug_func* alloc_func(void) |
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
|
33 { |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
34 if (num_funcs == func_storage) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
35 func_storage = func_storage ? func_storage * 2 : 4; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
36 funcs = realloc(funcs, sizeof(debug_func) * func_storage); |
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
|
37 } |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
38 return funcs + num_funcs++; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
39 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
40 |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
41 static debug_val new_native_func(debug_native_func impl, int max_args, int min_args) |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
42 { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
43 debug_func *f = alloc_func(); |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
44 f->impl.native = impl; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
45 f->max_args = max_args; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
46 f->min_args = min_args; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
47 f->is_native = 1; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
48 return (debug_val) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
49 .v = { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
50 .u32 = f - funcs |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
51 }, |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
52 .type = DBG_VAL_FUNC |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
53 }; |
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
|
54 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
56 static debug_val new_user_func(command_block *block, char **args, int num_args) |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
57 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
58 debug_func *f = alloc_func(); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
59 f->impl.block = *block; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
60 f->arg_names = args; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
61 f->max_args = f->min_args = num_args; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
62 f->is_native = 0; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
63 return (debug_val) { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
64 .v = { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
65 .u32 = f - funcs |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
66 }, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
67 .type = DBG_VAL_FUNC |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
68 }; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
69 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
70 |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
71 debug_val user_var_get(debug_var *var) |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 { |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
73 return var->val; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
74 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
75 |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
76 void user_var_set(debug_var *var, debug_val val) |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
77 { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
78 var->val = val; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
81 static void new_user_variable(debug_root *root, const char *name, debug_val val) |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 { |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
83 debug_var *var = calloc(1, sizeof(debug_var)); |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
84 var->get = user_var_get; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
85 var->set = user_var_set; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
86 var->val = val; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
87 root->variables = tern_insert_ptr(root->variables, name, var); |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
88 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
89 |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
90 static void new_readonly_variable(debug_root *root, const char *name, debug_val val) |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
91 { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
92 debug_var *var = calloc(1, sizeof(debug_var)); |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
93 var->get = user_var_get; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
94 var->set = NULL; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
95 var->val = val; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
96 root->variables = tern_insert_ptr(root->variables, name, var); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
99 static debug_array *arrays; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
100 static uint32_t num_arrays, array_storage; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
101 static debug_array *alloc_array(void) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
102 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
103 if (num_arrays == array_storage) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
104 array_storage = array_storage ? array_storage * 2 : 4; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
105 arrays = realloc(arrays, sizeof(debug_array) * array_storage); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
106 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
107 return arrays + num_arrays++; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
108 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
109 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
110 static debug_val new_fixed_array(void *base, debug_array_get get, debug_array_set set, uint32_t size) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
111 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
112 debug_array *array = alloc_array(); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
113 array->get = get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
114 array->set = set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
115 array->append = NULL; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
116 array->base = base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
117 array->size = array->storage = size; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
118 debug_val ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
119 ret.type = DBG_VAL_ARRAY; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
120 ret.v.u32 = array - arrays; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
121 return ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
122 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
123 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
124 static debug_val user_array_get(debug_array *array, uint32_t index) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
125 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
126 debug_val *data = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
127 return data[index]; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
128 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
129 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
130 static void user_array_set(debug_array *array, uint32_t index, debug_val value) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
131 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
132 debug_val *data = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
133 data[index] = value; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
134 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
135 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
136 static void user_array_append(debug_array *array, debug_val value) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
137 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
138 if (array->size == array->storage) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
139 array->storage *= 2; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
140 array->base = realloc(array->base, sizeof(debug_val) * array->storage); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
141 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
142 debug_val *data = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
143 data[array->size++] = value; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
144 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
145 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
146 static debug_val new_user_array(uint32_t size) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
147 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
148 debug_array *array = alloc_array(); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
149 array->get = user_array_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
150 array->set = user_array_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
151 array->append = user_array_append; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
152 array->size = size; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
153 array->storage = size ? size : 4; |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
154 array->base = calloc(array->storage, sizeof(debug_val)); |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
155 debug_val ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
156 ret.type = DBG_VAL_ARRAY; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
157 ret.v.u32 = array - arrays; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
158 return ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
159 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
160 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
161 debug_array *get_array(debug_val val) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
162 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
163 if (val.type != DBG_VAL_ARRAY) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
164 return NULL; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
165 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
166 return arrays + val.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
167 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
168 |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
169 static debug_string **debug_strings; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
170 static uint32_t num_debug_strings; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
171 static uint32_t debug_string_storage; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
172 static debug_val new_debug_string(char *str) |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
173 { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
174 if (num_debug_strings == debug_string_storage) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
175 debug_string_storage = debug_string_storage ? 2 * debug_string_storage : 4; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
176 debug_strings = realloc(debug_strings, debug_string_storage * sizeof(debug_string*)); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
177 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
178 debug_string *string = calloc(1, sizeof(debug_string)); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
179 string->size = string->storage = strlen(str); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
180 string->buffer = calloc(1, string->size + 1); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
181 memcpy(string->buffer, str, string->size + 1); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
182 debug_strings[num_debug_strings] = string; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
183 return (debug_val){ |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
184 .type = DBG_VAL_STRING, |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
185 .v = { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
186 .u32 = num_debug_strings++ |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
187 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
188 }; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
189 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
190 |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
191 static debug_string* get_string(debug_val val) |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
192 { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
193 if (val.type != DBG_VAL_STRING) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
194 return NULL; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
195 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
196 return debug_strings[val.v.u32]; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
197 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
198 |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
199 static char* get_cstring(debug_val val) |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
200 { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
201 debug_string *str = get_string(val); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
202 if (!str) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
203 return NULL; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
204 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
205 return str->buffer; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
206 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
207 |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
208 static uint8_t debug_cast_int(debug_val val, uint32_t *out) |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
209 { |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
210 if (val.type == DBG_VAL_U32) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
211 *out = val.v.u32; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
212 return 1; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
213 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
214 if (val.type == DBG_VAL_F32) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
215 *out = val.v.f32; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
216 return 1; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
217 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
218 return 0; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
219 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
220 |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
221 static uint8_t debug_cast_float(debug_val val, float *out) |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
222 { |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
223 if (val.type == DBG_VAL_U32) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
224 *out = val.v.u32; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
225 return 1; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
226 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
227 if (val.type == DBG_VAL_F32) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
228 *out = val.v.f32; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
229 return 1; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
230 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
231 return 0; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
232 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
233 |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
234 static uint8_t debug_cast_bool(debug_val val) |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
235 { |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
236 switch(val.type) |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
237 { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
238 case DBG_VAL_U32: return val.v.u32 != 0; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
239 case DBG_VAL_F32: return val.v.f32 != 0.0f; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
240 case DBG_VAL_ARRAY: return get_array(val)->size != 0; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
241 default: return 1; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
242 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
243 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
244 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
245 static debug_val debug_int(uint32_t i) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
246 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
247 debug_val ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
248 ret.type = DBG_VAL_U32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
249 ret.v.u32 = i; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
250 return ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
251 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
252 |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
253 static debug_val debug_float(float f) |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
254 { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
255 return (debug_val) { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
256 .type = DBG_VAL_F32, |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
257 .v = { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
258 .f32 = f |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
259 } |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
260 }; |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
261 } |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
262 |
2367
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
263 static debug_val debug_sin(debug_val *args, int num_args) |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
264 { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
265 float f; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
266 if (!debug_cast_float(args[0], &f)) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
267 return debug_float(0.0f); |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
268 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
269 return debug_float(sinf(f)); |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
270 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
271 |
2367
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
272 static debug_val debug_cos(debug_val *args, int num_args) |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
273 { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
274 float f; |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
275 if (!debug_cast_float(args[0], &f)) { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
276 return debug_float(0.0f); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
277 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
278 return debug_float(cosf(f)); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
279 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
280 |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
281 static debug_val debug_tan(debug_val *args, int num_args) |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
282 { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
283 float f; |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
284 if (!debug_cast_float(args[0], &f)) { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
285 return debug_float(0.0f); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
286 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
287 return debug_float(tanf(f)); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
288 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
289 |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
290 static debug_val debug_asin(debug_val *args, int num_args) |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
291 { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
292 float f; |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
293 if (!debug_cast_float(args[0], &f)) { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
294 return debug_float(0.0f); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
295 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
296 return debug_float(asinf(f)); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
297 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
298 |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
299 static debug_val debug_acos(debug_val *args, int num_args) |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
300 { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
301 float f; |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
302 if (!debug_cast_float(args[0], &f)) { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
303 return debug_float(0.0f); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
304 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
305 return debug_float(acosf(f)); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
306 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
307 |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
308 static debug_val debug_atan(debug_val *args, int num_args) |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
309 { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
310 float f; |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
311 if (!debug_cast_float(args[0], &f)) { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
312 return debug_float(0.0f); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
313 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
314 return debug_float(atanf(f)); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
315 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
316 |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
317 static debug_val debug_atan2(debug_val *args, int num_args) |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
318 { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
319 float f, f2; |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
320 if (!debug_cast_float(args[0], &f)) { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
321 return debug_float(0.0f); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
322 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
323 if (!debug_cast_float(args[1], &f2)) { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
324 return debug_float(0.0f); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
325 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
326 return debug_float(atan2f(f, f2)); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
327 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
328 |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
329 static debug_val array_pop(debug_val *args, int num_args) |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
330 { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
331 debug_array *array = get_array(*args); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
332 if (!array) { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
333 return debug_int(0); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
334 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
335 debug_val ret = array->get(array, array->size - 1); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
336 if (array->append) { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
337 array->size--; |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
338 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
339 return ret; |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
340 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
341 |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
342 static debug_val debug_size(debug_val *args, int num_args) |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
343 { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
344 debug_array *array = get_array(*args); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
345 if (!array) { |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
346 //TODO: string support |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
347 return debug_int(0); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
348 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
349 return debug_int(array->size); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
350 } |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
351 |
2380
1b21290358a8
Fix regression in debugger for Mega CD
Michael Pavone <pavone@retrodev.com>
parents:
2371
diff
changeset
|
352 static debug_root **roots; |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
353 static uint32_t num_roots, root_storage; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
354 |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
355 debug_root *find_root(void *cpu) |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
356 { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
357 for (uint32_t i = 0; i < num_roots; i++) |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
358 { |
2380
1b21290358a8
Fix regression in debugger for Mega CD
Michael Pavone <pavone@retrodev.com>
parents:
2371
diff
changeset
|
359 if (roots[i]->cpu_context == cpu) { |
1b21290358a8
Fix regression in debugger for Mega CD
Michael Pavone <pavone@retrodev.com>
parents:
2371
diff
changeset
|
360 return roots[i]; |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
361 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
362 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
363 if (num_roots == root_storage) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
364 root_storage = root_storage ? root_storage * 2 : 5; |
2380
1b21290358a8
Fix regression in debugger for Mega CD
Michael Pavone <pavone@retrodev.com>
parents:
2371
diff
changeset
|
365 roots = realloc(roots, root_storage * sizeof(debug_root*)); |
1b21290358a8
Fix regression in debugger for Mega CD
Michael Pavone <pavone@retrodev.com>
parents:
2371
diff
changeset
|
366 } |
1b21290358a8
Fix regression in debugger for Mega CD
Michael Pavone <pavone@retrodev.com>
parents:
2371
diff
changeset
|
367 debug_root *root = calloc(1, sizeof(debug_root)); |
1b21290358a8
Fix regression in debugger for Mega CD
Michael Pavone <pavone@retrodev.com>
parents:
2371
diff
changeset
|
368 roots[num_roots++] = root; |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
369 root->cpu_context = cpu; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
370 new_readonly_variable(root, "sin", new_native_func(debug_sin, 1, 1)); |
2367
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
371 new_readonly_variable(root, "cos", new_native_func(debug_cos, 1, 1)); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
372 new_readonly_variable(root, "tan", new_native_func(debug_tan, 1, 1)); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
373 new_readonly_variable(root, "asin", new_native_func(debug_asin, 1, 1)); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
374 new_readonly_variable(root, "acos", new_native_func(debug_acos, 1, 1)); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
375 new_readonly_variable(root, "atan", new_native_func(debug_atan, 1, 1)); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
376 new_readonly_variable(root, "atan2", new_native_func(debug_atan2, 2, 2)); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
377 new_readonly_variable(root, "pop", new_native_func(array_pop, 1, 1)); |
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
378 new_readonly_variable(root, "size", new_native_func(debug_size, 1, 1)); |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
379 return root; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
380 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
381 |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
382 bp_def ** find_breakpoint(bp_def ** cur, uint32_t address, uint8_t type) |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
383 { |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
384 if (type == BP_TYPE_CPU_WATCH) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
385 while (*cur) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
386 if ((*cur)->type == type && address >= (*cur)->address && address < ((*cur)->address + (*cur)->mask)) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
387 break; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
388 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
389 cur = &((*cur)->next); |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
390 } |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
391 } else { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
392 while (*cur) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
393 if ((*cur)->type == type && (*cur)->address == (((*cur)->mask) & address)) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
394 break; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
395 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
396 cur = &((*cur)->next); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
397 } |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
398 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
399 return cur; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
400 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
401 |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
402 bp_def ** find_breakpoint_idx(bp_def ** cur, uint32_t index) |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
403 { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
404 while (*cur) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
405 if ((*cur)->index == index) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
406 break; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
407 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
408 cur = &((*cur)->next); |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
409 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
410 return cur; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
411 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
412 |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
413 static const char *token_type_names[] = { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
414 "TOKEN_NONE", |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
415 "TOKEN_INT", |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
416 "TOKEN_DECIMAL", |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
417 "TOKEN_NAME", |
2364
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
418 "TOKEN_ARRAY", |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
419 "TOKEN_FUNCALL", |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
420 "TOKEN_OPER", |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
421 "TOKEN_SIZE", |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
422 "TOKEN_LBRACKET", |
2171
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
423 "TOKEN_RBRACKET", |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
424 "TOKEN_LPAREN", |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
425 "TOKEN_RPAREN", |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
426 "TOKEN_STRING" |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
427 }; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
428 |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
429 static char *parse_string_literal(char *start, char **end) |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
430 { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
431 uint32_t length = 0; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
432 uint8_t is_escape = 0; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
433 char *cur; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
434 for (cur = start; *cur && *cur != '"'; cur++) |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
435 { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
436 if (is_escape) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
437 switch (*cur) |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
438 { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
439 case 't': |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
440 case 'n': |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
441 case 'r': |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
442 case '\\': |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
443 break; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
444 default: |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
445 fprintf(stderr, "Unsupported escape character %c\n", *cur); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
446 return NULL; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
447 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
448 is_escape = 0; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
449 } else if (*cur == '\\') { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
450 is_escape = 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
451 continue; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
452 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
453 length++; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
454 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
455 if (!*cur) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
456 fprintf(stderr, "Unterminated string literal: %s\n", start); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
457 return NULL; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
458 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
459 *end = cur + 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
460 char *ret = calloc(1, length + 1); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
461 char *dst = ret; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
462 is_escape = 0; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
463 for (cur = start; *cur != '"'; ++cur) |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
464 { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
465 if (is_escape) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
466 switch (*cur) |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
467 { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
468 case 't': |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
469 *(dst++) = '\t'; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
470 break; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
471 case 'n': |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
472 *(dst++) = '\n'; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
473 break; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
474 case 'r': |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
475 *(dst++) = '\r'; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
476 break; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
477 case '\\': |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
478 *(dst++) = '\\'; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
479 break; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
480 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
481 is_escape = 0; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
482 } else if (*cur == '\\') { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
483 is_escape = 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
484 continue; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
485 } else { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
486 *(dst++) = *cur; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
487 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
488 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
489 *dst = 0; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
490 return ret; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
491 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
492 |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
493 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
|
494 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
495 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
|
496 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
497 ++start; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
498 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
499 if (!*start || *start == '\n' || *start == '\r') { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
500 *end = start; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
501 return (token){ |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
502 .type = TOKEN_NONE |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
503 }; |
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 if (*start == '$' || (*start == '0' && start[1] == 'x')) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
506 return (token) { |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
507 .type = TOKEN_INT, |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
508 .v = { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
509 .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
|
510 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
511 }; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
512 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
513 if (*start == '"') { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
514 char *str = parse_string_literal(start + 1, end); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
515 if (!str) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
516 *end = start; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
517 return (token){ |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
518 .type = TOKEN_NONE |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
519 }; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
520 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
521 return (token){ |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
522 .type = TOKEN_STRING, |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
523 .v = { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
524 .str = str |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
525 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
526 }; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
527 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
528 if (isdigit(*start)) { |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
529 uint32_t ipart = strtol(start, end, 10); |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
530 if (**end == '.') { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
531 start = *end + 1; |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
532 uint32_t fpart = strtol(start, end, 10); |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
533 float fval; |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
534 if (fpart) { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
535 float divisor = powf(10.0f, *end - start); |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
536 fval = ipart + fpart / divisor; |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
537 } else { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
538 fval = ipart; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
539 } |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
540 return (token) { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
541 .type = TOKEN_DECIMAL, |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
542 .v = { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
543 .f = fval |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
544 } |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
545 }; |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
546 } else { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
547 return (token) { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
548 .type = TOKEN_INT, |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
549 .v = { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
550 .num = ipart |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
551 } |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
552 }; |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
553 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
554 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
555 switch (*start) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
556 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
557 case '+': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
558 case '-': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
559 case '*': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
560 case '/': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
561 case '&': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
562 case '|': |
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 '!': |
2191
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
567 case '>': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
568 case '<': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
569 if ((*start == '!' || *start == '>' || *start == '<') && start[1] == '=') { |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
570 *end = start + 2; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
571 return (token) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
572 .type = TOKEN_OPER, |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
573 .v = { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
574 .op = {*start, start[1], 0} |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
575 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
576 }; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
577 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
578 *end = start + 1; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
579 return (token) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
580 .type = TOKEN_OPER, |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
581 .v = { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
582 .op = {*start, 0} |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
583 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
584 }; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
585 case '.': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
586 *end = start + 2; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
587 return (token) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
588 .type = TOKEN_SIZE, |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
589 .v = { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
590 .op = {start[1], 0} |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
591 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
592 }; |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
593 case '[': |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
594 *end = start + 1; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
595 return (token) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
596 .type = TOKEN_LBRACKET |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
597 }; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
598 case ']': |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
599 *end = start + 1; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
600 return (token) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
601 .type = TOKEN_RBRACKET |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
602 }; |
2171
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
603 case '(': |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
604 *end = start + 1; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
605 return (token) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
606 .type = TOKEN_LPAREN |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
607 }; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
608 case ')': |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
609 *end = start + 1; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
610 return (token) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
611 .type = TOKEN_RPAREN |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
612 }; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
613 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
614 *end = start + 1; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
615 token_type type = TOKEN_NAME; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
616 while (**end && !isspace(**end)) |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
617 { |
2172
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
618 uint8_t done = 0; |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
619 switch (**end) |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
620 { |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
621 case '[': |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
622 type = TOKEN_ARRAY; |
2364
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
623 done = 1; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
624 break; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
625 case '(': |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
626 type = TOKEN_FUNCALL; |
2172
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
627 case '+': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
628 case '-': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
629 case '*': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
630 case '/': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
631 case '&': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
632 case '|': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
633 case '^': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
634 case '~': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
635 case '=': |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
636 case '!': |
2191
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
637 case '>': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
638 case '<': |
2172
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
639 case '.': |
2357
344c6a3fe8a8
Fix annoying bug in debugger tokenizer
Michael Pavone <pavone@retrodev.com>
parents:
2302
diff
changeset
|
640 case ']': |
344c6a3fe8a8
Fix annoying bug in debugger tokenizer
Michael Pavone <pavone@retrodev.com>
parents:
2302
diff
changeset
|
641 case ')': |
2172
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
642 done = 1; |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
643 break; |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
644 } |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
645 if (done) { |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
646 break; |
a00773a336d8
Fix bug in debugger lexer
Michael Pavone <pavone@retrodev.com>
parents:
2171
diff
changeset
|
647 } |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
648 |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
649 ++*end; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
650 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
651 char *name = malloc(*end - start + 1); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
652 memcpy(name, start, *end - start); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
653 name[*end-start] = 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
654 return (token) { |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
655 .type = type, |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
656 .v = { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
657 .str = name |
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 }; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
660 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
661 |
2364
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
662 static void free_expr(expr *e); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
663 static void free_expr_int(expr *e) |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
664 { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
665 free_expr(e->left); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
666 if (e->type == EXPR_FUNCALL) { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
667 for (uint32_t i = 0; i < e->op.v.num; i++) |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
668 { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
669 free_expr_int(e->right + i); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
670 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
671 free(e->right); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
672 } else { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
673 free_expr(e->right); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
674 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
675 if (e->op.type == TOKEN_NAME || e->op.type == TOKEN_ARRAY || e->op.type == TOKEN_STRING) { |
2364
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
676 free(e->op.v.str); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
677 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
678 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
679 |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
680 static void free_expr(expr *e) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
681 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
682 if (!e) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
683 return; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
684 } |
2364
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
685 free_expr_int(e); |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
686 free(e); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
687 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
688 |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
689 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
|
690 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
|
691 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
692 static void handle_namespace(expr *e) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
693 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
694 if (e->op.type != TOKEN_NAME && e->op.type != TOKEN_ARRAY) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
695 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
696 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
697 char *start = e->op.v.str; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
698 char *orig_start = start; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
699 for (char *cur = start; *cur; ++cur) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
700 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
701 if (*cur == ':') { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
702 char *ns = malloc(cur - start + 1); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
703 memcpy(ns, start, cur - start); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
704 ns[cur - start] = 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
705 expr *inner = calloc(1, sizeof(expr)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
706 inner->type = EXPR_SCALAR; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
707 inner->op.type = TOKEN_NAME; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
708 start = cur + 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
709 inner->op.v.str = start; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
710 e->left = inner; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
711 e->type = EXPR_NAMESPACE; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
712 e->op.v.str = ns; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
713 e = inner; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
714 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
715 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
716 if (start != orig_start) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
717 //We've split the original string up into |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
718 //a bunch of individually allocated fragments |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
719 //this is just a little stup of the original |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
720 e->op.v.str = strdup(e->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
721 free(orig_start); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
722 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
723 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
724 |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
725 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
|
726 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
727 char *after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
728 token first = parse_token(start, &after_first); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
729 if (!first.type) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
730 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
731 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
732 if (first.type == TOKEN_SIZE) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
733 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
|
734 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
735 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
736 if (first.type == TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
737 expr *target = parse_scalar(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
738 if (!target) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
739 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
|
740 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
741 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
742 expr *ret = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
743 ret->type = EXPR_UNARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
744 ret->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
745 ret->left = target; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
746 *end = after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
747 return ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
748 } |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
749 if (first.type == TOKEN_LBRACKET || first.type == TOKEN_ARRAY) { |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
750 expr *ret = calloc(1, sizeof(expr)); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
751 ret->type = EXPR_MEM; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
752 if (first.type == TOKEN_ARRAY) { |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
753 //current token is the array name |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
754 //consume the bracket token |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
755 parse_token(after_first, &after_first); |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
756 ret->right = calloc(1, sizeof(expr)); |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
757 ret->right->type = EXPR_SCALAR; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
758 ret->right->op = first; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
759 handle_namespace(ret->right); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
760 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
761 |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
762 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
|
763 if (!ret->left) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
764 fprintf(stderr, "Expression expected after `[`\n"); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
765 free(ret); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
766 return NULL; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
767 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
768 token rbrack = parse_token(*end, end); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
769 if (rbrack.type != TOKEN_RBRACKET) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
770 fprintf(stderr, "Missing closing `]`"); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
771 free_expr(ret); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
772 return NULL; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
773 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
774 char *after_size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
775 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
|
776 if (size.type == TOKEN_SIZE) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
777 *end = after_size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
778 ret->op = size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
779 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
780 return ret; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
781 } |
2171
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
782 if (first.type == TOKEN_LPAREN) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
783 expr *ret = parse_expression(after_first, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
784 if (!ret) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
785 fprintf(stderr, "Expression expected after `(`\n"); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
786 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
787 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
788 token rparen = parse_token(*end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
789 if (rparen.type != TOKEN_RPAREN) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
790 fprintf(stderr, "Missing closing `)`"); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
791 free_expr(ret); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
792 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
793 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
794 return ret; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
795 } |
2364
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
796 if (first.type == TOKEN_FUNCALL) { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
797 expr *ret = calloc(1, sizeof(expr)); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
798 ret->left = calloc(1, sizeof(expr)); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
799 ret->left->type = EXPR_SCALAR; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
800 ret->left->op = first; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
801 ret->left->op.type = TOKEN_NAME; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
802 uint32_t storage = 0; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
803 ret->op.v.num = 0; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
804 token next = parse_token(after_first, end); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
805 while (next.type != TOKEN_RPAREN && next.type != TOKEN_NONE) |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
806 { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
807 expr *e = parse_expression(after_first, end); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
808 if (!e) { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
809 fprintf(stderr, "Expression expected after '('\n"); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
810 free_expr(ret); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
811 return NULL; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
812 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
813 if (storage == ret->op.v.num) { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
814 storage = storage ? storage * 2 : 1; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
815 ret->right = realloc(ret->right, storage * sizeof(expr)); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
816 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
817 ret->right[ret->op.v.num++] = *e; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
818 free(e); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
819 after_first = *end; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
820 next = parse_token(after_first, end); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
821 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
822 if (next.type != TOKEN_RPAREN) { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
823 fprintf(stderr, "Missing ')' after '('\n"); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
824 free_expr(ret); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
825 return NULL; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
826 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
827 return ret; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
828 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
829 if (first.type != TOKEN_INT && first.type != TOKEN_DECIMAL && first.type != TOKEN_NAME && first.type != TOKEN_STRING) { |
2171
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
830 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
|
831 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
832 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
833 token second = parse_token(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
834 if (second.type != TOKEN_SIZE) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
835 expr *ret = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
836 ret->type = EXPR_SCALAR; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
837 ret->op = first; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
838 handle_namespace(ret); |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
839 *end = after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
840 return ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
841 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
842 expr *ret = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
843 ret->type = EXPR_SIZE; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
844 ret->left = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
845 ret->left->type = EXPR_SCALAR; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
846 ret->left->op = second; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
847 handle_namespace(ret->left); |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
848 ret->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
849 return ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
850 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
851 |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
852 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
|
853 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
854 char *after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
855 token first = parse_token(start, &after_first); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
856 if (first.type != TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
857 *end = start; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
858 return left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
859 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
860 expr *bin = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
861 bin->left = left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
862 bin->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
863 bin->type = EXPR_BINARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
864 switch (first.v.op[0]) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
865 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
866 case '*': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
867 case '/': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
868 case '&': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
869 case '|': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
870 case '^': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
871 bin->right = parse_scalar(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
872 return maybe_binary(bin, *end, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
873 case '+': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
874 case '-': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
875 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
|
876 return maybe_binary(bin, *end, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
877 case '=': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
878 case '!': |
2191
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
879 case '>': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
880 case '<': |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
881 bin->right = parse_expression(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
882 return bin; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
883 default: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
884 bin->left = NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
885 free(bin); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
886 return left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
887 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
888 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
889 |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
890 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
|
891 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
892 char *after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
893 token first = parse_token(start, &after_first); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
894 if (first.type != TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
895 *end = start; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
896 return left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
897 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
898 expr *bin = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
899 bin->left = left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
900 bin->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
901 bin->type = EXPR_BINARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
902 switch (first.v.op[0]) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
903 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
904 case '*': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
905 case '/': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
906 case '&': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
907 case '|': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
908 case '^': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
909 bin->right = parse_scalar(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
910 return maybe_binary(bin, *end, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
911 default: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
912 bin->left = NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
913 free(bin); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
914 return left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
915 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
916 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
917 |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
918 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
|
919 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
920 char *after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
921 token first = parse_token(start, &after_first); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
922 if (!first.type) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
923 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
924 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
925 if (first.type == TOKEN_SIZE) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
926 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
|
927 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
928 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
929 if (first.type == TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
930 expr *target = parse_scalar(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
931 if (!target) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
932 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
|
933 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
934 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
935 expr *ret = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
936 ret->type = EXPR_UNARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
937 ret->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
938 ret->left = target; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
939 return ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
940 } |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
941 if (first.type == TOKEN_LBRACKET || first.type == TOKEN_ARRAY) { |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
942 expr *ret = calloc(1, sizeof(expr)); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
943 ret->type = EXPR_MEM; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
944 if (first.type == TOKEN_ARRAY) { |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
945 //current token is the array name |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
946 //consume the bracket token |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
947 parse_token(after_first, &after_first); |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
948 ret->right = calloc(1, sizeof(expr)); |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
949 ret->right->type = EXPR_SCALAR; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
950 ret->right->op = first; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
951 handle_namespace(ret->right); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
952 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
953 |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
954 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
|
955 if (!ret->left) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
956 fprintf(stderr, "Expression expected after `[`\n"); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
957 free(ret); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
958 return NULL; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
959 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
960 token rbrack = parse_token(*end, end); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
961 if (rbrack.type != TOKEN_RBRACKET) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
962 fprintf(stderr, "Missing closing `]`"); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
963 free_expr(ret); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
964 return NULL; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
965 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
966 char *after_size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
967 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
|
968 if (size.type == TOKEN_SIZE) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
969 *end = after_size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
970 ret->op = size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
971 } |
2171
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
972 return maybe_muldiv(ret, *end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
973 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
974 if (first.type == TOKEN_LPAREN) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
975 expr *ret = parse_expression(after_first, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
976 if (!ret) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
977 fprintf(stderr, "Expression expected after `(`\n"); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
978 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
979 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
980 token rparen = parse_token(*end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
981 if (rparen.type != TOKEN_RPAREN) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
982 fprintf(stderr, "Missing closing `)`"); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
983 free_expr(ret); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
984 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
985 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
986 return maybe_muldiv(ret, *end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
987 } |
2364
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
988 if (first.type == TOKEN_FUNCALL) { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
989 expr *ret = calloc(1, sizeof(expr)); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
990 ret->left = calloc(1, sizeof(expr)); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
991 ret->left->type = EXPR_SCALAR; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
992 ret->left->op = first; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
993 ret->left->op.type = TOKEN_NAME; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
994 uint32_t storage = 0; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
995 ret->op.v.num = 0; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
996 token next = parse_token(after_first, end); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
997 while (next.type != TOKEN_RPAREN && next.type != TOKEN_NONE) |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
998 { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
999 expr *e = parse_expression(after_first, end); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1000 if (!e) { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1001 fprintf(stderr, "Expression expected after '('\n"); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1002 free_expr(ret); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1003 return NULL; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1004 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1005 if (storage == ret->op.v.num) { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1006 storage = storage ? storage * 2 : 1; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1007 ret->right = realloc(ret->right, storage * sizeof(expr)); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1008 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1009 ret->right[ret->op.v.num++] = *e; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1010 free(e); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1011 after_first = *end; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1012 next = parse_token(after_first, end); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1013 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1014 if (next.type != TOKEN_RPAREN) { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1015 fprintf(stderr, "Missing ')' after '('\n"); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1016 free_expr(ret); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1017 return NULL; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1018 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1019 return maybe_muldiv(ret, *end, end); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1020 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
1021 if (first.type != TOKEN_INT && first.type != TOKEN_DECIMAL && first.type != TOKEN_NAME && first.type != TOKEN_STRING) { |
2171
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1022 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
|
1023 return NULL; |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1024 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1025 char *after_second; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1026 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
|
1027 if (second.type == TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1028 expr *ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1029 expr *bin = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1030 bin->type = EXPR_BINARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1031 bin->left = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1032 bin->left->type = EXPR_SCALAR; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1033 bin->left->op = first; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1034 handle_namespace(bin->left); |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1035 bin->op = second; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1036 switch (second.v.op[0]) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1037 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1038 case '*': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1039 case '/': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1040 case '&': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1041 case '|': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1042 case '^': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1043 bin->right = parse_scalar(after_second, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1044 return maybe_muldiv(bin, *end, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1045 case '+': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1046 case '-': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1047 case '=': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1048 case '!': |
2191
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
1049 case '>': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
1050 case '<': |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1051 ret = bin->left; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1052 bin->left = NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1053 free_expr(bin); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1054 return ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1055 default: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1056 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
|
1057 free(bin->left); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1058 free(bin); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1059 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1060 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1061 } else if (second.type == TOKEN_SIZE) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1062 expr *value = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1063 value->type = EXPR_SIZE; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1064 value->op = second; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1065 value->left = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1066 value->left->type = EXPR_SCALAR; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1067 value->left->op = first; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1068 handle_namespace(value->left); |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1069 return maybe_muldiv(value, after_second, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1070 } else { |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1071 expr *ret = calloc(1, sizeof(expr)); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1072 ret->type = EXPR_SCALAR; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1073 ret->op = first; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1074 handle_namespace(ret); |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1075 *end = after_first; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1076 return ret; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1077 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1078 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1079 |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1080 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
|
1081 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1082 char *after_first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1083 token first = parse_token(start, &after_first); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1084 if (!first.type) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1085 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1086 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1087 if (first.type == TOKEN_SIZE) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1088 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
|
1089 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1090 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1091 if (first.type == TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1092 expr *target = parse_scalar(after_first, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1093 if (!target) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1094 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
|
1095 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1096 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1097 expr *ret = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1098 ret->type = EXPR_UNARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1099 ret->op = first; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1100 ret->left = target; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1101 return ret; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1102 } |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1103 if (first.type == TOKEN_LBRACKET || first.type == TOKEN_ARRAY) { |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1104 expr *ret = calloc(1, sizeof(expr)); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1105 ret->type = EXPR_MEM; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1106 if (first.type == TOKEN_ARRAY) { |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1107 //current token is the array name |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1108 //consume the bracket token |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1109 parse_token(after_first, &after_first); |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1110 ret->right = calloc(1, sizeof(expr)); |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1111 ret->right->type = EXPR_SCALAR; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1112 ret->right->op = first; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1113 handle_namespace(ret->right); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1114 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1115 |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1116 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
|
1117 if (!ret->left) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1118 fprintf(stderr, "Expression expected after `[`\n"); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1119 free(ret); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1120 return NULL; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1121 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1122 token rbrack = parse_token(*end, end); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1123 if (rbrack.type != TOKEN_RBRACKET) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1124 fprintf(stderr, "Missing closing `]`"); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1125 free_expr(ret); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1126 return NULL; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1127 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1128 char *after_size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1129 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
|
1130 if (size.type == TOKEN_SIZE) { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1131 *end = after_size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1132 ret->op = size; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1133 } |
2171
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1134 return maybe_binary(ret, *end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1135 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1136 if (first.type == TOKEN_LPAREN) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1137 expr *ret = parse_expression(after_first, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1138 if (!ret) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1139 fprintf(stderr, "Expression expected after `(`\n"); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1140 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1141 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1142 token rparen = parse_token(*end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1143 if (rparen.type != TOKEN_RPAREN) { |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1144 fprintf(stderr, "Missing closing `)`"); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1145 free_expr(ret); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1146 return NULL; |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1147 } |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1148 return maybe_binary(ret, *end, end); |
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1149 } |
2364
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1150 if (first.type == TOKEN_FUNCALL) { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1151 expr *ret = calloc(1, sizeof(expr)); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1152 ret->type = EXPR_FUNCALL; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1153 ret->left = calloc(1, sizeof(expr)); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1154 ret->left->type = EXPR_SCALAR; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1155 ret->left->op = first; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1156 ret->left->op.type = TOKEN_NAME; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1157 uint32_t storage = 0; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1158 ret->op.v.num = 0; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1159 //consume LPAREN |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1160 parse_token(after_first, end); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1161 after_first = *end; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1162 token next = parse_token(after_first, end); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1163 while (next.type != TOKEN_RPAREN && next.type != TOKEN_NONE) |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1164 { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1165 expr *e = parse_expression(after_first, end); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1166 if (!e) { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1167 fprintf(stderr, "Expression expected after '('\n"); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1168 free_expr(ret); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1169 return NULL; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1170 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1171 if (storage == ret->op.v.num) { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1172 storage = storage ? storage * 2 : 1; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1173 ret->right = realloc(ret->right, storage * sizeof(expr)); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1174 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1175 ret->right[ret->op.v.num++] = *e; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1176 free(e); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1177 after_first = *end; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1178 next = parse_token(after_first, end); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1179 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1180 if (next.type != TOKEN_RPAREN) { |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1181 fprintf(stderr, "Missing ')' after '('\n"); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1182 free_expr(ret); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1183 return NULL; |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1184 } |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1185 return maybe_binary(ret, *end, end); |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
1186 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
1187 if (first.type != TOKEN_INT && first.type != TOKEN_DECIMAL && first.type != TOKEN_NAME && first.type != TOKEN_STRING) { |
2171
4b47155965c8
Implement parentheses in debugger parser
Michael Pavone <pavone@retrodev.com>
parents:
2170
diff
changeset
|
1188 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
|
1189 return NULL; |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1190 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1191 char *after_second; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1192 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
|
1193 if (second.type == TOKEN_OPER) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1194 expr *bin = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1195 bin->type = EXPR_BINARY; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1196 bin->left = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1197 bin->left->type = EXPR_SCALAR; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1198 bin->left->op = first; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1199 handle_namespace(bin->left); |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1200 bin->op = second; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1201 switch (second.v.op[0]) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1202 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1203 case '*': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1204 case '/': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1205 case '&': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1206 case '|': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1207 case '^': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1208 bin->right = parse_scalar(after_second, end); |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
1209 if (!bin->right) { |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
1210 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
|
1211 free_expr(bin); |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
1212 return NULL; |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
1213 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1214 return maybe_binary(bin, *end, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1215 case '+': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1216 case '-': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1217 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
|
1218 if (!bin->right) { |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
1219 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
|
1220 free_expr(bin); |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
1221 return NULL; |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
1222 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1223 return maybe_binary(bin, *end, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1224 case '=': |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1225 case '!': |
2191
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
1226 case '>': |
d87a76afbd8a
Add '>', '<', '>=' and '<=' operators to debugger expression engine
Michael Pavone <pavone@retrodev.com>
parents:
2190
diff
changeset
|
1227 case '<': |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1228 bin->right = parse_expression(after_second, end); |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
1229 if (!bin->right) { |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
1230 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
|
1231 free_expr(bin); |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
1232 return NULL; |
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
1233 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1234 return bin; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1235 default: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1236 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
|
1237 free(bin->left); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1238 free(bin); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1239 return NULL; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1240 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1241 } else if (second.type == TOKEN_SIZE) { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1242 expr *value = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1243 value->type = EXPR_SIZE; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1244 value->op = second; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1245 value->left = calloc(1, sizeof(expr)); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1246 value->left->type = EXPR_SCALAR; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1247 value->left->op = first; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1248 handle_namespace(value->left); |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1249 return maybe_binary(value, after_second, end); |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1250 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1251 if (second.type == TOKEN_NAME) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1252 free(second.v.str); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1253 } |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1254 expr *ret = calloc(1, sizeof(expr)); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1255 ret->type = EXPR_SCALAR; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1256 ret->op = first; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1257 handle_namespace(ret); |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1258 *end = after_first; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1259 return ret; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1260 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1261 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1262 |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1263 static uint8_t execute_block(debug_root *root, command_block * block); |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1264 uint8_t eval_expr(debug_root *root, expr *e, debug_val *out) |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1265 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1266 debug_val right; |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1267 debug_val *args; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1268 debug_func *func; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1269 int num_args; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1270 switch(e->type) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1271 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1272 case EXPR_SCALAR: |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1273 if (e->op.type == TOKEN_NAME || e->op.type == TOKEN_ARRAY) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1274 debug_var *var = tern_find_ptr(root->variables, e->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1275 if (!var) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1276 return 0; |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
1277 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1278 *out = var->get(var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1279 return 1; |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
1280 } else if (e->op.type == TOKEN_INT) { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
1281 *out = debug_int(e->op.v.num); |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
1282 return 1; |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
1283 } else if (e->op.type == TOKEN_DECIMAL){ |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
1284 *out = debug_float(e->op.v.f); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
1285 return 1; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1286 } else { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
1287 *out = new_debug_string(e->op.v.str); |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1288 return 1; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1289 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1290 case EXPR_UNARY: |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
1291 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
|
1292 return 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1293 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1294 switch (e->op.v.op[0]) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1295 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1296 case '!': |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1297 if (out->type != DBG_VAL_U32) { fprintf(stderr, "operator ! is only defined for integers"); return 0; } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1298 out->v.u32 = !out->v.u32; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1299 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1300 case '~': |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1301 if (out->type != DBG_VAL_U32) { fprintf(stderr, "operator ~ is only defined for integers"); return 0; } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1302 out->v.u32 = ~out->v.u32; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1303 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1304 case '-': |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1305 if (out->type == DBG_VAL_U32) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1306 out->v.u32 = -out->v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1307 } else if (out->type == DBG_VAL_F32) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1308 out->v.f32 = -out->v.f32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1309 } else { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1310 fprintf(stderr, "operator ~ is only defined for integers and floats"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1311 return 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1312 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1313 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1314 default: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1315 return 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1316 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1317 return 1; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1318 case EXPR_BINARY: |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
1319 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
|
1320 return 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1321 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1322 if (out->type != right.type) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1323 if (out->type == DBG_VAL_F32) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1324 if (right.type == DBG_VAL_U32) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1325 right.type = DBG_VAL_F32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1326 float v = right.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1327 right.v.f32 = v; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1328 } else { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1329 fprintf(stderr, "Invalid type on right side of binary operator\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1330 return 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1331 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1332 } else if (out->type == DBG_VAL_U32) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1333 if (right.type == DBG_VAL_F32) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1334 out->type = DBG_VAL_F32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1335 float v = out->v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1336 out->v.f32 = v; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1337 } else { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1338 fprintf(stderr, "Invalid type on right side of binary operator\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1339 return 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1340 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1341 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1342 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1343 if (out->type == DBG_VAL_U32) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1344 switch (e->op.v.op[0]) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1345 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1346 case '+': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1347 out->v.u32 += right.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1348 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1349 case '-': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1350 out->v.u32 -= right.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1351 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1352 case '*': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1353 out->v.u32 *= right.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1354 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1355 case '/': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1356 out->v.u32 /= right.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1357 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1358 case '&': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1359 out->v.u32 &= right.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1360 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1361 case '|': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1362 out->v.u32 |= right.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1363 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1364 case '^': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1365 out->v.u32 ^= right.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1366 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1367 case '=': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1368 out->v.u32 = out->v.u32 == right.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1369 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1370 case '!': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1371 out->v.u32 = out->v.u32 != right.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1372 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1373 case '>': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1374 out->v.u32 = e->op.v.op[1] ? out->v.u32 >= right.v.u32 : out->v.u32 > right.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1375 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1376 case '<': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1377 out->v.u32 = e->op.v.op[1] ? out->v.u32 <= right.v.u32 : out->v.u32 < right.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1378 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1379 default: |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1380 return 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1381 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1382 } else if (out->type == DBG_VAL_F32) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1383 switch (e->op.v.op[0]) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1384 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1385 case '+': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1386 out->v.f32 += right.v.f32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1387 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1388 case '-': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1389 out->v.f32 -= right.v.f32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1390 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1391 case '*': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1392 out->v.f32 *= right.v.f32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1393 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1394 case '/': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1395 out->v.f32 /= right.v.f32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1396 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1397 case '=': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1398 out->v.u32 = out->v.f32 == right.v.f32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1399 out->type = DBG_VAL_U32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1400 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1401 case '!': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1402 out->v.u32 = out->v.f32 != right.v.f32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1403 out->type = DBG_VAL_U32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1404 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1405 case '>': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1406 out->v.u32 = e->op.v.op[1] ? out->v.f32 >= right.v.f32 : out->v.f32 > right.v.f32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1407 out->type = DBG_VAL_U32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1408 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1409 case '<': |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1410 out->v.u32 = e->op.v.op[1] ? out->v.f32 <= right.v.f32 : out->v.f32 < right.v.f32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1411 out->type = DBG_VAL_U32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1412 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1413 default: |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1414 return 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1415 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1416 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1417 return 1; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1418 case EXPR_SIZE: |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
1419 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
|
1420 return 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1421 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1422 if (out->type != DBG_VAL_U32) { fprintf(stderr, "Size expressions are only defined for integers"); return 0; } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1423 switch (e->op.v.op[0]) |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1424 { |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1425 case 'b': |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1426 out->v.u32 &= 0xFF; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1427 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1428 case 'w': |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1429 out->v.u32 &= 0xFFFF; |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1430 break; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1431 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1432 return 1; |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1433 case EXPR_MEM: |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
1434 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
|
1435 return 0; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1436 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1437 if (out->type != DBG_VAL_U32) { fprintf(stderr, "Array index must be integer"); return 0; } |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1438 if (e->right) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1439 if (!eval_expr(root, e->right, &right)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1440 return 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1441 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1442 debug_array *array = get_array(right); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1443 if (!array) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1444 fprintf(stderr, "Attempt to index into value that is not an array"); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1445 return 0; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1446 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1447 if (out->v.u32 >= array->size) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1448 return 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1449 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1450 *out = array->get(array, out->v.u32); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1451 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1452 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1453 return root->read_mem(root, &out->v.u32, e->op.v.op[0]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1454 case EXPR_NAMESPACE: |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1455 root = tern_find_ptr(root->other_roots, e->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1456 if (!root) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1457 fprintf(stderr, "%s is not a valid namespace\n", e->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1458 return 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1459 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1460 return eval_expr(root, e->left, out); |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1461 case EXPR_FUNCALL: |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1462 if (!eval_expr(root, e->left, out)) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1463 return 0; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1464 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1465 if (out->type != DBG_VAL_FUNC) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1466 fprintf(stderr, "Funcall expression requires function"); |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1467 return 0; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1468 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1469 func = funcs + out->v.u32; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1470 num_args = e->op.v.num; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1471 if (func->min_args > 0 && num_args < func->min_args) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1472 fprintf(stderr, "Function requires at least %d args, but %d given\n", func->min_args, num_args); |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1473 return 0; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1474 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1475 if (func->max_args >= 0 && num_args > func->max_args) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1476 fprintf(stderr, "Function requires no more than %d args, but %d given\n", func->max_args, num_args); |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1477 return 0; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1478 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1479 args = calloc(num_args, sizeof(debug_val)); |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1480 for (int i = 0; i < num_args; i++) |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1481 { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1482 if (!eval_expr(root, e->right + i, args + i)) { |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1483 free(args); |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1484 return 0; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1485 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1486 } |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1487 if (func->is_native) { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1488 *out = func->impl.native(args, num_args); |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1489 free(args); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1490 return 1; |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1491 } else { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1492 //TODO: Implement me |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1493 debug_root *func_root = calloc(1, sizeof(debug_root)); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1494 for (int i = 0; i < num_args; i++) |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1495 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1496 new_user_variable(func_root, func->arg_names[i], args[i]); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1497 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1498 free(args); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1499 func_root->other_roots = tern_insert_ptr(func_root->other_roots, "parent", root); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1500 execute_block(func_root, &func->impl.block); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1501 *out = func_root->retval; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1502 //FIXME: properly free root |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1503 tern_free(func_root->variables); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1504 tern_free(func_root->other_roots); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1505 free(func_root); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
1506 return 1; |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
1507 } |
2169
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1508 default: |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1509 return 0; |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1510 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1511 } |
cb9572145f8e
WIP support for expression parsing in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2133
diff
changeset
|
1512 |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1513 char * find_param(char * buf) |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1514 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1515 for (; *buf; buf++) { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1516 if (*buf == ' ') { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1517 if (*(buf+1)) { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1518 return buf+1; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1519 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1520 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1521 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1522 return NULL; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1523 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1524 |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1525 void strip_nl(char * buf) |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1526 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1527 for(; *buf; buf++) { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1528 if (*buf == '\n') { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1529 *buf = 0; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1530 return; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1531 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1532 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1533 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1534 |
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
|
1535 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
|
1536 { |
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
|
1537 //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
|
1538 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
|
1539 } |
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
|
1540 |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1541 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
|
1542 { |
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
|
1543 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
|
1544 } |
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
|
1545 |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1546 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
|
1547 { |
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
|
1548 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
|
1549 } |
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
|
1550 |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
1551 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
|
1552 { |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2174
diff
changeset
|
1553 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
|
1554 if (size == 'b') { |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1555 *out = m68k_read_byte(*out, context); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1556 } else if (size == 'l') { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1557 if (*out & 1) { |
2386
9f178feb3cb0
Prefix most hex-formatted values output by debugger with $ for consistency with number literal parsing
Michael Pavone <pavone@retrodev.com>
parents:
2380
diff
changeset
|
1558 fprintf(stderr, "Longword access to odd addresses ($%X) is not allowed\n", *out); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1559 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1560 } |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1561 *out = m68k_read_long(*out, context); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1562 } else { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1563 if (*out & 1) { |
2386
9f178feb3cb0
Prefix most hex-formatted values output by debugger with $ for consistency with number literal parsing
Michael Pavone <pavone@retrodev.com>
parents:
2380
diff
changeset
|
1564 fprintf(stderr, "Wword access to odd addresses ($%X) is not allowed\n", *out); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1565 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1566 } |
2170
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1567 *out = m68k_read_word(*out, context); |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1568 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1569 return 1; |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1570 } |
ada3130b1396
Add memory indirection syntax to debugger parser/evaluator
Michael Pavone <pavone@retrodev.com>
parents:
2169
diff
changeset
|
1571 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1572 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
|
1573 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1574 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1575 if (size == 'b') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1576 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
|
1577 } else if (size == 'l') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1578 if (address & 1) { |
2386
9f178feb3cb0
Prefix most hex-formatted values output by debugger with $ for consistency with number literal parsing
Michael Pavone <pavone@retrodev.com>
parents:
2380
diff
changeset
|
1579 fprintf(stderr, "Longword access to odd addresses ($%X) is not allowed\n", address); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1580 return 0; |
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 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
|
1583 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
|
1584 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1585 if (address & 1) { |
2386
9f178feb3cb0
Prefix most hex-formatted values output by debugger with $ for consistency with number literal parsing
Michael Pavone <pavone@retrodev.com>
parents:
2380
diff
changeset
|
1586 fprintf(stderr, "Wword access to odd addresses ($%X) is not allowed\n", address); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1587 return 0; |
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 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
|
1590 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1591 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1592 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
1593 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1594 static debug_val m68k_dreg_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1595 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1596 m68k_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1597 return debug_int(context->dregs[var->val.v.u32]); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1598 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1599 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1600 static void m68k_dreg_set(debug_var *var, debug_val val) |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1601 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1602 m68k_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1603 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1604 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1605 fprintf(stderr, "M68K register d%d can only be set to an integer\n", var->val.v.u32); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1606 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1607 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1608 context->dregs[var->val.v.u32] = ival; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1609 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1610 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1611 static debug_val m68k_areg_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1612 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1613 m68k_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1614 return debug_int(context->aregs[var->val.v.u32]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1615 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1616 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1617 static void m68k_areg_set(debug_var *var, debug_val val) |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1618 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1619 m68k_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1620 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1621 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1622 fprintf(stderr, "M68K register a%d can only be set to an integer\n", var->val.v.u32); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1623 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1624 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1625 context->aregs[var->val.v.u32] = ival; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1626 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1627 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1628 static debug_val m68k_sr_get(debug_var *var) |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1629 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1630 m68k_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1631 debug_val ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1632 ret.v.u32 = context->status << 8; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1633 for (int flag = 0; flag < 5; flag++) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1634 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1635 ret.v.u32 |= context->flags[flag] << (4-flag); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1636 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1637 ret.type = DBG_VAL_U32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1638 return ret; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1639 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1640 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1641 static void m68k_sr_set(debug_var *var, debug_val val) |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1642 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1643 m68k_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1644 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1645 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1646 fprintf(stderr, "M68K register sr can only be set to an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1647 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1648 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1649 context->status = ival >> 8; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1650 for (int flag = 0; flag < 5; flag++) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1651 context->flags[flag] = (ival & (1 << (4 - flag))) != 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1652 } |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1653 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1654 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1655 static debug_val m68k_cycle_get(debug_var *var) |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1656 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1657 m68k_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1658 return debug_int(context->current_cycle); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1659 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1660 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1661 static debug_val m68k_usp_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1662 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1663 m68k_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1664 return debug_int(context->status & 0x20 ? context->aregs[8] : context->aregs[7]); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1665 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1666 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1667 static void m68k_usp_set(debug_var *var, debug_val val) |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1668 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1669 m68k_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1670 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1671 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1672 fprintf(stderr, "M68K register usp can only be set to an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1673 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1674 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1675 context->aregs[context->status & 0x20 ? 8 : 7] = ival; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1676 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1677 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1678 static debug_val m68k_ssp_get(debug_var *var) |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1679 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1680 m68k_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1681 return debug_int(context->status & 0x20 ? context->aregs[7] : context->aregs[8]); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1682 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1683 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1684 static void m68k_ssp_set(debug_var *var, debug_val val) |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1685 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1686 m68k_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1687 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1688 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1689 fprintf(stderr, "M68K register ssp can only be set to an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1690 return; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1691 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1692 context->aregs[context->status & 0x20 ? 7 : 8] = ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1693 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1694 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1695 static debug_val root_address_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1696 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1697 debug_root *root = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1698 return debug_int(root->address); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1699 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1700 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1701 static void m68k_names(debug_root *root) |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1702 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1703 debug_var *var; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1704 for (char i = 0; i < 8; i++) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1705 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1706 char rname[3] = {'d', '0' + i, 0}; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1707 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1708 var->get = m68k_dreg_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1709 var->set = m68k_dreg_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1710 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1711 var->val.v.u32 = i; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1712 root->variables = tern_insert_ptr(root->variables, rname, var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1713 rname[0] = 'D'; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1714 root->variables = tern_insert_ptr(root->variables, rname, var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1715 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1716 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1717 var->get = m68k_areg_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1718 var->set = m68k_areg_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1719 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1720 var->val.v.u32 = i; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1721 rname[0] = 'a'; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1722 root->variables = tern_insert_ptr(root->variables, rname, var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1723 rname[0] = 'A'; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1724 root->variables = tern_insert_ptr(root->variables, rname, var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1725 if (i == 7) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1726 root->variables = tern_insert_ptr(root->variables, "sp", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1727 root->variables = tern_insert_ptr(root->variables, "SP", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1728 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1729 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1730 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1731 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1732 var->get = m68k_sr_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1733 var->set = m68k_sr_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1734 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1735 root->variables = tern_insert_ptr(root->variables, "sr", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1736 root->variables = tern_insert_ptr(root->variables, "SR", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1737 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1738 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1739 var->get = root_address_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1740 var->ptr = root; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1741 root->variables = tern_insert_ptr(root->variables, "pc", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1742 root->variables = tern_insert_ptr(root->variables, "PC", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1743 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1744 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1745 var->get = m68k_usp_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1746 var->set = m68k_usp_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1747 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1748 root->variables = tern_insert_ptr(root->variables, "usp", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1749 root->variables = tern_insert_ptr(root->variables, "USP", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1750 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1751 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1752 var->get = m68k_ssp_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1753 var->set = m68k_ssp_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1754 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1755 root->variables = tern_insert_ptr(root->variables, "ssp", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1756 root->variables = tern_insert_ptr(root->variables, "SSP", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1757 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1758 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1759 var->get = m68k_cycle_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1760 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1761 root->variables = tern_insert_ptr(root->variables, "cycle", var); |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1762 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1763 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1764 static debug_val vcounter_get(debug_var *var) |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1765 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1766 vdp_context *vdp = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1767 return debug_int(vdp->vcounter); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1768 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1769 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1770 static debug_val hcounter_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1771 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1772 vdp_context *vdp = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1773 return debug_int(vdp->hslot); |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1774 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1775 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1776 static debug_val vdp_address_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1777 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1778 vdp_context *vdp = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1779 return debug_int(vdp->address); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1780 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1781 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1782 static void vdp_address_set(debug_var *var, debug_val val) |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1783 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1784 vdp_context *vdp = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1785 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1786 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1787 fprintf(stderr, "vdp address can only be set to an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1788 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1789 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1790 vdp->address = ival & 0x1FFFF; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1791 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1792 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1793 static debug_val vdp_cd_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1794 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1795 vdp_context *vdp = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1796 return debug_int(vdp->cd); |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1797 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1798 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1799 static void vdp_cd_set(debug_var *var, debug_val val) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1800 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1801 vdp_context *vdp = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1802 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1803 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1804 fprintf(stderr, "vdp cd can only be set to an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1805 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1806 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1807 vdp->cd = ival & 0x3F; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1808 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1809 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1810 static debug_val vdp_status_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1811 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1812 vdp_context *vdp = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1813 return debug_int(vdp_status(vdp)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1814 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1815 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1816 static debug_val debug_vram_get(debug_array *array, uint32_t index) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1817 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1818 vdp_context *vdp = array->base; |
2413
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
1819 if (!(vdp->regs[REG_MODE_2] & BIT_MODE_5)) { |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
1820 index = mode4_address_map[index & 0x3FFF] ^ 1; |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
1821 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1822 return debug_int(vdp->vdpmem[index]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1823 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1824 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1825 static void debug_vram_set(debug_array *array, uint32_t index, debug_val val) |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1826 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1827 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1828 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1829 fprintf(stderr, "vram can only be set to integers\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1830 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1831 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1832 vdp_context *vdp = array->base; |
2413
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
1833 if (!(vdp->regs[REG_MODE_2] & BIT_MODE_5)) { |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
1834 index = mode4_address_map[index & 0x3FFF] ^ 1; |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
1835 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1836 vdp->vdpmem[index] = ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1837 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1838 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1839 static debug_val debug_vsram_get(debug_array *array, uint32_t index) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1840 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1841 vdp_context *vdp = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1842 return debug_int(vdp->vsram[index] & VSRAM_BITS); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1843 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1844 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1845 static void debug_vsram_set(debug_array *array, uint32_t index, debug_val val) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1846 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1847 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1848 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1849 fprintf(stderr, "vsram can only be set to integers\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1850 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1851 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1852 vdp_context *vdp = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1853 vdp->vsram[index] = ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1854 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1855 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1856 static debug_val debug_cram_get(debug_array *array, uint32_t index) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1857 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1858 vdp_context *vdp = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1859 return debug_int(vdp->cram[index] & CRAM_BITS); |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1860 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1861 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1862 static void debug_cram_set(debug_array *array, uint32_t index, debug_val val) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1863 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1864 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1865 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1866 fprintf(stderr, "cram can only be set to integers\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1867 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1868 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1869 vdp_context *vdp = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1870 vdp->cram[index] = ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1871 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1872 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1873 static debug_val debug_vreg_get(debug_array *array, uint32_t index) |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1874 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1875 vdp_context *vdp = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1876 return debug_int(vdp->regs[index]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1877 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1878 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1879 static void debug_vreg_set(debug_array *array, uint32_t index, debug_val val) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1880 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1881 vdp_context *vdp = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1882 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1883 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1884 fprintf(stderr, "vdp registers can only be set to integers\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1885 return; |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1886 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1887 vdp_reg_write(vdp, index, ival); |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1888 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1889 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1890 static debug_root* find_vdp_root(vdp_context *context) |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1891 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1892 debug_root *root = find_root(context); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1893 debug_var *var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1894 var->get = vcounter_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1895 var->ptr = context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1896 root->variables = tern_insert_ptr(root->variables, "vcounter", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1897 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1898 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1899 var->get = hcounter_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1900 var->ptr = context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1901 root->variables = tern_insert_ptr(root->variables, "hcounter", var); |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1902 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1903 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1904 var->get = vdp_address_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1905 var->set = vdp_address_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1906 var->ptr = context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1907 root->variables = tern_insert_ptr(root->variables, "address", var); |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1908 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1909 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1910 var->get = vdp_cd_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1911 var->set = vdp_cd_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1912 var->ptr = context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1913 root->variables = tern_insert_ptr(root->variables, "cd", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1914 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1915 new_readonly_variable(root, "vram", new_fixed_array(context, debug_vram_get, debug_vram_set, VRAM_SIZE)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1916 new_readonly_variable(root, "vsram", new_fixed_array(context, debug_vsram_get, debug_vsram_set, context->vsram_size)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1917 new_readonly_variable(root, "cram", new_fixed_array(context, debug_cram_get, debug_cram_set, CRAM_SIZE)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1918 new_readonly_variable(root, "reg", new_fixed_array(context, debug_vreg_get, debug_vreg_set, VDP_REGS)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1919 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1920 return root; |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1921 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1922 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1923 static debug_val debug_part1_get(debug_array *array, uint32_t index) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1924 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1925 ym2612_context *ym = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1926 return debug_int(ym->part1_regs[index]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1927 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1928 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1929 static void debug_part1_set(debug_array *array, uint32_t index, debug_val val) |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1930 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1931 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1932 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1933 fprintf(stderr, "ym2612 registers can only be set to integers\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1934 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1935 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1936 ym2612_context *ym = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1937 uint8_t old_part = ym->selected_part; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1938 uint8_t old_reg = ym->selected_reg; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1939 ym->selected_part = 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1940 ym->selected_reg = index; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1941 ym_data_write(ym, ival); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1942 ym->selected_part = old_part; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1943 ym->selected_reg = old_reg; |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1944 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1945 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1946 static debug_val debug_part2_get(debug_array *array, uint32_t index) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1947 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1948 ym2612_context *ym = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1949 return debug_int(ym->part2_regs[index]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1950 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1951 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1952 static void debug_part2_set(debug_array *array, uint32_t index, debug_val val) |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1953 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1954 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1955 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1956 fprintf(stderr, "ym2612 registers can only be set to integers\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1957 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1958 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1959 ym2612_context *ym = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1960 uint8_t old_part = ym->selected_part; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1961 uint8_t old_reg = ym->selected_reg; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1962 ym->selected_part = 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1963 ym->selected_reg = index; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1964 ym_data_write(ym, ival); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1965 ym->selected_part = old_part; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1966 ym->selected_reg = old_reg; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1967 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1968 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1969 static debug_root* find_ym2612_root(ym2612_context *context) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1970 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1971 debug_root *root = find_root(context); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1972 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1973 new_readonly_variable(root, "part1", new_fixed_array(context, debug_part1_get, debug_part1_set, YM_REG_END)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1974 new_readonly_variable(root, "part2", new_fixed_array(context, debug_part2_get, debug_part2_set, YM_REG_END)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1975 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1976 return root; |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1977 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1978 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1979 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1980 static debug_val debug_psgfreq_get(debug_array *array, uint32_t index) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1981 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1982 psg_context *psg = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1983 return debug_int(psg->counter_load[index]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1984 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1985 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1986 static void debug_psgfreq_set(debug_array *array, uint32_t index, debug_val val) |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1987 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1988 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1989 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1990 fprintf(stderr, "psg registers can only be set to integers\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1991 return; |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1992 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1993 psg_context *psg = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1994 psg->counter_load[index] = ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1995 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1996 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1997 static debug_val debug_psgcount_get(debug_array *array, uint32_t index) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1998 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1999 psg_context *psg = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2000 return debug_int(psg->counters[index]); |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
2001 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
2002 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2003 static void debug_psgcount_set(debug_array *array, uint32_t index, debug_val val) |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2004 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2005 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2006 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2007 fprintf(stderr, "psg registers can only be set to integers\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2008 return; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2009 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2010 psg_context *psg = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2011 psg->counters[index] = ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2012 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2013 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2014 static debug_val debug_psgvol_get(debug_array *array, uint32_t index) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2015 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2016 psg_context *psg = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2017 return debug_int(psg->volume[index]); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2018 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2019 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2020 static void debug_psgvol_set(debug_array *array, uint32_t index, debug_val val) |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2021 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2022 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2023 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2024 fprintf(stderr, "psg registers can only be set to integers\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2025 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2026 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2027 psg_context *psg = array->base; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2028 psg->volume[index] = ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2029 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2030 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2031 debug_root *find_psg_root(psg_context *psg) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2032 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2033 debug_root *root = find_root(psg); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2034 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2035 new_readonly_variable(root, "frequency", new_fixed_array(psg, debug_psgfreq_get, debug_psgfreq_set, 4)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2036 new_readonly_variable(root, "counter", new_fixed_array(psg, debug_psgcount_get, debug_psgcount_set, 4)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2037 new_readonly_variable(root, "volume", new_fixed_array(psg, debug_psgvol_get, debug_psgvol_set, 4)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2038 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2039 return root; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2040 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2041 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2042 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
|
2043 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2044 char *prefix = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2045 char * full = alloc_concat(prefix, key); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2046 fprintf(stderr, "\t%s\n", full); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2047 free(full); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2048 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2049 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2050 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
|
2051 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2052 char *cur = text; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2053 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
|
2054 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2055 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2056 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2057 char *name = malloc(cur - text + 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2058 memcpy(name, text, cur - text); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2059 name[cur-text] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2060 uint8_t ret = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2061 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
|
2062 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
|
2063 if (!def) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2064 tern_node *node = prefix_res; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2065 while (node) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2066 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2067 if (node->left || node->right) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2068 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2069 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2070 if (node->el) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2071 node = node->straight.next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2072 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2073 def = node->straight.value.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2074 break; |
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 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2077 if (!def && prefix_res) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2078 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
|
2079 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
|
2080 goto cleanup_name; |
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 if (!def) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2084 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
|
2085 goto cleanup_name; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2086 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2087 char *format = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2088 if (*cur == '/') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2089 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2090 text = cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2091 while (*cur && !isspace(*cur)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2092 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2093 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2094 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2095 format = malloc(cur - text + 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2096 memcpy(format, text, cur - text); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2097 format[cur - text] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2098 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2099 int num_args = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2100 command_arg *args = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2101 if (*cur && *cur != '\n') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2102 ++cur; |
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 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
|
2105 if (def->raw_args) { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2106 while (*cur && *cur != '\n') |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2107 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2108 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2109 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2110 char *raw_param = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2111 if (cur != text) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2112 raw_param = malloc(cur - text + 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2113 memcpy(raw_param, text, cur - text); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2114 raw_param[cur - text] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2115 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2116 out->raw = raw_param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2117 out->args = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2118 out->num_args = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2119 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2120 int arg_storage = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2121 if (def->max_args > 0) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2122 arg_storage = def->max_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2123 } else if (def->max_args) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2124 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
|
2125 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2126 if (arg_storage) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2127 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
|
2128 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2129 while (*text && *text != '\n') |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2130 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2131 char *after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2132 expr *e = parse_expression(text, &after); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2133 if (e) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2134 if (num_args == arg_storage) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2135 if (def->max_args >= 0) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2136 free_expr(e); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2137 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
|
2138 goto cleanup_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2139 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2140 arg_storage *= 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2141 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
|
2142 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2143 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2144 args[num_args].parsed = e; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2145 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
|
2146 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
|
2147 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
|
2148 text = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2149 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2150 goto cleanup_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2151 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2152 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2153 if (num_args < def->min_args) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2154 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
|
2155 goto cleanup_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2156 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2157 out->raw = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2158 out->args = args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2159 out->num_args = num_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2160 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2161 out->def = def; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2162 out->format = format; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
2163 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2164 ret = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2165 cleanup_args: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2166 if (!ret) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2167 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
|
2168 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2169 free_expr(args[i].parsed); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2170 free(args[i].raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2171 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2172 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
|
2173 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2174 cleanup_name: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2175 free(name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2176 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2177 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2178 |
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
|
2179 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
|
2180 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
|
2181 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2182 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
|
2183 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2184 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
|
2185 } |
e17d99c96c89
Make blocks an 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 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
|
2187 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2188 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2189 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
|
2190 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2191 free(cmd->format); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2192 free(cmd->raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2193 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
|
2194 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2195 free(cmd->args[i].raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2196 free_expr(cmd->args[i].parsed); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2197 } |
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
|
2198 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
|
2199 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
|
2200 free(cmd->args); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2201 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2202 |
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
|
2203 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
|
2204 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
|
2205 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
|
2206 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
|
2207 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
|
2208 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
|
2209 }; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2210 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2211 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
|
2212 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2213 ++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
|
2214 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
|
2215 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2216 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
|
2217 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2218 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
|
2219 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
|
2220 #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
|
2221 #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
|
2222 #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
|
2223 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
|
2224 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
|
2225 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
|
2226 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
|
2227 #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
|
2228 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
|
2229 process_events(); |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2252
diff
changeset
|
2230 #ifndef IS_LIB |
2252
6a07b13894f7
Fix input processing while waiting for console input in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2216
diff
changeset
|
2231 render_update_display(); |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2252
diff
changeset
|
2232 #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
|
2233 #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
|
2234 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
|
2235 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
|
2236 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
|
2237 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
|
2238 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
|
2239 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2240 #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
|
2241 } 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
|
2242 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2243 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
|
2244 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
|
2245 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
|
2246 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
|
2247 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2248 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
|
2249 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
|
2250 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
|
2251 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2252 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
|
2253 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
|
2254 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
|
2255 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2256 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
|
2257 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
|
2258 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2259 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2260 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
|
2261 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
|
2262 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
|
2263 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2264 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
|
2265 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
|
2266 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
|
2267 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
|
2268 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
|
2269 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2270 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
|
2271 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
|
2272 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
|
2273 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2274 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
|
2275 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2276 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
|
2277 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
|
2278 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
|
2279 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
|
2280 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
|
2281 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
|
2282 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
|
2283 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
|
2284 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
|
2285 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
|
2286 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
|
2287 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2288 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
|
2289 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
|
2290 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
|
2291 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2292 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
|
2293 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
|
2294 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
|
2295 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
|
2296 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2297 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2298 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2299 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
|
2300 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2301 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2302 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
|
2303 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2304 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
|
2305 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
|
2306 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2307 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
|
2308 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
|
2309 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
|
2310 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2311 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2312 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2313 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
|
2314 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2315 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2316 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
|
2317 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2318 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2319 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
|
2320 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
|
2321 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
|
2322 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
|
2323 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
|
2324 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
|
2325 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
|
2326 } |
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
|
2327 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
|
2328 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
|
2329 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2330 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
|
2331 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
|
2332 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
|
2333 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
|
2334 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
|
2335 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
|
2336 } |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2337 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
|
2338 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
|
2339 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
|
2340 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
|
2341 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
|
2342 } |
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
|
2343 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
|
2344 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2345 } |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2346 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
|
2347 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
|
2348 } else { |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2349 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
|
2350 } |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2351 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
|
2352 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2353 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2354 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
|
2355 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2356 exit(0); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2357 } |
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 typedef struct { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2360 size_t num_commands; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2361 size_t longest_command; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2362 } help_state; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2363 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2364 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
|
2365 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2366 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2367 if (def->visited) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2368 return; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2369 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2370 def->visited = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2371 help_state *state = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2372 state->num_commands++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2373 size_t len = strlen(def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2374 if (len > state->longest_command) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2375 state->longest_command = len; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2376 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2377 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2378 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2379 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
|
2380 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2381 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2382 def->visited = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2383 } |
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 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
|
2386 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2387 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2388 if (def->visited) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2389 return; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2390 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2391 def->visited = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2392 help_state *state = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2393 size_t len = strlen(def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2394 printf(" %s", def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2395 while (len < state->longest_command) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2396 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2397 len++; |
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 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
|
2400 const char *extra_desc = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2401 if (strlen(def->desc) <= remaining) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2402 printf(" - %s\n", def->desc); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2403 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2404 char split[76]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2405 int split_point = remaining; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2406 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
|
2407 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2408 --split_point; |
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 if (!split_point) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2411 split_point = remaining; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2412 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2413 memcpy(split, def->desc, split_point); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2414 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
|
2415 split[split_point] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2416 printf(" - %s\n", split); |
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 if (def->names[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2419 fputs(" Aliases: ", stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2420 len = strlen(" Aliases: "); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2421 const char **name = def->names + 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2422 uint8_t first = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2423 while (*name) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2424 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2425 if (first) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2426 first = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2427 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2428 putchar(','); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2429 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2430 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
|
2431 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2432 fputs(*name, stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2433 len += strlen(*name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2434 ++name; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2435 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2436 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2437 len = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2438 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2439 if (extra_desc) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2440 while (len < state->longest_command + 5) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2441 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2442 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
|
2443 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2444 fputs(extra_desc, stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2445 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2446 putchar('\n'); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2447 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2448 |
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
|
2449 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
|
2450 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2451 help_state state = {0,0}; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2452 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
|
2453 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
|
2454 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
|
2455 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
|
2456 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2457 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2458 |
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
|
2459 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
|
2460 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2461 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2462 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2463 |
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
|
2464 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
|
2465 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2466 strcpy(format_str, "%s: %d\n"); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2467 if (format) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2468 switch (format[0]) |
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 case 'x': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2471 case 'X': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2472 case 'd': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2473 case 'c': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2474 case 's': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2475 format_str[5] = format[0]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2476 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2477 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2478 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
|
2479 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2480 } |
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
|
2481 } |
e17d99c96c89
Make blocks an 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 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2483 static void do_print(debug_root *root, char *format_str, char *raw, debug_val 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
|
2484 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2485 switch(value.type) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2486 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2487 case DBG_VAL_U32: |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2488 if (format_str[5] == 's') { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2489 char tmp[128]; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2490 int j; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2491 uint32_t addr = value.v.u32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2492 for (j = 0; j < sizeof(tmp)-1; j++, addr++) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2493 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2494 uint32_t tmp_addr = addr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2495 root->read_mem(root, &tmp_addr, 'b'); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2496 char c = tmp_addr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2497 if (c < 0x20 || c > 0x7F) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2498 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2499 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2500 tmp[j] = c; |
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
|
2501 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2502 tmp[j] = 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2503 printf(format_str, raw, tmp); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2504 } else { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2505 printf(format_str, raw, value.v.u32); |
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
|
2506 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2507 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2508 case DBG_VAL_F32: { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2509 char tmp = format_str[5]; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2510 format_str[5] = 'f'; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2511 printf(format_str, raw, value.v.f32); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2512 format_str[5] = tmp; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2513 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2514 } |
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
|
2515 } |
e17d99c96c89
Make blocks an 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 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2517 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2518 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
|
2519 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2520 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
|
2521 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
|
2522 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
|
2523 { |
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
|
2524 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
|
2525 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2526 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2527 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2528 |
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
|
2529 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
|
2530 { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2531 char *fmt = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2532 if (!fmt) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2533 fprintf(stderr, "First parameter to printf must be a string\n"); |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2534 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2535 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2536 char *cur = fmt; |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2537 char format_str[3] = {'%', 'd', 0}; |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2538 uint32_t cur_param = 1; |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2539 while (*cur) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2540 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2541 if (*cur == '%') { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2542 switch(cur[1]) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2543 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2544 case 'x': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2545 case 'X': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2546 case 'c': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2547 case 'd': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2548 case 's': |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2549 case 'f': |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2550 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2551 default: |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2552 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
|
2553 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2554 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2555 format_str[1] = cur[1]; |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2556 if (cur_param == cmd->num_args) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2557 fprintf(stderr, "Not enough arguments for format char %c\n", *cur); |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2558 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2559 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2560 debug_val val = cmd->args[cur_param++].value; |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2561 if (cur[1] == 's') { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2562 if (val.type == DBG_VAL_STRING) { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2563 printf(format_str, get_cstring(val)); |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2564 } else { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2565 char tmp[128]; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2566 uint32_t address; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2567 if (!debug_cast_int(val, &address)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2568 fprintf(stderr, "Format char 's' accepts only integers and strings\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2569 return 1; |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2570 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2571 int j; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2572 for (j = 0; j < sizeof(tmp)-1; j++, address++) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2573 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2574 uint32_t addr = address; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2575 root->read_mem(root, &addr, 'b'); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2576 char c = addr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2577 if (c < 0x20 || c > 0x7F) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2578 break; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2579 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2580 tmp[j] = c; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2581 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2582 tmp[j] = 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2583 printf(format_str, tmp); |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2584 } |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2585 } else if (cur[1] == 'f') { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2586 float fval; |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2587 if (!debug_cast_float(val, &fval)) { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2588 fprintf(stderr, "Format char '%c' only accepts floats\n", cur[1]); |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2589 return 1; |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2590 } |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2591 printf(format_str, fval); |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2592 } else { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2593 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2594 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2595 fprintf(stderr, "Format char '%c' only accepts integers\n", cur[1]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2596 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2597 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2598 printf(format_str, ival); |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2599 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2600 cur += 2; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2601 } else { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2602 putchar(*cur); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2603 ++cur; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2604 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2605 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2606 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2607 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2608 |
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
|
2609 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
|
2610 { |
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
|
2611 cmd_print(root, cmd); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2612 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
|
2613 ndisp->next = root->displays; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2614 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
|
2615 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
|
2616 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
|
2617 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
|
2618 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
|
2619 cmd->num_args = 0; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2620 root->displays = ndisp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2621 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
|
2622 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2623 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2624 |
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
|
2625 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
|
2626 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2627 disp_def **cur = &root->displays; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2628 uint32_t index; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2629 if (!debug_cast_int(cmd->args[0].value, &index)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2630 fprintf(stderr, "Argument to deletedisplay must be an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2631 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2632 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2633 while (*cur) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2634 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2635 if ((*cur)->index == index) { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2636 disp_def *del_disp = *cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2637 *cur = del_disp->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2638 free(del_disp->format); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2639 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
|
2640 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2641 free(del_disp->args[i].raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2642 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
|
2643 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2644 free(del_disp->args); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2645 free(del_disp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2646 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2647 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2648 cur = &(*cur)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2649 } |
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 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2652 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2653 |
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
|
2654 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
|
2655 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2656 if (current_system->soft_reset) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2657 current_system->soft_reset(current_system); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2658 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2659 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2660 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
|
2661 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2662 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2663 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2664 |
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
|
2665 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
|
2666 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2667 uint32_t index; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2668 if (!debug_cast_int(cmd->args[0].value, &index)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2669 fprintf(stderr, "Argument to commands must be an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2670 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2671 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2672 bp_def **target = find_breakpoint_idx(&root->breakpoints, index); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2673 if (!target) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2674 fprintf(stderr, "Breakpoint %d does not exist!\n", index); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2675 return 1; |
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 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
|
2678 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2679 free_parsed_command((*target)->commands + i); |
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 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
|
2682 (*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
|
2683 (*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
|
2684 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
|
2685 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
|
2686 return 1; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2687 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2688 |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2689 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
|
2690 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2691 uint8_t debugging = 1; |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2692 for (int i = 0; i < block->num_commands && debugging; i++) |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2693 { |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2694 debugging = run_command(root, block->commands + i); |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2695 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2696 return debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2697 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2698 |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2699 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
|
2700 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2701 return execute_block(root, debug_cast_bool(cmd->args[0].value) ? &cmd->block : &cmd->else_block); |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2702 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2703 |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2704 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
|
2705 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2706 if (!debug_cast_bool(cmd->args[0].value)) { |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2707 return execute_block(root, &cmd->else_block); |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2708 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2709 int debugging = 1; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2710 do { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2711 debugging = execute_block(root, &cmd->block) && debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2712 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
|
2713 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
|
2714 return 1; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2715 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2716 } while (debug_cast_bool(cmd->args[0].value)); |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2717 return debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2718 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2719 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2720 const char *expr_type_names[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2721 "EXPR_NONE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2722 "EXPR_SCALAR", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2723 "EXPR_UNARY", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2724 "EXPR_BINARY", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2725 "EXPR_SIZE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2726 "EXPR_MEM" |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2727 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2728 |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2729 static uint8_t cmd_function(debug_root *root, parsed_command *cmd) |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2730 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2731 debug_root *set_root = root; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2732 expr *set_expr = cmd->args[0].parsed; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2733 while (set_expr->type == EXPR_NAMESPACE) |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2734 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2735 set_root = tern_find_ptr(set_root->other_roots, set_expr->op.v.str); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2736 if (!set_root) { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2737 fprintf(stderr, "%s is not a valid namespace\n", set_expr->op.v.str); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2738 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2739 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2740 set_expr = set_expr->left; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2741 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2742 if (set_expr->type != EXPR_SCALAR || set_expr->op.type != TOKEN_NAME) { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2743 fprintf(stderr, "Arguments to function must be names, bug argument 0 is %s\n", expr_type_names[set_expr->type]); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2744 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2745 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2746 debug_var *var = tern_find_ptr(set_root->variables, set_expr->op.v.str); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2747 if (var) { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2748 fprintf(stderr, "%s is already defined\n", set_expr->op.v.str); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2749 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2750 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2751 for (uint32_t i = 1; i < cmd->num_args; i++) |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2752 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2753 if (cmd->args[i].parsed->type != EXPR_SCALAR || cmd->args[i].parsed->op.type != TOKEN_NAME) { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2754 fprintf(stderr, "Arguments to function must be names, bug argument %d is %s\n", i, expr_type_names[cmd->args[i].parsed->type]); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2755 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2756 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2757 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2758 char **args = calloc(cmd->num_args - 1, sizeof(char *)); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2759 for (uint32_t i = 1; i < cmd->num_args; i++) |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2760 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2761 args[i - 1] = cmd->args[i].parsed->op.v.str; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2762 cmd->args[i].parsed->op.v.str = NULL; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2763 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2764 new_readonly_variable(set_root, set_expr->op.v.str, new_user_func(&cmd->block, args, cmd->num_args - 1)); |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2765 cmd->block.commands = NULL; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2766 cmd->block.num_commands = 0; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2767 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2768 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2769 |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2770 static uint8_t cmd_return(debug_root *root, parsed_command *cmd) |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2771 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2772 root->retval = cmd->args[0].value; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2773 return 0; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2774 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2775 |
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
|
2776 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
|
2777 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2778 char *name = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2779 char size = 0; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2780 debug_root *set_root = root; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2781 expr *set_expr = cmd->args[0].parsed; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2782 while (set_expr->type == EXPR_NAMESPACE) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2783 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2784 set_root = tern_find_ptr(set_root->other_roots, set_expr->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2785 if (!set_root) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2786 fprintf(stderr, "%s is not a valid namespace\n", set_expr->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2787 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2788 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2789 set_expr = set_expr->left; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2790 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2791 debug_val address; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2792 debug_array *array = NULL; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2793 switch (set_expr->type) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2794 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2795 case EXPR_SCALAR: |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2796 if (set_expr->op.type == TOKEN_NAME) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2797 name = set_expr->op.v.str; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2798 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2799 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
|
2800 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2801 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2802 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2803 case EXPR_SIZE: |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2804 size = set_expr->op.v.op[0]; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2805 if (set_expr->left->op.type == TOKEN_NAME) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2806 name = set_expr->left->op.v.str; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2807 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2808 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
|
2809 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2810 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2811 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2812 case EXPR_MEM: |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2813 size = set_expr->op.v.op[0]; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2814 if (!eval_expr(root, set_expr->left, &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
|
2815 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
|
2816 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2817 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2818 if (address.type != DBG_VAL_U32) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2819 fprintf(stderr, "Index in array expression must be integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2820 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2821 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2822 if (set_expr->right) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2823 debug_val right; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2824 if (!eval_expr(root, set_expr->right, &right)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2825 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2826 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2827 array = get_array(right); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2828 if (!array) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2829 fprintf(stderr, "%s does not refer to an array\n", cmd->args[0].raw); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2830 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2831 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2832 if (!array->set) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2833 fprintf(stderr, "Array %s is read-only\n", set_expr->right->op.v.str); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2834 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2835 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2836 if (address.v.u32 >= array->size) { |
2386
9f178feb3cb0
Prefix most hex-formatted values output by debugger with $ for consistency with number literal parsing
Michael Pavone <pavone@retrodev.com>
parents:
2380
diff
changeset
|
2837 fprintf(stderr, "Address $%X is out of bounds for array %s\n", address.v.u32, set_expr->right->op.v.str); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2838 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2839 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2840 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2841 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2842 default: |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2843 fprintf(stderr, "First argument to set must be a name or memory expression, got %s\n", expr_type_names[set_expr->type]); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2844 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2845 } |
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
|
2846 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
|
2847 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
|
2848 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2849 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2850 debug_val value = cmd->args[1].value; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2851 if (name) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2852 debug_var *var = tern_find_ptr(set_root->variables, name); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2853 if (!var) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2854 fprintf(stderr, "%s is not defined\n", name); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2855 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2856 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2857 if (!var->set) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2858 fprintf(stderr, "%s is read-only\n", name); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2859 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2860 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2861 if (size && size != 'l') { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2862 debug_val old = var->get(var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2863 if (size == 'b') { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2864 old.v.u32 &= 0xFFFFFF00; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2865 value.v.u32 &= 0xFF; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2866 value.v.u32 |= old.v.u32; |
2358
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2867 } else { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2868 old.v.u32 &= 0xFFFF0000; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2869 value.v.u32 &= 0xFFFF; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2870 value.v.u32 |= old.v.u32; |
2358
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2871 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2872 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2873 var->set(var, value); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2874 } else if (array) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2875 array->set(array, address.v.u32, value); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2876 } else if (!root->write_mem(root, address.v.u32, value.v.u32, size)) { |
2386
9f178feb3cb0
Prefix most hex-formatted values output by debugger with $ for consistency with number literal parsing
Michael Pavone <pavone@retrodev.com>
parents:
2380
diff
changeset
|
2877 fprintf(stderr, "Failed to write to address $%X\n", address.v.u32); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2878 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2879 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2880 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2881 |
2358
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2882 static uint8_t cmd_variable(debug_root *root, parsed_command *cmd) |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2883 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2884 debug_root *set_root = root; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2885 expr *set_expr = cmd->args[0].parsed; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2886 while (set_expr->type == EXPR_NAMESPACE) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2887 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2888 set_root = tern_find_ptr(set_root->other_roots, set_expr->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2889 if (!set_root) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2890 fprintf(stderr, "%s is not a valid namespace\n", set_expr->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2891 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2892 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2893 set_expr = set_expr->left; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2894 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2895 if (set_expr->type != EXPR_SCALAR || set_expr->op.type != TOKEN_NAME) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2896 fprintf(stderr, "First argument to variable must be a name, got %s\n", expr_type_names[set_expr->type]); |
2358
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2897 return 1; |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2898 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2899 debug_var *var = tern_find_ptr(set_root->variables, set_expr->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2900 if (var) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2901 fprintf(stderr, "%s is already defined\n", set_expr->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2902 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2903 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2904 debug_val value; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2905 value.type = DBG_VAL_U32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2906 value.v.u32 = 0; |
2358
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2907 if (cmd->num_args > 1) { |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2908 if (!eval_expr(root, cmd->args[1].parsed, &cmd->args[1].value)) { |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2909 fprintf(stderr, "Failed to eval %s\n", cmd->args[1].raw); |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2910 return 1; |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2911 } |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2912 value = cmd->args[1].value; |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2913 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2914 new_user_variable(set_root, set_expr->op.v.str, value); |
2358
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2915 return 1; |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2916 } |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
2917 |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2918 static uint8_t cmd_array(debug_root *root, parsed_command *cmd) |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2919 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2920 debug_root *set_root = root; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2921 expr *set_expr = cmd->args[0].parsed; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2922 while (set_expr->type == EXPR_NAMESPACE) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2923 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2924 set_root = tern_find_ptr(set_root->other_roots, set_expr->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2925 if (!set_root) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2926 fprintf(stderr, "%s is not a valid namespace\n", set_expr->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2927 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2928 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2929 set_expr = set_expr->left; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2930 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2931 if (set_expr->type != EXPR_SCALAR || set_expr->op.type != TOKEN_NAME) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2932 fprintf(stderr, "First argument to array must be a name, got %s\n", expr_type_names[set_expr->type]); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2933 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2934 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2935 debug_var *var = tern_find_ptr(set_root->variables, set_expr->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2936 debug_array *array; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2937 if (var) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2938 debug_val val = var->get(var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2939 array = get_array(val); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2940 if (!array) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2941 fprintf(stderr, "%s is already defined as a non-array value\n", set_expr->op.v.str); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2942 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2943 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2944 } else { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2945 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2946 var->get = user_var_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2947 var->set = user_var_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2948 var->val = new_user_array(cmd->num_args - 1); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2949 set_root->variables = tern_insert_ptr(set_root->variables, set_expr->op.v.str, var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2950 array = get_array(var->val); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2951 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2952 if (array->set == user_array_set) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2953 array->size = cmd->num_args - 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2954 if (array->storage < array->size) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2955 array->storage = array->size; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2956 array->base = realloc(array->base, sizeof(debug_val) * array->storage); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2957 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2958 } |
2367
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
2959 for (uint32_t i = 1; i < cmd->num_args && i <= array->size; i++) |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2960 { |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2961 if (!eval_expr(root, cmd->args[i].parsed, &cmd->args[i].value)) { |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2962 fprintf(stderr, "Failed to eval %s\n", cmd->args[i].raw); |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2963 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2964 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2965 array->set(array, i - 1, cmd->args[i].value); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2966 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2967 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2968 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2969 |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2970 static uint8_t cmd_append(debug_root *root, parsed_command *cmd) |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2971 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2972 debug_array *array = get_array(cmd->args[0].value); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2973 if (!array) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2974 fprintf(stderr, "%s is not an array\n", cmd->args[0].raw); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2975 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2976 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2977 if (!array->append) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2978 fprintf(stderr, "Array %s doesn't support appending\n", cmd->args[0].raw); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2979 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2980 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2981 array->append(array, cmd->args[1].value); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2982 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2983 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2984 |
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
|
2985 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
|
2986 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2987 uint32_t frames; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2988 if (!debug_cast_int(cmd->args[0].value, &frames)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2989 fprintf(stderr, "Argument to frames must be an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2990 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2991 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2992 current_system->enter_debugger_frames = frames; |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2993 return 0; |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2994 } |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
2995 |
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
|
2996 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
|
2997 { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2998 char *bind = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2999 if (!bind) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3000 fprintf(stderr, "Argument to bindup must be a string\n"); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3001 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3002 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3003 if (!bind_up(bind)) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3004 fprintf(stderr, "%s is not a valid binding name\n", bind); |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3005 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3006 return 1; |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3007 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3008 |
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
|
3009 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
|
3010 { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3011 char *bind = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3012 if (!bind) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3013 fprintf(stderr, "Argument to binddown must be a string\n"); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3014 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3015 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3016 if (!bind_down(bind)) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3017 fprintf(stderr, "%s is not a valid binding name\n", bind); |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3018 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3019 return 1; |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3020 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3021 |
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
|
3022 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
|
3023 { |
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
|
3024 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
|
3025 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
|
3026 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3027 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3028 uint32_t index; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3029 if (!debug_cast_int(cmd->args[0].value, &index)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3030 fprintf(stderr, "First argument to condition must be an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3031 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3032 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3033 bp_def **target = find_breakpoint_idx(&root->breakpoints, index); |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3034 if (!*target) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3035 fprintf(stderr, "Failed to find breakpoint %u\n", index); |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3036 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3037 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3038 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
|
3039 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
|
3040 (*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
|
3041 cmd->args[1].parsed = NULL; |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3042 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3043 (*target)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3044 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3045 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3046 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3047 |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3048 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
|
3049 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3050 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
|
3051 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
|
3052 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
|
3053 *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
|
3054 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3055 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3056 |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3057 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
|
3058 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3059 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
|
3060 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
|
3061 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
|
3062 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
|
3063 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3064 putchar(' '); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3065 len++; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3066 } |
2386
9f178feb3cb0
Prefix most hex-formatted values output by debugger with $ for consistency with number literal parsing
Michael Pavone <pavone@retrodev.com>
parents:
2380
diff
changeset
|
3067 printf("$%X\n", (uint32_t)val.intval); |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3068 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3069 |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3070 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
|
3071 { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3072 if (cmd->num_args) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3073 char *filename = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3074 if (!filename) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3075 fprintf(stderr, "Argument to symbols must be a string if provided\n"); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3076 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3077 } |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3078 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
|
3079 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
|
3080 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
|
3081 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
|
3082 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3083 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
|
3084 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
|
3085 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3086 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
|
3087 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
|
3088 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
|
3089 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
|
3090 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
|
3091 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
|
3092 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
|
3093 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
|
3094 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
|
3095 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3096 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3097 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3098 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3099 } else { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3100 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
|
3101 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
|
3102 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
|
3103 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
|
3104 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3105 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
|
3106 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3107 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3108 static uint8_t cmd_save(debug_root *root, parsed_command *cmd) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3109 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3110 char size = cmd->format ? cmd->format[0] : 'b'; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3111 if (size != 'b' && size != 'w' && size != 'l') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3112 fprintf(stderr, "Invalid size %s\n", cmd->format); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3113 return 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3114 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3115 if (!eval_expr(root, cmd->args[0].parsed, &cmd->args[0].value)) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3116 fprintf(stderr, "Failed to eval %s\n", cmd->args[0].raw); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3117 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3118 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3119 char *fname = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3120 if (!fname) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3121 fprintf(stderr, "First argument to save must be a string\n"); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3122 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3123 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3124 FILE *f = fopen(fname, "wb"); |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3125 if (!f) { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3126 fprintf(stderr, "Failed to open %s for writing\n", fname); |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3127 return 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3128 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3129 uint32_t start = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3130 debug_val val; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3131 debug_array * arr = NULL; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3132 if (cmd->args[1].parsed->type == EXPR_MEM) { |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3133 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3134 if (!eval_expr(root, cmd->args[1].parsed->left, &val)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3135 fprintf(stderr, "Failed to eval start index\n"); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3136 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3137 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3138 if (!debug_cast_int(val, &start)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3139 fprintf(stderr, "Start index must evaluate to integer\n"); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3140 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3141 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3142 if (cmd->args[1].parsed->right) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3143 if (!eval_expr(root, cmd->args[1].parsed->right, &val)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3144 fprintf(stderr, "Failed to eval array name in argument %s\n", cmd->args[1].raw); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3145 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3146 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3147 arr = get_array(val); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3148 if (!arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3149 fprintf(stderr, "Name in argument %s did not evaluate to an array\n", cmd->args[1].raw); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3150 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3151 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3152 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3153 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3154 if (!eval_expr(root, cmd->args[1].parsed, &val)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3155 fprintf(stderr, "Failed to eval %s\n", cmd->args[1].raw); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3156 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3157 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3158 arr = get_array(val); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3159 if (!arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3160 fprintf(stderr, "Argument %s did not evaluate to an array\n", cmd->args[1].raw); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3161 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3162 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3163 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3164 uint32_t count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3165 if (cmd->num_args > 2) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3166 if (!eval_expr(root, cmd->args[2].parsed, &val)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3167 fprintf(stderr, "Failed to eval %s\n", cmd->args[2].raw); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3168 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3169 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3170 if (!debug_cast_int(val, &count)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3171 fprintf(stderr, "Count must evaluate to integer\n"); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3172 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3173 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3174 } else if (arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3175 count = arr->size < start ? 0 : arr->size - start; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3176 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3177 count = root->chunk_end(root, start) - start; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3178 if (size == 'l') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3179 count /= 4; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3180 } else if (size == 'w') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3181 count /= 2; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3182 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3183 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3184 union { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3185 uint8_t b[1024]; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3186 uint16_t w[512]; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3187 uint32_t l[256]; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3188 } buffer; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3189 uint32_t cur = start; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3190 if (size == 'l') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3191 while (count) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3192 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3193 uint32_t n = count < 256 ? count : 256; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3194 count -= n; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3195 for (uint32_t i = 0; i < n ; i++) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3196 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3197 if (arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3198 val = arr->get(arr, cur++); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3199 if (!debug_cast_int(val, buffer.l + i)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3200 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3201 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3202 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3203 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3204 buffer.l[i] = cur; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3205 cur += 4; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3206 if (!root->read_mem(root, buffer.l + i, 'l')) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3207 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3208 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3209 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3210 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3211 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3212 fwrite(buffer.l, sizeof(uint32_t), n, f); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3213 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3214 } else if (size == 'w') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3215 while (count) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3216 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3217 uint32_t n = count < 512 ? count : 512; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3218 count -= n; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3219 uint32_t tmp; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3220 for (uint32_t i = 0; i < n ; i++) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3221 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3222 if (arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3223 val = arr->get(arr, cur++); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3224 if (!debug_cast_int(val, &tmp)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3225 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3226 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3227 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3228 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3229 tmp = cur; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3230 cur += 2; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3231 if (!root->read_mem(root, &tmp, 'w')) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3232 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3233 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3234 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3235 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3236 buffer.w[i] = tmp; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3237 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3238 fwrite(buffer.w, sizeof(uint16_t), n, f); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3239 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3240 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3241 while (count) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3242 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3243 uint32_t n = count < 1024 ? count : 1024; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3244 count -= n; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3245 uint32_t tmp; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3246 for (uint32_t i = 0; i < n ; i++) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3247 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3248 if (arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3249 val = arr->get(arr, cur++); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3250 if (!debug_cast_int(val, &tmp)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3251 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3252 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3253 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3254 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3255 tmp = cur++; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3256 if (!root->read_mem(root, &tmp, 'b')) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3257 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3258 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3259 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3260 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3261 buffer.b[i] = tmp; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3262 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3263 fwrite(buffer.b, sizeof(uint8_t), n, f); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3264 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3265 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3266 cleanup: |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3267 fclose(f); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3268 return 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3269 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3270 |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3271 static uint8_t cmd_load(debug_root *root, parsed_command *cmd) |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3272 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3273 char size = cmd->format ? cmd->format[0] : 'b'; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3274 if (size != 'b' && size != 'w' && size != 'l') { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3275 fprintf(stderr, "Invalid size %s\n", cmd->format); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3276 return 1; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3277 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3278 if (!eval_expr(root, cmd->args[0].parsed, &cmd->args[0].value)) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3279 fprintf(stderr, "Failed to eval %s\n", cmd->args[0].raw); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3280 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3281 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3282 char *fname = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3283 if (!fname) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3284 fprintf(stderr, "First argument to load must be a string\n"); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3285 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3286 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3287 FILE *f = fopen(fname, "rb"); |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3288 if (!f) { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3289 fprintf(stderr, "Failed to open %s for reading\n", fname); |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3290 return 1; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3291 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3292 uint32_t start = 0; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3293 debug_val val; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3294 debug_array * arr = NULL; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3295 if (cmd->args[1].parsed->type == EXPR_MEM) { |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3296 |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3297 if (!eval_expr(root, cmd->args[1].parsed->left, &val)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3298 fprintf(stderr, "Failed to eval start index\n"); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3299 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3300 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3301 if (!debug_cast_int(val, &start)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3302 fprintf(stderr, "Start index must evaluate to integer\n"); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3303 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3304 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3305 if (cmd->args[1].parsed->right) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3306 if (!eval_expr(root, cmd->args[1].parsed->right, &val)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3307 fprintf(stderr, "Failed to eval array name in argument %s\n", cmd->args[1].raw); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3308 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3309 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3310 arr = get_array(val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3311 if (!arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3312 fprintf(stderr, "Name in argument %s did not evaluate to an array\n", cmd->args[1].raw); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3313 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3314 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3315 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3316 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3317 if (!eval_expr(root, cmd->args[1].parsed, &val)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3318 fprintf(stderr, "Failed to eval %s\n", cmd->args[1].raw); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3319 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3320 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3321 arr = get_array(val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3322 if (!arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3323 fprintf(stderr, "Argument %s did not evaluate to an array\n", cmd->args[1].raw); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3324 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3325 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3326 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3327 uint32_t count = 0; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3328 uint8_t has_count = 0; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3329 if (cmd->num_args > 2) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3330 if (!eval_expr(root, cmd->args[2].parsed, &val)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3331 fprintf(stderr, "Failed to eval %s\n", cmd->args[2].raw); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3332 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3333 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3334 if (!debug_cast_int(val, &count)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3335 fprintf(stderr, "Count must evaluate to integer\n"); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3336 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3337 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3338 has_count = 1; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3339 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3340 union { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3341 uint8_t b[1024]; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3342 uint16_t w[512]; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3343 uint32_t l[256]; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3344 } buffer; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3345 uint32_t cur = start; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3346 if (size == 'l') { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3347 while (count || !has_count) |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3348 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3349 uint32_t n = (has_count && count < 256) ? count : 256; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3350 count -= n; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3351 n = fread(buffer.l, sizeof(uint32_t), n, f); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3352 if (!n) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3353 break; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3354 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3355 for (uint32_t i = 0; i < n ; i++) |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3356 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3357 if (arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3358 val = debug_int(buffer.l[i]); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3359 if (cur >= arr->size) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3360 if (arr->append) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3361 arr->append(arr, val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3362 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3363 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3364 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3365 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3366 arr->set(arr, cur, val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3367 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3368 cur++; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3369 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3370 if (!root->write_mem(root, cur, buffer.l[i], 'l')) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3371 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3372 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3373 cur += 4; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3374 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3375 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3376 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3377 } else if (size == 'w') { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3378 while (count || !has_count) |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3379 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3380 uint32_t n = (has_count && count < 512) ? count : 512; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3381 count -= n; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3382 n = fread(buffer.w, sizeof(uint16_t), n, f); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3383 if (!n) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3384 break; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3385 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3386 for (uint32_t i = 0; i < n ; i++) |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3387 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3388 if (arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3389 val = debug_int(buffer.w[i]); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3390 if (cur >= arr->size) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3391 if (arr->append) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3392 arr->append(arr, val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3393 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3394 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3395 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3396 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3397 arr->set(arr, cur, val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3398 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3399 cur++; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3400 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3401 if (!root->write_mem(root, cur, buffer.w[i], 'w')) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3402 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3403 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3404 cur += 2; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3405 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3406 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3407 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3408 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3409 while (count || !has_count) |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3410 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3411 uint32_t n = (has_count && count < 1024) ? count : 1024; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3412 count -= n; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3413 n = fread(buffer.b, sizeof(uint8_t), n, f); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3414 if (!n) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3415 break; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3416 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3417 for (uint32_t i = 0; i < n ; i++) |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3418 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3419 if (arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3420 val = debug_int(buffer.b[i]); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3421 if (cur >= arr->size) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3422 if (arr->append) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3423 arr->append(arr, val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3424 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3425 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3426 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3427 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3428 arr->set(arr, cur, val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3429 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3430 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3431 if (!root->write_mem(root, cur, buffer.b[i], 'b')) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3432 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3433 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3434 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3435 cur++; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3436 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3437 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3438 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3439 cleanup: |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3440 fclose(f); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3441 return 1; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3442 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3443 |
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
|
3444 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
|
3445 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3446 uint32_t index; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3447 if (!debug_cast_int(cmd->args[0].value, &index)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3448 fprintf(stderr, "Argument to delete must be an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3449 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3450 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3451 bp_def **this_bp = find_breakpoint_idx(&root->breakpoints, index); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3452 if (!*this_bp) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3453 fprintf(stderr, "Breakpoint %d does not exist\n", index); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3454 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3455 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3456 bp_def *tmp = *this_bp; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3457 if (tmp->type == BP_TYPE_CPU) { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3458 remove_breakpoint(root->cpu_context, tmp->address); |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3459 } else if (tmp->type == BP_TYPE_CPU_WATCH) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3460 m68k_remove_watchpoint(root->cpu_context, tmp->address, tmp->mask); |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3461 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3462 *this_bp = (*this_bp)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3463 if (tmp->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3464 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
|
3465 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3466 free_parsed_command(tmp->commands + i); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3467 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3468 free(tmp->commands); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3469 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3470 free(tmp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3471 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3472 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3473 |
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
|
3474 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
|
3475 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3476 uint32_t address; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3477 if (!debug_cast_int(cmd->args[0].value, &address)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3478 fprintf(stderr, "Argument to breakpoint must be an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3479 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3480 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3481 insert_breakpoint(root->cpu_context, address, debugger); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3482 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
|
3483 new_bp->next = root->breakpoints; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3484 new_bp->address = address; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3485 new_bp->mask = 0xFFFFFF; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3486 new_bp->index = root->bp_index++; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3487 new_bp->type = BP_TYPE_CPU; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3488 root->breakpoints = new_bp; |
2386
9f178feb3cb0
Prefix most hex-formatted values output by debugger with $ for consistency with number literal parsing
Michael Pavone <pavone@retrodev.com>
parents:
2380
diff
changeset
|
3489 printf("68K Breakpoint %d set at $%X\n", new_bp->index, address); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3490 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3491 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3492 |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3493 static uint8_t cmd_watchpoint_m68k(debug_root *root, parsed_command *cmd) |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3494 { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3495 uint32_t address; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3496 if (!debug_cast_int(cmd->args[0].value, &address)) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3497 fprintf(stderr, "First argument to watchpoint must be an integer\n"); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3498 return 1; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3499 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3500 uint32_t size; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3501 if (cmd->num_args > 1) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3502 if (!debug_cast_int(cmd->args[1].value, &size)) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3503 fprintf(stderr, "Second argument to watchpoint must be an integer if provided\n"); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3504 return 1; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3505 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3506 } else { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3507 //default to byte for odd addresses, word for even |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3508 size = (address & 1) ? 1 : 2; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3509 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3510 m68k_add_watchpoint(root->cpu_context, address, size); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3511 bp_def *new_bp = calloc(1, sizeof(bp_def)); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3512 new_bp->next = root->breakpoints; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3513 new_bp->address = address; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3514 new_bp->mask = size; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3515 new_bp->index = root->bp_index++; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3516 new_bp->type = BP_TYPE_CPU_WATCH; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3517 root->breakpoints = new_bp; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3518 printf("68K Watchpoint %d set for $%X\n", new_bp->index, address); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3519 return 1; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3520 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3521 |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3522 static void on_vdp_reg_write(vdp_context *context, uint16_t reg, uint16_t value) |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3523 { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3524 value &= 0xFF; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3525 if (context->regs[reg] == value) { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3526 return; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3527 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3528 genesis_context *gen = (genesis_context *)context->system; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3529 debug_root *root = find_m68k_root(gen->m68k); |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3530 bp_def **this_bp = find_breakpoint(&root->breakpoints, reg, BP_TYPE_VDPREG); |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3531 int debugging = 1; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3532 if (*this_bp) { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3533 if ((*this_bp)->condition) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3534 debug_val condres; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3535 if (eval_expr(root, (*this_bp)->condition, &condres)) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3536 if (!condres.v.u32) { |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3537 return; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3538 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3539 } else { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3540 fprintf(stderr, "Failed to eval condition for VDP Register Breakpoint %u\n", (*this_bp)->index); |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3541 free_expr((*this_bp)->condition); |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3542 (*this_bp)->condition = NULL; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3543 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3544 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3545 for (uint32_t i = 0; debugging && i < (*this_bp)->num_commands; i++) |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3546 { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3547 debugging = run_command(root, (*this_bp)->commands + i); |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3548 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3549 if (debugging) { |
2386
9f178feb3cb0
Prefix most hex-formatted values output by debugger with $ for consistency with number literal parsing
Michael Pavone <pavone@retrodev.com>
parents:
2380
diff
changeset
|
3550 printf("VDP Register Breakpoint %d hit on register write $%X - Old: $%X, New: $%X\n", (*this_bp)->index, reg, context->regs[reg], value); |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3551 gen->header.enter_debugger = 1; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3552 if (gen->m68k->sync_cycle > gen->m68k->current_cycle + 1) { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3553 gen->m68k->sync_cycle = gen->m68k->current_cycle + 1; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3554 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3555 if (gen->m68k->target_cycle > gen->m68k->sync_cycle) { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3556 gen->m68k->target_cycle = gen->m68k->sync_cycle; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3557 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3558 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3559 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3560 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3561 |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3562 static uint8_t cmd_vdp_reg_break(debug_root *root, parsed_command *cmd) |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3563 { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3564 bp_def *new_bp = calloc(1, sizeof(bp_def)); |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3565 new_bp->next = root->breakpoints; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3566 if (cmd->num_args) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3567 if (!debug_cast_int(cmd->args[0].value, &new_bp->address)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3568 fprintf(stderr, "Arguments to vdpregbreak must be integers if provided\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3569 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3570 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3571 if (cmd->num_args > 1) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3572 if (!debug_cast_int(cmd->args[1].value, &new_bp->mask)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3573 fprintf(stderr, "Arguments to vdpregbreak must be integers if provided\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3574 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3575 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3576 } else { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3577 new_bp->mask = 0xFF; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3578 } |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3579 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3580 new_bp->index = root->bp_index++; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3581 new_bp->type = BP_TYPE_VDPREG; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3582 root->breakpoints = new_bp; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3583 m68k_context *m68k = root->cpu_context; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3584 genesis_context *gen = m68k->system; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3585 gen->vdp->reg_hook = on_vdp_reg_write; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3586 printf("VDP Register Breakpoint %d set\n", new_bp->index); |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3587 return 1; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3588 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3589 |
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
|
3590 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
|
3591 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3592 uint32_t address; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3593 if (!debug_cast_int(cmd->args[0].value, &address)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3594 fprintf(stderr, "Argument to advance must be an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3595 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3596 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3597 insert_breakpoint(root->cpu_context, address, debugger); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3598 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3599 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3600 |
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
|
3601 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
|
3602 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3603 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3604 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3605 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3606 if (inst->op == M68K_RTS) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3607 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
|
3608 } 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
|
3609 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
|
3610 } else if(m68k_is_branch(inst)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3611 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
|
3612 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3613 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
|
3614 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
|
3615 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3616 if (inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3617 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
|
3618 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
|
3619 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3620 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3621 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3622 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
|
3623 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
|
3624 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3625 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3626 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
|
3627 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3628 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3629 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
|
3630 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3631 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3632 |
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
|
3633 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
|
3634 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3635 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3636 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3637 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3638 if (inst->op == M68K_RTS) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3639 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
|
3640 } 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
|
3641 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
|
3642 } 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
|
3643 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
|
3644 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
|
3645 if (root->branch_t < after) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3646 root->branch_t = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3647 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3648 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3649 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
|
3650 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3651 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3652 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
|
3653 if (target > after) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3654 if (inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3655 after = target; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3656 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3657 root->branch_f = target; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3658 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3659 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
|
3660 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3661 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3662 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3663 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
|
3664 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3665 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3666 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
|
3667 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3668 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3669 |
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
|
3670 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
|
3671 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3672 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3673 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3674 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3675 if (inst->op == M68K_RTS) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3676 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
|
3677 } 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
|
3678 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
|
3679 } 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
|
3680 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
|
3681 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3682 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
|
3683 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
|
3684 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3685 if ( inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3686 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
|
3687 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
|
3688 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3689 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3690 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3691 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
|
3692 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
|
3693 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3694 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3695 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
|
3696 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3697 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3698 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
|
3699 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3700 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3701 |
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
|
3702 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
|
3703 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3704 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3705 uint32_t stack = context->aregs[7]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3706 uint8_t non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3707 do { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3708 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
|
3709 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
|
3710 if (bt_address) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3711 stack += 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3712 non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3713 m68kinst inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3714 char buf[128]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3715 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
|
3716 m68k_disasm(&inst, buf); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3717 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
|
3718 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3719 //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
|
3720 stack += 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3721 non_adr_count++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3722 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3723 //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
|
3724 } while (stack && non_adr_count < 6); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3725 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3726 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3727 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3728 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
|
3729 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3730 m68k_context *context = root->cpu_context; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3731 uint32_t address = root->address; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3732 if (cmd->num_args) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3733 if (!debug_cast_int(cmd->args[0].value, &address)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3734 fprintf(stderr, "Argument to disassemble must be an integer if provided\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3735 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3736 } |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3737 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3738 char disasm_buf[1024]; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3739 m68kinst inst; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3740 do { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3741 label_def *def = find_label(root->disasm, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3742 if (def) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3743 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
|
3744 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3745 printf("%s:\n", def->labels[i]); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3746 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3747 } |
2252
6a07b13894f7
Fix input processing while waiting for console input in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2216
diff
changeset
|
3748 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3749 address = m68k_decode(m68k_instruction_fetch, context, &inst, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3750 m68k_disasm_labels(&inst, disasm_buf, root->disasm); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3751 printf("\t%s\n", disasm_buf); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3752 } while(!m68k_is_terminal(&inst)); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3753 return 1; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3754 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3755 |
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
|
3756 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
|
3757 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3758 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3759 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3760 vdp_print_sprite_table(gen->vdp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3761 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3762 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3763 |
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
|
3764 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
|
3765 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3766 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3767 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3768 vdp_print_reg_explain(gen->vdp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3769 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3770 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3771 |
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
|
3772 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
|
3773 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3774 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3775 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
|
3776 if (cmd->num_args) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3777 ym_print_channel_info(gen->ym, cmd->args[0].value.v.u32 - 1); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3778 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3779 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
|
3780 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
|
3781 } |
2173
894c7873a2b1
Consume all expressions in debugger print command
Michael Pavone <pavone@retrodev.com>
parents:
2172
diff
changeset
|
3782 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3783 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3784 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3785 |
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
|
3786 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
|
3787 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3788 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3789 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3790 ym_print_timer_info(gen->ym); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3791 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3792 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3793 |
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
|
3794 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
|
3795 { |
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
|
3796 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3797 while (param && *param && isblank(*param)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3798 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3799 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3800 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3801 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3802 genesis_context *gen = m68k->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3803 segacd_context *cd = gen->expansion; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3804 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
|
3805 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3806 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
|
3807 if (!sub_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3808 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
|
3809 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3810 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3811 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
|
3812 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3813 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3814 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
|
3815 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3816 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3817 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3818 cd->enter_debugger = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3819 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3820 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3821 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3822 |
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
|
3823 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
|
3824 { |
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
|
3825 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3826 while (param && *param && isblank(*param)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3827 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3828 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3829 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3830 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3831 segacd_context *cd = m68k->system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
3832 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3833 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
|
3834 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3835 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
|
3836 if (!main_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3837 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
|
3838 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3839 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3840 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
|
3841 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3842 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3843 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
|
3844 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3845 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3846 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3847 cd->genesis->header.enter_debugger = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3848 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3849 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3850 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3851 |
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
|
3852 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
|
3853 { |
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
|
3854 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3855 while (param && *param && isblank(*param)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3856 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3857 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3858 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3859 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3860 genesis_context *gen = m68k->system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
3861 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3862 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
|
3863 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3864 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
|
3865 if (!z80_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3866 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
|
3867 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3868 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3869 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
|
3870 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3871 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3872 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
|
3873 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3874 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3875 } else { |
2184
408fb8a7e990
Implement argumentless variant of z80 debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2183
diff
changeset
|
3876 gen->enter_z80_debugger = 1; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3877 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3878 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3879 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3880 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3881 command_def common_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3882 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3883 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3884 "quit", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3885 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3886 .usage = "quit", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3887 .desc = "Quit BlastEm", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3888 .impl = cmd_quit, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3889 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3890 .max_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3891 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3892 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3893 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3894 "help", "?", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3895 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3896 .usage = "help", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3897 .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
|
3898 .impl = cmd_help, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3899 .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
|
3900 .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
|
3901 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3902 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3903 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3904 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3905 "continue", "c", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3906 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3907 .usage = "continue", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3908 .desc = "Resume execution", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3909 .impl = cmd_continue, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3910 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3911 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3912 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3913 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3914 .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
|
3915 "print", "p", NULL |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3916 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3917 .usage = "print[/FORMAT] EXPRESSION...", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3918 .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
|
3919 .impl = cmd_print, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3920 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3921 .max_args = -1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3922 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3923 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3924 .names = (const char *[]){ |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3925 "printf", NULL |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3926 }, |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3927 .usage = "printf FORMAT EXPRESSION...", |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3928 .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
|
3929 .impl = cmd_printf, |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3930 .min_args = 1, |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3931 .max_args = -1 |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3932 }, |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3933 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3934 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3935 "softreset", "sr", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3936 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3937 .usage = "softreset", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3938 .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
|
3939 .impl = cmd_softreset, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3940 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3941 .max_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3942 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3943 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3944 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3945 "display", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3946 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3947 .usage = "display[/FORMAT] EXPRESSION...", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3948 .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
|
3949 .impl = cmd_display, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3950 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3951 .max_args = -1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3952 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3953 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3954 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3955 "deletedisplay", "dd", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3956 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3957 .usage = "deletedisplay DISPLAYNUM", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3958 .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
|
3959 .impl = cmd_delete_display, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3960 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3961 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3962 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3963 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3964 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3965 "commands", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3966 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3967 .usage = "command BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3968 .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
|
3969 .impl = cmd_command, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3970 .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
|
3971 .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
|
3972 .has_block = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3973 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3974 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3975 .names = (const char *[]){ |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3976 "function", NULL |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3977 }, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3978 .usage = "function NAME [ARGS...]", |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3979 .desc = "Creates a user-defined function named NAME with arguments ARGS", |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3980 .impl = cmd_function, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3981 .min_args = 1, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3982 .max_args = -1, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3983 .has_block = 1, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3984 .skip_eval = 1 |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3985 }, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3986 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3987 .names = (const char *[]){ |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3988 "return", NULL |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3989 }, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3990 .usage = "return VALUE", |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3991 .desc = "Return from a user defined function with the result VALUE", |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3992 .impl = cmd_return, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3993 .min_args = 1, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3994 .max_args = 1 |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3995 }, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3996 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
3997 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3998 "set", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3999 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4000 .usage = "set MEM|NAME VALUE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4001 .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
|
4002 .impl = cmd_set, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4003 .min_args = 2, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4004 .max_args = 2, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4005 .skip_eval = 1 |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4006 }, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4007 { |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4008 .names = (const char *[]){ |
2358
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
4009 "variable", NULL |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
4010 }, |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
4011 .usage = "variable NAME [VALUE]", |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
4012 .desc = "Create a new variable called NAME and set it to VALUE or 0 if no value provided", |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
4013 .impl = cmd_variable, |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
4014 .min_args = 1, |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
4015 .max_args = 2, |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
4016 .skip_eval = 1 |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
4017 }, |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
4018 { |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2357
diff
changeset
|
4019 .names = (const char *[]){ |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4020 "array", NULL |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4021 }, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4022 .usage = "array NAME [VALUE...]", |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4023 .desc = "Create a new array called NAME if it doesn't already exist. The array is initialized with the remaining parameters", |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4024 .impl = cmd_array, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4025 .min_args = 1, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4026 .max_args = -1, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4027 .skip_eval = 1 |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4028 }, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4029 { |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4030 .names = (const char *[]){ |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4031 "append", NULL |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4032 }, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4033 .usage = "append NAME VALUE", |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4034 .desc = "Increase the size of array NAME by 1 and set the last element to VALUE", |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4035 .impl = cmd_append, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4036 .min_args = 2, |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4037 .max_args = 2 |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4038 }, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4039 { |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4040 .names = (const char *[]){ |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4041 "frames", NULL |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4042 }, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4043 .usage = "frames EXPRESSION", |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4044 .desc = "Resume execution for EXPRESSION video frames", |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4045 .impl = cmd_frames, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4046 .min_args = 1, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4047 .max_args = 1 |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4048 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4049 { |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4050 .names = (const char *[]){ |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4051 "bindup", NULL |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4052 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4053 .usage = "bindup NAME", |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4054 .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
|
4055 .impl = cmd_bindup, |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4056 .min_args = 1, |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
4057 .max_args = 1 |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4058 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4059 { |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4060 .names = (const char *[]){ |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4061 "binddown", NULL |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4062 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4063 .usage = "bindown NAME", |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4064 .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
|
4065 .impl = cmd_binddown, |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4066 .min_args = 1, |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
4067 .max_args = 1 |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4068 }, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4069 { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4070 .names = (const char *[]){ |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4071 "condition", NULL |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4072 }, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4073 .usage = "condition BREAKPOINT [EXPRESSION]", |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4074 .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
|
4075 .impl = cmd_condition, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4076 .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
|
4077 .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
|
4078 .skip_eval = 1 |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4079 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4080 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4081 .names = (const char *[]){ |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4082 "if", NULL |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4083 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4084 .usage = "if CONDITION", |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4085 .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
|
4086 .impl = cmd_if, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4087 .min_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4088 .max_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4089 .has_block = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4090 .accepts_else = 1 |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4091 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4092 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4093 .names = (const char *[]){ |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4094 "while", NULL |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4095 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4096 .usage = "while CONDITION", |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4097 .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
|
4098 .impl = cmd_while, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4099 .min_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4100 .max_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4101 .has_block = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4102 .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
|
4103 }, |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4104 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4105 .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
|
4106 "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
|
4107 }, |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4108 .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
|
4109 .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
|
4110 .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
|
4111 .min_args = 0, |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
4112 .max_args = 1 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4113 }, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4114 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4115 .names = (const char *[]){ |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4116 "save", NULL |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4117 }, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4118 .usage = "save[/SIZE] FILENAME ARRAY [COUNT]", |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4119 .desc = "Saves COUNT elements of size SIZE from the array or memory region specified by ARRAY to a file", |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4120 .impl = cmd_save, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4121 .min_args = 2, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4122 .max_args = 3, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4123 .skip_eval = 1 |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4124 }, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4125 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4126 .names = (const char *[]){ |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4127 "load", NULL |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4128 }, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4129 .usage = "load[/SIZE] FILENAME ARRAY [COUNT]", |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4130 .desc = "Loads COUNT elements of size SIZE from a file to the array or memory region specified by ARRAY", |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4131 .impl = cmd_load, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4132 .min_args = 2, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4133 .max_args = 3, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4134 .skip_eval = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4135 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4136 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4137 #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
|
4138 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4139 command_def m68k_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4140 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4141 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4142 "breakpoint", "b", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4143 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4144 .usage = "breakpoint ADDRESSS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4145 .desc = "Set a breakpoint at ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4146 .impl = cmd_breakpoint_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4147 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4148 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4149 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4150 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4151 .names = (const char *[]){ |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4152 "watchpoint", NULL |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4153 }, |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4154 .usage = "watchpoint ADDRESS [SIZE]", |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4155 .desc = "Set a watchpoint at ADDRESS with an optional SIZE in bytes. SIZE defaults to 2 for even address and 1 for odd", |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4156 .impl = cmd_watchpoint_m68k, |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4157 .min_args = 1, |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4158 .max_args = 2 |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4159 }, |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4160 { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4161 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4162 "advance", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4163 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4164 .usage = "advance ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4165 .desc = "Advance to ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4166 .impl = cmd_advance_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4167 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4168 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4169 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4170 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4171 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4172 "step", "s", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4173 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4174 .usage = "step", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4175 .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
|
4176 .impl = cmd_step_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4177 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4178 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4179 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4180 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4181 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4182 "over", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4183 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4184 .usage = "over", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4185 .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
|
4186 .impl = cmd_over_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4187 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4188 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4189 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4190 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4191 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4192 "next", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4193 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4194 .usage = "next", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4195 .desc = "Advance to the next instruction", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4196 .impl = cmd_next_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4197 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4198 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4199 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4200 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4201 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4202 "backtrace", "bt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4203 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4204 .usage = "backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4205 .desc = "Print a backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4206 .impl = cmd_backtrace_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4207 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4208 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4209 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4210 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4211 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4212 "delete", "d", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4213 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4214 .usage = "delete BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4215 .desc = "Remove breakpoint identified by BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4216 .impl = cmd_delete_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4217 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4218 .max_args = 1 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4219 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4220 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4221 .names = (const char *[]){ |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4222 "disassemble", "disasm", NULL |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4223 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4224 .usage = "disassemble [ADDRESS]", |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4225 .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
|
4226 .impl = cmd_disassemble_m68k, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4227 .min_args = 0, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4228 .max_args = 1 |
2112
3abb64bd0da6
Add support for printing strings in 68K debugger
Michael Pavone <pavone@retrodev.com>
parents:
2107
diff
changeset
|
4229 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4230 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4231 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4232 #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
|
4233 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4234 command_def genesis_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4235 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4236 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4237 "vdpsprites", "vs", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4238 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4239 .usage = "vdpsprites", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4240 .desc = "Print the VDP sprite table", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4241 .impl = cmd_vdp_sprites, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4242 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4243 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4244 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4245 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4246 .names = (const char *[]){ |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4247 "vdpregs", "vr", NULL |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4248 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4249 .usage = "vdpregs", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4250 .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
|
4251 .impl = cmd_vdp_regs, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4252 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4253 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4254 }, |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4255 { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4256 .names = (const char *[]){ |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4257 "vdpregbreak", "vregbreak", "vrb", NULL |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4258 }, |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4259 .usage = "vdpregbreak [REGISTER [MASK]]", |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4260 .desc = "Enter debugger on VDP register write. If REGISTER is provided, breakpoint will only fire for writes to that register. If MASK is also provided, it will be applied to the register number before comparison with REGISTER", |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4261 .impl = cmd_vdp_reg_break, |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4262 .min_args = 0, |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4263 .max_args = 2 |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4264 }, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4265 #ifndef NO_Z80 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4266 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4267 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4268 "z80", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4269 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4270 .usage = "z80 [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4271 .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
|
4272 .impl = cmd_gen_z80, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4273 .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
|
4274 .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
|
4275 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4276 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4277 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4278 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4279 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4280 "ymchannel", "yc", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4281 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4282 .usage = "ymchannel [CHANNEL]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4283 .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
|
4284 .impl = cmd_ym_channel, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4285 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4286 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4287 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4288 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4289 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4290 "ymtimer", "yt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4291 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4292 .usage = "ymtimer", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4293 .desc = "Print YM-2612 timer info", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4294 .impl = cmd_ym_timer, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4295 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4296 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4297 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4298 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4299 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4300 #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
|
4301 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4302 command_def scd_main_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4303 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4304 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4305 "subcpu", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4306 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4307 .usage = "subcpu [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4308 .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
|
4309 .impl = cmd_sub, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4310 .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
|
4311 .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
|
4312 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4313 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4314 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4315 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4316 #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
|
4317 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4318 command_def scd_sub_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4319 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4320 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4321 "maincpu", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4322 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4323 .usage = "maincpu [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4324 .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
|
4325 .impl = cmd_main, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4326 .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
|
4327 .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
|
4328 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4329 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4330 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4331 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4332 #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
|
4333 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4334 #ifndef NO_Z80 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4335 |
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
|
4336 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
|
4337 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4338 uint32_t index; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4339 if (!debug_cast_int(cmd->args[0].value, &index)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4340 fprintf(stderr, "Argument to delete must be an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4341 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4342 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4343 bp_def **this_bp = find_breakpoint_idx(&root->breakpoints, index); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4344 if (!*this_bp) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4345 fprintf(stderr, "Breakpoint %d does not exist\n", index); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4346 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4347 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4348 bp_def *tmp = *this_bp; |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4349 if (tmp->type == BP_TYPE_CPU) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4350 zremove_breakpoint(root->cpu_context, tmp->address); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4351 } else if (tmp->type == BP_TYPE_CPU_WATCH) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4352 z80_remove_watchpoint(root->cpu_context, tmp->address, tmp->mask); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4353 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4354 *this_bp = (*this_bp)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4355 if (tmp->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4356 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
|
4357 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4358 free_parsed_command(tmp->commands + i); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4359 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4360 free(tmp->commands); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4361 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4362 free(tmp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4363 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4364 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4365 |
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
|
4366 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
|
4367 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4368 uint32_t address; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4369 if (!debug_cast_int(cmd->args[0].value, &address)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4370 fprintf(stderr, "Argument to breakpoint must be an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4371 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4372 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4373 zinsert_breakpoint(root->cpu_context, address, (uint8_t *)zdebugger); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4374 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
|
4375 new_bp->next = root->breakpoints; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4376 new_bp->address = address; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4377 new_bp->mask = 0xFFFF; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4378 new_bp->type = BP_TYPE_CPU; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4379 new_bp->index = root->bp_index++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4380 root->breakpoints = new_bp; |
2386
9f178feb3cb0
Prefix most hex-formatted values output by debugger with $ for consistency with number literal parsing
Michael Pavone <pavone@retrodev.com>
parents:
2380
diff
changeset
|
4381 printf("Z80 Breakpoint %d set at $%X\n", new_bp->index, address); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4382 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4383 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4384 |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4385 static uint8_t cmd_watchpoint_z80(debug_root *root, parsed_command *cmd) |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4386 { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4387 uint32_t address; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4388 if (!debug_cast_int(cmd->args[0].value, &address)) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4389 fprintf(stderr, "First argument to watchpoint must be an integer\n"); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4390 return 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4391 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4392 uint32_t size = 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4393 if (cmd->num_args > 1) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4394 if (!debug_cast_int(cmd->args[1].value, &size)) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4395 fprintf(stderr, "Second argument to watchpoint must be an integer if provided\n"); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4396 return 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4397 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4398 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4399 z80_add_watchpoint(root->cpu_context, address, size); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4400 bp_def *new_bp = calloc(1, sizeof(bp_def)); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4401 new_bp->next = root->breakpoints; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4402 new_bp->address = address; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4403 new_bp->mask = size; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4404 new_bp->index = root->bp_index++; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4405 new_bp->type = BP_TYPE_CPU_WATCH; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4406 root->breakpoints = new_bp; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4407 printf("Z80 Watchpoint %d set for $%X\n", new_bp->index, address); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4408 return 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4409 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4410 |
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
|
4411 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
|
4412 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4413 uint32_t address; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4414 if (!debug_cast_int(cmd->args[0].value, &address)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4415 fprintf(stderr, "Argument to advance must be an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4416 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4417 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4418 zinsert_breakpoint(root->cpu_context, address, (uint8_t *)zdebugger); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4419 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4420 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4421 |
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
|
4422 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
|
4423 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4424 z80inst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4425 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4426 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4427 //TODO: handle conditional branches |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4428 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
|
4429 if (inst->addr_mode == Z80_IMMED) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4430 after = inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4431 } 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
|
4432 #ifndef NEW_CORE |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4433 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
|
4434 } 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
|
4435 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
|
4436 } 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
|
4437 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
|
4438 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4439 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4440 } else if(inst->op == Z80_JR) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4441 after += inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4442 } else if(inst->op == Z80_RET) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4443 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
|
4444 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4445 after = *sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4446 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
|
4447 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4448 after |= *sp << 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4449 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4450 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4451 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4452 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
|
4453 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4454 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4455 |
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
|
4456 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
|
4457 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4458 fputs("not implemented yet\n", stderr); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4459 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4460 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4461 |
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
|
4462 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
|
4463 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4464 z80inst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4465 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4466 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4467 //TODO: handle conditional branches |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4468 if (inst->op == Z80_JP) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4469 if (inst->addr_mode == Z80_IMMED) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4470 after = inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4471 } 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
|
4472 #ifndef NEW_CORE |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4473 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
|
4474 } 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
|
4475 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
|
4476 } 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
|
4477 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
|
4478 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4479 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4480 } else if(inst->op == Z80_JR) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4481 after += inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4482 } else if(inst->op == Z80_RET) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4483 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
|
4484 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4485 after = *sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4486 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
|
4487 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4488 after |= *sp << 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4489 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4490 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4491 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4492 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
|
4493 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4494 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4495 |
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
|
4496 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
|
4497 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4498 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4499 uint32_t stack = context->sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4500 uint8_t non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4501 do { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4502 uint32_t bt_address = stack; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4503 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
|
4504 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4505 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4506 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
|
4507 if (bt_address != 0xFEEDFEED) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4508 stack += 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4509 non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4510 z80inst inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4511 char buf[128]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4512 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
|
4513 z80_decode(pc, &inst); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4514 z80_disasm(&inst, buf, bt_address); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4515 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
|
4516 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4517 //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
|
4518 stack++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4519 non_adr_count++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4520 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4521 //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
|
4522 } while (stack && non_adr_count < 6); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4523 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4524 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4525 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4526 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
|
4527 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4528 z80_context *context = root->cpu_context; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4529 uint32_t address = root->address; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4530 if (cmd->num_args) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4531 if (!debug_cast_int(cmd->args[0].value, &address)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4532 fprintf(stderr, "Argument to disassemble must be an integer if provided\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4533 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4534 } |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4535 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4536 char disasm_buf[1024]; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4537 z80inst inst; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4538 do { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4539 label_def *def = find_label(root->disasm, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4540 if (def) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4541 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
|
4542 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4543 printf("%s:\n", def->labels[i]); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4544 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4545 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4546 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
|
4547 uint8_t *after = z80_decode(pc, &inst); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4548 z80_disasm(&inst, disasm_buf, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4549 address += after - pc; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4550 printf("\t%s\n", disasm_buf); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4551 } while(!z80_is_terminal(&inst)); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4552 return 1; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4553 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4554 |
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
|
4555 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
|
4556 { |
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
|
4557 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
|
4558 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
|
4559 { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4560 ++param; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4561 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4562 genesis_context *gen = (genesis_context *)current_system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
4563 |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4564 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
|
4565 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
|
4566 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
|
4567 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
|
4568 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
|
4569 return 1; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4570 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4571 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
|
4572 return 1; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4573 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4574 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
|
4575 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
|
4576 return ret; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4577 } else { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4578 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
|
4579 return 0; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4580 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4581 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4582 |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4583 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
|
4584 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4585 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
|
4586 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
|
4587 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
|
4588 return 1; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4589 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4590 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4591 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
|
4592 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4593 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
|
4594 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
|
4595 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
|
4596 return 1; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4597 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4598 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4599 command_def z80_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4600 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4601 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4602 "breakpoint", "b", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4603 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4604 .usage = "breakpoint ADDRESSS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4605 .desc = "Set a breakpoint at ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4606 .impl = cmd_breakpoint_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4607 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4608 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4609 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4610 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4611 .names = (const char *[]){ |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4612 "watchpoint", NULL |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4613 }, |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4614 .usage = "watchpoint ADDRESS [SIZE]", |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4615 .desc = "Set a watchpoint at ADDRESS with an optional SIZE in bytes. SIZE defaults to 1", |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4616 .impl = cmd_watchpoint_z80, |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4617 .min_args = 1, |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4618 .max_args = 2 |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4619 }, |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4620 { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4621 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4622 "advance", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4623 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4624 .usage = "advance ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4625 .desc = "Advance to ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4626 .impl = cmd_advance_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4627 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4628 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4629 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4630 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4631 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4632 "step", "s", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4633 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4634 .usage = "step", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4635 .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
|
4636 .impl = cmd_step_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4637 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4638 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4639 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4640 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4641 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4642 "over", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4643 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4644 .usage = "over", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4645 .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
|
4646 .impl = cmd_over_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4647 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4648 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4649 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4650 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4651 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4652 "next", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4653 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4654 .usage = "next", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4655 .desc = "Advance to the next instruction", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4656 .impl = cmd_next_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4657 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4658 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4659 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4660 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4661 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4662 "backtrace", "bt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4663 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4664 .usage = "backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4665 .desc = "Print a backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4666 .impl = cmd_backtrace_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4667 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4668 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4669 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4670 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4671 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4672 "delete", "d", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4673 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4674 .usage = "delete BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4675 .desc = "Remove breakpoint identified by BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4676 .impl = cmd_delete_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4677 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4678 .max_args = 1 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4679 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4680 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4681 .names = (const char *[]){ |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4682 "disassemble", "disasm", NULL |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4683 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4684 .usage = "disassemble [ADDRESS]", |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4685 .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
|
4686 .impl = cmd_disassemble_z80, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4687 .min_args = 0, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4688 .max_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4689 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4690 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4691 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4692 #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
|
4693 |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4694 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
|
4695 { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4696 .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
|
4697 "m68k", NULL |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4698 }, |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4699 .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
|
4700 .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
|
4701 .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
|
4702 .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
|
4703 .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
|
4704 .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
|
4705 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4706 }; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4707 |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4708 #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
|
4709 |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4710 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
|
4711 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4712 .names = (const char *[]){ |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4713 "vdpsprites", "vs", NULL |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4714 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4715 .usage = "vdpsprites", |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4716 .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
|
4717 .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
|
4718 .min_args = 0, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4719 .max_args = 0 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4720 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4721 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4722 .names = (const char *[]){ |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4723 "vdpsregs", "vr", NULL |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4724 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4725 .usage = "vdpregs", |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4726 .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
|
4727 .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
|
4728 .min_args = 0, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4729 .max_args = 0 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4730 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4731 }; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4732 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4733 #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
|
4734 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4735 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4736 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4737 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
|
4738 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4739 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
|
4740 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4741 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
|
4742 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4743 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
|
4744 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4745 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4746 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4747 |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4748 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
|
4749 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4750 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
|
4751 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
|
4752 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
|
4753 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4754 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
|
4755 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4756 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4757 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4758 static debug_val debug_frame_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4759 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4760 vdp_context *vdp = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4761 return debug_int(vdp->frame); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4762 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4763 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4764 static uint32_t m68k_chunk_end(debug_root *root, uint32_t start_address) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4765 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4766 m68k_context *m68k = root->cpu_context; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4767 memmap_chunk const *chunk = find_map_chunk(start_address, &m68k->options->gen, 0, NULL); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4768 if (!chunk) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4769 return start_address; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4770 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4771 if (chunk->mask == m68k->options->gen.address_mask) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4772 return chunk->end; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4773 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4774 return (start_address & ~chunk->mask) + chunk->mask + 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4775 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4776 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4777 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
|
4778 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4779 debug_root *root = find_root(context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4780 if (root && !root->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4781 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
|
4782 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
|
4783 root->read_mem = read_m68k; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4784 root->write_mem = write_m68k; |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4785 root->chunk_end = m68k_chunk_end; |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4786 root->disasm = create_68000_disasm(); |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4787 m68k_names(root); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4788 debug_var *var; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4789 switch (current_system->type) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4790 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4791 case SYSTEM_GENESIS: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4792 case SYSTEM_SEGACD: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4793 //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
|
4794 if (context->system == current_system) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4795 genesis_context *gen = context->system; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4796 root->other_roots = tern_insert_ptr(root->other_roots, "z80", find_z80_root(gen->z80)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4797 root->other_roots = tern_insert_ptr(root->other_roots, "vdp", find_vdp_root(gen->vdp)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4798 root->other_roots = tern_insert_ptr(root->other_roots, "ym", find_ym2612_root(gen->ym)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4799 root->other_roots = tern_insert_ptr(root->other_roots, "psg", find_psg_root(gen->psg)); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4800 add_commands(root, genesis_commands, NUM_GENESIS); |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4801 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4802 var->get = debug_frame_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4803 var->ptr = gen->vdp; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4804 root->variables = tern_insert_ptr(root->variables, "frame", var); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4805 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
|
4806 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
|
4807 add_commands(root, scd_main_commands, NUM_SCD_MAIN); |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4808 segacd_context *scd = gen->expansion; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4809 root->other_roots = tern_insert_ptr(root->other_roots, "sub", find_m68k_root(scd->m68k)); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4810 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4811 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4812 } 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
|
4813 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
|
4814 add_commands(root, scd_sub_commands, NUM_SCD_SUB); |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4815 segacd_context *scd = context->system; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4816 root->other_roots = tern_insert_ptr(root->other_roots, "main", find_m68k_root(scd->genesis->m68k)); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4817 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4818 default: |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4819 break; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4820 } |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4821 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
|
4822 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4823 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
|
4824 } |
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
|
4825 |
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
|
4826 #ifndef NO_Z80 |
548
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
4827 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4828 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
|
4829 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4830 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4831 uint32_t address = *out; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4832 *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
|
4833 if (size == 'w') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4834 *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
|
4835 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4836 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4837 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4838 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4839 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
|
4840 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4841 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4842 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
|
4843 if (size == 'w') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4844 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
|
4845 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4846 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4847 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4848 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4849 static debug_val z80_reg8_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4850 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4851 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4852 return debug_int(context->regs[var->val.v.u32]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4853 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4854 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4855 static void z80_reg8_set(debug_var *var, debug_val val) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4856 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4857 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4858 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4859 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4860 fprintf(stderr, "Z80 register %s can only be set to an integer\n", z80_regs[var->val.v.u32]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4861 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4862 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4863 context->regs[var->val.v.u32] = ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4864 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4865 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4866 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4867 static debug_val z80_alt_reg8_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4868 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4869 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4870 return debug_int(context->alt_regs[var->val.v.u32]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4871 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4872 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4873 static void z80_alt_reg8_set(debug_var *var, debug_val val) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4874 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4875 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4876 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4877 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4878 fprintf(stderr, "Z80 register %s' can only be set to an integer\n", z80_regs[var->val.v.u32]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4879 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4880 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4881 context->alt_regs[var->val.v.u32] = ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4882 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4883 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4884 static debug_val z80_flags_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4885 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4886 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4887 debug_val ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4888 ret.type = DBG_VAL_U32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4889 ret.v.u32 = context->flags[ZF_S] << 7; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4890 ret.v.u32 |= context->flags[ZF_Z] << 6; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4891 ret.v.u32 |= context->flags[ZF_H] << 4; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4892 ret.v.u32 |= context->flags[ZF_PV] << 2; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4893 ret.v.u32 |= context->flags[ZF_N] << 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4894 ret.v.u32 |= context->flags[ZF_C]; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4895 return ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4896 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4897 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4898 static debug_val z80_alt_flags_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4899 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4900 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4901 debug_val ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4902 ret.type = DBG_VAL_U32; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4903 ret.v.u32 = context->alt_flags[ZF_S] << 7; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4904 ret.v.u32 |= context->alt_flags[ZF_Z] << 6; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4905 ret.v.u32 |= context->alt_flags[ZF_H] << 4; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4906 ret.v.u32 |= context->alt_flags[ZF_PV] << 2; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4907 ret.v.u32 |= context->alt_flags[ZF_N] << 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4908 ret.v.u32 |= context->alt_flags[ZF_C]; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4909 return ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4910 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4911 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4912 static void z80_flags_set(debug_var *var, debug_val val) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4913 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4914 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4915 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4916 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4917 fprintf(stderr, "Z80 register F can only be set to an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4918 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4919 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4920 context->flags[ZF_S] = ival >> 7 & 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4921 context->flags[ZF_Z] = ival >> 6 & 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4922 context->flags[ZF_H] = ival >> 4 & 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4923 context->flags[ZF_PV] = ival >> 2 & 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4924 context->flags[ZF_N] = ival >> 1 & 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4925 context->flags[ZF_C] = ival & 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4926 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4927 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4928 static void z80_alt_flags_set(debug_var *var, debug_val val) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4929 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4930 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4931 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4932 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4933 fprintf(stderr, "Z80 register F' can only be set to an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4934 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4935 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4936 context->alt_flags[ZF_S] = ival >> 7 & 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4937 context->alt_flags[ZF_Z] = ival >> 6 & 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4938 context->alt_flags[ZF_H] = ival >> 4 & 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4939 context->alt_flags[ZF_PV] = ival >> 2 & 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4940 context->alt_flags[ZF_N] = ival >> 1 & 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4941 context->alt_flags[ZF_C] = ival & 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4942 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4943 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4944 static debug_val z80_regpair_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4945 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4946 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4947 debug_val ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4948 if (var->val.v.u32 == Z80_AF) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4949 ret = z80_flags_get(var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4950 ret.v.u32 |= context->regs[Z80_A] << 8; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4951 } else { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4952 ret = debug_int(context->regs[z80_high_reg(var->val.v.u32)] << 8 | context->regs[z80_low_reg(var->val.v.u32)]); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4953 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4954 return ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4955 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4956 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4957 static void z80_regpair_set(debug_var *var, debug_val val) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4958 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4959 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4960 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4961 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4962 fprintf(stderr, "Z80 register %s can only be set to an integer\n", z80_regs[var->val.v.u32]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4963 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4964 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4965 if (var->val.v.u32 == Z80_AF) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4966 context->regs[Z80_A] = ival >> 8; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4967 z80_flags_set(var, val); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4968 } else { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4969 context->regs[z80_high_reg(var->val.v.u32)] = ival >> 8; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4970 context->regs[z80_low_reg(var->val.v.u32)] = ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4971 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4972 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4973 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4974 static debug_val z80_alt_regpair_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4975 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4976 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4977 debug_val ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4978 if (var->val.v.u32 == Z80_AF) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4979 ret = z80_alt_flags_get(var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4980 ret.v.u32 |= context->alt_regs[Z80_A] << 8; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4981 } else { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4982 ret = debug_int(context->alt_regs[z80_high_reg(var->val.v.u32)] << 8 | context->alt_regs[z80_low_reg(var->val.v.u32)]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4983 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4984 return ret; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4985 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4986 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4987 static void z80_alt_regpair_set(debug_var *var, debug_val val) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4988 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4989 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4990 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4991 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4992 fprintf(stderr, "Z80 register %s' can only be set to an integer\n", z80_regs[var->val.v.u32]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4993 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4994 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4995 if (var->val.v.u32 == Z80_AF) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4996 context->regs[Z80_A] = ival >> 8; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4997 z80_alt_flags_set(var, val); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4998 } else { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4999 context->alt_regs[z80_high_reg(var->val.v.u32)] = ival >> 8; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5000 context->alt_regs[z80_low_reg(var->val.v.u32)] = ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5001 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5002 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5003 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5004 static debug_val z80_sp_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5005 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5006 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5007 return debug_int(context->sp); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5008 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5009 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5010 static void z80_sp_set(debug_var *var, debug_val val) |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5011 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5012 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5013 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5014 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5015 fprintf(stderr, "Z80 register sp can only be set to an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5016 return; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5017 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5018 context->sp = ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5019 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5020 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5021 static debug_val z80_im_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5022 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5023 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5024 return debug_int(context->im); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5025 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5026 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5027 static void z80_im_set(debug_var *var, debug_val val) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5028 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5029 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5030 uint32_t ival; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5031 if (!debug_cast_int(val, &ival)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5032 fprintf(stderr, "Z80 register im can only be set to an integer\n"); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5033 return; |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5034 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5035 context->im = ival & 3; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5036 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5037 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5038 static debug_val z80_iff1_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5039 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5040 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5041 return debug_int(context->iff1); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5042 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5043 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5044 static void z80_iff1_set(debug_var *var, debug_val val) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5045 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5046 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5047 context->iff1 = debug_cast_bool(val); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5048 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5049 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5050 static debug_val z80_iff2_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5051 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5052 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5053 return debug_int(context->iff2); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5054 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5055 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5056 static void z80_iff2_set(debug_var *var, debug_val val) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5057 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5058 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5059 context->iff2 = debug_cast_bool(val); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5060 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5061 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5062 static debug_val z80_cycle_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5063 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5064 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5065 return debug_int(context->current_cycle); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5066 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5067 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5068 static debug_val z80_pc_get(debug_var *var) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5069 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5070 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5071 return debug_int(context->pc); |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5072 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5073 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5074 static void z80_names(debug_root *root) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5075 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5076 debug_var *var; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5077 for (int i = 0; i < Z80_UNUSED; i++) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5078 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5079 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5080 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5081 if (i < Z80_BC) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5082 var->get = z80_reg8_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5083 var->set = z80_reg8_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5084 } else if (i == Z80_SP) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5085 var->get = z80_sp_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5086 var->set = z80_sp_set; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5087 } else { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5088 var->get = z80_regpair_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5089 var->set = z80_regpair_set; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5090 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5091 var->val.v.u32 = i; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5092 root->variables = tern_insert_ptr(root->variables, z80_regs[i], var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5093 size_t name_size = strlen(z80_regs[i]); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5094 char *name = malloc(name_size + 2); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5095 char *d = name; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5096 for (const char *c = z80_regs[i]; *c; c++, d++) |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5097 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5098 *d = toupper(*c); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5099 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5100 name[name_size] = 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5101 root->variables = tern_insert_ptr(root->variables, name, var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5102 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5103 if (i < Z80_IXL || (i > Z80_R && i < Z80_IX && i != Z80_SP)) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5104 memcpy(name, z80_regs[i], name_size); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5105 name[name_size] = '\''; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5106 name[name_size + 1] = 0; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5107 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5108 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5109 if (i < Z80_BC) { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5110 var->get = z80_alt_reg8_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5111 var->set = z80_alt_reg8_set; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5112 } else { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5113 var->get = z80_alt_regpair_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5114 var->set = z80_alt_regpair_set; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5115 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5116 var->val.v.u32 = i; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5117 root->variables = tern_insert_ptr(root->variables, name, var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5118 d = name; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5119 for (const char *c = z80_regs[i]; *c; c++, d++) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5120 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5121 *d = toupper(*c); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5122 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5123 root->variables = tern_insert_ptr(root->variables, name, var); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5124 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5125 free(name); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5126 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5127 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5128 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5129 var->get = z80_flags_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5130 var->set = z80_flags_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5131 root->variables = tern_insert_ptr(root->variables, "f", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5132 root->variables = tern_insert_ptr(root->variables, "F", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5133 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5134 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5135 var->get = z80_alt_flags_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5136 var->set = z80_alt_flags_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5137 root->variables = tern_insert_ptr(root->variables, "f'", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5138 root->variables = tern_insert_ptr(root->variables, "F'", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5139 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5140 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5141 var->get = z80_im_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5142 var->set = z80_im_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5143 root->variables = tern_insert_ptr(root->variables, "im", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5144 root->variables = tern_insert_ptr(root->variables, "IM", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5145 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5146 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5147 var->get = z80_iff1_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5148 var->set = z80_iff1_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5149 root->variables = tern_insert_ptr(root->variables, "iff1", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5150 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5151 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5152 var->get = z80_iff2_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5153 var->set = z80_iff2_set; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5154 root->variables = tern_insert_ptr(root->variables, "iff2", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5155 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5156 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5157 var->get = z80_cycle_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5158 root->variables = tern_insert_ptr(root->variables, "cycle", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5159 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5160 var->ptr = root->cpu_context; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5161 var->get = z80_pc_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5162 root->variables = tern_insert_ptr(root->variables, "pc", var); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5163 root->variables = tern_insert_ptr(root->variables, "PC", var); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5164 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5165 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5166 static uint32_t z80_chunk_end(debug_root *root, uint32_t start_address) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5167 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5168 z80_context *z80 = root->cpu_context; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5169 memmap_chunk const *chunk = find_map_chunk(start_address, &z80->options->gen, 0, NULL); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5170 if (!chunk) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5171 return start_address; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5172 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5173 if (chunk->mask == z80->options->gen.address_mask) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5174 return chunk->end; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5175 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5176 return (start_address & ~chunk->mask) + chunk->mask + 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5177 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5178 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5179 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
|
5180 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5181 debug_root *root = find_root(context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5182 if (root && !root->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5183 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
|
5184 add_commands(root, z80_commands, NUM_Z80); |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5185 z80_names(root); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5186 genesis_context *gen; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5187 sms_context *sms; |
2413
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5188 coleco_context *coleco; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5189 debug_var *var; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5190 //TODO: populate names |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5191 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
|
5192 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5193 case SYSTEM_GENESIS: |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5194 case SYSTEM_SEGACD: |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5195 gen = context->system; |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
5196 add_commands(root, gen_z80_commands, NUM_GEN_Z80); |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5197 root->other_roots = tern_insert_ptr(root->other_roots, "m68k", find_m68k_root(gen->m68k)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5198 //root->resolve = resolve_z80; |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5199 break; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5200 case SYSTEM_SMS: |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5201 sms = context->system; |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5202 add_commands(root, sms_commands, NUM_SMS); |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5203 root->other_roots = tern_insert_ptr(root->other_roots, "vdp", find_vdp_root(sms->vdp)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5204 root->other_roots = tern_insert_ptr(root->other_roots, "psg", find_psg_root(sms->psg)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5205 var = calloc(1, sizeof(debug_var)); |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5206 var->get = debug_frame_get; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5207 var->ptr = sms->vdp; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5208 root->variables = tern_insert_ptr(root->variables, "frame", var); |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5209 break; |
2413
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5210 case SYSTEM_COLECOVISION: |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5211 coleco = context->system; |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5212 root->other_roots = tern_insert_ptr(root->other_roots, "vdp", find_vdp_root(coleco->vdp)); |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5213 root->other_roots = tern_insert_ptr(root->other_roots, "psg", find_psg_root(coleco->psg)); |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5214 break; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5215 //default: |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5216 //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
|
5217 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5218 root->read_mem = read_z80; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5219 root->write_mem = write_z80; |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
5220 root->disasm = create_z80_disasm(); |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5221 root->chunk_end = z80_chunk_end; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5222 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5223 return root; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5224 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5225 |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5226 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
|
5227 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5228 static char last_cmd[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5229 char input_buf[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5230 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
|
5231 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
|
5232 init_terminal(); |
2180
b87658ba3b94
Fix bug in Z80 debugger for SMS mode post-refactor
Michael Pavone <pavone@retrodev.com>
parents:
2179
diff
changeset
|
5233 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
|
5234 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
|
5235 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
|
5236 } |
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
|
5237 root->address = address; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5238 //Check if this is a user set breakpoint, or just a temporary one |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5239 int debugging; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
5240 bp_def ** this_bp = find_breakpoint(&root->breakpoints, address, BP_TYPE_CPU); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5241 if (*this_bp) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5242 if ((*this_bp)->condition) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5243 debug_val condres; |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5244 if (eval_expr(root, (*this_bp)->condition, &condres)) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5245 if (!condres.v.u32) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5246 return context; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5247 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5248 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5249 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
|
5250 free_expr((*this_bp)->condition); |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5251 (*this_bp)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5252 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5253 } |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5254 debugging = 1; |
2208
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5255 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
|
5256 { |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5257 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
|
5258 } |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5259 if (debugging) { |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5260 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
|
5261 } else { |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5262 fflush(stdout); |
2208
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5263 return context; |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5264 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5265 } else { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5266 zremove_breakpoint(context, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5267 } |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5268 if (context->wp_hit) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5269 context->wp_hit = 0; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5270 this_bp = find_breakpoint(&root->breakpoints, context->wp_hit_address, BP_TYPE_CPU_WATCH); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5271 if (*this_bp) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5272 if ((*this_bp)->condition) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5273 debug_val condres; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5274 if (eval_expr(root, (*this_bp)->condition, &condres)) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5275 if (!condres.v.u32) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5276 return context; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5277 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5278 } else { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5279 fprintf(stderr, "Failed to eval condition for Z80 watchpoint %u\n", (*this_bp)->index); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5280 free_expr((*this_bp)->condition); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5281 (*this_bp)->condition = NULL; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5282 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5283 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5284 debugging = 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5285 for (uint32_t i = 0; debugging && i < (*this_bp)->num_commands; i++) |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5286 { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5287 debugging = run_command(root, (*this_bp)->commands + i); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5288 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5289 if (debugging) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5290 if (context->wp_old_value != context->wp_hit_value) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5291 printf("Z80 Watchpoint %d hit, old value: %X, new value %X\n", (*this_bp)->index, context->wp_old_value, context->wp_hit_value); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5292 } else { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5293 printf("Z80 Watchpoint %d hit\n", (*this_bp)->index); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5294 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5295 } else { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5296 fflush(stdout); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5297 return context; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5298 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5299 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5300 } |
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
|
5301 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
|
5302 if (!pc) { |
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
1111
diff
changeset
|
5303 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
|
5304 } |
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
|
5305 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
|
5306 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
|
5307 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
|
5308 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
|
5309 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
|
5310 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
|
5311 make_format_str(format_str, cur->format); |
2183
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5312 for (int i = 0; i < cur->num_args; i++) |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5313 { |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5314 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
|
5315 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
|
5316 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5317 } |
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
|
5318 |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5319 z80_disasm(&inst, input_buf, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5320 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
|
5321 debugger_repl(root); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5322 return context; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5323 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5324 |
548
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
5325 #endif |
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
5326 |
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
|
5327 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
|
5328 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5329 static char last_cmd[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5330 char input_buf[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5331 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
|
5332 |
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
|
5333 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
|
5334 |
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
|
5335 context->options->sync_components(context, 0); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5336 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
|
5337 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
|
5338 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
|
5339 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5340 //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
|
5341 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
|
5342 if (address == root->branch_t) { |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
5343 bp_def ** f_bp = find_breakpoint(&root->breakpoints, root->branch_f, BP_TYPE_CPU); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5344 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
|
5345 remove_breakpoint(context, root->branch_f); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5346 } |
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
|
5347 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
|
5348 } else if(address == root->branch_f) { |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
5349 bp_def ** t_bp = find_breakpoint(&root->breakpoints, root->branch_t, BP_TYPE_CPU); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5350 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
|
5351 remove_breakpoint(context, root->branch_t); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5352 } |
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
|
5353 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
|
5354 } |
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
|
5355 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5356 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
|
5357 int debugging = 1; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5358 //Check if this is a user set breakpoint, or just a temporary one |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
5359 bp_def ** this_bp = find_breakpoint(&root->breakpoints, address, BP_TYPE_CPU); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5360 if (*this_bp) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5361 if ((*this_bp)->condition) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5362 debug_val condres; |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5363 if (eval_expr(root, (*this_bp)->condition, &condres)) { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5364 if (!condres.v.u32) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5365 return; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5366 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5367 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5368 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
|
5369 free_expr((*this_bp)->condition); |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5370 (*this_bp)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5371 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5372 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5373 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
|
5374 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5375 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
|
5376 } |
5a3ac6093ea2
Add support for executing a list of debugger commands when a breakpoint is hit
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
5377 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
|
5378 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
|
5379 } else { |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5380 fflush(stdout); |
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
|
5381 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
|
5382 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5383 } else { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5384 remove_breakpoint(context, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5385 } |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5386 if (context->wp_hit) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5387 context->wp_hit = 0; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5388 this_bp = find_breakpoint(&root->breakpoints, context->wp_hit_address, BP_TYPE_CPU_WATCH); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5389 if (*this_bp) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5390 if ((*this_bp)->condition) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5391 debug_val condres; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5392 if (eval_expr(root, (*this_bp)->condition, &condres)) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5393 if (!condres.v.u32) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5394 return; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5395 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5396 } else { |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5397 fprintf(stderr, "Failed to eval condition for M68K watchpoint %u\n", (*this_bp)->index); |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5398 free_expr((*this_bp)->condition); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5399 (*this_bp)->condition = NULL; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5400 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5401 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5402 for (uint32_t i = 0; debugging && i < (*this_bp)->num_commands; i++) |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5403 { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5404 debugging = run_command(root, (*this_bp)->commands + i); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5405 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5406 if (debugging) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5407 if (context->wp_old_value != context->wp_hit_value) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5408 printf("68K Watchpoint %d hit, old value: %X, new value %X\n", (*this_bp)->index, context->wp_old_value, context->wp_hit_value); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5409 } else { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5410 printf("68K Watchpoint %d hit\n", (*this_bp)->index); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5411 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5412 } else { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5413 fflush(stdout); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5414 return; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5415 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5416 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5417 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5418 if (context->system == current_system) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5419 genesis_context *gen = context->system; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5420 vdp_force_update_framebuffer(gen->vdp); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5421 } |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5422 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
|
5423 root->after = after; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5424 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
|
5425 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
|
5426 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
|
5427 make_format_str(format_str, cur->format); |
2183
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5428 for (int i = 0; i < cur->num_args; i++) |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5429 { |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5430 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
|
5431 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
|
5432 } |
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
|
5433 } |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
5434 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
|
5435 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
|
5436 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
|
5437 return; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5438 } |