Debugger: Clean up layering violation

This commit is contained in:
Vicki Pfau 2023-09-07 00:22:10 -07:00
parent b2dd7611ea
commit 7015a104be
5 changed files with 40 additions and 40 deletions

View File

@ -14,7 +14,6 @@ CXX_GUARD_START
#include <mgba/core/log.h>
#include <mgba-util/table.h>
#include <mgba-util/vector.h>
#include <mgba/internal/debugger/stack-trace.h>
mLOG_DECLARE_CATEGORY(DEBUGGER);
@ -58,6 +57,14 @@ enum mDebuggerEntryReason {
DEBUGGER_ENTER_STACK
};
enum mStackTraceMode {
STACK_TRACE_DISABLED = 0,
STACK_TRACE_ENABLED = 1,
STACK_TRACE_BREAK_ON_RETURN = 2,
STACK_TRACE_BREAK_ON_CALL = 4,
STACK_TRACE_BREAK_ON_BOTH = STACK_TRACE_BREAK_ON_RETURN | STACK_TRACE_BREAK_ON_CALL
};
struct mDebuggerModule;
struct mDebuggerEntryInfo {
uint32_t address;
@ -104,6 +111,28 @@ DECLARE_VECTOR(mBreakpointList, struct mBreakpoint);
DECLARE_VECTOR(mWatchpointList, struct mWatchpoint);
DECLARE_VECTOR(mDebuggerModuleList, struct mDebuggerModule*);
struct mStackFrame {
int callSegment;
uint32_t callAddress;
int entrySegment;
uint32_t entryAddress;
int frameBaseSegment;
uint32_t frameBaseAddress;
void* regs;
bool finished;
bool breakWhenFinished;
bool interrupt;
};
DECLARE_VECTOR(mStackFrames, struct mStackFrame);
struct mStackTrace {
struct mStackFrames stack;
size_t registersSize;
void (*formatRegisters)(struct mStackFrame* frame, char* out, size_t* length);
};
struct mDebugger;
struct ParseTree;
struct mDebuggerPlatform {
@ -127,8 +156,8 @@ struct mDebuggerPlatform {
bool (*lookupIdentifier)(struct mDebuggerPlatform*, const char* name, int32_t* value, int* segment);
uint32_t (*getStackTraceMode)(struct mDebuggerPlatform*);
void (*setStackTraceMode)(struct mDebuggerPlatform*, uint32_t mode);
enum mStackTraceMode (*getStackTraceMode)(struct mDebuggerPlatform*);
void (*setStackTraceMode)(struct mDebuggerPlatform*, enum mStackTraceMode mode);
bool (*updateStackTrace)(struct mDebuggerPlatform* d);
};

View File

@ -36,7 +36,7 @@ struct ARMDebugger {
struct ARMMemory originalMemory;
ssize_t nextId;
uint32_t stackTraceMode;
enum mStackTraceMode stackTraceMode;
void (*entered)(struct mDebugger*, enum mDebuggerEntryReason, struct mDebuggerEntryInfo*);

View File

@ -12,43 +12,13 @@ CXX_GUARD_START
#include <mgba/core/cpu.h>
#include <mgba/core/log.h>
#include <mgba/debugger/debugger.h>
#include <mgba-util/vector.h>
struct mDebuggerSymbols;
enum mStackTraceMode {
STACK_TRACE_DISABLED = 0,
STACK_TRACE_ENABLED = 1,
STACK_TRACE_BREAK_ON_RETURN = 2,
STACK_TRACE_BREAK_ON_CALL = 4,
STACK_TRACE_BREAK_ON_BOTH = STACK_TRACE_BREAK_ON_RETURN | STACK_TRACE_BREAK_ON_CALL
};
struct mStackFrame {
int callSegment;
uint32_t callAddress;
int entrySegment;
uint32_t entryAddress;
int frameBaseSegment;
uint32_t frameBaseAddress;
void* regs;
bool finished;
bool breakWhenFinished;
bool interrupt;
};
DECLARE_VECTOR(mStackFrames, struct mStackFrame);
struct mStackTrace {
struct mStackFrames stack;
size_t registersSize;
void (*formatRegisters)(struct mStackFrame* frame, char* out, size_t* length);
};
void mStackTraceInit(struct mStackTrace* stack, size_t registersSize);
void mStackTraceDeinit(struct mStackTrace* stack);
struct mDebuggerSymbols;
void mStackTraceClear(struct mStackTrace* stack);
size_t mStackTraceGetDepth(struct mStackTrace* stack);
struct mStackFrame* mStackTracePush(struct mStackTrace* stack, uint32_t pc, uint32_t destAddress, uint32_t sp, void* regs);

View File

@ -243,8 +243,8 @@ static bool ARMDebuggerHasBreakpoints(struct mDebuggerPlatform*);
static void ARMDebuggerTrace(struct mDebuggerPlatform*, char* out, size_t* length);
static void ARMDebuggerFormatRegisters(struct ARMRegisterFile* regs, char* out, size_t* length);
static void ARMDebuggerFrameFormatRegisters(struct mStackFrame* frame, char* out, size_t* length);
static uint32_t ARMDebuggerGetStackTraceMode(struct mDebuggerPlatform*);
static void ARMDebuggerSetStackTraceMode(struct mDebuggerPlatform*, uint32_t);
static enum mStackTraceMode ARMDebuggerGetStackTraceMode(struct mDebuggerPlatform*);
static void ARMDebuggerSetStackTraceMode(struct mDebuggerPlatform*, enum mStackTraceMode);
static bool ARMDebuggerUpdateStackTrace(struct mDebuggerPlatform* d);
struct mDebuggerPlatform* ARMDebuggerPlatformCreate(void) {
@ -527,12 +527,12 @@ static void ARMDebuggerFrameFormatRegisters(struct mStackFrame* frame, char* out
ARMDebuggerFormatRegisters(frame->regs, out, length);
}
static uint32_t ARMDebuggerGetStackTraceMode(struct mDebuggerPlatform* d) {
static enum mStackTraceMode ARMDebuggerGetStackTraceMode(struct mDebuggerPlatform* d) {
struct ARMDebugger* debugger = (struct ARMDebugger*) d;
return debugger->stackTraceMode;
}
static void ARMDebuggerSetStackTraceMode(struct mDebuggerPlatform* d, uint32_t mode) {
static void ARMDebuggerSetStackTraceMode(struct mDebuggerPlatform* d, enum mStackTraceMode mode) {
struct ARMDebugger* debugger = (struct ARMDebugger*) d;
struct mStackTrace* stack = &d->p->stackTrace;
if (mode == STACK_TRACE_DISABLED && debugger->stackTraceMode != STACK_TRACE_DISABLED) {

View File

@ -14,6 +14,7 @@
#include <mgba/core/timing.h>
#include <mgba/core/version.h>
#include <mgba/internal/debugger/parser.h>
#include <mgba/internal/debugger/stack-trace.h>
#ifdef USE_ELF
#include <mgba-util/elf-read.h>
#endif