Mercurial > repos > blastem
annotate debug.c @ 2515:0775f5e0c468 default tip
Clear EDT on DTTRG. Fixes Cliffhanger and OrionNavattan's Mode 1 demo
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 05 Sep 2024 23:44:01 -0700 |
parents | b0f314b19964 |
children |
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 |
2499
d74d3998482c
Make some progress on compiling full emulator with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2459
diff
changeset
|
1538 return read_byte(address, (void **)context->mem_pointers, &context->opts->gen, context); |
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
|
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 { |
2499
d74d3998482c
Make some progress on compiling full emulator with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2459
diff
changeset
|
1543 return read_word(address, (void **)context->mem_pointers, &context->opts->gen, 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
|
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') { |
2499
d74d3998482c
Make some progress on compiling full emulator with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2459
diff
changeset
|
1576 write_byte(address, value, (void **)context->mem_pointers, &context->opts->gen, context); |
2178
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 } |
2499
d74d3998482c
Make some progress on compiling full emulator with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2459
diff
changeset
|
1582 write_word(address, value >> 16, (void **)context->mem_pointers, &context->opts->gen, context); |
d74d3998482c
Make some progress on compiling full emulator with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2459
diff
changeset
|
1583 write_word(address + 2, value, (void **)context->mem_pointers, &context->opts->gen, context); |
2178
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 } |
2499
d74d3998482c
Make some progress on compiling full emulator with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2459
diff
changeset
|
1589 write_word(address, value, (void **)context->mem_pointers, &context->opts->gen, context); |
2178
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; |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
1633 #ifdef NEW_CORE |
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
1634 //TODO: implement me |
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
1635 #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
|
1636 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
|
1637 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1639 } |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
1640 #endif |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1642 return ret; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1643 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1644 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1646 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1648 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
|
1649 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
|
1650 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
|
1651 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
|
1652 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1653 context->status = ival >> 8; |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
1654 #ifdef NEW_CORE |
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
1655 //TODO: implement me |
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
1656 #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
|
1657 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
|
1658 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
|
1659 } |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
1660 #endif |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1661 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1662 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1664 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1665 m68k_context *context = var->ptr; |
2499
d74d3998482c
Make some progress on compiling full emulator with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2459
diff
changeset
|
1666 return debug_int(context->cycles); |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1668 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1670 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1672 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
|
1673 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1674 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1676 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1677 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
|
1678 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
|
1679 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
|
1680 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
|
1681 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
|
1682 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1683 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
|
1684 } |
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 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
|
1687 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1689 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
|
1690 } |
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 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
|
1693 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1695 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
|
1696 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
|
1697 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
|
1698 return; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1699 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1700 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
|
1701 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1702 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1704 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1706 return debug_int(root->address); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1707 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
1708 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1710 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1712 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
|
1713 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1715 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
|
1716 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
|
1717 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
|
1718 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
|
1719 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
|
1720 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
|
1721 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
|
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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1725 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
|
1726 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
|
1727 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
|
1728 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
|
1729 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
|
1730 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
|
1731 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
|
1732 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
|
1733 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
|
1734 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
|
1735 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
|
1736 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 = 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
|
1740 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
|
1741 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
|
1742 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
|
1743 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
|
1744 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
|
1745 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 = 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
|
1747 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
|
1748 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
|
1749 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
|
1750 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
|
1751 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 = 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
|
1753 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
|
1754 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
|
1755 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
|
1756 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
|
1757 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
|
1758 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 = 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
|
1760 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
|
1761 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
|
1762 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
|
1763 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
|
1764 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
|
1765 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1767 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
|
1768 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
|
1769 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
|
1770 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1771 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1773 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1774 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
|
1775 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
|
1776 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1779 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1781 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
|
1782 } |
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 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
|
1785 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1787 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
|
1788 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1791 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1793 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
|
1794 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
|
1795 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
|
1796 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
|
1797 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1798 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
|
1799 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1802 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1804 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
|
1805 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1806 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
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 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
|
1810 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
|
1811 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
|
1812 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
|
1813 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
|
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 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
|
1816 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1819 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1820 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
|
1821 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
|
1822 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1825 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1826 vdp_context *vdp = array->base; |
2413
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
1827 if (!(vdp->regs[REG_MODE_2] & BIT_MODE_5)) { |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
1828 index = mode4_address_map[index & 0x3FFF] ^ 1; |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
1829 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1833 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
|
1834 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1835 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
|
1836 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
|
1837 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
|
1838 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
|
1839 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 vdp_context *vdp = array->base; |
2413
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
1841 if (!(vdp->regs[REG_MODE_2] & BIT_MODE_5)) { |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
1842 index = mode4_address_map[index & 0x3FFF] ^ 1; |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
1843 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1845 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1848 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1850 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
|
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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
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 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
|
1856 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
|
1857 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
|
1858 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
|
1859 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1860 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
|
1861 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
|
1862 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1865 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1867 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
|
1868 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1869 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
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 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
|
1873 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
|
1874 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
|
1875 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
|
1876 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1878 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
|
1879 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1882 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1884 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
|
1885 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1886 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1888 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1889 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
|
1890 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
|
1891 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
|
1892 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
|
1893 return; |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1894 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1896 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1897 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1899 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1901 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
|
1902 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
|
1903 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
|
1904 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
|
1905 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 = 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
|
1907 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
|
1908 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
|
1909 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
|
1910 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 = 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
|
1912 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
|
1913 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
|
1914 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
|
1915 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
|
1916 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1918 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
|
1919 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
|
1920 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
|
1921 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
|
1922 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1924 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
|
1925 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
|
1926 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
|
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 return root; |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1929 } |
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 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
|
1932 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1934 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
|
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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1938 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1940 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
|
1941 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
|
1942 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
|
1943 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1944 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
|
1945 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
|
1946 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
|
1947 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
|
1948 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
|
1949 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
|
1950 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
|
1951 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
|
1952 } |
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 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
|
1955 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1957 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
|
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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1961 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1963 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
|
1964 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
|
1965 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
|
1966 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1968 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
|
1969 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
|
1970 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
|
1971 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
|
1972 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
|
1973 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
|
1974 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
|
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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1977 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
|
1978 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1980 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1982 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
|
1983 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 return root; |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1985 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
1986 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
1987 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1989 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1991 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
|
1992 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1995 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
1997 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
|
1998 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
|
1999 return; |
2360
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
2000 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2001 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
|
2002 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
|
2003 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2004 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2006 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2008 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
|
2009 } |
053ba4551c62
Expose some more emu state via debugger array mechanism
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
2010 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2012 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2014 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
|
2015 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
|
2016 return; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2017 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2018 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
|
2019 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
|
2020 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2021 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2023 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2025 return debug_int(psg->volume[index]); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2026 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2027 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2029 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2031 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
|
2032 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
|
2033 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
|
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 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
|
2036 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
|
2037 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2040 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2041 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
|
2042 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2043 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
|
2044 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
|
2045 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
|
2046 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2047 return root; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2048 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2049 |
2422
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2050 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
|
2051 { |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2052 io_port *port = find_gamepad(array->base, index + 1); |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2053 uint32_t ret = 0; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2054 if (port) { |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2055 ret |= port->input[1]; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2056 ret |= port->input[0] << 2 & 0xC0; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2057 ret |= port->input[2] << 8 & 0xF00; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2058 } |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2059 return debug_int(ret); |
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 |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2062 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
|
2063 { |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2064 uint32_t ival; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2065 if (!debug_cast_int(val, &ival)) { |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2066 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
|
2067 return; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2068 } |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2069 io_port *port = find_gamepad(array->base, index + 1); |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2070 if (port) { |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2071 port->input[1] &= ~0x3F; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2072 port->input[1] |= ival & 0x3F; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2073 port->input[0] &= ~0x33; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2074 port->input[0] |= ival & 0x3; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2075 port->input[0] |= ival >> 2 & 0x30; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2076 port->input[2] &= ~0xF; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2077 port->input[2] |= ival >> 8 & 0xF; |
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 } |
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 debug_root *find_io_root(sega_io *io) |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2082 { |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2083 debug_root *root = find_root(io); |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2084 |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2085 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
|
2086 |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2087 return root; |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2088 } |
1978bd770023
Expose gamepad state in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2413
diff
changeset
|
2089 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2090 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
|
2091 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2092 char *prefix = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2093 char * full = alloc_concat(prefix, key); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2094 fprintf(stderr, "\t%s\n", full); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2095 free(full); |
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 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2098 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
|
2099 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2100 char *cur = text; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2101 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
|
2102 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2103 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2104 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2105 char *name = malloc(cur - text + 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2106 memcpy(name, text, cur - text); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2107 name[cur-text] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2108 uint8_t ret = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2109 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
|
2110 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
|
2111 if (!def) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2112 tern_node *node = prefix_res; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2113 while (node) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2114 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2115 if (node->left || node->right) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2116 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2117 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2118 if (node->el) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2119 node = node->straight.next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2120 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2121 def = node->straight.value.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2122 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2123 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2124 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2125 if (!def && prefix_res) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2126 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
|
2127 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
|
2128 goto cleanup_name; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2129 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2130 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2131 if (!def) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2132 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
|
2133 goto cleanup_name; |
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 char *format = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2136 if (*cur == '/') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2137 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2138 text = cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2139 while (*cur && !isspace(*cur)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2140 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2141 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2142 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2143 format = malloc(cur - text + 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2144 memcpy(format, text, cur - text); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2145 format[cur - text] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2146 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2147 int num_args = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2148 command_arg *args = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2149 if (*cur && *cur != '\n') { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2150 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2151 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2152 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
|
2153 if (def->raw_args) { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2154 while (*cur && *cur != '\n') |
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 ++cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2157 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2158 char *raw_param = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2159 if (cur != text) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2160 raw_param = malloc(cur - text + 1); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2161 memcpy(raw_param, text, cur - text); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2162 raw_param[cur - text] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2163 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2164 out->raw = raw_param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2165 out->args = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2166 out->num_args = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2167 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2168 int arg_storage = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2169 if (def->max_args > 0) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2170 arg_storage = def->max_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2171 } else if (def->max_args) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2172 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
|
2173 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2174 if (arg_storage) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2175 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
|
2176 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2177 while (*text && *text != '\n') |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2178 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2179 char *after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2180 expr *e = parse_expression(text, &after); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2181 if (e) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2182 if (num_args == arg_storage) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2183 if (def->max_args >= 0) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2184 free_expr(e); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2185 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
|
2186 goto cleanup_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2187 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2188 arg_storage *= 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2189 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
|
2190 } |
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 args[num_args].parsed = e; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2193 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
|
2194 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
|
2195 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
|
2196 text = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2197 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2198 goto cleanup_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2199 } |
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 if (num_args < def->min_args) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2202 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
|
2203 goto cleanup_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2204 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2205 out->raw = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2206 out->args = args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2207 out->num_args = num_args; |
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 out->def = def; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2210 out->format = format; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
2211 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2212 ret = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2213 cleanup_args: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2214 if (!ret) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2215 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
|
2216 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2217 free_expr(args[i].parsed); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2218 free(args[i].raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2219 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2220 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
|
2221 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2222 cleanup_name: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2223 free(name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2224 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2225 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2226 |
2188
e17d99c96c89
Make blocks an 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 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
|
2228 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
|
2229 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2230 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
|
2231 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2232 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
|
2233 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2234 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
|
2235 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2236 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2237 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
|
2238 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2239 free(cmd->format); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2240 free(cmd->raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2241 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
|
2242 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2243 free(cmd->args[i].raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2244 free_expr(cmd->args[i].parsed); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2245 } |
2188
e17d99c96c89
Make blocks an 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 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
|
2247 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
|
2248 free(cmd->args); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2249 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2250 |
2188
e17d99c96c89
Make blocks an 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 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
|
2252 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
|
2253 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
|
2254 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
|
2255 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
|
2256 END |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2257 }; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2258 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2259 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
|
2260 { |
e17d99c96c89
Make blocks an 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 ++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
|
2262 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
|
2263 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2264 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
|
2265 } |
e17d99c96c89
Make blocks an 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 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
|
2267 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
|
2268 #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
|
2269 #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
|
2270 #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
|
2271 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
|
2272 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
|
2273 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
|
2274 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
|
2275 #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
|
2276 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
|
2277 process_events(); |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2252
diff
changeset
|
2278 #ifndef IS_LIB |
2252
6a07b13894f7
Fix input processing while waiting for console input in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2216
diff
changeset
|
2279 render_update_display(); |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2252
diff
changeset
|
2280 #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
|
2281 #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
|
2282 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
|
2283 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
|
2284 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
|
2285 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
|
2286 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
|
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 #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
|
2289 } 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
|
2290 |
e17d99c96c89
Make blocks an 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 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
|
2292 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
|
2293 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
|
2294 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
|
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 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
|
2297 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
|
2298 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
|
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 (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
|
2301 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
|
2302 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
|
2303 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2304 if (!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
|
2305 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
|
2306 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2307 } |
e17d99c96c89
Make blocks an 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 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
|
2309 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
|
2310 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
|
2311 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2312 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
|
2313 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
|
2314 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
|
2315 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
|
2316 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
|
2317 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2318 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
|
2319 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
|
2320 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
|
2321 } |
e17d99c96c89
Make blocks an 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 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
|
2323 { |
e17d99c96c89
Make blocks an 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 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
|
2325 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
|
2326 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
|
2327 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
|
2328 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
|
2329 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
|
2330 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
|
2331 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
|
2332 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
|
2333 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
|
2334 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
|
2335 } |
e17d99c96c89
Make blocks an 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 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
|
2337 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
|
2338 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
|
2339 } |
e17d99c96c89
Make blocks an 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 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
|
2341 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
|
2342 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
|
2343 break; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2344 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2345 } |
e17d99c96c89
Make blocks an 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 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
|
2348 } |
e17d99c96c89
Make blocks an 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 |
e17d99c96c89
Make blocks an 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 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
|
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 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
|
2353 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
|
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 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
|
2356 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
|
2357 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
|
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 } |
e17d99c96c89
Make blocks an 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 } |
e17d99c96c89
Make blocks an 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 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
|
2362 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2363 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2364 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
|
2365 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2366 |
e17d99c96c89
Make blocks an 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 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
|
2368 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
|
2369 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
|
2370 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
|
2371 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
|
2372 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
|
2373 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
|
2374 } |
2188
e17d99c96c89
Make blocks an 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 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
|
2376 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
|
2377 { |
e17d99c96c89
Make blocks an 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 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
|
2379 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
|
2380 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
|
2381 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
|
2382 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
|
2383 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
|
2384 } |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2385 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
|
2386 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
|
2387 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
|
2388 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
|
2389 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
|
2390 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2391 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
|
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 } |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2394 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
|
2395 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
|
2396 } else { |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2397 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
|
2398 } |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
2399 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
|
2400 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2401 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2402 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
|
2403 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2404 exit(0); |
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 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2407 typedef struct { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2408 size_t num_commands; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2409 size_t longest_command; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2410 } help_state; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2411 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2412 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
|
2413 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2414 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2415 if (def->visited) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2416 return; |
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 def->visited = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2419 help_state *state = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2420 state->num_commands++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2421 size_t len = strlen(def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2422 if (len > state->longest_command) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2423 state->longest_command = len; |
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 } |
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 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
|
2428 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2429 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2430 def->visited = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2431 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2432 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2433 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
|
2434 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2435 command_def *def = val.ptrval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2436 if (def->visited) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2437 return; |
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 def->visited = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2440 help_state *state = data; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2441 size_t len = strlen(def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2442 printf(" %s", def->usage); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2443 while (len < state->longest_command) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2444 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2445 len++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2446 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2447 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
|
2448 const char *extra_desc = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2449 if (strlen(def->desc) <= remaining) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2450 printf(" - %s\n", def->desc); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2451 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2452 char split[76]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2453 int split_point = remaining; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2454 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
|
2455 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2456 --split_point; |
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 (!split_point) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2459 split_point = remaining; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2460 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2461 memcpy(split, def->desc, split_point); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2462 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
|
2463 split[split_point] = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2464 printf(" - %s\n", split); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2465 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2466 if (def->names[1]) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2467 fputs(" Aliases: ", stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2468 len = strlen(" Aliases: "); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2469 const char **name = def->names + 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2470 uint8_t first = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2471 while (*name) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2472 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2473 if (first) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2474 first = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2475 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2476 putchar(','); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2477 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2478 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
|
2479 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2480 fputs(*name, stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2481 len += strlen(*name); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2482 ++name; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2483 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2484 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2485 len = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2486 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2487 if (extra_desc) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2488 while (len < state->longest_command + 5) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2489 putchar(' '); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2490 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
|
2491 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2492 fputs(extra_desc, stdout); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2493 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2494 putchar('\n'); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2495 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2496 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2497 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
|
2498 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2499 help_state state = {0,0}; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2500 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
|
2501 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
|
2502 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
|
2503 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
|
2504 return 1; |
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 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2507 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
|
2508 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2509 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2510 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2511 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2512 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
|
2513 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2514 strcpy(format_str, "%s: %d\n"); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2515 if (format) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2516 switch (format[0]) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2517 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2518 case 'x': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2519 case 'X': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2520 case 'd': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2521 case 'c': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2522 case 's': |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2523 format_str[5] = format[0]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2524 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2525 default: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2526 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
|
2527 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2528 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2529 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2530 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2532 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2534 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2536 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
|
2537 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
|
2538 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
|
2539 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
|
2540 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
|
2541 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2543 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
|
2544 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
|
2545 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
|
2546 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
|
2547 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2549 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2551 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
|
2552 } 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
|
2553 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
|
2554 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2555 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
|
2556 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
|
2557 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
|
2558 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
|
2559 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
|
2560 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
|
2561 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
|
2562 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2563 } |
e17d99c96c89
Make blocks an 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 } |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2565 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2566 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
|
2567 { |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2568 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
|
2569 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
|
2570 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
|
2571 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2572 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
|
2573 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2574 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2575 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2576 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2577 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
|
2578 { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2579 char *fmt = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2580 if (!fmt) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2581 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
|
2582 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2583 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2584 char *cur = fmt; |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2585 char format_str[3] = {'%', 'd', 0}; |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2586 uint32_t cur_param = 1; |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2587 while (*cur) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2588 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2589 if (*cur == '%') { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2590 switch(cur[1]) |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2591 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2592 case 'x': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2593 case 'X': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2594 case 'c': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2595 case 'd': |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2596 case 's': |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2597 case 'f': |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2598 break; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2599 default: |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2600 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
|
2601 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2602 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2603 format_str[1] = cur[1]; |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2604 if (cur_param == cmd->num_args) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2605 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
|
2606 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2607 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2608 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
|
2609 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
|
2610 if (val.type == DBG_VAL_STRING) { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
2611 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
|
2612 } 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
|
2613 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
|
2614 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
|
2615 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
|
2616 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
|
2617 return 1; |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2618 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2620 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
|
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 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
|
2623 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
|
2624 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
|
2625 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
|
2626 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
|
2627 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2628 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
|
2629 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2630 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
|
2631 printf(format_str, tmp); |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2632 } |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2633 } else if (cur[1] == 'f') { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2634 float fval; |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2635 if (!debug_cast_float(val, &fval)) { |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2636 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
|
2637 return 1; |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2638 } |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
2639 printf(format_str, fval); |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2640 } 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
|
2641 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
|
2642 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
|
2643 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
|
2644 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
|
2645 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2646 printf(format_str, ival); |
2187
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 cur += 2; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2649 } else { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2650 putchar(*cur); |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2651 ++cur; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2652 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2653 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2654 return 1; |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2655 } |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
2656 |
2188
e17d99c96c89
Make blocks an 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 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
|
2658 { |
2188
e17d99c96c89
Make blocks an 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_print(root, cmd); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2660 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
|
2661 ndisp->next = root->displays; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2662 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
|
2663 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
|
2664 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
|
2665 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
|
2666 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
|
2667 cmd->num_args = 0; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2668 root->displays = ndisp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2669 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
|
2670 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2671 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2672 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2673 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
|
2674 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2675 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
|
2676 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
|
2677 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
|
2678 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
|
2679 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
|
2680 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2681 while (*cur) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2682 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2683 if ((*cur)->index == index) { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2684 disp_def *del_disp = *cur; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2685 *cur = del_disp->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2686 free(del_disp->format); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2687 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
|
2688 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2689 free(del_disp->args[i].raw); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2690 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
|
2691 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2692 free(del_disp->args); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2693 free(del_disp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2694 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2695 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2696 cur = &(*cur)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2697 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2698 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2699 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2700 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2701 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2702 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
|
2703 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2704 if (current_system->soft_reset) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2705 current_system->soft_reset(current_system); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2706 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2707 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2708 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
|
2709 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2710 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2711 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2712 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2713 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
|
2714 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2715 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
|
2716 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
|
2717 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
|
2718 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
|
2719 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2720 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
|
2721 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
|
2722 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
|
2723 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2724 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2725 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
|
2726 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2727 free_parsed_command((*target)->commands + i); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2728 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2729 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
|
2730 (*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
|
2731 (*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
|
2732 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
|
2733 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
|
2734 return 1; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2735 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2736 |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2737 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
|
2738 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2739 uint8_t debugging = 1; |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2740 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
|
2741 { |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2742 debugging = run_command(root, block->commands + i); |
2190
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 return debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2745 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2746 |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2747 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
|
2748 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2749 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
|
2750 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2751 |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2752 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
|
2753 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2754 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
|
2755 return execute_block(root, &cmd->else_block); |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2756 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2757 int debugging = 1; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2758 do { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2759 debugging = execute_block(root, &cmd->block) && debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2760 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
|
2761 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
|
2762 return 1; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2763 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2764 } 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
|
2765 return debugging; |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2766 } |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
2767 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2768 const char *expr_type_names[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2769 "EXPR_NONE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2770 "EXPR_SCALAR", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2771 "EXPR_UNARY", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2772 "EXPR_BINARY", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2773 "EXPR_SIZE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2774 "EXPR_MEM" |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2775 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2776 |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2777 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
|
2778 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2779 debug_root *set_root = root; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2780 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
|
2781 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
|
2782 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2783 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
|
2784 if (!set_root) { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2785 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
|
2786 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2787 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2788 set_expr = set_expr->left; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2789 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2790 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
|
2791 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
|
2792 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2793 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2794 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
|
2795 if (var) { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2796 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
|
2797 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2798 } |
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 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
|
2802 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
|
2803 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2804 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2805 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2806 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
|
2807 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
|
2808 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2809 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
|
2810 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
|
2811 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2812 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
|
2813 cmd->block.commands = NULL; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2814 cmd->block.num_commands = 0; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2815 return 1; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2816 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2817 |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2818 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
|
2819 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2820 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
|
2821 return 0; |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2822 } |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
2823 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2824 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
|
2825 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2826 char *name = NULL; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2827 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
|
2828 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
|
2829 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
|
2830 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
|
2831 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2832 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
|
2833 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
|
2834 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
|
2835 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
|
2836 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2838 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2839 debug_val address; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2840 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
|
2841 switch (set_expr->type) |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2842 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2843 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
|
2844 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
|
2845 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
|
2846 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2847 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
|
2848 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2849 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2850 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2851 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
|
2852 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
|
2853 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
|
2854 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
|
2855 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2856 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
|
2857 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2858 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2859 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2860 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
|
2861 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
|
2862 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
|
2863 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
|
2864 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2865 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2867 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
|
2868 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
|
2869 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2870 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
|
2871 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
|
2872 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
|
2873 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
|
2874 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2875 array = get_array(right); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2876 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
|
2877 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
|
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 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
|
2881 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
|
2882 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2883 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2884 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
|
2885 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
|
2886 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2887 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2888 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2889 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2890 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
|
2891 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
|
2892 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2893 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
2894 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
|
2895 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
|
2896 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2897 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2899 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
|
2900 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
|
2901 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
|
2902 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
|
2903 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
|
2904 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2906 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
|
2907 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2908 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2910 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
|
2911 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
|
2912 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
|
2913 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
|
2914 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
|
2915 } 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
|
2916 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
|
2917 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
|
2918 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
|
2919 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2920 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2921 var->set(var, value); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2922 } 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
|
2923 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
|
2924 } 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
|
2925 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
|
2926 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2927 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2928 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
2929 |
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
|
2930 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
|
2931 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2933 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
|
2934 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
|
2935 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2937 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
|
2938 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
|
2939 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
|
2940 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2942 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2944 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
|
2945 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
|
2946 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2947 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
|
2948 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
|
2949 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
|
2950 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
|
2951 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2952 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
|
2953 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
|
2954 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
|
2955 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
|
2956 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
|
2957 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
|
2958 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
|
2959 } |
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
|
2960 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
|
2961 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2963 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
|
2964 } |
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
|
2965 |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2966 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
|
2967 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2969 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
|
2970 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
|
2971 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2973 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
|
2974 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
|
2975 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
|
2976 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2978 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2980 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
|
2981 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2982 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
2984 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
|
2985 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
|
2986 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
|
2987 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
|
2988 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
|
2989 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
|
2990 return 1; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2991 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
2992 } 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
|
2993 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
|
2994 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
|
2995 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
|
2996 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
|
2997 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
|
2998 array = get_array(var->val); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
2999 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3000 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
|
3001 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
|
3002 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
|
3003 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
|
3004 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
|
3005 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3006 } |
2367
48cc69b4c358
Add some more builtin functions to debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2366
diff
changeset
|
3007 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
|
3008 { |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3009 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
|
3010 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
|
3011 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3012 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3013 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
|
3014 } |
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 |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3018 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
|
3019 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3020 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
|
3021 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
|
3022 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
|
3023 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3024 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3025 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
|
3026 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
|
3027 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3028 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 array->append(array, cmd->args[1].value); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3030 return 1; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3031 } |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
3032 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3033 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
|
3034 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3035 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
|
3036 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
|
3037 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
|
3038 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
|
3039 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3040 current_system->enter_debugger_frames = frames; |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
3041 return 0; |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
3042 } |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
3043 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3044 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
|
3045 { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3046 char *bind = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3047 if (!bind) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3048 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
|
3049 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3050 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3051 if (!bind_up(bind)) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3052 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
|
3053 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3054 return 1; |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3055 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3056 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3057 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
|
3058 { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3059 char *bind = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3060 if (!bind) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3061 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
|
3062 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3063 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3064 if (!bind_down(bind)) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3065 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
|
3066 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3067 return 1; |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3068 } |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
3069 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3070 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
|
3071 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3072 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
|
3073 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
|
3074 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3075 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3076 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
|
3077 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
|
3078 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
|
3079 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
|
3080 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3081 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
|
3082 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
|
3083 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
|
3084 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3085 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3086 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
|
3087 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
|
3088 (*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
|
3089 cmd->args[1].parsed = NULL; |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3090 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3091 (*target)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3092 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3093 return 1; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3094 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
3095 |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3096 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
|
3097 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3098 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
|
3099 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
|
3100 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
|
3101 *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
|
3102 } |
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 |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3105 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
|
3106 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3107 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
|
3108 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
|
3109 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
|
3110 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
|
3111 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3112 putchar(' '); |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3113 len++; |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3114 } |
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
|
3115 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
|
3116 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3117 |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3118 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
|
3119 { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3120 if (cmd->num_args) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3121 char *filename = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3122 if (!filename) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3123 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
|
3124 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3125 } |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3126 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
|
3127 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
|
3128 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
|
3129 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
|
3130 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3131 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
|
3132 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
|
3133 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3134 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
|
3135 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
|
3136 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
|
3137 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
|
3138 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
|
3139 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
|
3140 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
|
3141 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
|
3142 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
|
3143 } |
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 } |
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 } else { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3148 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
|
3149 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
|
3150 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
|
3151 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
|
3152 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3153 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
|
3154 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
3155 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3156 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
|
3157 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3158 char size = cmd->format ? cmd->format[0] : 'b'; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3159 if (size != 'b' && size != 'w' && size != 'l') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3160 fprintf(stderr, "Invalid size %s\n", cmd->format); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3161 return 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3162 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3163 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
|
3164 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
|
3165 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3166 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3167 char *fname = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3168 if (!fname) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3169 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
|
3170 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3171 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3172 FILE *f = fopen(fname, "wb"); |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3173 if (!f) { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3174 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
|
3175 return 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3176 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3177 uint32_t start = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3178 debug_val val; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3179 debug_array * arr = NULL; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3180 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
|
3181 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3182 if (!eval_expr(root, cmd->args[1].parsed->left, &val)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3183 fprintf(stderr, "Failed to eval start index\n"); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3184 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3185 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3186 if (!debug_cast_int(val, &start)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3187 fprintf(stderr, "Start index must evaluate to integer\n"); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3188 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3189 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3190 if (cmd->args[1].parsed->right) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3191 if (!eval_expr(root, cmd->args[1].parsed->right, &val)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3192 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
|
3193 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3194 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3195 arr = get_array(val); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3196 if (!arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3197 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
|
3198 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3199 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3200 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3201 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3202 if (!eval_expr(root, cmd->args[1].parsed, &val)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3203 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
|
3204 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3205 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3206 arr = get_array(val); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3207 if (!arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3208 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
|
3209 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3210 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3211 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3212 uint32_t count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3213 if (cmd->num_args > 2) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3214 if (!eval_expr(root, cmd->args[2].parsed, &val)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3215 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
|
3216 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3217 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3218 if (!debug_cast_int(val, &count)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3219 fprintf(stderr, "Count must evaluate to integer\n"); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3220 goto cleanup; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3221 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3222 } else if (arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3223 count = arr->size < start ? 0 : arr->size - start; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3224 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3225 count = root->chunk_end(root, start) - start; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3226 if (size == 'l') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3227 count /= 4; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3228 } else if (size == 'w') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3229 count /= 2; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3230 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3231 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3232 union { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3233 uint8_t b[1024]; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3234 uint16_t w[512]; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3235 uint32_t l[256]; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3236 } buffer; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3237 uint32_t cur = start; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3238 if (size == 'l') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3239 while (count) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3240 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3241 uint32_t n = count < 256 ? count : 256; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3242 count -= n; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3243 for (uint32_t i = 0; i < n ; i++) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3244 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3245 if (arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3246 val = arr->get(arr, cur++); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3247 if (!debug_cast_int(val, buffer.l + i)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3248 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3249 count = 0; |
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 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3252 buffer.l[i] = cur; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3253 cur += 4; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3254 if (!root->read_mem(root, buffer.l + i, 'l')) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3255 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3256 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3257 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3258 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3259 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3260 fwrite(buffer.l, sizeof(uint32_t), n, f); |
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 } else if (size == 'w') { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3263 while (count) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3264 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3265 uint32_t n = count < 512 ? count : 512; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3266 count -= n; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3267 uint32_t tmp; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3268 for (uint32_t i = 0; i < n ; i++) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3269 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3270 if (arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3271 val = arr->get(arr, cur++); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3272 if (!debug_cast_int(val, &tmp)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3273 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3274 count = 0; |
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 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3277 tmp = cur; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3278 cur += 2; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3279 if (!root->read_mem(root, &tmp, 'w')) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3280 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3281 count = 0; |
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 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3284 buffer.w[i] = tmp; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3285 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3286 fwrite(buffer.w, sizeof(uint16_t), n, f); |
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 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3289 while (count) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3290 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3291 uint32_t n = count < 1024 ? count : 1024; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3292 count -= n; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3293 uint32_t tmp; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3294 for (uint32_t i = 0; i < n ; i++) |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3295 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3296 if (arr) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3297 val = arr->get(arr, cur++); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3298 if (!debug_cast_int(val, &tmp)) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3299 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3300 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3301 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3302 } else { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3303 tmp = cur++; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3304 if (!root->read_mem(root, &tmp, 'b')) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3305 n = i; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3306 count = 0; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3307 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3308 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3309 buffer.b[i] = tmp; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3310 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3311 fwrite(buffer.b, sizeof(uint8_t), n, f); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3312 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3313 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3314 cleanup: |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3315 fclose(f); |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3316 return 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3317 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
3318 |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3319 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
|
3320 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3321 char size = cmd->format ? cmd->format[0] : 'b'; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3322 if (size != 'b' && size != 'w' && size != 'l') { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3323 fprintf(stderr, "Invalid size %s\n", cmd->format); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3324 return 1; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3325 } |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3326 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
|
3327 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
|
3328 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3329 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3330 char *fname = get_cstring(cmd->args[0].value); |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3331 if (!fname) { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3332 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
|
3333 return 1; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3334 } |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3335 FILE *f = fopen(fname, "rb"); |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3336 if (!f) { |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3337 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
|
3338 return 1; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3339 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3340 uint32_t start = 0; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3341 debug_val val; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3342 debug_array * arr = NULL; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3343 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
|
3344 |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3345 if (!eval_expr(root, cmd->args[1].parsed->left, &val)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3346 fprintf(stderr, "Failed to eval start index\n"); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3347 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3348 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3349 if (!debug_cast_int(val, &start)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3350 fprintf(stderr, "Start index must evaluate to integer\n"); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3351 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3352 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3353 if (cmd->args[1].parsed->right) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3354 if (!eval_expr(root, cmd->args[1].parsed->right, &val)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3355 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
|
3356 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3357 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3358 arr = get_array(val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3359 if (!arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3360 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
|
3361 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3362 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3363 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3364 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3365 if (!eval_expr(root, cmd->args[1].parsed, &val)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3366 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
|
3367 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3368 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3369 arr = get_array(val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3370 if (!arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3371 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
|
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 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3375 uint32_t count = 0; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3376 uint8_t has_count = 0; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3377 if (cmd->num_args > 2) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3378 if (!eval_expr(root, cmd->args[2].parsed, &val)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3379 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
|
3380 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3381 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3382 if (!debug_cast_int(val, &count)) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3383 fprintf(stderr, "Count must evaluate to integer\n"); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3384 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3385 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3386 has_count = 1; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3387 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3388 union { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3389 uint8_t b[1024]; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3390 uint16_t w[512]; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3391 uint32_t l[256]; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3392 } buffer; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3393 uint32_t cur = start; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3394 if (size == 'l') { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3395 while (count || !has_count) |
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 uint32_t n = (has_count && count < 256) ? count : 256; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3398 count -= n; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3399 n = fread(buffer.l, sizeof(uint32_t), n, f); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3400 if (!n) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3401 break; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3402 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3403 for (uint32_t i = 0; i < n ; i++) |
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 if (arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3406 val = debug_int(buffer.l[i]); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3407 if (cur >= arr->size) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3408 if (arr->append) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3409 arr->append(arr, val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3410 } else { |
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 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3414 arr->set(arr, cur, val); |
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 cur++; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3417 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3418 if (!root->write_mem(root, cur, buffer.l[i], 'l')) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3419 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3420 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3421 cur += 4; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3422 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3423 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3424 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3425 } else if (size == 'w') { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3426 while (count || !has_count) |
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 uint32_t n = (has_count && count < 512) ? count : 512; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3429 count -= n; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3430 n = fread(buffer.w, sizeof(uint16_t), n, f); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3431 if (!n) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3432 break; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3433 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3434 for (uint32_t i = 0; i < n ; i++) |
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 if (arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3437 val = debug_int(buffer.w[i]); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3438 if (cur >= arr->size) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3439 if (arr->append) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3440 arr->append(arr, val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3441 } else { |
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 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3445 arr->set(arr, cur, val); |
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 cur++; |
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 if (!root->write_mem(root, cur, buffer.w[i], 'w')) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3450 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3451 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3452 cur += 2; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3453 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3454 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3455 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3456 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3457 while (count || !has_count) |
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 uint32_t n = (has_count && count < 1024) ? count : 1024; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3460 count -= n; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3461 n = fread(buffer.b, sizeof(uint8_t), n, f); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3462 if (!n) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3463 break; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3464 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3465 for (uint32_t i = 0; i < n ; i++) |
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 if (arr) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3468 val = debug_int(buffer.b[i]); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3469 if (cur >= arr->size) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3470 if (arr->append) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3471 arr->append(arr, val); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3472 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3473 goto cleanup; |
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 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3476 arr->set(arr, cur, val); |
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 } else { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3479 if (!root->write_mem(root, cur, buffer.b[i], 'b')) { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3480 goto cleanup; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3481 } |
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 cur++; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3484 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3485 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3486 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3487 cleanup: |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3488 fclose(f); |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3489 return 1; |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3490 } |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
3491 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3492 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
|
3493 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3494 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
|
3495 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
|
3496 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
|
3497 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
|
3498 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3499 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
|
3500 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
|
3501 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
|
3502 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3503 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3504 bp_def *tmp = *this_bp; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3505 if (tmp->type == BP_TYPE_CPU) { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3506 remove_breakpoint(root->cpu_context, tmp->address); |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3507 } else if (tmp->type == BP_TYPE_CPU_WATCH) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3508 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
|
3509 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3510 *this_bp = (*this_bp)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3511 if (tmp->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3512 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
|
3513 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3514 free_parsed_command(tmp->commands + i); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3515 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3516 free(tmp->commands); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3517 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3518 free(tmp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3519 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3520 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3521 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3522 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
|
3523 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
3525 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
|
3526 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
|
3527 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
|
3528 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3529 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
|
3530 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
|
3531 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
|
3532 new_bp->address = address; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3533 new_bp->mask = 0xFFFFFF; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3534 new_bp->index = root->bp_index++; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3535 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
|
3536 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
|
3537 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
|
3538 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3539 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3540 |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3541 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
|
3542 { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3543 uint32_t address; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3544 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
|
3545 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
|
3546 return 1; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3547 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3548 uint32_t size; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3549 if (cmd->num_args > 1) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3550 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
|
3551 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
|
3552 return 1; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3553 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3554 } else { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3555 //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
|
3556 size = (address & 1) ? 1 : 2; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3557 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3558 m68k_add_watchpoint(root->cpu_context, address, size); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3559 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
|
3560 new_bp->next = root->breakpoints; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3561 new_bp->address = address; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3562 new_bp->mask = size; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3563 new_bp->index = root->bp_index++; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3564 new_bp->type = BP_TYPE_CPU_WATCH; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3565 root->breakpoints = new_bp; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3566 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
|
3567 return 1; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3568 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
3569 |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3570 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
|
3571 { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3572 value &= 0xFF; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3573 if (context->regs[reg] == value) { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3574 return; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3575 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3576 genesis_context *gen = (genesis_context *)context->system; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3577 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
|
3578 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
|
3579 int debugging = 1; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3580 if (*this_bp) { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3581 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
|
3582 debug_val condres; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3583 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
|
3584 if (!condres.v.u32) { |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3585 return; |
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 } else { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3588 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
|
3589 free_expr((*this_bp)->condition); |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3590 (*this_bp)->condition = NULL; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3591 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3592 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3593 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
|
3594 { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3595 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
|
3596 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3597 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
|
3598 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
|
3599 gen->header.enter_debugger = 1; |
2499
d74d3998482c
Make some progress on compiling full emulator with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2459
diff
changeset
|
3600 if (gen->m68k->sync_cycle > gen->m68k->cycles + 1) { |
d74d3998482c
Make some progress on compiling full emulator with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2459
diff
changeset
|
3601 gen->m68k->sync_cycle = gen->m68k->cycles + 1; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3602 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3603 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
|
3604 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
|
3605 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3606 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3607 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3608 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3609 |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3610 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
|
3611 { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3612 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
|
3613 new_bp->next = root->breakpoints; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3614 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
|
3615 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
|
3616 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
|
3617 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
|
3618 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3619 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
|
3620 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
|
3621 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
|
3622 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
|
3623 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3624 } 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
|
3625 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
|
3626 } |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3627 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3628 new_bp->index = root->bp_index++; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3629 new_bp->type = BP_TYPE_VDPREG; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3630 root->breakpoints = new_bp; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3631 m68k_context *m68k = root->cpu_context; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3632 genesis_context *gen = m68k->system; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3633 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
|
3634 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
|
3635 return 1; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3636 } |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
3637 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3638 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
|
3639 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3640 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
|
3641 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
|
3642 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
|
3643 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
|
3644 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3645 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
|
3646 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3647 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3648 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3649 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
|
3650 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3651 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3652 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3653 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3654 if (inst->op == M68K_RTS) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3655 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
|
3656 } 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
|
3657 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
|
3658 } else if(m68k_is_branch(inst)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3659 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
|
3660 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3661 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
|
3662 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
|
3663 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3664 if (inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3665 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
|
3666 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
|
3667 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3668 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3669 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3670 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
|
3671 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
|
3672 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3673 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3674 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
|
3675 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3676 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3677 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
|
3678 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3679 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3680 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3681 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
|
3682 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3683 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3684 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3685 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3686 if (inst->op == M68K_RTS) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3687 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
|
3688 } 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
|
3689 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
|
3690 } 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
|
3691 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
|
3692 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
|
3693 if (root->branch_t < after) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3694 root->branch_t = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3695 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3696 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3697 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
|
3698 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3699 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3700 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
|
3701 if (target > after) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3702 if (inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3703 after = target; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3704 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3705 root->branch_f = target; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3706 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3707 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
|
3708 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3709 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3710 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3711 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
|
3712 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3713 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3714 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
|
3715 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3716 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3717 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3718 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
|
3719 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3720 m68kinst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3721 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3722 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3723 if (inst->op == M68K_RTS) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3724 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
|
3725 } 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
|
3726 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
|
3727 } 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
|
3728 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
|
3729 root->branch_f = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3730 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
|
3731 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
|
3732 } else if(inst->op == M68K_DBCC) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3733 if ( inst->extra.cond == COND_FALSE) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3734 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
|
3735 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
|
3736 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3737 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3738 root->branch_t = after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3739 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
|
3740 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
|
3741 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3742 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3743 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
|
3744 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3745 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3746 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
|
3747 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3748 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3749 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3750 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
|
3751 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3752 m68k_context *context = root->cpu_context; |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
3753 #ifdef NEW_CORE |
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
3754 //TODO: implement me |
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
3755 #else |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3756 uint32_t stack = context->aregs[7]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3757 uint8_t non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3758 do { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3759 uint32_t bt_address = m68k_instruction_fetch(stack, context); |
2499
d74d3998482c
Make some progress on compiling full emulator with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2459
diff
changeset
|
3760 bt_address = get_instruction_start(context->opts, bt_address - 2); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3761 if (bt_address) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3762 stack += 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3763 non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3764 m68kinst inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3765 char buf[128]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3766 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
|
3767 m68k_disasm(&inst, buf); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3768 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
|
3769 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3770 //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
|
3771 stack += 2; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3772 non_adr_count++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3773 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3774 //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
|
3775 } while (stack && non_adr_count < 6); |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
3776 #endif |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3777 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3778 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3779 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3780 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
|
3781 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3782 m68k_context *context = root->cpu_context; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3783 uint32_t address = root->address; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3784 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
|
3785 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
|
3786 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
|
3787 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
|
3788 } |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3789 } |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
3790 #ifndef NEW_CORE |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3791 char disasm_buf[1024]; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3792 m68kinst inst; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3793 do { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3794 label_def *def = find_label(root->disasm, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3795 if (def) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3796 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
|
3797 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3798 printf("%s:\n", def->labels[i]); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3799 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3800 } |
2252
6a07b13894f7
Fix input processing while waiting for console input in debugger
Michael Pavone <pavone@retrodev.com>
parents:
2216
diff
changeset
|
3801 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3802 address = m68k_decode(m68k_instruction_fetch, context, &inst, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3803 m68k_disasm_labels(&inst, disasm_buf, root->disasm); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3804 printf("\t%s\n", disasm_buf); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3805 } while(!m68k_is_terminal(&inst)); |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
3806 #endif |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3807 return 1; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3808 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
3809 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3810 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
|
3811 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3812 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3813 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3814 vdp_print_sprite_table(gen->vdp); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3815 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3816 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3817 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3818 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
|
3819 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3820 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3821 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3822 vdp_print_reg_explain(gen->vdp); |
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_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
|
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; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3830 if (cmd->num_args) { |
2505
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
3831 if (cmd->args[0].value.v.u32 < 1 || cmd->args[0].value.v.u32 > 6) { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
3832 printf("%d is not a valid YM2612 channel number. Valid values are 1-6\n", cmd->args[0].value.v.u32); |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
3833 return 1; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
3834 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
3835 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
|
3836 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3837 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
|
3838 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
|
3839 } |
2173
894c7873a2b1
Consume all expressions in debugger print command
Michael Pavone <pavone@retrodev.com>
parents:
2172
diff
changeset
|
3840 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3841 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3842 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3843 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3844 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
|
3845 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3846 m68k_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3847 genesis_context * gen = context->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3848 ym_print_timer_info(gen->ym); |
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 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3852 static uint8_t cmd_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
|
3853 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3854 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3855 while (param && *param && isblank(*param)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3856 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3857 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3858 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3859 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3860 genesis_context *gen = m68k->system; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3861 segacd_context *cd = gen->expansion; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3862 if (param && *param && !isspace(*param)) { |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2191
diff
changeset
|
3863 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3864 debug_root *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
|
3865 if (!sub_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3866 fputs("Failed to get debug root for Sub CPU\n", stderr); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3867 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3868 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3869 if (!parse_command(sub_root, param, &cmd)) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3870 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3871 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3872 uint8_t ret = run_command(sub_root, &cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3873 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3874 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3875 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3876 cd->enter_debugger = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3877 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3878 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3879 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3880 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3881 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
|
3882 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3883 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3884 while (param && *param && isblank(*param)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3885 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3886 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3887 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3888 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3889 segacd_context *cd = m68k->system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
3890 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3891 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
|
3892 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3893 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
|
3894 if (!main_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3895 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
|
3896 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3897 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3898 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
|
3899 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3900 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3901 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
|
3902 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3903 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3904 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3905 cd->genesis->header.enter_debugger = 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3906 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3907 } |
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 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3910 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
|
3911 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
3912 char *param = cmd->raw; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3913 while (param && *param && isblank(*param)) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3914 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3915 ++param; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3916 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3917 m68k_context *m68k = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3918 genesis_context *gen = m68k->system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
3919 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3920 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
|
3921 parsed_command cmd = {0}; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3922 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
|
3923 if (!z80_root) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3924 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
|
3925 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3926 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3927 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
|
3928 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3929 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3930 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
|
3931 free_parsed_command(&cmd); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3932 return ret; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3933 } else { |
2184
408fb8a7e990
Implement argumentless variant of z80 debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2183
diff
changeset
|
3934 gen->enter_z80_debugger = 1; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3935 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3936 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3937 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3938 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3939 command_def common_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3940 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3941 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3942 "quit", NULL |
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 .usage = "quit", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3945 .desc = "Quit BlastEm", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3946 .impl = cmd_quit, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3947 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3948 .max_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3949 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3950 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3951 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3952 "help", "?", NULL |
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 .usage = "help", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3955 .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
|
3956 .impl = cmd_help, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3957 .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
|
3958 .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
|
3959 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3960 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3961 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3962 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3963 "continue", "c", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3964 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3965 .usage = "continue", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3966 .desc = "Resume execution", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3967 .impl = cmd_continue, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3968 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3969 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3970 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3971 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3972 .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
|
3973 "print", "p", NULL |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3974 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3975 .usage = "print[/FORMAT] EXPRESSION...", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3976 .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
|
3977 .impl = cmd_print, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3978 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3979 .max_args = -1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3980 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3981 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3982 .names = (const char *[]){ |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3983 "printf", NULL |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3984 }, |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3985 .usage = "printf FORMAT EXPRESSION...", |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3986 .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
|
3987 .impl = cmd_printf, |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3988 .min_args = 1, |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
3989 .max_args = -1 |
2187
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3990 }, |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3991 { |
d0129f19ca52
Add a printf command to the debugger
Michael Pavone <pavone@retrodev.com>
parents:
2186
diff
changeset
|
3992 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3993 "softreset", "sr", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3994 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3995 .usage = "softreset", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3996 .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
|
3997 .impl = cmd_softreset, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3998 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
3999 .max_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4000 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4001 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4002 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4003 "display", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4004 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4005 .usage = "display[/FORMAT] EXPRESSION...", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4006 .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
|
4007 .impl = cmd_display, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4008 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4009 .max_args = -1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4010 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4011 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4012 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4013 "deletedisplay", "dd", NULL |
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 .usage = "deletedisplay DISPLAYNUM", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4016 .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
|
4017 .impl = cmd_delete_display, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4018 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4019 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4020 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4021 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4022 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4023 "commands", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4024 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4025 .usage = "command BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4026 .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
|
4027 .impl = cmd_command, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4028 .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
|
4029 .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
|
4030 .has_block = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4031 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4032 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4033 .names = (const char *[]){ |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4034 "function", NULL |
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 .usage = "function NAME [ARGS...]", |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4037 .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
|
4038 .impl = cmd_function, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4039 .min_args = 1, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4040 .max_args = -1, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4041 .has_block = 1, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4042 .skip_eval = 1 |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4043 }, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4044 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4045 .names = (const char *[]){ |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4046 "return", NULL |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4047 }, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4048 .usage = "return VALUE", |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4049 .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
|
4050 .impl = cmd_return, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4051 .min_args = 1, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4052 .max_args = 1 |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4053 }, |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4054 { |
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2367
diff
changeset
|
4055 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4056 "set", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4057 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4058 .usage = "set MEM|NAME VALUE", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4059 .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
|
4060 .impl = cmd_set, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4061 .min_args = 2, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4062 .max_args = 2, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4063 .skip_eval = 1 |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4064 }, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4065 { |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4066 .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
|
4067 "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
|
4068 }, |
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
|
4069 .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
|
4070 .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
|
4071 .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
|
4072 .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
|
4073 .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
|
4074 .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
|
4075 }, |
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
|
4076 { |
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
|
4077 .names = (const char *[]){ |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4078 "array", NULL |
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 .usage = "array NAME [VALUE...]", |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4081 .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
|
4082 .impl = cmd_array, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4083 .min_args = 1, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4084 .max_args = -1, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4085 .skip_eval = 1 |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4086 }, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4087 { |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4088 .names = (const char *[]){ |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4089 "append", NULL |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4090 }, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4091 .usage = "append NAME VALUE", |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4092 .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
|
4093 .impl = cmd_append, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4094 .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
|
4095 .max_args = 2 |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4096 }, |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4097 { |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
4098 .names = (const char *[]){ |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4099 "frames", NULL |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4100 }, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4101 .usage = "frames EXPRESSION", |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4102 .desc = "Resume execution for EXPRESSION video frames", |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4103 .impl = cmd_frames, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4104 .min_args = 1, |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
4105 .max_args = 1 |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4106 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4107 { |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4108 .names = (const char *[]){ |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4109 "bindup", NULL |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4110 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4111 .usage = "bindup NAME", |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4112 .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
|
4113 .impl = cmd_bindup, |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4114 .min_args = 1, |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
4115 .max_args = 1 |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4116 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4117 { |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4118 .names = (const char *[]){ |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4119 "binddown", NULL |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4120 }, |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4121 .usage = "bindown NAME", |
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4122 .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
|
4123 .impl = cmd_binddown, |
2181
0c723b8b637c
Add bindup and binddown debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2180
diff
changeset
|
4124 .min_args = 1, |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
4125 .max_args = 1 |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4126 }, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4127 { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4128 .names = (const char *[]){ |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4129 "condition", NULL |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4130 }, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4131 .usage = "condition BREAKPOINT [EXPRESSION]", |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4132 .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
|
4133 .impl = cmd_condition, |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
4134 .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
|
4135 .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
|
4136 .skip_eval = 1 |
2190
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4137 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4138 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4139 .names = (const char *[]){ |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4140 "if", NULL |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4141 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4142 .usage = "if CONDITION", |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4143 .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
|
4144 .impl = cmd_if, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4145 .min_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4146 .max_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4147 .has_block = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4148 .accepts_else = 1 |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4149 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4150 { |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4151 .names = (const char *[]){ |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4152 "while", NULL |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4153 }, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4154 .usage = "while CONDITION", |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4155 .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
|
4156 .impl = cmd_while, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4157 .min_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4158 .max_args = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4159 .has_block = 1, |
59e0dcc01b2c
Add 'if' and 'while' debugger commands
Michael Pavone <pavone@retrodev.com>
parents:
2189
diff
changeset
|
4160 .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
|
4161 }, |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4162 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4163 .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
|
4164 "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
|
4165 }, |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4166 .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
|
4167 .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
|
4168 .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
|
4169 .min_args = 0, |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2394
diff
changeset
|
4170 .max_args = 1 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4171 }, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4172 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4173 .names = (const char *[]){ |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4174 "save", NULL |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4175 }, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4176 .usage = "save[/SIZE] FILENAME ARRAY [COUNT]", |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4177 .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
|
4178 .impl = cmd_save, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4179 .min_args = 2, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4180 .max_args = 3, |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4181 .skip_eval = 1 |
2394
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4182 }, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4183 { |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4184 .names = (const char *[]){ |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4185 "load", NULL |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4186 }, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4187 .usage = "load[/SIZE] FILENAME ARRAY [COUNT]", |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4188 .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
|
4189 .impl = cmd_load, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4190 .min_args = 2, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4191 .max_args = 3, |
340299a76db7
Add debugger load command
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
4192 .skip_eval = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4193 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4194 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4195 #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
|
4196 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4197 command_def m68k_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4198 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4199 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4200 "breakpoint", "b", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4201 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4202 .usage = "breakpoint ADDRESSS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4203 .desc = "Set a breakpoint at ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4204 .impl = cmd_breakpoint_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4205 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4206 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4207 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4208 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4209 .names = (const char *[]){ |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4210 "watchpoint", NULL |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4211 }, |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4212 .usage = "watchpoint ADDRESS [SIZE]", |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4213 .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
|
4214 .impl = cmd_watchpoint_m68k, |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4215 .min_args = 1, |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4216 .max_args = 2 |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4217 }, |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4218 { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
4219 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4220 "advance", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4221 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4222 .usage = "advance ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4223 .desc = "Advance to ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4224 .impl = cmd_advance_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4225 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4226 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4227 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4228 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4229 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4230 "step", "s", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4231 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4232 .usage = "step", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4233 .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
|
4234 .impl = cmd_step_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4235 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4236 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4237 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4238 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4239 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4240 "over", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4241 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4242 .usage = "over", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4243 .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
|
4244 .impl = cmd_over_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4245 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4246 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4247 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4248 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4249 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4250 "next", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4251 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4252 .usage = "next", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4253 .desc = "Advance to the next instruction", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4254 .impl = cmd_next_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4255 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4256 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4257 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4258 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4259 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4260 "backtrace", "bt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4261 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4262 .usage = "backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4263 .desc = "Print a backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4264 .impl = cmd_backtrace_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4265 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4266 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4267 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4268 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4269 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4270 "delete", "d", NULL |
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 .usage = "delete BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4273 .desc = "Remove breakpoint identified by BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4274 .impl = cmd_delete_m68k, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4275 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4276 .max_args = 1 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4277 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4278 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4279 .names = (const char *[]){ |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4280 "disassemble", "disasm", NULL |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4281 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4282 .usage = "disassemble [ADDRESS]", |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4283 .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
|
4284 .impl = cmd_disassemble_m68k, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4285 .min_args = 0, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4286 .max_args = 1 |
2112
3abb64bd0da6
Add support for printing strings in 68K debugger
Michael Pavone <pavone@retrodev.com>
parents:
2107
diff
changeset
|
4287 } |
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 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4290 #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
|
4291 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4292 command_def genesis_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4293 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4294 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4295 "vdpsprites", "vs", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4296 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4297 .usage = "vdpsprites", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4298 .desc = "Print the VDP sprite table", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4299 .impl = cmd_vdp_sprites, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4300 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4301 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4302 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4303 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4304 .names = (const char *[]){ |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4305 "vdpregs", "vr", NULL |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4306 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4307 .usage = "vdpregs", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4308 .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
|
4309 .impl = cmd_vdp_regs, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4310 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4311 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4312 }, |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4313 { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4314 .names = (const char *[]){ |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4315 "vdpregbreak", "vregbreak", "vrb", NULL |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4316 }, |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4317 .usage = "vdpregbreak [REGISTER [MASK]]", |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4318 .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
|
4319 .impl = cmd_vdp_reg_break, |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4320 .min_args = 0, |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4321 .max_args = 2 |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4322 }, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4323 #ifndef NO_Z80 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4324 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4325 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4326 "z80", NULL |
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 .usage = "z80 [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4329 .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
|
4330 .impl = cmd_gen_z80, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4331 .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
|
4332 .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
|
4333 .raw_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4334 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4335 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4336 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4337 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4338 "ymchannel", "yc", NULL |
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 .usage = "ymchannel [CHANNEL]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4341 .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
|
4342 .impl = cmd_ym_channel, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4343 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4344 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4345 }, |
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 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4348 "ymtimer", "yt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4349 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4350 .usage = "ymtimer", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4351 .desc = "Print YM-2612 timer info", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4352 .impl = cmd_ym_timer, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4353 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4354 .max_args = 0 |
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 }; |
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 #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
|
4359 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4360 command_def scd_main_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4361 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4362 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4363 "subcpu", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4364 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4365 .usage = "subcpu [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4366 .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
|
4367 .impl = cmd_sub, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4368 .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
|
4369 .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
|
4370 .raw_args = 1 |
2178
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 }; |
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 #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
|
4375 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4376 command_def scd_sub_commands[] = { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4377 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4378 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4379 "maincpu", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4380 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4381 .usage = "maincpu [COMMAND]", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4382 .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
|
4383 .impl = cmd_main, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4384 .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
|
4385 .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
|
4386 .raw_args = 1 |
2178
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 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4389 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4390 #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
|
4391 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4392 #ifndef NO_Z80 |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
4393 #ifndef NEW_CORE |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4394 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4395 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
|
4396 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4397 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
|
4398 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
|
4399 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
|
4400 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
|
4401 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4402 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
|
4403 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
|
4404 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
|
4405 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4406 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4407 bp_def *tmp = *this_bp; |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4408 if (tmp->type == BP_TYPE_CPU) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4409 zremove_breakpoint(root->cpu_context, tmp->address); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4410 } else if (tmp->type == BP_TYPE_CPU_WATCH) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4411 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
|
4412 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4413 *this_bp = (*this_bp)->next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4414 if (tmp->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4415 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
|
4416 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4417 free_parsed_command(tmp->commands + i); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4418 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4419 free(tmp->commands); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4420 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4421 free(tmp); |
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 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4425 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
|
4426 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4427 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
|
4428 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
|
4429 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
|
4430 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
|
4431 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4432 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
|
4433 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
|
4434 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
|
4435 new_bp->address = address; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4436 new_bp->mask = 0xFFFF; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
4437 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
|
4438 new_bp->index = root->bp_index++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4439 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
|
4440 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
|
4441 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4442 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4443 |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4444 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
|
4445 { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4446 uint32_t address; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4447 if (!debug_cast_int(cmd->args[0].value, &address)) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4448 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
|
4449 return 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4450 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4451 uint32_t size = 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4452 if (cmd->num_args > 1) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4453 if (!debug_cast_int(cmd->args[1].value, &size)) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4454 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
|
4455 return 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4456 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4457 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4458 z80_add_watchpoint(root->cpu_context, address, size); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4459 bp_def *new_bp = calloc(1, sizeof(bp_def)); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4460 new_bp->next = root->breakpoints; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4461 new_bp->address = address; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4462 new_bp->mask = size; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4463 new_bp->index = root->bp_index++; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4464 new_bp->type = BP_TYPE_CPU_WATCH; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4465 root->breakpoints = new_bp; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4466 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
|
4467 return 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4468 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4469 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4470 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
|
4471 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4472 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
|
4473 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
|
4474 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
|
4475 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
|
4476 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
4477 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
|
4478 return 0; |
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 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4481 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
|
4482 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4483 z80inst *inst = root->inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4484 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4485 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4486 //TODO: handle conditional branches |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4487 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
|
4488 if (inst->addr_mode == Z80_IMMED) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4489 after = inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4490 } 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
|
4491 #ifndef NEW_CORE |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4492 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
|
4493 } 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
|
4494 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
|
4495 } 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
|
4496 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
|
4497 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4498 } |
2505
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4499 #ifndef NEW_CORE |
2506
b0f314b19964
Some more improvements to Z80 step, next and over commands
Michael Pavone <pavone@retrodev.com>
parents:
2505
diff
changeset
|
4500 } else if (inst->op == Z80_JPCC || inst->op == Z80_CALLCC) { |
2505
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4501 uint8_t invert = 0; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4502 uint8_t flag = 0; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4503 switch (inst->reg) |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4504 { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4505 case Z80_CC_NZ: |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4506 invert = 1; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4507 case Z80_CC_Z: |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4508 flag = context->flags[ZF_Z]; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4509 break; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4510 case Z80_CC_NC: |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4511 invert = 1; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4512 case Z80_CC_C: |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4513 flag = context->flags[ZF_C]; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4514 break; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4515 case Z80_CC_PO: |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4516 invert = 1; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4517 case Z80_CC_PE: |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4518 flag = context->flags[ZF_PV]; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4519 break; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4520 case Z80_CC_P: |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4521 invert = 1; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4522 case Z80_CC_M: |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4523 flag = context->flags[ZF_S]; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4524 break; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4525 } |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4526 if (invert) { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4527 flag = !flag; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4528 } |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4529 if (flag) { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4530 after = inst->immed; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4531 } |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4532 } else if (inst->op == Z80_JRCC) { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4533 uint8_t invert = 0; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4534 uint8_t flag = 0; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4535 switch (inst->reg) |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4536 { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4537 case Z80_CC_NZ: |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4538 invert = 1; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4539 case Z80_CC_Z: |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4540 flag = context->flags[ZF_Z]; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4541 break; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4542 case Z80_CC_NC: |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4543 invert = 1; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4544 case Z80_CC_C: |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4545 flag = context->flags[ZF_C]; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4546 break; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4547 } |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4548 if (invert) { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4549 flag = !flag; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4550 } |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4551 if (flag) { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4552 after += inst->immed; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4553 } |
2506
b0f314b19964
Some more improvements to Z80 step, next and over commands
Michael Pavone <pavone@retrodev.com>
parents:
2505
diff
changeset
|
4554 } else if (inst->op == Z80_DJNZ) { |
b0f314b19964
Some more improvements to Z80 step, next and over commands
Michael Pavone <pavone@retrodev.com>
parents:
2505
diff
changeset
|
4555 if (context->regs[Z80_B] != 1) { |
b0f314b19964
Some more improvements to Z80 step, next and over commands
Michael Pavone <pavone@retrodev.com>
parents:
2505
diff
changeset
|
4556 after += inst->immed; |
b0f314b19964
Some more improvements to Z80 step, next and over commands
Michael Pavone <pavone@retrodev.com>
parents:
2505
diff
changeset
|
4557 } |
2505
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4558 #endif |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4559 } else if(inst->op == Z80_JR) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4560 after += inst->immed; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4561 } else if(inst->op == Z80_RET) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4562 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
|
4563 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4564 after = *sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4565 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
|
4566 if (sp) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4567 after |= *sp << 8; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4568 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4569 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4570 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4571 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
|
4572 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4573 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4574 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4575 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
|
4576 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4577 z80inst *inst = root->inst; |
2506
b0f314b19964
Some more improvements to Z80 step, next and over commands
Michael Pavone <pavone@retrodev.com>
parents:
2505
diff
changeset
|
4578 if (inst->op != Z80_CALL && inst->op != Z80_CALLCC && inst->op != Z80_RST) { |
b0f314b19964
Some more improvements to Z80 step, next and over commands
Michael Pavone <pavone@retrodev.com>
parents:
2505
diff
changeset
|
4579 return cmd_step_z80(root, cmd); |
b0f314b19964
Some more improvements to Z80 step, next and over commands
Michael Pavone <pavone@retrodev.com>
parents:
2505
diff
changeset
|
4580 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4581 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4582 uint32_t after = root->after; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4583 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
|
4584 return 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4585 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4586 |
2505
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4587 static uint8_t cmd_over_z80(debug_root *root, parsed_command *cmd) |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4588 { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4589 z80inst *inst = root->inst; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4590 z80_context *context = root->cpu_context; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4591 uint32_t after = root->after; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4592 #ifndef NEW_CORE |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4593 if (inst->op == Z80_JPCC) { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4594 if (inst->immed < after) { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4595 zinsert_breakpoint(context, inst->immed, (uint8_t *)zdebugger); |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4596 return 0; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4597 } |
2506
b0f314b19964
Some more improvements to Z80 step, next and over commands
Michael Pavone <pavone@retrodev.com>
parents:
2505
diff
changeset
|
4598 } else if (inst->op == Z80_JRCC || inst->op == Z80_DJNZ) { |
2505
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4599 after += inst->immed; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4600 if (after < root->after) { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4601 zinsert_breakpoint(context, after, (uint8_t *)zdebugger); |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4602 return 0; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4603 } |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4604 } |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4605 #endif |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4606 return cmd_next_z80(root, cmd); |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4607 } |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4608 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4609 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
|
4610 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4611 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4612 uint32_t stack = context->sp; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4613 uint8_t non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4614 do { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4615 uint32_t bt_address = stack; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4616 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
|
4617 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4618 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4619 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
|
4620 if (bt_address != 0xFEEDFEED) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4621 stack += 4; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4622 non_adr_count = 0; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4623 z80inst inst; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4624 char buf[128]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4625 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
|
4626 z80_decode(pc, &inst); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4627 z80_disasm(&inst, buf, bt_address); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4628 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
|
4629 } else { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4630 //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
|
4631 stack++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4632 non_adr_count++; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4633 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4634 //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
|
4635 } while (stack && non_adr_count < 6); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4636 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4637 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4638 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4639 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
|
4640 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4641 z80_context *context = root->cpu_context; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4642 uint32_t address = root->address; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4643 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
|
4644 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
|
4645 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
|
4646 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
|
4647 } |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4648 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4649 char disasm_buf[1024]; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4650 z80inst inst; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4651 do { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4652 label_def *def = find_label(root->disasm, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4653 if (def) { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4654 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
|
4655 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4656 printf("%s:\n", def->labels[i]); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4657 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4658 } |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4659 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
|
4660 uint8_t *after = z80_decode(pc, &inst); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4661 z80_disasm(&inst, disasm_buf, address); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4662 address += after - pc; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4663 printf("\t%s\n", disasm_buf); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4664 } while(!z80_is_terminal(&inst)); |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4665 return 1; |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4666 } |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
4667 #endif //NEW_CORE |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4668 |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4669 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
|
4670 { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
4671 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
|
4672 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
|
4673 { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4674 ++param; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4675 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4676 genesis_context *gen = (genesis_context *)current_system; |
2186
935e684f2d58
Fix crash bug in expression parser
Michael Pavone <pavone@retrodev.com>
parents:
2185
diff
changeset
|
4677 |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4678 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
|
4679 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
|
4680 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
|
4681 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
|
4682 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
|
4683 return 1; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4684 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4685 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
|
4686 return 1; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4687 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4688 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
|
4689 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
|
4690 return ret; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4691 } else { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4692 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
|
4693 return 0; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4694 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4695 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4696 |
2505
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4697 static uint8_t cmd_ym_channel_z80(debug_root *root, parsed_command *cmd) |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4698 { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4699 z80_context *context = root->cpu_context; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4700 genesis_context * gen = context->system; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4701 if (cmd->num_args) { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4702 if (cmd->args[0].value.v.u32 < 1 || cmd->args[0].value.v.u32 > 6) { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4703 printf("%d is not a valid YM2612 channel number. Valid values are 1-6\n", cmd->args[0].value.v.u32); |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4704 return 1; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4705 } |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4706 ym_print_channel_info(gen->ym, cmd->args[0].value.v.u32 - 1); |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4707 } else { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4708 for (int i = 0; i < 6; i++) { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4709 ym_print_channel_info(gen->ym, i); |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4710 } |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4711 } |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4712 return 1; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4713 } |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4714 |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4715 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
|
4716 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4717 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
|
4718 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
|
4719 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
|
4720 return 1; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4721 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4722 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4723 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
|
4724 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4725 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
|
4726 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
|
4727 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
|
4728 return 1; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4729 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4730 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4731 command_def z80_commands[] = { |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
4732 #ifndef NEW_CORE |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4733 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4734 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4735 "breakpoint", "b", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4736 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4737 .usage = "breakpoint ADDRESSS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4738 .desc = "Set a breakpoint at ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4739 .impl = cmd_breakpoint_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4740 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4741 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4742 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4743 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4744 .names = (const char *[]){ |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4745 "watchpoint", NULL |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4746 }, |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4747 .usage = "watchpoint ADDRESS [SIZE]", |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4748 .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
|
4749 .impl = cmd_watchpoint_z80, |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4750 .min_args = 1, |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4751 .max_args = 2 |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4752 }, |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4753 { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
4754 .names = (const char *[]){ |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4755 "advance", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4756 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4757 .usage = "advance ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4758 .desc = "Advance to ADDRESS", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4759 .impl = cmd_advance_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4760 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4761 .max_args = 1 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4762 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4763 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4764 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4765 "step", "s", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4766 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4767 .usage = "step", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4768 .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
|
4769 .impl = cmd_step_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4770 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4771 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4772 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4773 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4774 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4775 "over", NULL |
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 .usage = "over", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4778 .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
|
4779 .impl = cmd_over_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4780 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4781 .max_args = 0 |
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 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4784 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4785 "next", NULL |
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 .usage = "next", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4788 .desc = "Advance to the next instruction", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4789 .impl = cmd_next_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4790 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4791 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4792 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4793 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4794 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4795 "backtrace", "bt", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4796 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4797 .usage = "backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4798 .desc = "Print a backtrace", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4799 .impl = cmd_backtrace_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4800 .min_args = 0, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4801 .max_args = 0 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4802 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4803 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4804 .names = (const char *[]){ |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4805 "delete", "d", NULL |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4806 }, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4807 .usage = "delete BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4808 .desc = "Remove breakpoint identified by BREAKPOINT", |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4809 .impl = cmd_delete_z80, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4810 .min_args = 1, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4811 .max_args = 1 |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4812 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4813 { |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4814 .names = (const char *[]){ |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4815 "disassemble", "disasm", NULL |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4816 }, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4817 .usage = "disassemble [ADDRESS]", |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4818 .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
|
4819 .impl = cmd_disassemble_z80, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4820 .min_args = 0, |
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
4821 .max_args = 1 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4822 } |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
4823 #endif //NEW_CORE |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4824 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4825 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4826 #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
|
4827 |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4828 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
|
4829 { |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4830 .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
|
4831 "m68k", NULL |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4832 }, |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4833 .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
|
4834 .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
|
4835 .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
|
4836 .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
|
4837 .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
|
4838 .raw_args = 1 |
2505
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4839 }, |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4840 { |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4841 .names = (const char *[]){ |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4842 "ymchannel", NULL |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4843 }, |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4844 .usage = "ymchannel [CHANNEL]", |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4845 .desc = "Print YM-2612 channel and operator params. Limited to CHANNEL if specified", |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4846 .impl = cmd_ym_channel_z80, |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4847 .min_args = 0, |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
4848 .max_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
|
4849 } |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4850 }; |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4851 |
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
4852 #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
|
4853 |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4854 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
|
4855 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4856 .names = (const char *[]){ |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4857 "vdpsprites", "vs", NULL |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4858 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4859 .usage = "vdpsprites", |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4860 .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
|
4861 .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
|
4862 .min_args = 0, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4863 .max_args = 0 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4864 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4865 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4866 .names = (const char *[]){ |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4867 "vdpsregs", "vr", NULL |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4868 }, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4869 .usage = "vdpregs", |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4870 .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
|
4871 .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
|
4872 .min_args = 0, |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4873 .max_args = 0 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4874 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4875 }; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4876 |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
4877 #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
|
4878 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4879 #endif |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4880 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4881 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
|
4882 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4883 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
|
4884 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4885 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
|
4886 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4887 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
|
4888 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4889 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4890 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4891 |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4892 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
|
4893 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4894 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
|
4895 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
|
4896 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
|
4897 { |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4898 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
|
4899 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4900 } |
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4901 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
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 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
|
4905 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
|
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 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4908 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
|
4909 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4910 m68k_context *m68k = root->cpu_context; |
2499
d74d3998482c
Make some progress on compiling full emulator with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2459
diff
changeset
|
4911 memmap_chunk const *chunk = find_map_chunk(start_address, &m68k->opts->gen, 0, NULL); |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4912 if (!chunk) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4913 return start_address; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4914 } |
2499
d74d3998482c
Make some progress on compiling full emulator with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2459
diff
changeset
|
4915 if (chunk->mask == m68k->opts->gen.address_mask) { |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4916 return chunk->end; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4917 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4918 return (start_address & ~chunk->mask) + chunk->mask + 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4919 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4920 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4921 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
|
4922 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4923 debug_root *root = find_root(context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4924 if (root && !root->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4925 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
|
4926 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
|
4927 root->read_mem = read_m68k; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4928 root->write_mem = write_m68k; |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
4929 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
|
4930 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
|
4931 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
|
4932 debug_var *var; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4933 switch (current_system->type) |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4934 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4935 case SYSTEM_GENESIS: |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4936 case SYSTEM_SEGACD: |
2459
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4937 case SYSTEM_PICO: |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4938 case SYSTEM_COPERA: |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4939 //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
|
4940 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
|
4941 genesis_context *gen = context->system; |
2459
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4942 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
|
4943 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
|
4944 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
|
4945 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
4947 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
|
4948 uint32_t num_commands = NUM_GENESIS; |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4949 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
|
4950 num_commands -= 3; |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4951 } else { |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4952 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
|
4953 } |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2422
diff
changeset
|
4954 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
|
4955 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
|
4956 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
|
4957 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
|
4958 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
|
4959 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
|
4960 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
|
4961 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
|
4962 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
|
4963 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
|
4964 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4965 break; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4966 } 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
|
4967 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
|
4968 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
|
4969 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
|
4970 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
|
4971 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4972 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
|
4973 break; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4974 } |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
4975 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
|
4976 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4977 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
|
4978 } |
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
|
4979 |
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
|
4980 #ifndef NO_Z80 |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
4981 #ifdef NEW_CORE |
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
4982 #define Z80_OPTS opts |
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
4983 #else |
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
4984 #define Z80_OPTS options |
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
4985 #endif |
548
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
4986 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4987 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
|
4988 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4989 z80_context *context = root->cpu_context; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4990 uint32_t address = *out; |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
4991 *out = read_byte(address, (void **)context->mem_pointers, &context->Z80_OPTS->gen, context); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4992 if (size == 'w') { |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
4993 *out |= read_byte(address + 1, (void **)context->mem_pointers, &context->Z80_OPTS->gen, context) << 8; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4994 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4995 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4996 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4997 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
4998 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
|
4999 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5000 z80_context *context = root->cpu_context; |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5001 write_byte(address, value, (void **)context->mem_pointers, &context->Z80_OPTS->gen, context); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5002 if (size == 'w') { |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5003 write_byte(address + 1, value >> 8, (void **)context->mem_pointers, &context->Z80_OPTS->gen, context); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5004 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5005 return 1; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5006 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5007 |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5008 #ifndef NEW_CORE |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5010 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5012 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
|
5013 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5016 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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_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
|
5018 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
|
5019 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
|
5020 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
|
5021 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
|
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 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
|
5024 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5025 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5026 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5027 static 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
|
5028 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5029 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5030 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
|
5031 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5034 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5036 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
|
5037 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
|
5038 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
|
5039 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
|
5040 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5042 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5043 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5044 static 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
|
5045 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5046 z80_context *context = var->ptr; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5047 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
|
5048 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
|
5049 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
|
5050 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
|
5051 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
|
5052 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
|
5053 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
|
5054 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
|
5055 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
|
5056 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5057 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5058 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
|
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 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
|
5061 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
|
5062 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
|
5063 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
|
5064 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
|
5065 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
|
5066 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
|
5067 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
|
5068 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
|
5069 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
|
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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5073 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5074 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
|
5075 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
|
5076 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
|
5077 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
|
5078 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
|
5079 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5081 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
|
5082 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
|
5083 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
|
5084 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
|
5085 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
|
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 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
|
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 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
|
5092 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
|
5093 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
|
5094 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
|
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 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
|
5097 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
|
5098 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
|
5099 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
|
5100 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
|
5101 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
|
5102 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5103 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
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 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
|
5107 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
|
5108 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
|
5109 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
|
5110 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
|
5111 } 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
|
5112 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
|
5113 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5115 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5118 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5120 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
|
5121 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
|
5122 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
|
5123 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
|
5124 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5125 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
|
5126 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
|
5127 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
|
5128 } 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
|
5129 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
|
5130 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
|
5131 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5135 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5137 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
|
5138 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
|
5139 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
|
5140 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
|
5141 } 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
|
5142 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
|
5143 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5145 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5148 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5149 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
|
5150 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
|
5151 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
|
5152 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
|
5153 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
|
5154 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5156 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
|
5157 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
|
5158 } 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
|
5159 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
|
5160 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
|
5161 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5162 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5163 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5165 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5167 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
|
5168 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5170 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
|
5171 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5172 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
|
5173 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
|
5174 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
|
5175 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
|
5176 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
|
5177 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5179 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5182 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5184 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
|
5185 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5188 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5190 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
|
5191 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
|
5192 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
|
5193 return; |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5194 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5196 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5199 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5201 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
|
5202 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5205 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5207 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
|
5208 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5211 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5213 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
|
5214 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5215 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5216 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
|
5217 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5218 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
|
5219 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
|
5220 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5221 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5222 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
|
5223 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5224 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
|
5225 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
|
5226 } |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5227 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5228 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
|
5229 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5230 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
|
5231 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
|
5232 } |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5233 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5234 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
|
5235 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5237 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
|
5238 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5240 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
|
5241 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
|
5242 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
|
5243 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
|
5244 } 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
|
5245 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
|
5246 var->set = z80_sp_set; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5247 } 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
|
5248 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
|
5249 var->set = z80_regpair_set; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5250 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 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
|
5252 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
|
5253 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
|
5254 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
|
5255 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
|
5256 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
|
5257 { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types 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 *d = toupper(*c); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5259 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5260 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
|
5261 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
|
5262 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5263 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
|
5264 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
|
5265 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
|
5266 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
|
5267 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
|
5268 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
|
5269 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
|
5270 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
|
5271 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
|
5272 } 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
|
5273 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
|
5274 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
|
5275 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5276 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
|
5277 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
|
5278 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
|
5279 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
|
5280 { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5281 *d = toupper(*c); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5282 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5283 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
|
5284 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5285 free(name); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5286 } |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5287 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
|
5288 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
|
5289 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
|
5290 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
|
5291 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
|
5292 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
|
5293 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
|
5294 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
|
5295 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
|
5296 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
|
5297 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
|
5298 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
|
5299 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
|
5300 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
|
5301 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
|
5302 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
|
5303 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
|
5304 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
|
5305 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
|
5306 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
|
5307 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
|
5308 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
|
5309 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
|
5310 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
|
5311 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
|
5312 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
|
5313 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
|
5314 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
|
5315 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
|
5316 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
|
5317 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
|
5318 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
|
5319 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
|
5320 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
|
5321 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
|
5322 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
|
5323 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
|
5324 } |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5325 #endif //NEW_CORE |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5326 |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5327 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
|
5328 { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5329 z80_context *z80 = root->cpu_context; |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5330 memmap_chunk const *chunk = find_map_chunk(start_address, &z80->Z80_OPTS->gen, 0, NULL); |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5331 if (!chunk) { |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5332 return start_address; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5333 } |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5334 if (chunk->mask == z80->Z80_OPTS->gen.address_mask) { |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5335 return chunk->end; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5336 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5337 return (start_address & ~chunk->mask) + chunk->mask + 1; |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5338 } |
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5339 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5340 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
|
5341 { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5342 debug_root *root = find_root(context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5343 if (root && !root->commands) { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5344 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
|
5345 add_commands(root, z80_commands, NUM_Z80); |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5346 #ifndef NEW_CORE |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5347 z80_names(root); |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5348 #endif |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
5349 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
|
5350 sms_context *sms; |
2413
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5351 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
|
5352 debug_var *var; |
2198
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5353 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
|
5354 { |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5355 case SYSTEM_GENESIS: |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5356 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
|
5357 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
|
5358 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
|
5359 root->other_roots = tern_insert_ptr(root->other_roots, "m68k", find_m68k_root(gen->m68k)); |
2505
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
5360 root->other_roots = tern_insert_ptr(root->other_roots, "io", find_io_root(&gen->io)); |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
5361 root->other_roots = tern_insert_ptr(root->other_roots, "vdp", find_vdp_root(gen->vdp)); |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
5362 root->other_roots = tern_insert_ptr(root->other_roots, "psg", find_psg_root(gen->psg)); |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
5363 root->other_roots = tern_insert_ptr(root->other_roots, "ym", find_ym2612_root(gen->ym)); |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
5364 var = calloc(1, sizeof(debug_var)); |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
5365 var->get = debug_frame_get; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
5366 var->ptr = gen->vdp; |
927083238a39
Z80 debugger improvements
Michael Pavone <pavone@retrodev.com>
parents:
2500
diff
changeset
|
5367 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
|
5368 break; |
0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
5369 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
|
5370 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
|
5371 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
|
5372 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
|
5373 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
|
5374 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
|
5375 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
|
5376 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
|
5377 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
|
5378 break; |
2413
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5379 case SYSTEM_COLECOVISION: |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5380 coleco = context->system; |
64cf80e683aa
Initial support for Colecovision emulation
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
5381 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
|
5382 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
|
5383 break; |
2185
3d2cc2af1da3
Add an m68k command for switching back to 68K debugger from Z80
Michael Pavone <pavone@retrodev.com>
parents:
2184
diff
changeset
|
5384 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5385 root->read_mem = read_z80; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5386 root->write_mem = write_z80; |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2214
diff
changeset
|
5387 root->disasm = create_z80_disasm(); |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2386
diff
changeset
|
5388 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
|
5389 } |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5390 return root; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5391 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5392 |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5393 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
|
5394 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5395 static char last_cmd[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5396 char input_buf[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5397 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
|
5398 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
|
5399 init_terminal(); |
2180
b87658ba3b94
Fix bug in Z80 debugger for SMS mode post-refactor
Michael Pavone <pavone@retrodev.com>
parents:
2179
diff
changeset
|
5400 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
|
5401 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
|
5402 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
|
5403 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
5404 root->address = address; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5405 //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
|
5406 int debugging; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
5407 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
|
5408 if (*this_bp) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5409 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
|
5410 debug_val condres; |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5411 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
|
5412 if (!condres.v.u32) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5413 return context; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5414 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5415 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5416 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
|
5417 free_expr((*this_bp)->condition); |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5418 (*this_bp)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5419 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5420 } |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5421 debugging = 1; |
2208
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5422 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
|
5423 { |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5424 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
|
5425 } |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5426 if (debugging) { |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5427 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
|
5428 } else { |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5429 fflush(stdout); |
2208
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5430 return context; |
3809a0bd680e
Fix a couple of Z80 debugger issues
Michael Pavone <pavone@retrodev.com>
parents:
2198
diff
changeset
|
5431 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5432 } else { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5433 zremove_breakpoint(context, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5434 } |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5435 #ifndef NEW_CORE |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5436 if (context->wp_hit) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5437 context->wp_hit = 0; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5438 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
|
5439 if (*this_bp) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5440 if ((*this_bp)->condition) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5441 debug_val condres; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5442 if (eval_expr(root, (*this_bp)->condition, &condres)) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5443 if (!condres.v.u32) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5444 return context; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5445 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5446 } else { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5447 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
|
5448 free_expr((*this_bp)->condition); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5449 (*this_bp)->condition = NULL; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5450 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5451 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5452 debugging = 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5453 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
|
5454 { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5455 debugging = run_command(root, (*this_bp)->commands + i); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5456 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5457 if (debugging) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5458 if (context->wp_old_value != context->wp_hit_value) { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5459 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
|
5460 } else { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5461 printf("Z80 Watchpoint %d hit\n", (*this_bp)->index); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5462 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5463 } else { |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5464 fflush(stdout); |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5465 return context; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5466 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5467 } |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5468 } |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5469 #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
|
5470 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
|
5471 if (!pc) { |
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
1111
diff
changeset
|
5472 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
|
5473 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
5474 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
|
5475 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
|
5476 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
|
5477 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
|
5478 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
|
5479 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
|
5480 make_format_str(format_str, cur->format); |
2183
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5481 for (int i = 0; i < cur->num_args; i++) |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5482 { |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5483 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
|
5484 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
|
5485 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5486 } |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2187
diff
changeset
|
5487 |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5488 z80_disasm(&inst, input_buf, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5489 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
|
5490 debugger_repl(root); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5491 return context; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5492 } |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5493 |
548
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
5494 #endif |
a3afee2271ce
Initial work on the x86-32 target
Michael Pavone <pavone@retrodev.com>
parents:
525
diff
changeset
|
5495 |
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
|
5496 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
|
5497 { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5498 static char last_cmd[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5499 char input_buf[1024]; |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5500 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
|
5501 |
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
|
5502 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
|
5503 |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5504 #ifndef NEW_CORE |
2499
d74d3998482c
Make some progress on compiling full emulator with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2459
diff
changeset
|
5505 context->opts->sync_components(context, 0); |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5506 #endif |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5507 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
|
5508 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
|
5509 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
|
5510 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5511 //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
|
5512 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
|
5513 if (address == root->branch_t) { |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
5514 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
|
5515 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
|
5516 remove_breakpoint(context, root->branch_f); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5517 } |
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
|
5518 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
|
5519 } else if(address == root->branch_f) { |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2360
diff
changeset
|
5520 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
|
5521 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
|
5522 remove_breakpoint(context, root->branch_t); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5523 } |
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
|
5524 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
|
5525 } |
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
|
5526 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5527 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
|
5528 int debugging = 1; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5529 //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
|
5530 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
|
5531 if (*this_bp) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5532 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
|
5533 debug_val condres; |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5534 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
|
5535 if (!condres.v.u32) { |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5536 return; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5537 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5538 } else { |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5539 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
|
5540 free_expr((*this_bp)->condition); |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5541 (*this_bp)->condition = NULL; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5542 } |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5543 } |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5544 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
|
5545 { |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2177
diff
changeset
|
5546 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
|
5547 } |
5a3ac6093ea2
Add support for executing a list of debugger commands when a breakpoint is hit
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
5548 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
|
5549 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
|
5550 } else { |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5551 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
|
5552 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
|
5553 } |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5554 } else { |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5555 remove_breakpoint(context, address); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5556 } |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5557 if (context->wp_hit) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5558 context->wp_hit = 0; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5559 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
|
5560 if (*this_bp) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5561 if ((*this_bp)->condition) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5562 debug_val condres; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5563 if (eval_expr(root, (*this_bp)->condition, &condres)) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5564 if (!condres.v.u32) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5565 return; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5566 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5567 } else { |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2396
diff
changeset
|
5568 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
|
5569 free_expr((*this_bp)->condition); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5570 (*this_bp)->condition = NULL; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5571 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5572 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5573 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
|
5574 { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5575 debugging = run_command(root, (*this_bp)->commands + i); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5576 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5577 if (debugging) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5578 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
|
5579 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
|
5580 } else { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5581 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
|
5582 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5583 } else { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5584 fflush(stdout); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5585 return; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5586 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5587 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5588 } |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5589 if (context->system == current_system) { |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5590 genesis_context *gen = context->system; |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5591 vdp_force_update_framebuffer(gen->vdp); |
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
5592 } |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5593 #ifndef NEW_CORE |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5594 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
|
5595 root->after = after; |
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2181
diff
changeset
|
5596 root->inst = &inst; |
2500
d44fe974fb85
Get blastem compiling with new 68K core
Michael Pavone <pavone@retrodev.com>
parents:
2499
diff
changeset
|
5597 #endif |
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
|
5598 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
|
5599 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
|
5600 make_format_str(format_str, cur->format); |
2183
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5601 for (int i = 0; i < cur->num_args; i++) |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5602 { |
eb2e0e61b1b4
Fix stale values in display
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
5603 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
|
5604 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
|
5605 } |
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
|
5606 } |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2208
diff
changeset
|
5607 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
|
5608 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
|
5609 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
|
5610 return; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5611 } |