mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-26 17:32:40 +00:00
Remove duplicate code paths for stepping/typing-into the debugger
This commit is contained in:
parent
b62f5e9e7f
commit
4ca642a715
@ -85,6 +85,7 @@ extern const struct opcode_struct *opcodes;
|
||||
void c_interface_debugging();
|
||||
#endif
|
||||
|
||||
void debugger_setInputText(const char *text);
|
||||
void c_debugger_go(void);
|
||||
bool c_debugger_should_break(void);
|
||||
void c_debugger_set_timeout(const unsigned int secs);
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
const struct opcode_struct *opcodes;
|
||||
|
||||
static char input_str[1024] = { 0 }; // ASCII values
|
||||
|
||||
static stepping_struct_t stepping_struct = { 0 };
|
||||
static unsigned int stepping_timeout = 0;
|
||||
|
||||
@ -1153,16 +1155,12 @@ static int begin_cpu_stepping() {
|
||||
ERRLOG("pthread_cond_wait : %d", err);
|
||||
}
|
||||
|
||||
#if TESTING
|
||||
#warning FIXME TODO : this is mis-named now ... GLVideo pushes sync state so we do not need to force poll ... but we need this to type the testing strings ... should refactor to leverage a common codepath, preferablly using the 'typing' mechanism here...
|
||||
extern void testing_video_sync();
|
||||
testing_video_sync();
|
||||
#elif defined(INTERFACE_CLASSIC)
|
||||
#if defined(INTERFACE_CLASSIC)
|
||||
if ((ch = c_mygetch(0)) != -1) {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if ( (stepping_struct.step_type != TYPING) && (idx > textlen) ) {
|
||||
if ( (stepping_struct.step_type == TYPING) && (idx > textlen) ) {
|
||||
break; // finished typing
|
||||
}
|
||||
if (stepping_timeout && (stepping_struct.timeout < time(NULL))) {
|
||||
@ -1495,9 +1493,19 @@ void c_interface_debugging() {
|
||||
/* -------------------------------------------------------------------------
|
||||
debugger testing-driven API
|
||||
------------------------------------------------------------------------- */
|
||||
void debugger_setInputText(const char *text) {
|
||||
strcat(input_str, text);
|
||||
}
|
||||
|
||||
void c_debugger_go(void) {
|
||||
void *buf = NULL;
|
||||
if (strlen(input_str)) {
|
||||
buf = STRDUP(input_str);
|
||||
input_str[0] = '\0';
|
||||
}
|
||||
|
||||
void c_debugger_go() {
|
||||
stepping_struct_t s = (stepping_struct_t){
|
||||
.step_text = buf,
|
||||
.step_type = GOING,
|
||||
.timeout = time(NULL) + stepping_timeout
|
||||
};
|
||||
@ -1507,6 +1515,8 @@ void c_debugger_go() {
|
||||
|
||||
debugger_go(s);
|
||||
|
||||
FREE(buf);
|
||||
|
||||
is_debugging = false;
|
||||
num_buffer_lines = 0;
|
||||
}
|
||||
|
@ -11,58 +11,18 @@
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
#define TESTBUF_SZ 1024
|
||||
|
||||
bool test_do_reboot = true;
|
||||
char mdstr[(SHA_DIGEST_LENGTH*2)+1];
|
||||
|
||||
static char input_str[TESTBUF_SZ]; // ASCII
|
||||
static unsigned int input_length = 0;
|
||||
static unsigned int input_counter = 0;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void test_common_setup() {
|
||||
input_counter = 0;
|
||||
input_length = 0;
|
||||
input_str[0] = '\0';
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test video functions and stubs
|
||||
|
||||
void testing_video_sync() {
|
||||
|
||||
if (!input_length) {
|
||||
input_length = strlen(input_str);
|
||||
}
|
||||
|
||||
if (input_counter >= input_length) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t ch = (uint8_t)input_str[input_counter];
|
||||
if (ch == '\n') {
|
||||
ch = '\r';
|
||||
}
|
||||
|
||||
if ( (apple_ii_64k[0][0xC000] & 0x80) || (apple_ii_64k[1][0xC000] & 0x80) ) {
|
||||
// last character typed not processed by emulator...
|
||||
return;
|
||||
}
|
||||
|
||||
apple_ii_64k[0][0xC000] = ch | 0x80;
|
||||
apple_ii_64k[1][0xC000] = ch | 0x80;
|
||||
|
||||
++input_counter;
|
||||
void test_common_setup(void) {
|
||||
}
|
||||
|
||||
void test_type_input(const char *input) {
|
||||
strcat(input_str, input);
|
||||
debugger_setInputText(input);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void test_breakpoint(void *arg) {
|
||||
fprintf(GREATEST_STDOUT, "DISPLAY NOTE: busy-spinning in test_breakpoint(), needs gdb/lldb intervention to continue...\n");
|
||||
volatile bool debug_continue = false;
|
||||
@ -72,9 +32,7 @@ void test_breakpoint(void *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void test_common_init() {
|
||||
void test_common_init(void) {
|
||||
GREATEST_SET_BREAKPOINT_CB(test_breakpoint, NULL);
|
||||
|
||||
do_logging = false;// silence regular emulator logging
|
||||
|
Loading…
x
Reference in New Issue
Block a user