Less strict matching for delete
and unwatch
. Fixes #71
This commit is contained in:
parent
1fcde88d8a
commit
7df571d42f
@ -929,16 +929,32 @@ static bool delete(GB_gameboy_t *gb, char *arguments, char *modifiers, const deb
|
|||||||
|
|
||||||
if (error) return true;
|
if (error) return true;
|
||||||
|
|
||||||
uint16_t index = find_breakpoint(gb, result);
|
uint16_t index = 0;
|
||||||
if (index >= gb->n_breakpoints || gb->breakpoints[index].key != key) {
|
for (unsigned i = 0; i < gb->n_breakpoints; i++) {
|
||||||
|
if (gb->breakpoints[i].key == key) {
|
||||||
|
/* Full match */
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (gb->breakpoints[i].addr == result.value && result.has_bank != (gb->breakpoints[i].bank != (uint16_t) -1)) {
|
||||||
|
/* Partial match */
|
||||||
|
index = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index >= gb->n_breakpoints) {
|
||||||
GB_log(gb, "No breakpoint set at %s\n", debugger_value_to_string(gb, result, true));
|
GB_log(gb, "No breakpoint set at %s\n", debugger_value_to_string(gb, result, true));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.bank = gb->breakpoints[index].bank;
|
||||||
|
result.has_bank = gb->breakpoints[index].bank != (uint16_t) -1;
|
||||||
|
|
||||||
if (gb->breakpoints[index].condition) {
|
if (gb->breakpoints[index].condition) {
|
||||||
free(gb->breakpoints[index].condition);
|
free(gb->breakpoints[index].condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
memmove(&gb->breakpoints[index], &gb->breakpoints[index + 1], (gb->n_breakpoints - index - 1) * sizeof(gb->breakpoints[0]));
|
memmove(&gb->breakpoints[index], &gb->breakpoints[index + 1], (gb->n_breakpoints - index - 1) * sizeof(gb->breakpoints[0]));
|
||||||
gb->n_breakpoints--;
|
gb->n_breakpoints--;
|
||||||
gb->breakpoints = realloc(gb->breakpoints, gb->n_breakpoints * sizeof(gb->breakpoints[0]));
|
gb->breakpoints = realloc(gb->breakpoints, gb->n_breakpoints * sizeof(gb->breakpoints[0]));
|
||||||
@ -1086,11 +1102,26 @@ static bool unwatch(GB_gameboy_t *gb, char *arguments, char *modifiers, const de
|
|||||||
|
|
||||||
if (error) return true;
|
if (error) return true;
|
||||||
|
|
||||||
uint16_t index = find_watchpoint(gb, result);
|
uint16_t index = 0;
|
||||||
if (index >= gb->n_watchpoints || gb->watchpoints[index].key != key) {
|
for (unsigned i = 0; i < gb->n_watchpoints; i++) {
|
||||||
|
if (gb->watchpoints[i].key == key) {
|
||||||
|
/* Full match */
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (gb->watchpoints[i].addr == result.value && result.has_bank != (gb->watchpoints[i].bank != (uint16_t) -1)) {
|
||||||
|
/* Partial match */
|
||||||
|
index = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index >= gb->n_watchpoints) {
|
||||||
GB_log(gb, "No watchpoint set at %s\n", debugger_value_to_string(gb, result, true));
|
GB_log(gb, "No watchpoint set at %s\n", debugger_value_to_string(gb, result, true));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.bank = gb->watchpoints[index].bank;
|
||||||
|
result.has_bank = gb->watchpoints[index].bank != (uint16_t) -1;
|
||||||
|
|
||||||
if (gb->watchpoints[index].condition) {
|
if (gb->watchpoints[index].condition) {
|
||||||
free(gb->watchpoints[index].condition);
|
free(gb->watchpoints[index].condition);
|
||||||
|
Loading…
Reference in New Issue
Block a user