Mercurial > repos > blastem
annotate debug.h @ 2476:aaf7bb58ffca
Fix bug in Gen/MD serialize routine that could cause a use-after free in some cases
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 03 Mar 2024 13:47:59 -0800 |
parents | bf4f1a8d1d48 |
children | d74d3998482c |
rev | line source |
---|---|
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #ifndef DEBUG_H_ |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #define DEBUG_H_ |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 #include <stdint.h> |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
5 #include "tern.h" |
569
9b7fcf748be0
Rename x86_68k_options and m68k_to_x86.h to m68k_options and m68k_core.h respectively
Michael Pavone <pavone@retrodev.com>
parents:
524
diff
changeset
|
6 #include "m68k_core.h" |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1329
diff
changeset
|
7 #ifdef NEW_CORE |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1329
diff
changeset
|
8 #include "z80.h" |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1329
diff
changeset
|
9 #else |
1129
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
10 #include "z80_to_x86.h" |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1329
diff
changeset
|
11 #endif |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
12 #include "disasm.h" |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
14 typedef enum { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
15 TOKEN_NONE, |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
16 TOKEN_INT, |
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
17 TOKEN_DECIMAL, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
18 TOKEN_NAME, |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
19 TOKEN_ARRAY, |
2364
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
20 TOKEN_FUNCALL, |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
21 TOKEN_OPER, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
22 TOKEN_SIZE, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
23 TOKEN_LBRACKET, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
24 TOKEN_RBRACKET, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
25 TOKEN_LPAREN, |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
26 TOKEN_RPAREN, |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
27 TOKEN_STRING |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
28 } token_type; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
29 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
30 typedef struct { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
31 token_type type; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
32 union { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
33 char *str; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
34 char op[3]; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
35 uint32_t num; |
2363
b865f33fd47e
Basic float support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2362
diff
changeset
|
36 float f; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
37 } v; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
38 } token; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
40 typedef enum { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
41 EXPR_NONE, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
42 EXPR_SCALAR, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
43 EXPR_UNARY, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
44 EXPR_BINARY, |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
45 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
|
46 EXPR_MEM, |
2364
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
47 EXPR_NAMESPACE, |
c822bb628fc3
Add support for function call expressions in debug parser
Michael Pavone <pavone@retrodev.com>
parents:
2363
diff
changeset
|
48 EXPR_FUNCALL |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
49 } expr_type; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
50 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
51 typedef struct expr expr; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
52 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
53 struct expr { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
54 expr_type type; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
55 expr *left; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
56 expr *right; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
57 token op; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
58 }; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
59 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
60 enum { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
61 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
|
62 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
|
63 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
|
64 DBG_VAL_STRING, |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
65 DBG_VAL_FUNC |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
66 }; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
67 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
68 typedef struct { |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
69 union { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
70 uint32_t 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
|
71 float 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
|
72 } 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
|
73 uint32_t 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
|
74 } debug_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
|
75 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
76 typedef struct { |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
77 char *raw; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
78 expr *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
|
79 debug_val value; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
80 } command_arg; |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2107
diff
changeset
|
82 typedef struct debug_root debug_root; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
83 typedef struct parsed_command 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:
2182
diff
changeset
|
84 typedef uint8_t (*cmd_fun)(debug_root *root, parsed_command *cmd); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
85 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
86 typedef struct { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
87 const char **names; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
88 const char *usage; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
89 const char *desc; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
90 cmd_fun impl; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
91 int min_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
92 int max_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
93 uint8_t skip_eval; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
94 uint8_t visited; |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
95 uint8_t 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:
2182
diff
changeset
|
96 uint8_t 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:
2182
diff
changeset
|
97 uint8_t raw_args; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
98 } command_def; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
99 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
100 typedef struct disp_def { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
101 struct disp_def *next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
102 char *format; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
103 int num_args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
104 command_arg *args; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
105 uint32_t index; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
106 } disp_def; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
107 |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
108 typedef struct { |
2188
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
109 parsed_command *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:
2182
diff
changeset
|
110 int 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:
2182
diff
changeset
|
111 } command_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:
2182
diff
changeset
|
112 |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
113 struct 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:
2182
diff
changeset
|
114 command_def *def; |
e17d99c96c89
Make blocks an explicitly supported concept in the debugger rather than a one-off for the commands command
Michael Pavone <pavone@retrodev.com>
parents:
2182
diff
changeset
|
115 char *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:
2182
diff
changeset
|
116 char *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:
2182
diff
changeset
|
117 command_arg *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:
2182
diff
changeset
|
118 int 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:
2182
diff
changeset
|
119 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:
2182
diff
changeset
|
120 command_block 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:
2182
diff
changeset
|
121 }; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
122 |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
123 enum { |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
124 BP_TYPE_CPU, |
2396
bf4f1a8d1d48
Implement 68K watchpoints in internal debugger
Michael Pavone <pavone@retrodev.com>
parents:
2395
diff
changeset
|
125 BP_TYPE_CPU_WATCH, |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
126 BP_TYPE_VDPREG, |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
127 BP_TYPE_VDPDMA, |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
128 BP_TYPE_VDPDATA |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
129 }; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
130 |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
131 typedef struct bp_def { |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
132 struct bp_def *next; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
133 parsed_command *commands; |
2182
2d7f8195be3b
Add support for conditional breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2178
diff
changeset
|
134 expr *condition; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
135 uint32_t num_commands; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
136 uint32_t address; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
137 uint32_t index; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
138 uint32_t mask; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
139 uint8_t type; |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
140 } bp_def; |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
141 |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
142 typedef struct debug_array debug_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
|
143 typedef debug_val (*debug_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
|
144 typedef void (*debug_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
|
145 typedef void (*debug_array_append)(debug_array *array, debug_val value); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
146 |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
147 struct debug_array{ |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
148 debug_array_get get; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
149 debug_array_set set; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
150 debug_array_append 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
|
151 void *base; |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
152 uint32_t size; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
153 uint32_t storage; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
154 }; |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
155 |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
156 typedef debug_val (*debug_native_func)(debug_val *args, int num_args); |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
157 typedef struct { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
158 union { |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
159 debug_native_func native; |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2365
diff
changeset
|
160 command_block block; |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
161 } impl; |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2365
diff
changeset
|
162 char **arg_names; |
2365
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
163 int max_args; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
164 int min_args; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
165 uint8_t is_native; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
166 } debug_func; |
8c060849a503
Basic function call support in debug language
Michael Pavone <pavone@retrodev.com>
parents:
2364
diff
changeset
|
167 |
2395
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
168 typedef struct { |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
169 char *buffer; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
170 uint32_t size; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
171 uint32_t storage; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
172 } debug_string; |
ebca8ab02701
Basic string support in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2393
diff
changeset
|
173 |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
174 typedef struct debug_var 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
|
175 typedef debug_val (*debug_var_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
|
176 typedef void (*debug_var_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
|
177 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
178 struct 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
|
179 debug_var_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
|
180 debug_var_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
|
181 void *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
|
182 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
|
183 }; |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
184 |
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
185 typedef debug_var *(*resolver)(debug_root *root, const char *name); |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2107
diff
changeset
|
186 typedef uint8_t (*reader)(debug_root *root, uint32_t *out, char size); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
187 typedef uint8_t (*writer)(debug_root *root, uint32_t address, uint32_t value, char size); |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2371
diff
changeset
|
188 typedef uint32_t (*find_chunk_end)(debug_root *root, uint32_t start_address); |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2107
diff
changeset
|
189 |
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2107
diff
changeset
|
190 struct debug_root { |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
191 void *cpu_context; |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
192 bp_def *breakpoints; |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
193 disp_def *displays; |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
194 tern_node *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
|
195 tern_node *variables; |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
196 tern_node *symbols; |
2362
b6c5a0fa3dfc
Refactor debugger a bit. Allow types other than integers to be passed in expressions and stored in arrays. Better namespace support
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
197 tern_node *other_roots; |
2214
7591c67b8d1e
Support for loading symbols in debugger for use during name resolution and disassembly
Michael Pavone <pavone@retrodev.com>
parents:
2193
diff
changeset
|
198 disasm_context *disasm; |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
199 reader read_mem; |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
200 writer write_mem; |
2393
5f4917b9ecfa
Add debugger save command
Michael Pavone <pavone@retrodev.com>
parents:
2371
diff
changeset
|
201 find_chunk_end chunk_end; |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
202 parsed_command last_cmd; |
2371
1fe5afe263f3
Initial stab at user-defined functions in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2365
diff
changeset
|
203 debug_val retval; |
2193
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
204 uint32_t bp_index; |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
205 uint32_t disp_index; |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
206 uint32_t branch_t; |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
207 uint32_t branch_f; |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
208 void *inst; |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
209 uint32_t address; |
d00fb9c6a6a2
Fix a couple of debugger regressions introduced with changes to support blocks
Michael Pavone <pavone@retrodev.com>
parents:
2188
diff
changeset
|
210 uint32_t after; |
2175
8c28c5466d70
Minor cleanup of debugger changes
Michael Pavone <pavone@retrodev.com>
parents:
2107
diff
changeset
|
211 }; |
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:
1921
diff
changeset
|
212 |
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:
1921
diff
changeset
|
213 debug_root *find_root(void *cpu); |
2178
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
214 debug_root *find_m68k_root(m68k_context *context); |
f6d5bde4d07f
Finish debugger refactor started with expression parser changes
Michael Pavone <pavone@retrodev.com>
parents:
2175
diff
changeset
|
215 debug_root *find_z80_root(z80_context *context); |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
216 bp_def ** find_breakpoint(bp_def ** cur, uint32_t address, uint8_t type); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
217 bp_def ** find_breakpoint_idx(bp_def ** cur, uint32_t index); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 void add_display(disp_def ** head, uint32_t *index, char format_char, char * param); |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
219 void remove_display(disp_def ** head, uint32_t index); |
1329
85a90964b557
Fix interaction between 68K debugger and instruction retranslation due to self modifying code or bank switching
Michael Pavone <pavone@retrodev.com>
parents:
1129
diff
changeset
|
220 void debugger(m68k_context * context, uint32_t address); |
1129
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
829
diff
changeset
|
221 z80_context * zdebugger(z80_context * context, uint16_t address); |
1921
5d028088e320
Added help commands to debugger
Eric Fry <yuv422@users.noreply.github.com>
parents:
1752
diff
changeset
|
222 void print_m68k_help(); |
5d028088e320
Added help commands to debugger
Eric Fry <yuv422@users.noreply.github.com>
parents:
1752
diff
changeset
|
223 void print_z80_help(); |
524
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 |
fb39534b6604
Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
225 #endif //DEBUG_H_ |