add debugger command to enable and disable

This commit is contained in:
James Larrowe 2020-05-30 16:35:07 -04:00
parent f105f28017
commit abdece7737
3 changed files with 23 additions and 3 deletions

View File

@ -832,6 +832,23 @@ static bool registers(GB_gameboy_t *gb, char *arguments, char *modifiers, const
return true; return true;
} }
/* Enable or disable software breakpoints */
static bool softbreak(GB_gameboy_t *gb, char *arguments, char *modifiers, const debugger_command_t *command)
{
NO_MODIFIERS
if (strcmp(lstrip(arguments), "on") == 0) {
gb->has_software_breakpoints = true;
}
else if(strcmp(lstrip(arguments), "off") == 0) {
gb->has_software_breakpoints = false;
}
else {
print_usage(gb, command);
}
return true;
}
/* Find the index of the closest breakpoint equal or greater to addr */ /* Find the index of the closest breakpoint equal or greater to addr */
static uint16_t find_breakpoint(GB_gameboy_t *gb, value_t addr) static uint16_t find_breakpoint(GB_gameboy_t *gb, value_t addr)
{ {
@ -1780,6 +1797,7 @@ static const debugger_command_t commands[] = {
"a more (c)ompact one, or a one-(l)iner", "", "(f|c|l)"}, "a more (c)ompact one, or a one-(l)iner", "", "(f|c|l)"},
{"lcd", 3, lcd, "Displays information about the current state of the LCD controller"}, {"lcd", 3, lcd, "Displays information about the current state of the LCD controller"},
{"palettes", 3, palettes, "Displays the current CGB palettes"}, {"palettes", 3, palettes, "Displays the current CGB palettes"},
{"softbreak", 2, softbreak, "Enables or disables software breakpoints", "(on|off)"},
{"breakpoint", 1, breakpoint, "Add a new breakpoint at the specified address/expression" HELP_NEWLINE {"breakpoint", 1, breakpoint, "Add a new breakpoint at the specified address/expression" HELP_NEWLINE
"Can also modify the condition of existing breakpoints." HELP_NEWLINE "Can also modify the condition of existing breakpoints." HELP_NEWLINE
"If the j modifier is used, the breakpoint will occur just before" HELP_NEWLINE "If the j modifier is used, the breakpoint will occur just before" HELP_NEWLINE

View File

@ -601,7 +601,7 @@ struct GB_gameboy_internal_s {
/* Breakpoints */ /* Breakpoints */
uint16_t n_breakpoints; uint16_t n_breakpoints;
struct GB_breakpoint_s *breakpoints; struct GB_breakpoint_s *breakpoints;
bool has_jump_to_breakpoints; bool has_jump_to_breakpoints, has_software_breakpoints;
void *nontrivial_jump_state; void *nontrivial_jump_state;
bool non_trivial_jump_breakpoint_occured; bool non_trivial_jump_breakpoint_occured;

View File

@ -790,10 +790,12 @@ LD_X_Y(l,b) LD_X_Y(l,c) LD_X_Y(l,d) LD_X_Y(l,e) LD_X_Y(l,h) LD_X_DHL
LD_DHL_Y(b) LD_DHL_Y(c) LD_DHL_Y(d) LD_DHL_Y(e) LD_DHL_Y(h) LD_DHL_Y(l) LD_DHL_Y(a) LD_DHL_Y(b) LD_DHL_Y(c) LD_DHL_Y(d) LD_DHL_Y(e) LD_DHL_Y(h) LD_DHL_Y(l) LD_DHL_Y(a)
LD_X_Y(a,b) LD_X_Y(a,c) LD_X_Y(a,d) LD_X_Y(a,e) LD_X_Y(a,h) LD_X_Y(a,l) LD_X_DHL(a) LD_X_Y(a,b) LD_X_Y(a,c) LD_X_Y(a,d) LD_X_Y(a,e) LD_X_Y(a,h) LD_X_Y(a,l) LD_X_DHL(a)
// simply fire the debugger // fire the debugger if software breakpoints are enabled
static void ld_b_b(GB_gameboy_t *gb, uint8_t opcode) static void ld_b_b(GB_gameboy_t *gb, uint8_t opcode)
{ {
if(gb->has_software_breakpoints) {
GB_debugger_break(gb); GB_debugger_break(gb);
}
} }
static void add_a_r(GB_gameboy_t *gb, uint8_t opcode) static void add_a_r(GB_gameboy_t *gb, uint8_t opcode)