comparison debug.c @ 2185:3d2cc2af1da3

Add an m68k command for switching back to 68K debugger from Z80
author Michael Pavone <pavone@retrodev.com>
date Sat, 13 Aug 2022 23:24:54 -0700
parents 408fb8a7e990
children 935e684f2d58
comparison
equal deleted inserted replaced
2184:408fb8a7e990 2185:3d2cc2af1da3
2076 //TODO: Make sure we don't wander into an invalid memory region 2076 //TODO: Make sure we don't wander into an invalid memory region
2077 } while (stack && non_adr_count < 6); 2077 } while (stack && non_adr_count < 6);
2078 return 1; 2078 return 1;
2079 } 2079 }
2080 2080
2081 static uint8_t cmd_gen_m68k(debug_root *root, char *format, char *param)
2082 {
2083 while (param && *param && isblank(*param))
2084 {
2085 ++param;
2086 }
2087 genesis_context *gen = (genesis_context *)current_system;
2088
2089 if (param && *param && !isspace(*param)) {
2090 parsed_command cmd;
2091 debug_root *m68k_root = find_m68k_root(gen->m68k);
2092 if (!m68k_root) {
2093 fputs("Failed to get debug root for M68K\n", stderr);
2094 return 1;
2095 }
2096 if (!parse_command(m68k_root, param, &cmd)) {
2097 return 1;
2098 }
2099 uint8_t ret = run_command(m68k_root, &cmd);
2100 free_parsed_command(&cmd);
2101 return ret;
2102 } else {
2103 gen->header.enter_debugger = 1;
2104 return 0;
2105 }
2106 }
2107
2081 command_def z80_commands[] = { 2108 command_def z80_commands[] = {
2082 { 2109 {
2083 .names = (const char *[]){ 2110 .names = (const char *[]){
2084 "breakpoint", "b", NULL 2111 "breakpoint", "b", NULL
2085 }, 2112 },
2150 .max_args = 1 2177 .max_args = 1
2151 } 2178 }
2152 }; 2179 };
2153 2180
2154 #define NUM_Z80 (sizeof(z80_commands)/sizeof(*z80_commands)) 2181 #define NUM_Z80 (sizeof(z80_commands)/sizeof(*z80_commands))
2182
2183 command_def gen_z80_commands[] = {
2184 {
2185 .names = (const char *[]){
2186 "m68k", NULL
2187 },
2188 .usage = "m68k [COMMAND]",
2189 .desc = "Run a M68K debugger command or switch to M68K context when no command is given",
2190 .raw_impl = cmd_gen_m68k,
2191 .min_args = 0,
2192 .max_args = -1
2193 }
2194 };
2195
2196 #define NUM_GEN_Z80 (sizeof(gen_z80_commands)/sizeof(*gen_z80_commands))
2155 2197
2156 #endif 2198 #endif
2157 2199
2158 void add_commands(debug_root *root, command_def *defs, uint32_t num_commands) 2200 void add_commands(debug_root *root, command_def *defs, uint32_t num_commands)
2159 { 2201 {
2677 { 2719 {
2678 debug_root *root = find_root(context); 2720 debug_root *root = find_root(context);
2679 if (root && !root->commands) { 2721 if (root && !root->commands) {
2680 add_commands(root, common_commands, NUM_COMMON); 2722 add_commands(root, common_commands, NUM_COMMON);
2681 add_commands(root, z80_commands, NUM_Z80); 2723 add_commands(root, z80_commands, NUM_Z80);
2724 if (current_system->type == SYSTEM_GENESIS || current_system->type == SYSTEM_SEGACD) {
2725 add_commands(root, gen_z80_commands, NUM_GEN_Z80);
2726 }
2682 root->read_mem = read_z80; 2727 root->read_mem = read_z80;
2683 root->write_mem = write_z80; 2728 root->write_mem = write_z80;
2684 root->set = set_z80; 2729 root->set = set_z80;
2685 root->resolve = resolve_z80; 2730 root->resolve = resolve_z80;
2686 } 2731 }