DS Core: Add symbol loading

This commit is contained in:
Vicki Pfau 2017-07-16 14:43:48 -07:00
parent 3bc8ed4e92
commit f80bcfaf5d
2 changed files with 28 additions and 0 deletions

View File

@ -6,6 +6,7 @@ Bugfixes:
- DS GX: Automatically normalize winding culling calculations (fixes mgba.io/i/699) - DS GX: Automatically normalize winding culling calculations (fixes mgba.io/i/699)
Misc: Misc:
- DS GX: Clean up and unify texture mapping - DS GX: Clean up and unify texture mapping
- DS Core: Add symbol loading
0.7.0: (Future) 0.7.0: (Future)
Features: Features:

View File

@ -9,11 +9,13 @@
#include <mgba/core/core.h> #include <mgba/core/core.h>
#include <mgba/core/log.h> #include <mgba/core/log.h>
#include <mgba/internal/arm/debugger/debugger.h> #include <mgba/internal/arm/debugger/debugger.h>
#include <mgba/internal/debugger/symbols.h>
#include <mgba/internal/ds/ds.h> #include <mgba/internal/ds/ds.h>
#include <mgba/internal/ds/extra/cli.h> #include <mgba/internal/ds/extra/cli.h>
#include <mgba/internal/ds/gx/software.h> #include <mgba/internal/ds/gx/software.h>
#include <mgba/internal/ds/input.h> #include <mgba/internal/ds/input.h>
#include <mgba/internal/ds/renderers/software.h> #include <mgba/internal/ds/renderers/software.h>
#include <mgba-util/elf-read.h>
#include <mgba-util/memory.h> #include <mgba-util/memory.h>
#include <mgba-util/patch.h> #include <mgba-util/patch.h>
#include <mgba-util/vfs.h> #include <mgba-util/vfs.h>
@ -536,6 +538,30 @@ static void _DSCoreDetachDebugger(struct mCore* core) {
DSDetachDebugger(core->board); DSDetachDebugger(core->board);
core->debugger = NULL; core->debugger = NULL;
} }
static void _DSCoreLoadSymbols(struct mCore* core, struct VFile* vf) {
#ifdef USE_ELF
bool closeAfter = false;
core->symbolTable = mDebuggerSymbolTableCreate();
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
if (!vf) {
closeAfter = true;
vf = mDirectorySetOpenSuffix(&core->dirs, core->dirs.base, ".elf", O_RDONLY);
}
#endif
if (!vf) {
return;
}
struct ELF* elf = ELFOpen(vf);
if (elf) {
mCoreLoadELFSymbols(core->symbolTable, elf);
ELFClose(elf);
}
if (closeAfter) {
vf->close(vf);
}
#endif
}
#endif #endif
static struct mCheatDevice* _DSCoreCheatDevice(struct mCore* core) { static struct mCheatDevice* _DSCoreCheatDevice(struct mCore* core) {
@ -657,6 +683,7 @@ struct mCore* DSCoreCreate(void) {
core->cliDebuggerSystem = _DSCoreCliDebuggerSystem; core->cliDebuggerSystem = _DSCoreCliDebuggerSystem;
core->attachDebugger = _DSCoreAttachDebugger; core->attachDebugger = _DSCoreAttachDebugger;
core->detachDebugger = _DSCoreDetachDebugger; core->detachDebugger = _DSCoreDetachDebugger;
core->loadSymbols = _DSCoreLoadSymbols;
#endif #endif
core->cheatDevice = _DSCoreCheatDevice; core->cheatDevice = _DSCoreCheatDevice;
core->savedataClone = _DSCoreSavedataClone; core->savedataClone = _DSCoreSavedataClone;