added HAVE_GDBSERVER define

This commit is contained in:
Anthony Pesch 2017-07-22 17:59:42 -04:00
parent 3a6feb0c94
commit 843199c277
2 changed files with 18 additions and 2 deletions

View File

@ -349,7 +349,7 @@ else()
set(REDREAM_SOURCES ${RELIB_SOURCES} src/host/sdl_host.c src/emulator.c src/tracer.c)
set(REDREAM_INCLUDES ${RELIB_INCLUDES})
set(REDREAM_LIBS ${RELIB_LIBS} ${IMGUI_LIBS} ${SDL_LIBS})
set(REDREAM_DEFS ${RELIB_DEFS} HAVE_IMGUI HAVE_MICROPROFILE)
set(REDREAM_DEFS ${RELIB_DEFS} HAVE_GDBSERVER HAVE_IMGUI HAVE_MICROPROFILE)
set(REDREAM_FLAGS ${RELIB_FLAGS})
endif()

View File

@ -1,11 +1,14 @@
#ifdef HAVE_GDBSERVER
#include "gdb/gdb_server.h"
#define GDB_SERVER_IMPL
#include "gdb/gdb_server.h"
#endif
#include "core/log.h"
#include "guest/debugger.h"
#include "guest/dreamcast.h"
#ifdef HAVE_GDBSERVER
struct debugger {
struct dreamcast *dc;
struct device *dev;
@ -55,8 +58,10 @@ static void debugger_gdb_server_read_reg(void *data, int n, intmax_t *value,
dbg->dev->debug_if->read_reg(dbg->dev, n, &v, size);
*value = v;
}
#endif
int debugger_init(struct debugger *dbg) {
#ifdef HAVE_GDBSERVER
/* use the first device found with a debug interface */
list_for_each_entry(dev, &dbg->dc->devices, struct device, it) {
if (dev->debug_if) {
@ -86,32 +91,43 @@ int debugger_init(struct debugger *dbg) {
dbg->sv = gdb_server_create(&target, 24690);
if (!dbg->sv) {
LOG_WARNING("Failed to create GDB server");
LOG_WARNING("failed to create GDB server");
return 0;
}
#endif
return 1;
}
void debugger_trap(struct debugger *dbg) {
#ifdef HAVE_GDBSERVER
gdb_server_interrupt(dbg->sv, GDB_SIGNAL_TRAP);
dc_suspend(dbg->dc);
#endif
}
void debugger_tick(struct debugger *dbg) {
#ifdef HAVE_GDBSERVER
gdb_server_pump(dbg->sv);
#endif
}
struct debugger *debugger_create(struct dreamcast *dc) {
#ifdef HAVE_GDBSERVER
struct debugger *dbg = calloc(1, sizeof(struct debugger));
dbg->dc = dc;
return dbg;
#else
return NULL;
#endif
}
void debugger_destroy(struct debugger *dbg) {
#ifdef HAVE_GDBSERVER
gdb_server_destroy(dbg->sv);
free(dbg);
#endif
}