Mercurial > repos > blastem
annotate debug.c @ 2487:2ea2f3aa5aa8
Remove dis.exe and zdis.exe from Windows builds due to silly antivirus false positives
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 15 Apr 2024 23:00:02 -0700 |
parents | cb62730d5c99 |
children | d74d3998482c |
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 |
2422
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2042 static debug_val debug_iopad_get(debug_array *array, uint32_t index) |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2043 { |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2044 io_port *port = find_gamepad(array->base, index + 1); |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2045 uint32_t ret = 0; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2046 if (port) { |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2047 ret |= port->input[1]; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2048 ret |= port->input[0] << 2 & 0xC0; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2049 ret |= port->input[2] << 8 & 0xF00; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2050 } |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2051 return debug_int(ret); |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2052 } |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2053 |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2054 static void debug_iopad_set(debug_array *array, uint32_t index, debug_val val) |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2055 { |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2056 uint32_t ival; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2057 if (!debug_cast_int(val, &ival)) { |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2058 fprintf(stderr, "pad state can only be set to integers\n"); |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2059 return; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2060 } |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2061 io_port *port = find_gamepad(array->base, index + 1); |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2062 if (port) { |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2063 port->input[1] &= ~0x3F; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2064 port->input[1] |= ival & 0x3F; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2065 port->input[0] &= ~0x33; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2066 port->input[0] |= ival & 0x3; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2067 port->input[0] |= ival >> 2 & 0x30; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2068 port->input[2] &= ~0xF; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2069 port->input[2] |= ival >> 8 & 0xF; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2070 } |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2071 } |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2072 |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2073 debug_root *find_io_root(sega_io *io) |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2074 { |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2075 debug_root *root = find_root(io); |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2076 |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2077 new_readonly_variable(root, "pads", new_fixed_array(io, debug_iopad_get, debug_iopad_set, MAX_JOYSTICKS)); |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2078 |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2079 return root; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2080 } |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2081 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2082 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
|
2083 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2084 char *prefix = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2085 char * full = alloc_concat(prefix, key); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2086 fprintf(stderr, "\t%s\n", full); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2087 free(full); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2088 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2089 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2090 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
|
2091 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2092 char *cur = text; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2093 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
|
2094 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2095 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2096 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2097 char *name = malloc(cur - text + 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2098 memcpy(name, text, cur - text); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2099 name[cur-text] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2100 uint8_t ret = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2101 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
|
2102 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
|
2103 if (!def) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2104 tern_node *node = prefix_res; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2105 while (node) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2106 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2107 if (node->left || node->right) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2108 break; |
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 if (node->el) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2111 node = node->straight.next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2112 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2113 def = node->straight.value.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2114 break; |
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 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2117 if (!def && prefix_res) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2118 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
|
2119 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
|
2120 goto cleanup_name; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2121 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2122 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2123 if (!def) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2124 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
|
2125 goto cleanup_name; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2126 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2127 char *format = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2128 if (*cur == '/') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2129 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2130 text = cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2131 while (*cur && !isspace(*cur)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2132 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2133 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2134 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2135 format = malloc(cur - text + 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2136 memcpy(format, text, cur - text); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2137 format[cur - text] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2138 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2139 int num_args = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2140 command_arg *args = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2141 if (*cur && *cur != '\n') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2142 ++cur; |
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 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
|
2145 if (def->raw_args) { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2146 while (*cur && *cur != '\n') |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2147 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2148 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2149 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2150 char *raw_param = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2151 if (cur != text) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2152 raw_param = malloc(cur - text + 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2153 memcpy(raw_param, text, cur - text); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2154 raw_param[cur - text] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2155 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2156 out->raw = raw_param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2157 out->args = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2158 out->num_args = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2159 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2160 int arg_storage = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2161 if (def->max_args > 0) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2162 arg_storage = def->max_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2163 } else if (def->max_args) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2164 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
|
2165 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2166 if (arg_storage) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2167 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
|
2168 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2169 while (*text && *text != '\n') |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2170 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2171 char *after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2172 expr *e = parse_expression(text, &after); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2173 if (e) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2174 if (num_args == arg_storage) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2175 if (def->max_args >= 0) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2176 free_expr(e); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2177 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
|
2178 goto cleanup_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2179 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2180 arg_storage *= 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2181 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
|
2182 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2183 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2184 args[num_args].parsed = e; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2185 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
|
2186 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
|
2187 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
|
2188 text = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2189 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2190 goto cleanup_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2191 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2192 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2193 if (num_args < def->min_args) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2194 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
|
2195 goto cleanup_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2196 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2197 out->raw = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2198 out->args = args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2199 out->num_args = num_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2200 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2201 out->def = def; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2202 out->format = format; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
2203 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2204 ret = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2205 cleanup_args: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2206 if (!ret) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2207 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
|
2208 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2209 free_expr(args[i].parsed); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2210 free(args[i].raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2211 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2212 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
|
2213 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2214 cleanup_name: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2215 free(name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2216 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2217 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2218 |
2188
e17d99c96c89
Make blocks an 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 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
|
2220 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
|
2221 { |
e17d99c96c89
Make blocks an 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 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
|
2223 { |
e17d99c96c89
Make blocks an 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 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
|
2225 } |
e17d99c96c89
Make blocks an 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 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
|
2227 } |
e17d99c96c89
Make blocks an 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 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2229 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
|
2230 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2231 free(cmd->format); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2232 free(cmd->raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2233 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
|
2234 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2235 free(cmd->args[i].raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2236 free_expr(cmd->args[i].parsed); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2237 } |
2188
e17d99c96c89
Make blocks an 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 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
|
2239 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
|
2240 free(cmd->args); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2241 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2242 |
2188
e17d99c96c89
Make blocks an 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 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
|
2244 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
|
2245 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
|
2246 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
|
2247 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
|
2248 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
|
2249 }; |
e17d99c96c89
Make blocks an 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 |
e17d99c96c89
Make blocks an 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 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
|
2252 { |
e17d99c96c89
Make blocks an 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 ++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
|
2254 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
|
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 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
|
2257 } |
e17d99c96c89
Make blocks an 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 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
|
2259 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
|
2260 #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
|
2261 #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
|
2262 #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
|
2263 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
|
2264 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
|
2265 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
|
2266 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
|
2267 #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
|
2268 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
|
2269 process_events(); |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2252
diff
changeset
|
2270 #ifndef IS_LIB |
2252
6a07b13894f7
Fix input processing while waiting for console input in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2216
diff
changeset
|
2271 render_update_display(); |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2252
diff
changeset
|
2272 #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
|
2273 #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
|
2274 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
|
2275 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
|
2276 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
|
2277 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
|
2278 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
|
2279 } |
e17d99c96c89
Make blocks an 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 #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
|
2281 } 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
|
2282 |
e17d99c96c89
Make blocks an 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 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
|
2284 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
|
2285 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
|
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 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
|
2289 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
|
2290 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
|
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 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
|
2293 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
|
2294 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
|
2295 } |
e17d99c96c89
Make blocks an 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 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
|
2297 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
|
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 } |
e17d99c96c89
Make blocks an 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 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
|
2301 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
|
2302 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
|
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 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
|
2305 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
|
2306 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
|
2307 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
|
2308 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
|
2309 { |
e17d99c96c89
Make blocks an 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 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
|
2311 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
|
2312 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
|
2313 } |
e17d99c96c89
Make blocks an 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 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
|
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 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
|
2317 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
|
2318 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
|
2319 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
|
2320 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
|
2321 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
|
2322 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
|
2323 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
|
2324 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
|
2325 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
|
2326 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
|
2327 } |
e17d99c96c89
Make blocks an 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 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
|
2329 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
|
2330 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
|
2331 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2332 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
|
2333 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
|
2334 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
|
2335 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
|
2336 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2337 } |
e17d99c96c89
Make blocks an 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 } |
e17d99c96c89
Make blocks an 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 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
|
2340 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2341 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2342 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
|
2343 { |
e17d99c96c89
Make blocks an 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 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
|
2345 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
|
2346 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2347 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
|
2348 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
|
2349 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
|
2350 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2351 } |
e17d99c96c89
Make blocks an 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 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
|
2354 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2355 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2356 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
|
2357 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2358 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2359 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
|
2360 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
|
2361 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
|
2362 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
|
2363 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
|
2364 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
|
2365 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
|
2366 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2367 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
|
2368 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
|
2369 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2370 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
|
2371 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
|
2372 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
|
2373 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
|
2374 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
|
2375 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
|
2376 } |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2377 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
|
2378 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
|
2379 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
|
2380 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
|
2381 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
|
2382 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2383 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
|
2384 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2385 } |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2386 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
|
2387 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
|
2388 } else { |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2389 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
|
2390 } |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2391 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
|
2392 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2393 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2394 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
|
2395 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2396 exit(0); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2397 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2398 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2399 typedef struct { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2400 size_t num_commands; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2401 size_t longest_command; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2402 } help_state; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2403 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2404 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
|
2405 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2406 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2407 if (def->visited) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2408 return; |
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 def->visited = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2411 help_state *state = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2412 state->num_commands++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2413 size_t len = strlen(def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2414 if (len > state->longest_command) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2415 state->longest_command = len; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2416 } |
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 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2419 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
|
2420 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2421 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2422 def->visited = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2423 } |
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 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
|
2426 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2427 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2428 if (def->visited) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2429 return; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2430 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2431 def->visited = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2432 help_state *state = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2433 size_t len = strlen(def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2434 printf(" %s", def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2435 while (len < state->longest_command) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2436 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2437 len++; |
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 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
|
2440 const char *extra_desc = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2441 if (strlen(def->desc) <= remaining) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2442 printf(" - %s\n", def->desc); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2443 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2444 char split[76]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2445 int split_point = remaining; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2446 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
|
2447 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2448 --split_point; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2449 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2450 if (!split_point) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2451 split_point = remaining; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2452 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2453 memcpy(split, def->desc, split_point); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2454 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
|
2455 split[split_point] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2456 printf(" - %s\n", split); |
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 if (def->names[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2459 fputs(" Aliases: ", stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2460 len = strlen(" Aliases: "); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2461 const char **name = def->names + 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2462 uint8_t first = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2463 while (*name) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2464 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2465 if (first) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2466 first = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2467 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2468 putchar(','); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2469 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2470 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
|
2471 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2472 fputs(*name, stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2473 len += strlen(*name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2474 ++name; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2475 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2476 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2477 len = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2478 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2479 if (extra_desc) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2480 while (len < state->longest_command + 5) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2481 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2482 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
|
2483 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2484 fputs(extra_desc, stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2485 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2486 putchar('\n'); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2487 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2488 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2489 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
|
2490 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2491 help_state state = {0,0}; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2492 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
|
2493 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
|
2494 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
|
2495 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
|
2496 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2497 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2498 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2499 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
|
2500 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2501 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2502 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2503 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2504 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
|
2505 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2506 strcpy(format_str, "%s: %d\n"); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2507 if (format) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2508 switch (format[0]) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2509 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2510 case 'x': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2511 case 'X': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2512 case 'd': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2513 case 'c': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2514 case 's': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2515 format_str[5] = format[0]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2516 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2517 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2518 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
|
2519 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2520 } |
2188
e17d99c96c89
Make blocks an 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 } |
e17d99c96c89
Make blocks an 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 |
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
|
2523 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
|
2524 { |
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
|
2525 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
|
2526 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2527 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
|
2528 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
|
2529 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
|
2530 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
|
2531 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
|
2532 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
|
2533 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2534 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
|
2535 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
|
2536 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
|
2537 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
|
2538 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
|
2539 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2540 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
|
2541 } |
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
|
2542 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
|
2543 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
|
2544 } 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
|
2545 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
|
2546 } |
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
|
2547 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
|
2548 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
|
2549 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
|
2550 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
|
2551 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
|
2552 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
|
2553 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
|
2554 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2555 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2556 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2557 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2558 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
|
2559 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2560 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
|
2561 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
|
2562 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
|
2563 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2564 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
|
2565 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2566 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2567 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2568 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2569 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
|
2570 { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2571 char *fmt = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2572 if (!fmt) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2573 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
|
2574 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2575 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2576 char *cur = fmt; |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2577 char format_str[3] = {'%', 'd', 0}; |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2578 uint32_t cur_param = 1; |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2579 while (*cur) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2580 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2581 if (*cur == '%') { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2582 switch(cur[1]) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2583 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2584 case 'x': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2585 case 'X': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2586 case 'c': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2587 case 'd': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2588 case 's': |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2589 case 'f': |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2590 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2591 default: |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2592 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
|
2593 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2594 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2595 format_str[1] = cur[1]; |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2596 if (cur_param == cmd->num_args) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2597 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
|
2598 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2599 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2600 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
|
2601 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
|
2602 if (val.type == DBG_VAL_STRING) { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2603 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
|
2604 } 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
|
2605 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
|
2606 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
|
2607 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
|
2608 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
|
2609 return 1; |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2610 } |
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
|
2611 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
|
2612 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
|
2613 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2614 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
|
2615 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
|
2616 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
|
2617 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
|
2618 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
|
2619 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2620 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
|
2621 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2622 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
|
2623 printf(format_str, tmp); |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2624 } |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2625 } else if (cur[1] == 'f') { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2626 float fval; |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2627 if (!debug_cast_float(val, &fval)) { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2628 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
|
2629 return 1; |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2630 } |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2631 printf(format_str, fval); |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2632 } 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
|
2633 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
|
2634 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
|
2635 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
|
2636 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
|
2637 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2638 printf(format_str, ival); |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2639 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2640 cur += 2; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2641 } else { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2642 putchar(*cur); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2643 ++cur; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2644 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2645 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2646 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2647 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2648 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2649 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
|
2650 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2651 cmd_print(root, cmd); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2652 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
|
2653 ndisp->next = root->displays; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2654 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
|
2655 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
|
2656 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
|
2657 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
|
2658 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
|
2659 cmd->num_args = 0; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2660 root->displays = ndisp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2661 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
|
2662 return 1; |
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_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
|
2666 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2667 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
|
2668 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
|
2669 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
|
2670 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
|
2671 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
|
2672 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2673 while (*cur) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2674 { |
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
|
2675 if ((*cur)->index == index) { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2676 disp_def *del_disp = *cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2677 *cur = del_disp->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2678 free(del_disp->format); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2679 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
|
2680 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2681 free(del_disp->args[i].raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2682 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
|
2683 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2684 free(del_disp->args); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2685 free(del_disp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2686 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2687 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2688 cur = &(*cur)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2689 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2690 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2691 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2692 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2693 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2694 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
|
2695 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2696 if (current_system->soft_reset) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2697 current_system->soft_reset(current_system); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2698 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2699 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2700 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
|
2701 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2702 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2703 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2704 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2705 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
|
2706 { |
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
|
2707 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
|
2708 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
|
2709 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
|
2710 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
|
2711 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2712 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
|
2713 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
|
2714 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
|
2715 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2716 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2717 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
|
2718 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2719 free_parsed_command((*target)->commands + i); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2720 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2721 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
|
2722 (*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
|
2723 (*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
|
2724 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
|
2725 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
|
2726 return 1; |
2178
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 |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2729 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
|
2730 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2731 uint8_t debugging = 1; |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2732 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
|
2733 { |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2734 debugging = run_command(root, block->commands + i); |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2735 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2736 return debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2737 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2738 |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2739 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
|
2740 { |
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
|
2741 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
|
2742 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2743 |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2744 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
|
2745 { |
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
|
2746 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
|
2747 return execute_block(root, &cmd->else_block); |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2748 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2749 int debugging = 1; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2750 do { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2751 debugging = execute_block(root, &cmd->block) && debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2752 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
|
2753 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
|
2754 return 1; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2755 } |
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
|
2756 } 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
|
2757 return debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2758 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2759 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2760 const char *expr_type_names[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2761 "EXPR_NONE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2762 "EXPR_SCALAR", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2763 "EXPR_UNARY", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2764 "EXPR_BINARY", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2765 "EXPR_SIZE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2766 "EXPR_MEM" |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2767 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2768 |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2769 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
|
2770 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2771 debug_root *set_root = root; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2772 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
|
2773 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
|
2774 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2775 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
|
2776 if (!set_root) { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2777 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
|
2778 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2779 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2780 set_expr = set_expr->left; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2781 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2782 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
|
2783 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
|
2784 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2785 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2786 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
|
2787 if (var) { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2788 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
|
2789 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2790 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2791 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
|
2792 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2793 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
|
2794 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
|
2795 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2796 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2797 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2798 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
|
2799 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
|
2800 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2801 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
|
2802 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
|
2803 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2804 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
|
2805 cmd->block.commands = NULL; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2806 cmd->block.num_commands = 0; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2807 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2808 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2809 |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2810 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
|
2811 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2812 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
|
2813 return 0; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2814 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2815 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2816 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
|
2817 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2818 char *name = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2819 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
|
2820 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
|
2821 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
|
2822 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
|
2823 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2825 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
|
2826 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
|
2827 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
|
2828 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2830 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2831 debug_val address; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2832 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
|
2833 switch (set_expr->type) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2834 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2835 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
|
2836 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
|
2837 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
|
2838 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2839 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
|
2840 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2841 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2842 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2843 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
|
2844 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
|
2845 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
|
2846 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
|
2847 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2848 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
|
2849 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2850 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2851 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2852 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
|
2853 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
|
2854 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
|
2855 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
|
2856 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2857 } |
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
|
2858 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
|
2859 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
|
2860 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
|
2861 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2863 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
|
2864 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
|
2865 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
|
2866 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2867 array = get_array(right); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2868 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
|
2869 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
|
2870 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2871 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2872 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
|
2873 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
|
2874 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2875 } |
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
|
2876 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
|
2877 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
|
2878 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2879 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2880 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2881 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2882 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
|
2883 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
|
2884 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2885 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2886 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
|
2887 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
|
2888 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2889 } |
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
|
2890 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
|
2891 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
|
2892 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
|
2893 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
|
2894 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
|
2895 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
|
2896 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2897 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
|
2898 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
|
2899 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2900 } |
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
|
2901 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
|
2902 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
|
2903 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
|
2904 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
|
2905 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
|
2906 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
|
2907 } 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
|
2908 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
|
2909 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
|
2910 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
|
2911 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2912 } |
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
|
2913 var->set(var, value); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2914 } 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
|
2915 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
|
2916 } 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
|
2917 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
|
2918 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2919 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2920 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2921 |
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
|
2922 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
|
2923 { |
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
|
2924 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
|
2925 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
|
2926 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
|
2927 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2929 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
|
2930 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
|
2931 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
|
2932 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2933 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
|
2934 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2936 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
|
2937 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
|
2938 } |
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
|
2939 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
|
2940 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
|
2941 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
|
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 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
|
2945 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
|
2946 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
|
2947 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
|
2948 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
|
2949 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
|
2950 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
|
2951 } |
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
|
2952 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
|
2953 } |
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
|
2954 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
|
2955 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
|
2956 } |
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
|
2957 |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2958 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
|
2959 { |
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
|
2960 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
|
2961 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
|
2962 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
|
2963 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2964 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
|
2965 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
|
2966 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
|
2967 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
|
2968 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2969 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
|
2970 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2971 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
|
2972 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
|
2973 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2974 } |
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
|
2975 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
|
2976 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
|
2977 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
|
2978 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
|
2979 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
|
2980 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
|
2981 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
|
2982 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
|
2983 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2984 } 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
|
2985 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
|
2986 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
|
2987 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
|
2988 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
|
2989 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
|
2990 array = get_array(var->val); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2991 } |
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
|
2992 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
|
2993 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
|
2994 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
|
2995 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
|
2996 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
|
2997 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2998 } |
2367
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
2999 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
|
3000 { |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3001 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
|
3002 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
|
3003 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3004 } |
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
|
3005 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
|
3006 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3007 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3008 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3009 |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3010 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
|
3011 { |
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
|
3012 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
|
3013 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
|
3014 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
|
3015 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3016 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3017 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
|
3018 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
|
3019 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3020 } |
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
|
3021 array->append(array, cmd->args[1].value); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3022 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3023 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3024 |
2188
e17d99c96c89
Make blocks an 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 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
|
3026 { |
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
|
3027 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
|
3028 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
|
3029 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
|
3030 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
|
3031 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 current_system->enter_debugger_frames = frames; |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
3033 return 0; |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
3034 } |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
3035 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3036 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
|
3037 { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3038 char *bind = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3039 if (!bind) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3040 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
|
3041 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3042 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3043 if (!bind_up(bind)) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3044 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
|
3045 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3046 return 1; |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3047 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3048 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3049 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
|
3050 { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3051 char *bind = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3052 if (!bind) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3053 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
|
3054 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3055 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3056 if (!bind_down(bind)) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3057 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
|
3058 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3059 return 1; |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3060 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3061 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3062 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
|
3063 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3064 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
|
3065 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
|
3066 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3067 } |
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
|
3068 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
|
3069 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
|
3070 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
|
3071 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
|
3072 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3073 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
|
3074 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
|
3075 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
|
3076 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3077 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3078 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
|
3079 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
|
3080 (*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
|
3081 cmd->args[1].parsed = NULL; |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3082 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3083 (*target)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3084 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3085 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3086 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3087 |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3088 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
|
3089 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3090 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
|
3091 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
|
3092 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
|
3093 *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
|
3094 } |
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 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
|
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 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
|
3100 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
|
3101 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
|
3102 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
|
3103 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3104 putchar(' '); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3105 len++; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3106 } |
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
|
3107 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
|
3108 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3109 |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3110 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
|
3111 { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3112 if (cmd->num_args) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3113 char *filename = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3114 if (!filename) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3115 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
|
3116 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3117 } |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3118 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
|
3119 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
|
3120 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
|
3121 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
|
3122 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3123 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
|
3124 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
|
3125 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3126 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
|
3127 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
|
3128 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
|
3129 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
|
3130 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
|
3131 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
|
3132 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
|
3133 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
|
3134 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
|
3135 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3136 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3137 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3138 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3139 } else { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3140 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
|
3141 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
|
3142 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
|
3143 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
|
3144 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3145 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
|
3146 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3147 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3148 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
|
3149 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3150 char size = cmd->format ? cmd->format[0] : 'b'; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3151 if (size != 'b' && size != 'w' && size != 'l') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3152 fprintf(stderr, "Invalid size %s\n", cmd->format); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3153 return 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3154 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3155 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
|
3156 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
|
3157 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3158 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3159 char *fname = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3160 if (!fname) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3161 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
|
3162 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3163 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3164 FILE *f = fopen(fname, "wb"); |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3165 if (!f) { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3166 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
|
3167 return 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3168 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3169 uint32_t start = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3170 debug_val val; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3171 debug_array * arr = NULL; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3172 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
|
3173 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3174 if (!eval_expr(root, cmd->args[1].parsed->left, &val)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3175 fprintf(stderr, "Failed to eval start index\n"); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3176 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3177 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3178 if (!debug_cast_int(val, &start)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3179 fprintf(stderr, "Start index must evaluate to integer\n"); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3180 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3181 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3182 if (cmd->args[1].parsed->right) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3183 if (!eval_expr(root, cmd->args[1].parsed->right, &val)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3184 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
|
3185 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3186 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3187 arr = get_array(val); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3188 if (!arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3189 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
|
3190 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3191 } |
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 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3194 if (!eval_expr(root, cmd->args[1].parsed, &val)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3195 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
|
3196 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3197 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3198 arr = get_array(val); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3199 if (!arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3200 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
|
3201 goto cleanup; |
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 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3204 uint32_t count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3205 if (cmd->num_args > 2) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3206 if (!eval_expr(root, cmd->args[2].parsed, &val)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3207 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
|
3208 goto cleanup; |
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 if (!debug_cast_int(val, &count)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3211 fprintf(stderr, "Count must evaluate to integer\n"); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3212 goto cleanup; |
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 (arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3215 count = arr->size < start ? 0 : arr->size - start; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3216 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3217 count = root->chunk_end(root, start) - start; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3218 if (size == 'l') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3219 count /= 4; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3220 } else if (size == 'w') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3221 count /= 2; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3222 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3223 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3224 union { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3225 uint8_t b[1024]; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3226 uint16_t w[512]; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3227 uint32_t l[256]; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3228 } buffer; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3229 uint32_t cur = start; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3230 if (size == 'l') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3231 while (count) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3232 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3233 uint32_t n = count < 256 ? count : 256; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3234 count -= n; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3235 for (uint32_t i = 0; i < n ; i++) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3236 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3237 if (arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3238 val = arr->get(arr, cur++); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3239 if (!debug_cast_int(val, buffer.l + i)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3240 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3241 count = 0; |
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 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3244 buffer.l[i] = cur; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3245 cur += 4; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3246 if (!root->read_mem(root, buffer.l + i, 'l')) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3247 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3248 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3249 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3250 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3251 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3252 fwrite(buffer.l, sizeof(uint32_t), n, f); |
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 if (size == 'w') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3255 while (count) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3256 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3257 uint32_t n = count < 512 ? count : 512; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3258 count -= n; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3259 uint32_t tmp; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3260 for (uint32_t i = 0; i < n ; i++) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3261 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3262 if (arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3263 val = arr->get(arr, cur++); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3264 if (!debug_cast_int(val, &tmp)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3265 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3266 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3267 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3268 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3269 tmp = cur; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3270 cur += 2; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3271 if (!root->read_mem(root, &tmp, 'w')) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3272 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3273 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3274 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3275 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3276 buffer.w[i] = tmp; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3277 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3278 fwrite(buffer.w, sizeof(uint16_t), n, f); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3279 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3280 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3281 while (count) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3282 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3283 uint32_t n = count < 1024 ? count : 1024; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3284 count -= n; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3285 uint32_t tmp; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3286 for (uint32_t i = 0; i < n ; i++) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3287 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3288 if (arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3289 val = arr->get(arr, cur++); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3290 if (!debug_cast_int(val, &tmp)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3291 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3292 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3293 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3294 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3295 tmp = cur++; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3296 if (!root->read_mem(root, &tmp, 'b')) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3297 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3298 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3299 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3300 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3301 buffer.b[i] = tmp; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3302 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3303 fwrite(buffer.b, sizeof(uint8_t), n, f); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3304 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3305 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3306 cleanup: |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3307 fclose(f); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3308 return 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3309 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3310 |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3311 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
|
3312 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3313 char size = cmd->format ? cmd->format[0] : 'b'; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3314 if (size != 'b' && size != 'w' && size != 'l') { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3315 fprintf(stderr, "Invalid size %s\n", cmd->format); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3316 return 1; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3317 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3318 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
|
3319 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
|
3320 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3321 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3322 char *fname = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3323 if (!fname) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3324 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
|
3325 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3326 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3327 FILE *f = fopen(fname, "rb"); |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3328 if (!f) { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3329 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
|
3330 return 1; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3331 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3332 uint32_t start = 0; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3333 debug_val val; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3334 debug_array * arr = NULL; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3335 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
|
3336 |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3337 if (!eval_expr(root, cmd->args[1].parsed->left, &val)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3338 fprintf(stderr, "Failed to eval start index\n"); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3339 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3340 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3341 if (!debug_cast_int(val, &start)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3342 fprintf(stderr, "Start index must evaluate to integer\n"); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3343 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3344 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3345 if (cmd->args[1].parsed->right) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3346 if (!eval_expr(root, cmd->args[1].parsed->right, &val)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3347 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
|
3348 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3349 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3350 arr = get_array(val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3351 if (!arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3352 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
|
3353 goto cleanup; |
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 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3356 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3357 if (!eval_expr(root, cmd->args[1].parsed, &val)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3358 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
|
3359 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3360 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3361 arr = get_array(val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3362 if (!arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3363 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
|
3364 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3365 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3366 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3367 uint32_t count = 0; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3368 uint8_t has_count = 0; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3369 if (cmd->num_args > 2) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3370 if (!eval_expr(root, cmd->args[2].parsed, &val)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3371 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
|
3372 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3373 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3374 if (!debug_cast_int(val, &count)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3375 fprintf(stderr, "Count must evaluate to integer\n"); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3376 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3377 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3378 has_count = 1; |
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 union { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3381 uint8_t b[1024]; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3382 uint16_t w[512]; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3383 uint32_t l[256]; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3384 } buffer; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3385 uint32_t cur = start; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3386 if (size == 'l') { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3387 while (count || !has_count) |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3388 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3389 uint32_t n = (has_count && count < 256) ? count : 256; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3390 count -= n; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3391 n = fread(buffer.l, sizeof(uint32_t), n, f); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3392 if (!n) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3393 break; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3394 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3395 for (uint32_t i = 0; i < n ; i++) |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3396 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3397 if (arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3398 val = debug_int(buffer.l[i]); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3399 if (cur >= arr->size) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3400 if (arr->append) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3401 arr->append(arr, val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3402 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3403 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3404 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3405 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3406 arr->set(arr, cur, val); |
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 cur++; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3409 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3410 if (!root->write_mem(root, cur, buffer.l[i], 'l')) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3411 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3412 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3413 cur += 4; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3414 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3415 } |
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 } else if (size == 'w') { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3418 while (count || !has_count) |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3419 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3420 uint32_t n = (has_count && count < 512) ? count : 512; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3421 count -= n; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3422 n = fread(buffer.w, sizeof(uint16_t), n, f); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3423 if (!n) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3424 break; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3425 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3426 for (uint32_t i = 0; i < n ; i++) |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3427 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3428 if (arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3429 val = debug_int(buffer.w[i]); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3430 if (cur >= arr->size) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3431 if (arr->append) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3432 arr->append(arr, val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3433 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3434 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3435 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3436 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3437 arr->set(arr, cur, val); |
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 cur++; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3440 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3441 if (!root->write_mem(root, cur, buffer.w[i], 'w')) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3442 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3443 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3444 cur += 2; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3445 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3446 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3447 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3448 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3449 while (count || !has_count) |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3450 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3451 uint32_t n = (has_count && count < 1024) ? count : 1024; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3452 count -= n; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3453 n = fread(buffer.b, sizeof(uint8_t), n, f); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3454 if (!n) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3455 break; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3456 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3457 for (uint32_t i = 0; i < n ; i++) |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3458 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3459 if (arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3460 val = debug_int(buffer.b[i]); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3461 if (cur >= arr->size) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3462 if (arr->append) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3463 arr->append(arr, val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3464 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3465 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3466 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3467 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3468 arr->set(arr, cur, val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3469 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3470 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3471 if (!root->write_mem(root, cur, buffer.b[i], 'b')) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3472 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3473 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3474 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3475 cur++; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3476 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3477 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3478 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3479 cleanup: |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3480 fclose(f); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3481 return 1; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3482 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3483 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3484 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
|
3485 { |
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
|
3486 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
|
3487 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
|
3488 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
|
3489 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
|
3490 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3491 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
|
3492 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
|
3493 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
|
3494 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3495 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3496 bp_def *tmp = *this_bp; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3497 if (tmp->type == BP_TYPE_CPU) { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3498 remove_breakpoint(root->cpu_context, tmp->address); |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3499 } else if (tmp->type == BP_TYPE_CPU_WATCH) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3500 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
|
3501 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3502 *this_bp = (*this_bp)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3503 if (tmp->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3504 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
|
3505 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3506 free_parsed_command(tmp->commands + i); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3507 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3508 free(tmp->commands); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3509 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3510 free(tmp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3511 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3512 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3513 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3514 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
|
3515 { |
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
|
3516 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
|
3517 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
|
3518 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
|
3519 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
|
3520 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3521 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
|
3522 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
|
3523 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
|
3524 new_bp->address = address; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3525 new_bp->mask = 0xFFFFFF; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3526 new_bp->index = root->bp_index++; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3527 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
|
3528 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
|
3529 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
|
3530 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3531 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3532 |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3533 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
|
3534 { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3535 uint32_t address; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3536 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
|
3537 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
|
3538 return 1; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3539 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3540 uint32_t size; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3541 if (cmd->num_args > 1) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3542 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
|
3543 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
|
3544 return 1; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3545 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3546 } else { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3547 //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
|
3548 size = (address & 1) ? 1 : 2; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3549 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3550 m68k_add_watchpoint(root->cpu_context, address, size); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3551 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
|
3552 new_bp->next = root->breakpoints; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3553 new_bp->address = address; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3554 new_bp->mask = size; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3555 new_bp->index = root->bp_index++; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3556 new_bp->type = BP_TYPE_CPU_WATCH; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3557 root->breakpoints = new_bp; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3558 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
|
3559 return 1; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3560 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3561 |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3562 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
|
3563 { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3564 value &= 0xFF; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3565 if (context->regs[reg] == value) { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3566 return; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3567 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3568 genesis_context *gen = (genesis_context *)context->system; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3569 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
|
3570 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
|
3571 int debugging = 1; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3572 if (*this_bp) { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3573 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
|
3574 debug_val condres; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3575 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
|
3576 if (!condres.v.u32) { |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3577 return; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3578 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3579 } else { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3580 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
|
3581 free_expr((*this_bp)->condition); |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3582 (*this_bp)->condition = NULL; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3583 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3584 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3585 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
|
3586 { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3587 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
|
3588 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3589 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
|
3590 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
|
3591 gen->header.enter_debugger = 1; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3592 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
|
3593 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
|
3594 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3595 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
|
3596 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
|
3597 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3598 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3599 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3600 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3601 |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3602 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
|
3603 { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3604 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
|
3605 new_bp->next = root->breakpoints; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3606 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
|
3607 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
|
3608 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
|
3609 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
|
3610 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3611 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
|
3612 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
|
3613 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
|
3614 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
|
3615 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3616 } 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
|
3617 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
|
3618 } |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3619 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3620 new_bp->index = root->bp_index++; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3621 new_bp->type = BP_TYPE_VDPREG; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3622 root->breakpoints = new_bp; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3623 m68k_context *m68k = root->cpu_context; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3624 genesis_context *gen = m68k->system; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3625 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
|
3626 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
|
3627 return 1; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3628 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3629 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3630 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
|
3631 { |
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
|
3632 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
|
3633 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
|
3634 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
|
3635 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
|
3636 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3637 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
|
3638 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3639 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3640 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3641 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
|
3642 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3643 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3644 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3645 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3646 if (inst->op == M68K_RTS) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3647 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
|
3648 } 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
|
3649 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
|
3650 } else if(m68k_is_branch(inst)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3651 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
|
3652 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3653 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
|
3654 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
|
3655 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3656 if (inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3657 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
|
3658 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
|
3659 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3660 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3661 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3662 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
|
3663 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
|
3664 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3665 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3666 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
|
3667 } |
2178
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 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
|
3670 return 0; |
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 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3673 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
|
3674 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3675 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3676 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3677 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3678 if (inst->op == M68K_RTS) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3679 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
|
3680 } 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
|
3681 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
|
3682 } 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
|
3683 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
|
3684 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
|
3685 if (root->branch_t < after) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3686 root->branch_t = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3687 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3688 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3689 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
|
3690 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3691 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3692 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
|
3693 if (target > after) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3694 if (inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3695 after = target; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3696 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3697 root->branch_f = target; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3698 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3699 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
|
3700 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3701 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3702 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3703 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
|
3704 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3705 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3706 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
|
3707 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3708 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3709 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3710 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
|
3711 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3712 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3713 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3714 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3715 if (inst->op == M68K_RTS) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3716 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
|
3717 } 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
|
3718 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
|
3719 } 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
|
3720 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
|
3721 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3722 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
|
3723 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
|
3724 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3725 if ( inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3726 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
|
3727 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
|
3728 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3729 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3730 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3731 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
|
3732 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
|
3733 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3734 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3735 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
|
3736 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3737 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3738 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
|
3739 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3740 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3741 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3742 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
|
3743 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3744 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3745 uint32_t stack = context->aregs[7]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3746 uint8_t non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3747 do { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3748 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
|
3749 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
|
3750 if (bt_address) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3751 stack += 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3752 non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3753 m68kinst inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3754 char buf[128]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3755 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
|
3756 m68k_disasm(&inst, buf); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3757 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
|
3758 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3759 //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
|
3760 stack += 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3761 non_adr_count++; |
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 //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
|
3764 } while (stack && non_adr_count < 6); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3765 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3766 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3767 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3768 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
|
3769 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3770 m68k_context *context = root->cpu_context; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3771 uint32_t address = root->address; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3772 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
|
3773 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
|
3774 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
|
3775 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
|
3776 } |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3777 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3778 char disasm_buf[1024]; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3779 m68kinst inst; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3780 do { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3781 label_def *def = find_label(root->disasm, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3782 if (def) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3783 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
|
3784 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3785 printf("%s:\n", def->labels[i]); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3786 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3787 } |
2252
6a07b13894f7
Fix input processing while waiting for console input in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2216
diff
changeset
|
3788 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3789 address = m68k_decode(m68k_instruction_fetch, context, &inst, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3790 m68k_disasm_labels(&inst, disasm_buf, root->disasm); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3791 printf("\t%s\n", disasm_buf); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3792 } while(!m68k_is_terminal(&inst)); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3793 return 1; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3794 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
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 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
|
3797 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3798 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3799 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3800 vdp_print_sprite_table(gen->vdp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3801 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3802 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3803 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3804 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
|
3805 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3806 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3807 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3808 vdp_print_reg_explain(gen->vdp); |
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 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3812 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
|
3813 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3814 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3815 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
|
3816 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
|
3817 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
|
3818 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3819 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
|
3820 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
|
3821 } |
2173
894c7873a2b1
Consume all expressions in debugger print command
Michael Pavone <pavone@retrodev.com>
parents:
2172
diff
changeset
|
3822 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3823 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3824 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3825 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3826 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
|
3827 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3828 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3829 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3830 ym_print_timer_info(gen->ym); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3831 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3832 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3833 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3834 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
|
3835 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3836 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3837 while (param && *param && isblank(*param)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3838 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3839 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3840 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3841 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3842 genesis_context *gen = m68k->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3843 segacd_context *cd = gen->expansion; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3844 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
|
3845 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3846 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
|
3847 if (!sub_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3848 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
|
3849 return 1; |
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 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
|
3852 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3853 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3854 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
|
3855 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3856 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3857 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3858 cd->enter_debugger = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3859 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3860 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3861 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3862 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3863 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
|
3864 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3865 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3866 while (param && *param && isblank(*param)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3867 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3868 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3869 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3870 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3871 segacd_context *cd = m68k->system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
3872 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3873 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
|
3874 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3875 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
|
3876 if (!main_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3877 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
|
3878 return 1; |
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 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
|
3881 return 1; |
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 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
|
3884 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3885 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3886 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3887 cd->genesis->header.enter_debugger = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3888 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3889 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3890 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3891 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3892 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
|
3893 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3894 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3895 while (param && *param && isblank(*param)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3896 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3897 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3898 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3899 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3900 genesis_context *gen = m68k->system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
3901 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3902 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
|
3903 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3904 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
|
3905 if (!z80_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3906 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
|
3907 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3908 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3909 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
|
3910 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3911 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3912 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
|
3913 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3914 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3915 } else { |
2184
408fb8a7e990
Implement argumentless variant of z80 debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2183
diff
changeset
|
3916 gen->enter_z80_debugger = 1; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3917 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3918 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3919 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3920 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3921 command_def common_commands[] = { |
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 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3924 "quit", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3925 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3926 .usage = "quit", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3927 .desc = "Quit BlastEm", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3928 .impl = cmd_quit, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3929 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3930 .max_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3931 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3932 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3933 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3934 "help", "?", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3935 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3936 .usage = "help", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3937 .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
|
3938 .impl = cmd_help, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3939 .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
|
3940 .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
|
3941 .raw_args = 1 |
2178
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 "continue", "c", 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 = "continue", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3948 .desc = "Resume execution", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3949 .impl = cmd_continue, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3950 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3951 .max_args = 0 |
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 *[]){ |
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
|
3955 "print", "p", NULL |
2178
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 = "print[/FORMAT] EXPRESSION...", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3958 .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
|
3959 .impl = cmd_print, |
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 *[]){ |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3965 "printf", NULL |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3966 }, |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3967 .usage = "printf FORMAT EXPRESSION...", |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3968 .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
|
3969 .impl = cmd_printf, |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3970 .min_args = 1, |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3971 .max_args = -1 |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3972 }, |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3973 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3974 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3975 "softreset", "sr", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3976 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3977 .usage = "softreset", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3978 .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
|
3979 .impl = cmd_softreset, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3980 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3981 .max_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3982 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3983 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3984 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3985 "display", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3986 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3987 .usage = "display[/FORMAT] EXPRESSION...", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3988 .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
|
3989 .impl = cmd_display, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3990 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3991 .max_args = -1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3992 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3993 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3994 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3995 "deletedisplay", "dd", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3996 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3997 .usage = "deletedisplay DISPLAYNUM", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3998 .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
|
3999 .impl = cmd_delete_display, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4000 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4001 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4002 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4003 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4004 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4005 "commands", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4006 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4007 .usage = "command BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4008 .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
|
4009 .impl = cmd_command, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4010 .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
|
4011 .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
|
4012 .has_block = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4013 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4014 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4015 .names = (const char *[]){ |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4016 "function", NULL |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4017 }, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4018 .usage = "function NAME [ARGS...]", |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4019 .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
|
4020 .impl = cmd_function, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4021 .min_args = 1, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4022 .max_args = -1, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4023 .has_block = 1, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4024 .skip_eval = 1 |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4025 }, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4026 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4027 .names = (const char *[]){ |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4028 "return", NULL |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4029 }, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4030 .usage = "return VALUE", |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4031 .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
|
4032 .impl = cmd_return, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4033 .min_args = 1, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4034 .max_args = 1 |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4035 }, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4036 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4037 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4038 "set", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4039 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4040 .usage = "set MEM|NAME VALUE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4041 .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
|
4042 .impl = cmd_set, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4043 .min_args = 2, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4044 .max_args = 2, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4045 .skip_eval = 1 |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4046 }, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4047 { |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4048 .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
|
4049 "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
|
4050 }, |
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
|
4051 .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
|
4052 .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
|
4053 .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
|
4054 .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
|
4055 .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
|
4056 .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
|
4057 }, |
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
|
4058 { |
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
|
4059 .names = (const char *[]){ |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4060 "array", NULL |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4061 }, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4062 .usage = "array NAME [VALUE...]", |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4063 .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
|
4064 .impl = cmd_array, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4065 .min_args = 1, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4066 .max_args = -1, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4067 .skip_eval = 1 |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4068 }, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4069 { |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4070 .names = (const char *[]){ |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4071 "append", NULL |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4072 }, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4073 .usage = "append NAME VALUE", |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4074 .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
|
4075 .impl = cmd_append, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4076 .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
|
4077 .max_args = 2 |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4078 }, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4079 { |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4080 .names = (const char *[]){ |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4081 "frames", NULL |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4082 }, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4083 .usage = "frames EXPRESSION", |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4084 .desc = "Resume execution for EXPRESSION video frames", |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4085 .impl = cmd_frames, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4086 .min_args = 1, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4087 .max_args = 1 |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4088 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4089 { |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4090 .names = (const char *[]){ |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4091 "bindup", NULL |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4092 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4093 .usage = "bindup NAME", |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4094 .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
|
4095 .impl = cmd_bindup, |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4096 .min_args = 1, |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
4097 .max_args = 1 |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4098 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4099 { |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4100 .names = (const char *[]){ |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4101 "binddown", NULL |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4102 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4103 .usage = "bindown NAME", |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4104 .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
|
4105 .impl = cmd_binddown, |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4106 .min_args = 1, |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
4107 .max_args = 1 |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4108 }, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4109 { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4110 .names = (const char *[]){ |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4111 "condition", NULL |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4112 }, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4113 .usage = "condition BREAKPOINT [EXPRESSION]", |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4114 .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
|
4115 .impl = cmd_condition, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4116 .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
|
4117 .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
|
4118 .skip_eval = 1 |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4119 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4120 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4121 .names = (const char *[]){ |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4122 "if", NULL |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4123 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4124 .usage = "if CONDITION", |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4125 .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
|
4126 .impl = cmd_if, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4127 .min_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4128 .max_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4129 .has_block = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4130 .accepts_else = 1 |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4131 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4132 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4133 .names = (const char *[]){ |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4134 "while", NULL |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4135 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4136 .usage = "while CONDITION", |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4137 .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
|
4138 .impl = cmd_while, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4139 .min_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4140 .max_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4141 .has_block = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4142 .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
|
4143 }, |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4144 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4145 .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
|
4146 "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
|
4147 }, |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4148 .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
|
4149 .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
|
4150 .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
|
4151 .min_args = 0, |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
4152 .max_args = 1 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4153 }, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4154 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4155 .names = (const char *[]){ |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4156 "save", NULL |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4157 }, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4158 .usage = "save[/SIZE] FILENAME ARRAY [COUNT]", |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4159 .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
|
4160 .impl = cmd_save, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4161 .min_args = 2, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4162 .max_args = 3, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4163 .skip_eval = 1 |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4164 }, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4165 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4166 .names = (const char *[]){ |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4167 "load", NULL |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4168 }, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4169 .usage = "load[/SIZE] FILENAME ARRAY [COUNT]", |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4170 .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
|
4171 .impl = cmd_load, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4172 .min_args = 2, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4173 .max_args = 3, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4174 .skip_eval = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4175 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4176 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4177 #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
|
4178 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4179 command_def m68k_commands[] = { |
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 "breakpoint", "b", 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 = "breakpoint ADDRESSS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4185 .desc = "Set a breakpoint at ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4186 .impl = cmd_breakpoint_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4187 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4188 .max_args = 1 |
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 *[]){ |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4192 "watchpoint", NULL |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4193 }, |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4194 .usage = "watchpoint ADDRESS [SIZE]", |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4195 .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
|
4196 .impl = cmd_watchpoint_m68k, |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4197 .min_args = 1, |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4198 .max_args = 2 |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4199 }, |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4200 { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4201 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4202 "advance", 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 = "advance ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4205 .desc = "Advance to ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4206 .impl = cmd_advance_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4207 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4208 .max_args = 1 |
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 "step", "s", 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 = "step", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4215 .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
|
4216 .impl = cmd_step_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4217 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4218 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4219 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4220 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4221 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4222 "over", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4223 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4224 .usage = "over", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4225 .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
|
4226 .impl = cmd_over_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4227 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4228 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4229 }, |
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 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4232 "next", NULL |
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 .usage = "next", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4235 .desc = "Advance to the next instruction", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4236 .impl = cmd_next_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4237 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4238 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4239 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4240 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4241 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4242 "backtrace", "bt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4243 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4244 .usage = "backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4245 .desc = "Print a backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4246 .impl = cmd_backtrace_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4247 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4248 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4249 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4250 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4251 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4252 "delete", "d", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4253 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4254 .usage = "delete BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4255 .desc = "Remove breakpoint identified by BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4256 .impl = cmd_delete_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4257 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4258 .max_args = 1 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4259 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4260 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4261 .names = (const char *[]){ |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4262 "disassemble", "disasm", NULL |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4263 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4264 .usage = "disassemble [ADDRESS]", |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4265 .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
|
4266 .impl = cmd_disassemble_m68k, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4267 .min_args = 0, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4268 .max_args = 1 |
2112
3abb64bd0da6
Add support for printing strings in 68K debugger
Michael Pavone <pavone@retrodev.com>
parents:
2107
diff
changeset
|
4269 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4270 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4271 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4272 #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
|
4273 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4274 command_def genesis_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4275 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4276 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4277 "vdpsprites", "vs", NULL |
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 .usage = "vdpsprites", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4280 .desc = "Print the VDP sprite table", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4281 .impl = cmd_vdp_sprites, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4282 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4283 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4284 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4285 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4286 .names = (const char *[]){ |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4287 "vdpregs", "vr", NULL |
2178
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 .usage = "vdpregs", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4290 .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
|
4291 .impl = cmd_vdp_regs, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4292 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4293 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4294 }, |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4295 { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4296 .names = (const char *[]){ |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4297 "vdpregbreak", "vregbreak", "vrb", NULL |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4298 }, |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4299 .usage = "vdpregbreak [REGISTER [MASK]]", |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4300 .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
|
4301 .impl = cmd_vdp_reg_break, |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4302 .min_args = 0, |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4303 .max_args = 2 |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4304 }, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4305 #ifndef NO_Z80 |
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 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4308 "z80", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4309 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4310 .usage = "z80 [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4311 .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
|
4312 .impl = cmd_gen_z80, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4313 .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
|
4314 .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
|
4315 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4316 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4317 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4318 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4319 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4320 "ymchannel", "yc", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4321 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4322 .usage = "ymchannel [CHANNEL]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4323 .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
|
4324 .impl = cmd_ym_channel, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4325 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4326 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4327 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4328 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4329 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4330 "ymtimer", "yt", NULL |
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 .usage = "ymtimer", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4333 .desc = "Print YM-2612 timer info", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4334 .impl = cmd_ym_timer, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4335 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4336 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4337 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4338 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4339 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4340 #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
|
4341 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4342 command_def scd_main_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4343 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4344 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4345 "subcpu", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4346 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4347 .usage = "subcpu [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4348 .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
|
4349 .impl = cmd_sub, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4350 .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
|
4351 .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
|
4352 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4353 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4354 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4355 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4356 #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
|
4357 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4358 command_def scd_sub_commands[] = { |
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 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4361 "maincpu", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4362 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4363 .usage = "maincpu [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4364 .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
|
4365 .impl = cmd_main, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4366 .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
|
4367 .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
|
4368 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4369 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4370 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4371 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4372 #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
|
4373 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4374 #ifndef NO_Z80 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4375 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4376 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
|
4377 { |
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
|
4378 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
|
4379 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
|
4380 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
|
4381 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
|
4382 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4383 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
|
4384 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
|
4385 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
|
4386 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4387 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4388 bp_def *tmp = *this_bp; |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4389 if (tmp->type == BP_TYPE_CPU) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4390 zremove_breakpoint(root->cpu_context, tmp->address); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4391 } else if (tmp->type == BP_TYPE_CPU_WATCH) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4392 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
|
4393 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4394 *this_bp = (*this_bp)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4395 if (tmp->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4396 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
|
4397 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4398 free_parsed_command(tmp->commands + i); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4399 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4400 free(tmp->commands); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4401 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4402 free(tmp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4403 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4404 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4405 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4406 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
|
4407 { |
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
|
4408 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
|
4409 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
|
4410 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
|
4411 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
|
4412 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4414 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
|
4415 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
|
4416 new_bp->address = address; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4417 new_bp->mask = 0xFFFF; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4418 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
|
4419 new_bp->index = root->bp_index++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4420 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
|
4421 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
|
4422 return 1; |
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 |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4425 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
|
4426 { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4427 uint32_t address; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4428 if (!debug_cast_int(cmd->args[0].value, &address)) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4429 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
|
4430 return 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4431 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4432 uint32_t size = 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4433 if (cmd->num_args > 1) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4434 if (!debug_cast_int(cmd->args[1].value, &size)) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4435 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
|
4436 return 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4437 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4438 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4439 z80_add_watchpoint(root->cpu_context, address, size); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4440 bp_def *new_bp = calloc(1, sizeof(bp_def)); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4441 new_bp->next = root->breakpoints; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4442 new_bp->address = address; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4443 new_bp->mask = size; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4444 new_bp->index = root->bp_index++; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4445 new_bp->type = BP_TYPE_CPU_WATCH; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4446 root->breakpoints = new_bp; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4447 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
|
4448 return 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4449 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4450 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4451 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
|
4452 { |
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
|
4453 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
|
4454 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
|
4455 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
|
4456 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
|
4457 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4458 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
|
4459 return 0; |
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_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
|
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 || 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
|
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_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
|
4497 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4498 fputs("not implemented yet\n", stderr); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4499 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4500 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4501 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4502 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
|
4503 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4504 z80inst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4505 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4506 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4507 //TODO: handle conditional branches |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4508 if (inst->op == Z80_JP) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4509 if (inst->addr_mode == Z80_IMMED) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4510 after = inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4511 } 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
|
4512 #ifndef NEW_CORE |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4513 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
|
4514 } 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
|
4515 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
|
4516 } 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
|
4517 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
|
4518 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4519 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4520 } else if(inst->op == Z80_JR) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4521 after += inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4522 } else if(inst->op == Z80_RET) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4523 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
|
4524 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4525 after = *sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4526 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
|
4527 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4528 after |= *sp << 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4529 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4530 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4531 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4532 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
|
4533 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4534 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4535 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4536 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
|
4537 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4538 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4539 uint32_t stack = context->sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4540 uint8_t non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4541 do { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4542 uint32_t bt_address = stack; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4543 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
|
4544 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4545 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4546 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
|
4547 if (bt_address != 0xFEEDFEED) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4548 stack += 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4549 non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4550 z80inst inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4551 char buf[128]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4552 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
|
4553 z80_decode(pc, &inst); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4554 z80_disasm(&inst, buf, bt_address); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4555 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
|
4556 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4557 //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
|
4558 stack++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4559 non_adr_count++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4560 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4561 //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
|
4562 } while (stack && non_adr_count < 6); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4563 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4564 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4565 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4566 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
|
4567 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4568 z80_context *context = root->cpu_context; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4569 uint32_t address = root->address; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4570 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
|
4571 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
|
4572 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
|
4573 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
|
4574 } |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4575 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4576 char disasm_buf[1024]; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4577 z80inst inst; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4578 do { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4579 label_def *def = find_label(root->disasm, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4580 if (def) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4581 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
|
4582 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4583 printf("%s:\n", def->labels[i]); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4584 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4585 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4586 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
|
4587 uint8_t *after = z80_decode(pc, &inst); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4588 z80_disasm(&inst, disasm_buf, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4589 address += after - pc; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4590 printf("\t%s\n", disasm_buf); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4591 } while(!z80_is_terminal(&inst)); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4592 return 1; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4593 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4594 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4595 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
|
4596 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4597 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
|
4598 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
|
4599 { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4600 ++param; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4601 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4602 genesis_context *gen = (genesis_context *)current_system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
4603 |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4604 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
|
4605 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
|
4606 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
|
4607 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
|
4608 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
|
4609 return 1; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4610 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4611 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
|
4612 return 1; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4613 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4614 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
|
4615 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
|
4616 return ret; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4617 } else { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4618 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
|
4619 return 0; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4620 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4621 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4622 |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4623 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
|
4624 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4625 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
|
4626 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
|
4627 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
|
4628 return 1; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4629 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4630 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4631 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
|
4632 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4633 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
|
4634 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
|
4635 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
|
4636 return 1; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4637 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4638 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4639 command_def z80_commands[] = { |
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 "breakpoint", "b", 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 = "breakpoint ADDRESSS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4645 .desc = "Set a breakpoint at ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4646 .impl = cmd_breakpoint_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4647 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4648 .max_args = 1 |
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 *[]){ |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4652 "watchpoint", NULL |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4653 }, |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4654 .usage = "watchpoint ADDRESS [SIZE]", |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4655 .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
|
4656 .impl = cmd_watchpoint_z80, |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4657 .min_args = 1, |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4658 .max_args = 2 |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4659 }, |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4660 { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4661 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4662 "advance", 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 = "advance ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4665 .desc = "Advance to ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4666 .impl = cmd_advance_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4667 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4668 .max_args = 1 |
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 "step", "s", 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 = "step", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4675 .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
|
4676 .impl = cmd_step_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4677 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4678 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4679 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4680 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4681 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4682 "over", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4683 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4684 .usage = "over", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4685 .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
|
4686 .impl = cmd_over_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4687 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4688 .max_args = 0 |
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 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4692 "next", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4693 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4694 .usage = "next", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4695 .desc = "Advance to the next instruction", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4696 .impl = cmd_next_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4697 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4698 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4699 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4700 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4701 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4702 "backtrace", "bt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4703 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4704 .usage = "backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4705 .desc = "Print a backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4706 .impl = cmd_backtrace_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4707 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4708 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4709 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4710 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4711 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4712 "delete", "d", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4713 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4714 .usage = "delete BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4715 .desc = "Remove breakpoint identified by BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4716 .impl = cmd_delete_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4717 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4718 .max_args = 1 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4719 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4720 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4721 .names = (const char *[]){ |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4722 "disassemble", "disasm", NULL |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4723 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4724 .usage = "disassemble [ADDRESS]", |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4725 .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
|
4726 .impl = cmd_disassemble_z80, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4727 .min_args = 0, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4728 .max_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4729 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4730 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4731 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4732 #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
|
4733 |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4734 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
|
4735 { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4736 .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
|
4737 "m68k", NULL |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4738 }, |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4739 .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
|
4740 .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
|
4741 .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
|
4742 .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
|
4743 .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
|
4744 .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
|
4745 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4746 }; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4747 |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4748 #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
|
4749 |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4750 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
|
4751 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4752 .names = (const char *[]){ |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4753 "vdpsprites", "vs", NULL |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4754 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4755 .usage = "vdpsprites", |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4756 .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
|
4757 .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
|
4758 .min_args = 0, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4759 .max_args = 0 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4760 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4761 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4762 .names = (const char *[]){ |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4763 "vdpsregs", "vr", NULL |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4764 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4765 .usage = "vdpregs", |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4766 .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
|
4767 .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
|
4768 .min_args = 0, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4769 .max_args = 0 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4770 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4771 }; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4772 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4773 #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
|
4774 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4775 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4776 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4777 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
|
4778 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4779 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
|
4780 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4781 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
|
4782 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4783 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
|
4784 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4785 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4786 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4787 |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4788 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
|
4789 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4790 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
|
4791 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
|
4792 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
|
4793 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4794 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
|
4795 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4796 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4797 |
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
|
4798 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
|
4799 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4800 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
|
4801 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
|
4802 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4804 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
|
4805 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4806 m68k_context *m68k = root->cpu_context; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4807 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
|
4808 if (!chunk) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4809 return start_address; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4810 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4811 if (chunk->mask == m68k->options->gen.address_mask) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4812 return chunk->end; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4813 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4814 return (start_address & ~chunk->mask) + chunk->mask + 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4815 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4816 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4817 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
|
4818 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4819 debug_root *root = find_root(context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4820 if (root && !root->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4821 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
|
4822 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
|
4823 root->read_mem = read_m68k; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4824 root->write_mem = write_m68k; |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4825 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
|
4826 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
|
4827 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
|
4828 debug_var *var; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4829 switch (current_system->type) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4830 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4831 case SYSTEM_GENESIS: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4832 case SYSTEM_SEGACD: |
2459
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4833 case SYSTEM_PICO: |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4834 case SYSTEM_COPERA: |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4835 //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
|
4836 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
|
4837 genesis_context *gen = context->system; |
2459
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4838 if (current_system->type == SYSTEM_GENESIS || current_system->type == SYSTEM_SEGACD) { |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4839 root->other_roots = tern_insert_ptr(root->other_roots, "z80", find_z80_root(gen->z80)); |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4840 root->other_roots = tern_insert_ptr(root->other_roots, "io", find_io_root(&gen->io)); |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4841 } |
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
|
4842 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
|
4843 root->other_roots = tern_insert_ptr(root->other_roots, "psg", find_psg_root(gen->psg)); |
2459
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4844 uint32_t num_commands = NUM_GENESIS; |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4845 if (current_system->type == SYSTEM_PICO || current_system->type == SYSTEM_COPERA) { |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4846 num_commands -= 3; |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4847 } else { |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4848 root->other_roots = tern_insert_ptr(root->other_roots, "ym", find_ym2612_root(gen->ym)); |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4849 } |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4850 add_commands(root, genesis_commands, num_commands); |
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
|
4851 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
|
4852 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
|
4853 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
|
4854 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
|
4855 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
|
4856 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
|
4857 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
|
4858 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
|
4859 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
|
4860 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4861 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4862 } 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
|
4863 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
|
4864 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
|
4865 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
|
4866 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
|
4867 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4868 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
|
4869 break; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4870 } |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4871 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
|
4872 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4873 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
|
4874 } |
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
|
4875 |
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
|
4876 #ifndef NO_Z80 |
548
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
4877 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4878 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
|
4879 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4880 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4881 uint32_t address = *out; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4882 *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
|
4883 if (size == 'w') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4884 *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
|
4885 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4886 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4887 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4888 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4889 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
|
4890 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4891 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4892 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
|
4893 if (size == 'w') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4894 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
|
4895 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4896 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4897 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4898 |
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
|
4899 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
|
4900 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4902 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
|
4903 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4906 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4908 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
|
4909 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
|
4910 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
|
4911 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
|
4912 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4913 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
|
4914 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4918 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4920 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
|
4921 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4924 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4926 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
|
4927 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
|
4928 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
|
4929 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
|
4930 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4932 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
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 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
|
4937 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
|
4938 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
|
4939 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
|
4940 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
|
4941 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
|
4942 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
|
4943 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
|
4944 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
|
4945 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
|
4946 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4949 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4951 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
|
4952 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
|
4953 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
|
4954 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
|
4955 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
|
4956 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
|
4957 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
|
4958 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
|
4959 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
|
4960 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4963 { |
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
|
4964 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
|
4965 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
|
4966 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
|
4967 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
|
4968 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
|
4969 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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->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
|
4971 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
|
4972 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
|
4973 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
|
4974 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
|
4975 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
|
4976 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4979 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4981 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
|
4982 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
|
4983 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
|
4984 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
|
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 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
|
4987 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
|
4988 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
|
4989 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
|
4990 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
|
4991 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
|
4992 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4995 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4997 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
|
4998 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
|
4999 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
|
5000 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
|
5001 } 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
|
5002 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
|
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 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
|
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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
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 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
|
5010 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
|
5011 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
|
5012 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
|
5013 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
|
5014 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5016 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
|
5017 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
|
5018 } 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
|
5019 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
|
5020 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
|
5021 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
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 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
|
5027 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
|
5028 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
|
5029 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
|
5030 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
|
5031 } 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
|
5032 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
|
5033 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5034 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
|
5035 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5038 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5040 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
|
5041 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
|
5042 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
|
5043 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
|
5044 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5046 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
|
5047 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
|
5048 } 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
|
5049 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
|
5050 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
|
5051 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5052 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5053 |
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
|
5054 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
|
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 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
|
5057 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
|
5058 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5061 { |
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
|
5062 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
|
5063 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
|
5064 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
|
5065 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
|
5066 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
|
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 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
|
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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5072 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5073 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
|
5074 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
|
5075 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5078 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5080 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
|
5081 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
|
5082 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
|
5083 return; |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5084 } |
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
|
5085 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
|
5086 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5087 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5089 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5090 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
|
5091 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
|
5092 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5095 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5097 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
|
5098 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5099 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5101 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5103 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
|
5104 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5107 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5109 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
|
5110 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5112 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
|
5113 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5115 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
|
5116 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5119 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5120 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
|
5121 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
|
5122 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5123 |
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
|
5124 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
|
5125 { |
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
|
5126 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
|
5127 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
|
5128 { |
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
|
5129 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
|
5130 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
|
5131 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
|
5132 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
|
5133 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
|
5134 } 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
|
5135 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
|
5136 var->set = z80_sp_set; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5137 } 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
|
5138 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
|
5139 var->set = z80_regpair_set; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5140 } |
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
|
5141 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
|
5142 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
|
5143 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
|
5144 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
|
5145 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
|
5146 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
|
5147 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 *d = toupper(*c); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5149 } |
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
|
5150 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
|
5151 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
|
5152 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5154 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
|
5155 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
|
5156 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
|
5157 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
|
5158 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
|
5159 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
|
5160 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
|
5161 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
|
5162 } 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
|
5163 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
|
5164 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
|
5165 } |
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
|
5166 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
|
5167 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
|
5168 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
|
5169 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
|
5170 { |
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
|
5171 *d = toupper(*c); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5172 } |
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
|
5173 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
|
5174 } |
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
|
5175 free(name); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5176 } |
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
|
5177 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
|
5178 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
|
5179 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
|
5180 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
|
5181 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
|
5182 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
|
5183 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
|
5184 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
|
5185 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
|
5186 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
|
5187 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
|
5188 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
|
5189 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
|
5190 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
|
5191 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
|
5192 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
|
5193 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
|
5194 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
|
5195 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
|
5196 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
|
5197 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
|
5198 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
|
5199 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
|
5200 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
|
5201 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
|
5202 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
|
5203 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
|
5204 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
|
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->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
|
5207 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
|
5208 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
|
5209 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
|
5210 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
|
5211 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
|
5212 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
|
5213 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
|
5214 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5215 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5216 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
|
5217 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5218 z80_context *z80 = root->cpu_context; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5219 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
|
5220 if (!chunk) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5221 return start_address; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5222 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5223 if (chunk->mask == z80->options->gen.address_mask) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5224 return chunk->end; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5225 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5226 return (start_address & ~chunk->mask) + chunk->mask + 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5227 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5228 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5229 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
|
5230 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5231 debug_root *root = find_root(context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5232 if (root && !root->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5233 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
|
5234 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
|
5235 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
|
5236 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
|
5237 sms_context *sms; |
2413
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5238 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
|
5239 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
|
5240 //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
|
5241 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
|
5242 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5243 case SYSTEM_GENESIS: |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5244 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
|
5245 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
|
5246 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
|
5247 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
|
5248 //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
|
5249 break; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5250 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
|
5251 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
|
5252 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
|
5253 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
|
5254 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
|
5255 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
|
5256 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
|
5257 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
|
5258 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
|
5259 break; |
2413
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5260 case SYSTEM_COLECOVISION: |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5261 coleco = context->system; |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5262 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
|
5263 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
|
5264 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
|
5265 //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
|
5266 //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
|
5267 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5268 root->read_mem = read_z80; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5269 root->write_mem = write_z80; |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
5270 root->disasm = create_z80_disasm(); |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5271 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
|
5272 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5273 return root; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5274 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5275 |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5276 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
|
5277 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5278 static char last_cmd[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5279 char input_buf[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5280 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
|
5281 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
|
5282 init_terminal(); |
2180
b87658ba3b94
Fix bug in Z80 debugger for SMS mode post-refactor
Michael Pavone <pavone@retrodev.com>
parents:
2179
diff
changeset
|
5283 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
|
5284 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
|
5285 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
|
5286 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
5287 root->address = address; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5288 //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
|
5289 int debugging; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
5290 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
|
5291 if (*this_bp) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5292 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
|
5293 debug_val condres; |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5294 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
|
5295 if (!condres.v.u32) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5296 return context; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5297 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5298 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5299 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
|
5300 free_expr((*this_bp)->condition); |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5301 (*this_bp)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5302 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5303 } |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5304 debugging = 1; |
2208
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5305 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
|
5306 { |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5307 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
|
5308 } |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5309 if (debugging) { |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5310 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
|
5311 } else { |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5312 fflush(stdout); |
2208
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5313 return context; |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5314 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5315 } else { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5316 zremove_breakpoint(context, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5317 } |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5318 if (context->wp_hit) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5319 context->wp_hit = 0; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5320 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
|
5321 if (*this_bp) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5322 if ((*this_bp)->condition) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5323 debug_val condres; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5324 if (eval_expr(root, (*this_bp)->condition, &condres)) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5325 if (!condres.v.u32) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5326 return context; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5327 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5328 } else { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5329 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
|
5330 free_expr((*this_bp)->condition); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5331 (*this_bp)->condition = NULL; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5332 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5333 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5334 debugging = 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5335 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
|
5336 { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5337 debugging = run_command(root, (*this_bp)->commands + i); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5338 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5339 if (debugging) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5340 if (context->wp_old_value != context->wp_hit_value) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5341 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
|
5342 } else { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5343 printf("Z80 Watchpoint %d hit\n", (*this_bp)->index); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5344 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5345 } else { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5346 fflush(stdout); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5347 return context; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5348 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5349 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5350 } |
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
|
5351 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
|
5352 if (!pc) { |
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
1111
diff
changeset
|
5353 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
|
5354 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
5355 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
|
5356 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
|
5357 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
|
5358 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
|
5359 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
|
5360 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
|
5361 make_format_str(format_str, cur->format); |
2183
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5362 for (int i = 0; i < cur->num_args; i++) |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5363 { |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5364 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
|
5365 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
|
5366 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5367 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
5368 |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5369 z80_disasm(&inst, input_buf, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5370 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
|
5371 debugger_repl(root); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5372 return context; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5373 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5374 |
548
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
5375 #endif |
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
5376 |
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
|
5377 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
|
5378 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5379 static char last_cmd[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5380 char input_buf[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5381 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
|
5382 |
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
|
5383 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
|
5384 |
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
|
5385 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
|
5386 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
|
5387 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
|
5388 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
|
5389 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5390 //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
|
5391 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
|
5392 if (address == root->branch_t) { |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
5393 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
|
5394 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
|
5395 remove_breakpoint(context, root->branch_f); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5396 } |
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
|
5397 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
|
5398 } else if(address == root->branch_f) { |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
5399 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
|
5400 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
|
5401 remove_breakpoint(context, root->branch_t); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5402 } |
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
|
5403 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
|
5404 } |
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
|
5405 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5406 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
|
5407 int debugging = 1; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5408 //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
|
5409 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
|
5410 if (*this_bp) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5411 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
|
5412 debug_val condres; |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5413 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
|
5414 if (!condres.v.u32) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5415 return; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5416 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5417 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5418 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
|
5419 free_expr((*this_bp)->condition); |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5420 (*this_bp)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5421 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5422 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5423 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
|
5424 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5425 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
|
5426 } |
5a3ac6093ea2
Add support for executing a list of debugger commands when a breakpoint is hit
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
5427 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
|
5428 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
|
5429 } else { |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5430 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
|
5431 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
|
5432 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5433 } else { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5434 remove_breakpoint(context, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5435 } |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5436 if (context->wp_hit) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5437 context->wp_hit = 0; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5438 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
|
5439 if (*this_bp) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5440 if ((*this_bp)->condition) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5441 debug_val condres; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5442 if (eval_expr(root, (*this_bp)->condition, &condres)) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5443 if (!condres.v.u32) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5444 return; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5445 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5446 } else { |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5447 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
|
5448 free_expr((*this_bp)->condition); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5449 (*this_bp)->condition = NULL; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5450 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5451 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5452 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
|
5453 { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5454 debugging = run_command(root, (*this_bp)->commands + i); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5455 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5456 if (debugging) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5457 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
|
5458 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
|
5459 } else { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5460 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
|
5461 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5462 } else { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5463 fflush(stdout); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5464 return; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5465 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5466 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5467 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5468 if (context->system == current_system) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5469 genesis_context *gen = context->system; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5470 vdp_force_update_framebuffer(gen->vdp); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5471 } |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5472 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
|
5473 root->after = after; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5474 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
|
5475 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
|
5476 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
|
5477 make_format_str(format_str, cur->format); |
2183
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5478 for (int i = 0; i < cur->num_args; i++) |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5479 { |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5480 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
|
5481 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
|
5482 } |
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
|
5483 } |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
5484 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
|
5485 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
|
5486 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
|
5487 return; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5488 } |