mirror of https://github.com/mgba-emu/mgba.git
Debugger: Clean up layering violation
This commit is contained in:
parent
b2dd7611ea
commit
7015a104be
|
@ -14,7 +14,6 @@ CXX_GUARD_START
|
||||||
#include <mgba/core/log.h>
|
#include <mgba/core/log.h>
|
||||||
#include <mgba-util/table.h>
|
#include <mgba-util/table.h>
|
||||||
#include <mgba-util/vector.h>
|
#include <mgba-util/vector.h>
|
||||||
#include <mgba/internal/debugger/stack-trace.h>
|
|
||||||
|
|
||||||
mLOG_DECLARE_CATEGORY(DEBUGGER);
|
mLOG_DECLARE_CATEGORY(DEBUGGER);
|
||||||
|
|
||||||
|
@ -58,6 +57,14 @@ enum mDebuggerEntryReason {
|
||||||
DEBUGGER_ENTER_STACK
|
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 mDebuggerModule;
|
||||||
struct mDebuggerEntryInfo {
|
struct mDebuggerEntryInfo {
|
||||||
uint32_t address;
|
uint32_t address;
|
||||||
|
@ -104,6 +111,28 @@ DECLARE_VECTOR(mBreakpointList, struct mBreakpoint);
|
||||||
DECLARE_VECTOR(mWatchpointList, struct mWatchpoint);
|
DECLARE_VECTOR(mWatchpointList, struct mWatchpoint);
|
||||||
DECLARE_VECTOR(mDebuggerModuleList, struct mDebuggerModule*);
|
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 mDebugger;
|
||||||
struct ParseTree;
|
struct ParseTree;
|
||||||
struct mDebuggerPlatform {
|
struct mDebuggerPlatform {
|
||||||
|
@ -127,8 +156,8 @@ struct mDebuggerPlatform {
|
||||||
|
|
||||||
bool (*lookupIdentifier)(struct mDebuggerPlatform*, const char* name, int32_t* value, int* segment);
|
bool (*lookupIdentifier)(struct mDebuggerPlatform*, const char* name, int32_t* value, int* segment);
|
||||||
|
|
||||||
uint32_t (*getStackTraceMode)(struct mDebuggerPlatform*);
|
enum mStackTraceMode (*getStackTraceMode)(struct mDebuggerPlatform*);
|
||||||
void (*setStackTraceMode)(struct mDebuggerPlatform*, uint32_t mode);
|
void (*setStackTraceMode)(struct mDebuggerPlatform*, enum mStackTraceMode mode);
|
||||||
bool (*updateStackTrace)(struct mDebuggerPlatform* d);
|
bool (*updateStackTrace)(struct mDebuggerPlatform* d);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ struct ARMDebugger {
|
||||||
struct ARMMemory originalMemory;
|
struct ARMMemory originalMemory;
|
||||||
|
|
||||||
ssize_t nextId;
|
ssize_t nextId;
|
||||||
uint32_t stackTraceMode;
|
enum mStackTraceMode stackTraceMode;
|
||||||
|
|
||||||
void (*entered)(struct mDebugger*, enum mDebuggerEntryReason, struct mDebuggerEntryInfo*);
|
void (*entered)(struct mDebugger*, enum mDebuggerEntryReason, struct mDebuggerEntryInfo*);
|
||||||
|
|
||||||
|
|
|
@ -12,43 +12,13 @@ CXX_GUARD_START
|
||||||
|
|
||||||
#include <mgba/core/cpu.h>
|
#include <mgba/core/cpu.h>
|
||||||
#include <mgba/core/log.h>
|
#include <mgba/core/log.h>
|
||||||
|
#include <mgba/debugger/debugger.h>
|
||||||
#include <mgba-util/vector.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 mStackTraceInit(struct mStackTrace* stack, size_t registersSize);
|
||||||
void mStackTraceDeinit(struct mStackTrace* stack);
|
void mStackTraceDeinit(struct mStackTrace* stack);
|
||||||
|
|
||||||
|
struct mDebuggerSymbols;
|
||||||
void mStackTraceClear(struct mStackTrace* stack);
|
void mStackTraceClear(struct mStackTrace* stack);
|
||||||
size_t mStackTraceGetDepth(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);
|
struct mStackFrame* mStackTracePush(struct mStackTrace* stack, uint32_t pc, uint32_t destAddress, uint32_t sp, void* regs);
|
||||||
|
|
|
@ -243,8 +243,8 @@ static bool ARMDebuggerHasBreakpoints(struct mDebuggerPlatform*);
|
||||||
static void ARMDebuggerTrace(struct mDebuggerPlatform*, char* out, size_t* length);
|
static void ARMDebuggerTrace(struct mDebuggerPlatform*, char* out, size_t* length);
|
||||||
static void ARMDebuggerFormatRegisters(struct ARMRegisterFile* regs, 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 void ARMDebuggerFrameFormatRegisters(struct mStackFrame* frame, char* out, size_t* length);
|
||||||
static uint32_t ARMDebuggerGetStackTraceMode(struct mDebuggerPlatform*);
|
static enum mStackTraceMode ARMDebuggerGetStackTraceMode(struct mDebuggerPlatform*);
|
||||||
static void ARMDebuggerSetStackTraceMode(struct mDebuggerPlatform*, uint32_t);
|
static void ARMDebuggerSetStackTraceMode(struct mDebuggerPlatform*, enum mStackTraceMode);
|
||||||
static bool ARMDebuggerUpdateStackTrace(struct mDebuggerPlatform* d);
|
static bool ARMDebuggerUpdateStackTrace(struct mDebuggerPlatform* d);
|
||||||
|
|
||||||
struct mDebuggerPlatform* ARMDebuggerPlatformCreate(void) {
|
struct mDebuggerPlatform* ARMDebuggerPlatformCreate(void) {
|
||||||
|
@ -527,12 +527,12 @@ static void ARMDebuggerFrameFormatRegisters(struct mStackFrame* frame, char* out
|
||||||
ARMDebuggerFormatRegisters(frame->regs, out, length);
|
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;
|
struct ARMDebugger* debugger = (struct ARMDebugger*) d;
|
||||||
return debugger->stackTraceMode;
|
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 ARMDebugger* debugger = (struct ARMDebugger*) d;
|
||||||
struct mStackTrace* stack = &d->p->stackTrace;
|
struct mStackTrace* stack = &d->p->stackTrace;
|
||||||
if (mode == STACK_TRACE_DISABLED && debugger->stackTraceMode != STACK_TRACE_DISABLED) {
|
if (mode == STACK_TRACE_DISABLED && debugger->stackTraceMode != STACK_TRACE_DISABLED) {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <mgba/core/timing.h>
|
#include <mgba/core/timing.h>
|
||||||
#include <mgba/core/version.h>
|
#include <mgba/core/version.h>
|
||||||
#include <mgba/internal/debugger/parser.h>
|
#include <mgba/internal/debugger/parser.h>
|
||||||
|
#include <mgba/internal/debugger/stack-trace.h>
|
||||||
#ifdef USE_ELF
|
#ifdef USE_ELF
|
||||||
#include <mgba-util/elf-read.h>
|
#include <mgba-util/elf-read.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue