fixup whitespace
This commit is contained in:
12
configure
vendored
12
configure
vendored
@@ -13,16 +13,16 @@ for arg in $@; do
|
|||||||
case $arg in
|
case $arg in
|
||||||
--debug)
|
--debug)
|
||||||
debug="yes"
|
debug="yes"
|
||||||
;;
|
;;
|
||||||
--release)
|
--release)
|
||||||
release="yes"
|
release="yes"
|
||||||
;;
|
;;
|
||||||
--coverage)
|
--coverage)
|
||||||
coverage="yes"
|
coverage="yes"
|
||||||
;;
|
;;
|
||||||
--perf)
|
--perf)
|
||||||
perf="yes"
|
perf="yes"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "unknown option $arg"
|
echo "unknown option $arg"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -61,8 +61,8 @@ if [[ "$debug" == "yes" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$coverage" == "yes" ]]; then
|
if [[ "$coverage" == "yes" ]]; then
|
||||||
ccflags_extra="$ccflags_extra --coverage -fprofile-arcs -ftest-coverage"
|
ccflags_extra="$ccflags_extra --coverage -fprofile-arcs -ftest-coverage"
|
||||||
ldflags_extra="$ldflags_extra -lgcov --coverage"
|
ldflags_extra="$ldflags_extra -lgcov --coverage"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
release_cflags="-O3 -flto"
|
release_cflags="-O3 -flto"
|
||||||
|
|||||||
@@ -27,17 +27,15 @@ assert $pc == 10
|
|||||||
assert $f == 0x2
|
assert $f == 0x2
|
||||||
step
|
step
|
||||||
|
|
||||||
breakpoint add 0xc
|
runto 0xc
|
||||||
step 100000
|
regs
|
||||||
breakpoint del 0
|
|
||||||
|
|
||||||
assert $pc == 0xc
|
assert $pc == 0xc
|
||||||
assert $hl == 0x7fff
|
assert $hl == 0x7fff
|
||||||
|
|
||||||
# TODO: There is a bug in GBDB where breakpoints fire at the start of an
|
# TODO: There is a bug in GBDB where breakpoints fire at the start of an
|
||||||
# instruction and "step" stops at the end of an instruction
|
# instruction and "step" stops at the end of an instruction
|
||||||
step; step
|
step; step
|
||||||
|
regs
|
||||||
assert $pc == 0xf
|
assert $pc == 0xf
|
||||||
assert $hl == 0xff26
|
assert $hl == 0xff26
|
||||||
|
|
||||||
@@ -61,11 +59,8 @@ step
|
|||||||
assert $pc == 0x16
|
assert $pc == 0x16
|
||||||
assert $c == 0x12
|
assert $c == 0x12
|
||||||
|
|
||||||
|
runto 0x27
|
||||||
break add 0x27
|
|
||||||
step 1000
|
|
||||||
assert $pc == 0x27
|
assert $pc == 0x27
|
||||||
break del 0
|
|
||||||
|
|
||||||
step; step
|
step; step
|
||||||
assert $pc == 0x28
|
assert $pc == 0x28
|
||||||
@@ -102,7 +97,7 @@ assert $pc == 0xa1
|
|||||||
|
|
||||||
break add 0xa3
|
break add 0xa3
|
||||||
step 100000
|
step 100000
|
||||||
break del 0
|
break del 2
|
||||||
assert $pc == 0xa3
|
assert $pc == 0xa3
|
||||||
step #FIXME: bugs
|
step #FIXME: bugs
|
||||||
|
|
||||||
@@ -127,7 +122,7 @@ assert $pc == 0x96
|
|||||||
break add 0x34
|
break add 0x34
|
||||||
step 10000
|
step 10000
|
||||||
assert $pc == 0x34
|
assert $pc == 0x34
|
||||||
break del 0
|
break del 3
|
||||||
|
|
||||||
step; step
|
step; step
|
||||||
assert $pc == 0x37
|
assert $pc == 0x37
|
||||||
@@ -141,7 +136,7 @@ break add 0x40
|
|||||||
step 10000
|
step 10000
|
||||||
assert $pc == 0x40
|
assert $pc == 0x40
|
||||||
assert $b == 0
|
assert $b == 0
|
||||||
break del 0
|
break del 4
|
||||||
|
|
||||||
step; step
|
step; step
|
||||||
assert $pc == 0x42
|
assert $pc == 0x42
|
||||||
@@ -158,8 +153,15 @@ step
|
|||||||
assert $pc == 0x4a
|
assert $pc == 0x4a
|
||||||
assert $c == 0x0c
|
assert $c == 0x0c
|
||||||
|
|
||||||
|
break add 0x55
|
||||||
|
step 10000
|
||||||
|
assert $pc == 0x55
|
||||||
|
assert $a == 0
|
||||||
|
break del 5
|
||||||
|
|
||||||
|
runto 0x100
|
||||||
|
assert $pc == 0x100
|
||||||
echo Test passed!
|
echo Test passed!
|
||||||
step 10000000
|
|
||||||
regs
|
regs
|
||||||
stat
|
stat
|
||||||
|
|
||||||
|
|||||||
114
src/apps/gbdb.c
114
src/apps/gbdb.c
@@ -452,55 +452,55 @@ static void do_run(void) {
|
|||||||
} else if (paused) {
|
} else if (paused) {
|
||||||
gb_log("Interrupted.\n");
|
gb_log("Interrupted.\n");
|
||||||
} else {
|
} else {
|
||||||
breakpoint_addr_hit(cpu.pc);
|
breakpoint_addr_hit(cpu.pc);
|
||||||
gb_log("Breakpoint hit\n");
|
gb_log("Breakpoint hit\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run(char *arg_list)
|
static void run(char *arg_list)
|
||||||
{
|
{
|
||||||
do_run();
|
do_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct breakpoint {
|
static struct breakpoint {
|
||||||
uint16_t addr;
|
uint16_t addr;
|
||||||
int id;
|
int id;
|
||||||
bool temp;
|
bool temp;
|
||||||
} breakpoints[MAX_BREAKPTS];
|
} breakpoints[MAX_BREAKPTS];
|
||||||
|
|
||||||
static int num_breakpoints = 0;
|
static int num_breakpoints = 0;
|
||||||
|
|
||||||
static struct breakpoint *get_breakpoint(int id)
|
static struct breakpoint *get_breakpoint(int id)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < num_breakpoints; i++) {
|
for (i = 0; i < num_breakpoints; i++) {
|
||||||
if (breakpoints[i].id == id) {
|
if (breakpoints[i].id == id) {
|
||||||
return &breakpoints[i];
|
return &breakpoints[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_set_breakpoint(uint16_t addr, bool temp)
|
static int do_set_breakpoint(uint16_t addr, bool temp)
|
||||||
{
|
{
|
||||||
static int id = 0;
|
static int id = 0;
|
||||||
if (num_breakpoints < ARRAY_SIZE(breakpoints)) {
|
if (num_breakpoints < ARRAY_SIZE(breakpoints)) {
|
||||||
breakpoints[num_breakpoints].addr = addr;
|
breakpoints[num_breakpoints].addr = addr;
|
||||||
breakpoints[num_breakpoints].id = id++;
|
breakpoints[num_breakpoints].id = id++;
|
||||||
breakpoints[num_breakpoints].temp = temp;
|
breakpoints[num_breakpoints].temp = temp;
|
||||||
num_breakpoints++;
|
num_breakpoints++;
|
||||||
} else {
|
} else {
|
||||||
printf("maximum number of breakpoints reached\n");
|
printf("maximum number of breakpoints reached\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_breakpoint(char *arg_string)
|
static void set_breakpoint(char *arg_string)
|
||||||
{
|
{
|
||||||
uint16_t addr, i;
|
uint16_t addr, i;
|
||||||
char *token = strtok(arg_string, " ");
|
char *token = strtok(arg_string, " ");
|
||||||
|
|
||||||
if (token == NULL) {
|
if (token == NULL) {
|
||||||
printf("usage: breakpoint add <addr>\n");
|
printf("usage: breakpoint add <addr>\n");
|
||||||
return;
|
return;
|
||||||
@@ -512,9 +512,9 @@ static void set_breakpoint(char *arg_string)
|
|||||||
|
|
||||||
static void runto(char *arg_string)
|
static void runto(char *arg_string)
|
||||||
{
|
{
|
||||||
uint16_t addr, i, rc;
|
uint16_t addr, i, rc;
|
||||||
char *token = strtok(arg_string, " ");
|
char *token = strtok(arg_string, " ");
|
||||||
|
|
||||||
if (token == NULL) {
|
if (token == NULL) {
|
||||||
printf("usage: runto <addr>\n");
|
printf("usage: runto <addr>\n");
|
||||||
return;
|
return;
|
||||||
@@ -523,8 +523,8 @@ static void runto(char *arg_string)
|
|||||||
addr = parse_val(token);
|
addr = parse_val(token);
|
||||||
rc = do_set_breakpoint(addr, true);
|
rc = do_set_breakpoint(addr, true);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
printf("failed to set breakpoint\n");
|
printf("failed to set breakpoint\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
do_run();
|
do_run();
|
||||||
@@ -532,49 +532,49 @@ static void runto(char *arg_string)
|
|||||||
|
|
||||||
static int do_delete_breakpoint(int id)
|
static int do_delete_breakpoint(int id)
|
||||||
{
|
{
|
||||||
struct breakpoint *bkpt = get_breakpoint(id);
|
struct breakpoint *bkpt = get_breakpoint(id);
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
if (bkpt == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
index = bkpt - breakpoints;
|
if (bkpt == NULL) {
|
||||||
memmove(&breakpoints[index], &breakpoints[index + 1],
|
return -1;
|
||||||
num_breakpoints - index - 1);
|
}
|
||||||
num_breakpoints--;
|
|
||||||
|
|
||||||
return 0;
|
index = bkpt - breakpoints;
|
||||||
|
memmove(&breakpoints[index], &breakpoints[index + 1],
|
||||||
|
num_breakpoints - index - 1);
|
||||||
|
num_breakpoints--;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void breakpoint_addr_hit(uint16_t addr)
|
static void breakpoint_addr_hit(uint16_t addr)
|
||||||
{
|
{
|
||||||
struct breakpoint *bkpt = NULL;
|
struct breakpoint *bkpt = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < num_breakpoints; i++) {
|
for (i = 0; i < num_breakpoints; i++) {
|
||||||
if (breakpoints[i].addr == addr) {
|
if (breakpoints[i].addr == addr) {
|
||||||
bkpt= &breakpoints[i];
|
bkpt= &breakpoints[i];
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (bkpt == NULL) {
|
|
||||||
printf("No breakpoint found at addr=%d\n", addr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bkpt->temp) {
|
if (bkpt == NULL) {
|
||||||
do_delete_breakpoint(bkpt->id);
|
printf("No breakpoint found at addr=%d\n", addr);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bkpt->temp) {
|
||||||
|
do_delete_breakpoint(bkpt->id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_breakpoint(char *arg_string)
|
static void delete_breakpoint(char *arg_string)
|
||||||
{
|
{
|
||||||
char *token = strtok(arg_string, " ");
|
char *token = strtok(arg_string, " ");
|
||||||
int rc, bkpt;
|
int rc, bkpt;
|
||||||
|
|
||||||
if (token == NULL) {
|
if (token == NULL) {
|
||||||
printf("usage: breakpoint rm <bkpt num>\n");
|
printf("usage: breakpoint rm <bkpt num>\n");
|
||||||
return;
|
return;
|
||||||
@@ -584,7 +584,7 @@ static void delete_breakpoint(char *arg_string)
|
|||||||
|
|
||||||
rc = do_delete_breakpoint(bkpt);
|
rc = do_delete_breakpoint(bkpt);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
printf("%d is not a valid breakpoint number\n", bkpt);
|
printf("%d is not a valid breakpoint number\n", bkpt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,9 +593,9 @@ static void display_breakpoints(char *arg_string)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (num_breakpoints) {
|
if (num_breakpoints) {
|
||||||
for (i = 0; i < num_breakpoints; i++) {
|
for (i = 0; i < num_breakpoints; i++) {
|
||||||
printf("#%d: 0x%04x\n", breakpoints[i].id, breakpoints[i].addr);
|
printf("#%d: 0x%04x\n", breakpoints[i].id, breakpoints[i].addr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("No breakpoints set\n");
|
printf("No breakpoints set\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user