mirror of
https://github.com/pevans/erc-c.git
synced 2024-11-27 20:51:17 +00:00
Add unbreak command, unbreak_all() function for testing
This commit is contained in:
parent
c17616c383
commit
01f230dc85
@ -72,13 +72,17 @@ extern vm_debug_cmd *vm_debug_find_cmd(const char *);
|
|||||||
extern void vm_debug_break(int);
|
extern void vm_debug_break(int);
|
||||||
extern void vm_debug_execute(const char *);
|
extern void vm_debug_execute(const char *);
|
||||||
extern void vm_debug_quit();
|
extern void vm_debug_quit();
|
||||||
|
extern void vm_debug_unbreak(int);
|
||||||
|
extern void vm_debug_unbreak_all();
|
||||||
|
|
||||||
|
extern DEBUG_CMD(break);
|
||||||
extern DEBUG_CMD(help);
|
extern DEBUG_CMD(help);
|
||||||
extern DEBUG_CMD(jump);
|
extern DEBUG_CMD(jump);
|
||||||
extern DEBUG_CMD(printaddr);
|
extern DEBUG_CMD(printaddr);
|
||||||
extern DEBUG_CMD(printstate);
|
extern DEBUG_CMD(printstate);
|
||||||
extern DEBUG_CMD(quit);
|
extern DEBUG_CMD(quit);
|
||||||
extern DEBUG_CMD(resume);
|
extern DEBUG_CMD(resume);
|
||||||
|
extern DEBUG_CMD(unbreak);
|
||||||
extern DEBUG_CMD(writeaddr);
|
extern DEBUG_CMD(writeaddr);
|
||||||
extern DEBUG_CMD(writestate);
|
extern DEBUG_CMD(writestate);
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
@ -20,12 +21,14 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* A table of breakpoints, arranged by address in a CPU. If
|
* A table of breakpoints, arranged by address in a CPU. If
|
||||||
* breakpoints[i] is zero, then there is no breakpoint. If it is
|
* breakpoints[i] is false, then there is no breakpoint. If it is
|
||||||
* non-zero, then there is a breakpoint at address i.
|
* true, then there is a breakpoint at address i.
|
||||||
*/
|
*/
|
||||||
static int breakpoints[BREAKPOINTS_MAX];
|
static bool breakpoints[BREAKPOINTS_MAX];
|
||||||
|
|
||||||
vm_debug_cmd cmdtable[] = {
|
vm_debug_cmd cmdtable[] = {
|
||||||
|
{ "break", "b", vm_debug_cmd_break, 1, "<addr>",
|
||||||
|
"Add breakpoint at <addr>", },
|
||||||
{ "help", "h", vm_debug_cmd_help, 0, "",
|
{ "help", "h", vm_debug_cmd_help, 0, "",
|
||||||
"Print out this list of commands", },
|
"Print out this list of commands", },
|
||||||
{ "jump", "j", vm_debug_cmd_jump, 1, "<addr>",
|
{ "jump", "j", vm_debug_cmd_jump, 1, "<addr>",
|
||||||
@ -38,6 +41,8 @@ vm_debug_cmd cmdtable[] = {
|
|||||||
"Quit the emulator", },
|
"Quit the emulator", },
|
||||||
{ "resume", "r", vm_debug_cmd_resume, 0, "",
|
{ "resume", "r", vm_debug_cmd_resume, 0, "",
|
||||||
"Resume execution", },
|
"Resume execution", },
|
||||||
|
{ "unbreak", "u", vm_debug_cmd_unbreak, 1, "<addr>",
|
||||||
|
"Remove breakpoint at <addr>", },
|
||||||
{ "writeaddr", "wa", vm_debug_cmd_writeaddr, 2, "<addr> <byte>",
|
{ "writeaddr", "wa", vm_debug_cmd_writeaddr, 2, "<addr> <byte>",
|
||||||
"Write <byte> at <addr>", },
|
"Write <byte> at <addr>", },
|
||||||
{ "writestate", "ws", vm_debug_cmd_writestate, 2, "<reg> <byte>",
|
{ "writestate", "ws", vm_debug_cmd_writestate, 2, "<reg> <byte>",
|
||||||
@ -90,7 +95,17 @@ vm_debug_break(int addr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
breakpoints[addr] = 1;
|
breakpoints[addr] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vm_debug_unbreak(int addr)
|
||||||
|
{
|
||||||
|
if (addr < 0 || addr >= BREAKPOINTS_MAX) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
breakpoints[addr] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -100,7 +115,13 @@ vm_debug_broke(int addr)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return breakpoints[addr] != 0;
|
return breakpoints[addr];
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vm_debug_unbreak_all()
|
||||||
|
{
|
||||||
|
memset(breakpoints, false, BREAKPOINTS_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@ -215,6 +236,11 @@ vm_debug_find_cmd(const char *str)
|
|||||||
sizeof(vm_debug_cmd), cmd_compar);
|
sizeof(vm_debug_cmd), cmd_compar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG_CMD(break)
|
||||||
|
{
|
||||||
|
vm_debug_break(args->addr1);
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG_CMD(help)
|
DEBUG_CMD(help)
|
||||||
{
|
{
|
||||||
FILE *stream = (FILE *)vm_di_get(VM_OUTPUT);
|
FILE *stream = (FILE *)vm_di_get(VM_OUTPUT);
|
||||||
@ -280,3 +306,8 @@ DEBUG_CMD(quit)
|
|||||||
{
|
{
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG_CMD(unbreak)
|
||||||
|
{
|
||||||
|
vm_debug_unbreak(args->addr1);
|
||||||
|
}
|
||||||
|
@ -49,6 +49,8 @@ teardown()
|
|||||||
fclose(stream);
|
fclose(stream);
|
||||||
|
|
||||||
apple2_free(mach);
|
apple2_free(mach);
|
||||||
|
|
||||||
|
vm_debug_unbreak_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
TestSuite(vm_debug, .init = setup, .fini = teardown);
|
TestSuite(vm_debug, .init = setup, .fini = teardown);
|
||||||
@ -177,4 +179,37 @@ Test(vm_debug, broke)
|
|||||||
cr_assert_eq(vm_debug_broke(0x23), true);
|
cr_assert_eq(vm_debug_broke(0x23), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Test(vm_debug, unbreak)
|
||||||
|
{
|
||||||
|
vm_debug_break(0x23);
|
||||||
|
|
||||||
|
cr_assert_eq(vm_debug_broke(0x23), true);
|
||||||
|
vm_debug_unbreak(0x23);
|
||||||
|
cr_assert_eq(vm_debug_broke(0x23), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Test(vm_debug, cmd_break)
|
||||||
|
{
|
||||||
|
args.addr1 = 123;
|
||||||
|
vm_debug_cmd_break(&args);
|
||||||
|
|
||||||
|
cr_assert_eq(vm_debug_broke(123), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Test(vm_debug, cmd_unbreak)
|
||||||
|
{
|
||||||
|
args.addr1 = 123;
|
||||||
|
vm_debug_cmd_break(&args);
|
||||||
|
cr_assert_eq(vm_debug_broke(123), true);
|
||||||
|
vm_debug_cmd_unbreak(&args);
|
||||||
|
cr_assert_eq(vm_debug_broke(123), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Test(vm_debug, unbreak_all)
|
||||||
|
{
|
||||||
|
vm_debug_break(55555);
|
||||||
|
vm_debug_unbreak_all();
|
||||||
|
cr_assert_eq(vm_debug_broke(55555), false);
|
||||||
|
}
|
||||||
|
|
||||||
/* Test(vm_debug, quit) */
|
/* Test(vm_debug, quit) */
|
||||||
|
Loading…
Reference in New Issue
Block a user