mirror of https://github.com/mgba-emu/mgba.git
Compile-time flag for disabling debugger
This commit is contained in:
parent
b3dc065144
commit
290b64b171
|
@ -3,11 +3,11 @@ project(GBAc)
|
|||
set(BINARY_NAME gbac CACHE INTERNAL "Name of output binaries")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -Wextra -Wno-error=type-limits --std=gnu99")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3 -Wall -Wextra --std=gnu99")
|
||||
set(USE_DEBUGGER ON CACHE BOOL "Whether or not to enable the ARM debugger")
|
||||
file(GLOB ARM_SRC ${CMAKE_SOURCE_DIR}/src/arm/*.c)
|
||||
file(GLOB GBA_SRC ${CMAKE_SOURCE_DIR}/src/gba/*.c)
|
||||
file(GLOB UTIL_SRC ${CMAKE_SOURCE_DIR}/src/util/*.c)
|
||||
file(GLOB RENDERER_SRC ${CMAKE_SOURCE_DIR}/src/gba/renderers/video-software.c)
|
||||
file(GLOB DEBUGGER_SRC ${CMAKE_SOURCE_DIR}/src/debugger/*.c)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src/arm)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src/gba)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src/debugger)
|
||||
|
@ -18,6 +18,15 @@ find_package(SDL 1.2 REQUIRED)
|
|||
file(GLOB SDL_SRC ${CMAKE_SOURCE_DIR}/src/sdl/sdl-*.c)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src/sdl)
|
||||
|
||||
if(USE_DEBUGGER)
|
||||
file(GLOB DEBUGGER_SRC ${CMAKE_SOURCE_DIR}/src/debugger/*.c)
|
||||
set(DEBUGGER_LIB "edit")
|
||||
add_definitions(-DUSE_DEBUGGER)
|
||||
else()
|
||||
set(DEBUGGER_SRC "")
|
||||
set(DEBUGGER_LIB "")
|
||||
endif()
|
||||
|
||||
if(BUILD_RASPI AND BUILD_EGL)
|
||||
set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/egl-main.c)
|
||||
set(OPENGL_LIBRARY "-lEGL -lGLESv2 -lbcm_host")
|
||||
|
@ -33,4 +42,4 @@ endif()
|
|||
include_directories(${SDL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
|
||||
|
||||
add_executable(${BINARY_NAME} ${ARM_SRC} ${GBA_SRC} ${DEBUGGER_SRC} ${RENDERER_SRC} ${UTIL_SRC} ${SDL_SRC} ${MAIN_SRC})
|
||||
target_link_libraries(${BINARY_NAME} m pthread edit ${SDL_LIBRARY} ${OPENGL_LIBRARY})
|
||||
target_link_libraries(${BINARY_NAME} m pthread ${DEBUGGER_LIB} ${SDL_LIBRARY} ${OPENGL_LIBRARY})
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#ifndef DEBUGGER_H
|
||||
#define DEBUGGER_H
|
||||
|
||||
#ifdef USE_DEBUGGER
|
||||
#include <histedit.h>
|
||||
|
||||
#include "arm.h"
|
||||
#endif
|
||||
|
||||
enum DebuggerState {
|
||||
DEBUGGER_PAUSED,
|
||||
|
@ -11,6 +13,8 @@ enum DebuggerState {
|
|||
DEBUGGER_EXITING
|
||||
};
|
||||
|
||||
#ifdef USE_DEBUGGER
|
||||
|
||||
struct DebugBreakpoint {
|
||||
struct DebugBreakpoint* next;
|
||||
int32_t address;
|
||||
|
@ -40,4 +44,12 @@ void ARMDebuggerDeinit(struct ARMDebugger*);
|
|||
void ARMDebuggerRun(struct ARMDebugger*);
|
||||
void ARMDebuggerEnter(struct ARMDebugger*);
|
||||
|
||||
#else
|
||||
|
||||
struct ARMDebugger {
|
||||
enum DebuggerState state;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,7 +17,9 @@ static void* _GBAThreadRun(void* context) {
|
|||
static pthread_once_t once = PTHREAD_ONCE_INIT;
|
||||
pthread_once(&once, _createTLS);
|
||||
|
||||
#ifdef USE_DEBUGGER
|
||||
struct ARMDebugger debugger;
|
||||
#endif
|
||||
struct GBA gba;
|
||||
struct GBAThread* threadContext = context;
|
||||
char* savedata = 0;
|
||||
|
@ -57,12 +59,18 @@ static void* _GBAThreadRun(void* context) {
|
|||
GBALoadROM(&gba, threadContext->fd, threadContext->fname);
|
||||
gba.savefile = savedata;
|
||||
}
|
||||
|
||||
#ifdef USE_DEBUGGER
|
||||
if (threadContext->useDebugger) {
|
||||
threadContext->debugger = &debugger;
|
||||
GBAAttachDebugger(&gba, &debugger);
|
||||
} else {
|
||||
threadContext->debugger = 0;
|
||||
}
|
||||
#else
|
||||
threadContext->debugger = 0;
|
||||
#endif
|
||||
|
||||
gba.keySource = &threadContext->activeKeys;
|
||||
|
||||
if (threadContext->startCallback) {
|
||||
|
@ -74,14 +82,18 @@ static void* _GBAThreadRun(void* context) {
|
|||
pthread_cond_broadcast(&threadContext->startCond);
|
||||
pthread_mutex_unlock(&threadContext->startMutex);
|
||||
|
||||
#ifdef USE_DEBUGGER
|
||||
if (threadContext->useDebugger) {
|
||||
ARMDebuggerRun(&debugger);
|
||||
threadContext->started = 0;
|
||||
} else {
|
||||
#endif
|
||||
while (threadContext->started) {
|
||||
ARMRun(&gba.cpu);
|
||||
}
|
||||
#ifdef USE_DEBUGGER
|
||||
}
|
||||
#endif
|
||||
|
||||
if (threadContext->cleanCallback) {
|
||||
threadContext->cleanCallback(threadContext);
|
||||
|
|
|
@ -36,6 +36,7 @@ static void _checkOverrides(struct GBA* gba, uint32_t code);
|
|||
void GBAInit(struct GBA* gba) {
|
||||
gba->errno = GBA_NO_ERROR;
|
||||
gba->errstr = 0;
|
||||
gba->debugger = 0;
|
||||
|
||||
ARMInit(&gba->cpu);
|
||||
|
||||
|
@ -266,10 +267,12 @@ static int32_t GBATimersProcessEvents(struct GBA* gba, int32_t cycles) {
|
|||
return nextEvent;
|
||||
}
|
||||
|
||||
#ifdef USE_DEBUGGER
|
||||
void GBAAttachDebugger(struct GBA* gba, struct ARMDebugger* debugger) {
|
||||
ARMDebuggerInit(debugger, &gba->cpu);
|
||||
gba->debugger = debugger;
|
||||
}
|
||||
#endif
|
||||
|
||||
void GBALoadROM(struct GBA* gba, int fd, const char* fname) {
|
||||
struct stat info;
|
||||
|
@ -434,11 +437,16 @@ void GBALog(struct GBA* gba, enum GBALogLevel level, const char* format, ...) {
|
|||
void GBAHitStub(struct ARMBoard* board, uint32_t opcode) {
|
||||
struct GBABoard* gbaBoard = (struct GBABoard*) board;
|
||||
GBALog(gbaBoard->p, GBA_LOG_STUB, "Stub opcode: %08x", opcode);
|
||||
#ifdef USE_DEBUGGER
|
||||
if (!gbaBoard->p->debugger) {
|
||||
abort();
|
||||
} else {
|
||||
ARMDebuggerEnter(gbaBoard->p->debugger);
|
||||
}
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void _checkOverrides(struct GBA* gba, uint32_t id) {
|
||||
|
|
Loading…
Reference in New Issue