Permalink
Browse files

DS Core: Add symbol loading

  • Loading branch information...
endrift committed Jul 16, 2017
1 parent 3bc8ed4 commit f80bcfaf5dc3847aa17281906ce52f33fa01953c
Showing with 28 additions and 0 deletions.
  1. +1 −0 CHANGES
  2. +27 −0 src/ds/core.c
View
@@ -6,6 +6,7 @@ Bugfixes:
- DS GX: Automatically normalize winding culling calculations (fixes mgba.io/i/699)
Misc:
- DS GX: Clean up and unify texture mapping
+ - DS Core: Add symbol loading
0.7.0: (Future)
Features:
View
@@ -9,11 +9,13 @@
#include <mgba/core/core.h>
#include <mgba/core/log.h>
#include <mgba/internal/arm/debugger/debugger.h>
+#include <mgba/internal/debugger/symbols.h>
#include <mgba/internal/ds/ds.h>
#include <mgba/internal/ds/extra/cli.h>
#include <mgba/internal/ds/gx/software.h>
#include <mgba/internal/ds/input.h>
#include <mgba/internal/ds/renderers/software.h>
+#include <mgba-util/elf-read.h>
#include <mgba-util/memory.h>
#include <mgba-util/patch.h>
#include <mgba-util/vfs.h>
@@ -536,6 +538,30 @@ static void _DSCoreDetachDebugger(struct mCore* core) {
DSDetachDebugger(core->board);
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
static struct mCheatDevice* _DSCoreCheatDevice(struct mCore* core) {
@@ -657,6 +683,7 @@ struct mCore* DSCoreCreate(void) {
core->cliDebuggerSystem = _DSCoreCliDebuggerSystem;
core->attachDebugger = _DSCoreAttachDebugger;
core->detachDebugger = _DSCoreDetachDebugger;
+ core->loadSymbols = _DSCoreLoadSymbols;
#endif
core->cheatDevice = _DSCoreCheatDevice;
core->savedataClone = _DSCoreSavedataClone;

0 comments on commit f80bcfa

Please sign in to comment.