mirror of https://github.com/mgba-emu/mgba.git
Feature: Move command-line debugger argument handling
This commit is contained in:
parent
b7284542bc
commit
319bdbd106
|
@ -59,6 +59,7 @@ void version(const char* arg0);
|
||||||
|
|
||||||
bool mArgumentsParse(struct mArguments* args, int argc, char* const* argv, struct mSubParser* subparsers, int nSubparsers);
|
bool mArgumentsParse(struct mArguments* args, int argc, char* const* argv, struct mSubParser* subparsers, int nSubparsers);
|
||||||
void mArgumentsApply(const struct mArguments* args, struct mSubParser* subparsers, int nSubparsers, struct mCoreConfig* config);
|
void mArgumentsApply(const struct mArguments* args, struct mSubParser* subparsers, int nSubparsers, struct mCoreConfig* config);
|
||||||
|
bool mArgumentsApplyDebugger(const struct mArguments*, struct mCore*, struct mDebugger*);
|
||||||
void mArgumentsDeinit(struct mArguments* args);
|
void mArgumentsDeinit(struct mArguments* args);
|
||||||
|
|
||||||
void mSubParserGraphicsInit(struct mSubParser* parser, struct mGraphicsOpts* opts);
|
void mSubParserGraphicsInit(struct mSubParser* parser, struct mGraphicsOpts* opts);
|
||||||
|
|
|
@ -9,6 +9,13 @@
|
||||||
#include <mgba/core/version.h>
|
#include <mgba/core/version.h>
|
||||||
#include <mgba-util/string.h>
|
#include <mgba-util/string.h>
|
||||||
|
|
||||||
|
#ifdef USE_GDB_STUB
|
||||||
|
#include <mgba/internal/debugger/gdb-stub.h>
|
||||||
|
#endif
|
||||||
|
#ifdef USE_EDITLINE
|
||||||
|
#include <mgba/internal/debugger/cli-el-backend.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <mgba-util/platform/windows/getopt.h>
|
#include <mgba-util/platform/windows/getopt.h>
|
||||||
|
@ -206,6 +213,34 @@ void mArgumentsApply(const struct mArguments* args, struct mSubParser* subparser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool mArgumentsApplyDebugger(const struct mArguments* args, struct mCore* core, struct mDebugger* debugger) {
|
||||||
|
bool hasDebugger = false;
|
||||||
|
|
||||||
|
#ifdef USE_EDITLINE
|
||||||
|
if (args->debugCli) {
|
||||||
|
struct mDebuggerModule* module = mDebuggerCreateModule(DEBUGGER_CLI, core);
|
||||||
|
if (module) {
|
||||||
|
struct CLIDebugger* cliDebugger = (struct CLIDebugger*) module;
|
||||||
|
CLIDebuggerAttachBackend(cliDebugger, CLIDebuggerEditLineBackendCreate());
|
||||||
|
mDebuggerAttachModule(debugger, module);
|
||||||
|
hasDebugger = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_GDB_STUB
|
||||||
|
if (args->debugGdb) {
|
||||||
|
struct mDebuggerModule* module = mDebuggerCreateModule(DEBUGGER_GDB, core);
|
||||||
|
if (module) {
|
||||||
|
mDebuggerAttachModule(debugger, module);
|
||||||
|
hasDebugger = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return hasDebugger;
|
||||||
|
}
|
||||||
|
|
||||||
void mArgumentsDeinit(struct mArguments* args) {
|
void mArgumentsDeinit(struct mArguments* args) {
|
||||||
free(args->fname);
|
free(args->fname);
|
||||||
args->fname = 0;
|
args->fname = 0;
|
||||||
|
|
|
@ -7,12 +7,6 @@
|
||||||
|
|
||||||
#include <mgba/internal/debugger/cli-debugger.h>
|
#include <mgba/internal/debugger/cli-debugger.h>
|
||||||
|
|
||||||
#ifdef USE_GDB_STUB
|
|
||||||
#include <mgba/internal/debugger/gdb-stub.h>
|
|
||||||
#endif
|
|
||||||
#ifdef USE_EDITLINE
|
|
||||||
#include <mgba/internal/debugger/cli-el-backend.h>
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_SCRIPTING
|
#ifdef ENABLE_SCRIPTING
|
||||||
#include <mgba/core/scripting.h>
|
#include <mgba/core/scripting.h>
|
||||||
|
|
||||||
|
@ -244,30 +238,8 @@ int mSDLRun(struct mSDLRenderer* renderer, struct mArguments* args) {
|
||||||
|
|
||||||
#ifdef USE_DEBUGGERS
|
#ifdef USE_DEBUGGERS
|
||||||
struct mDebugger debugger;
|
struct mDebugger debugger;
|
||||||
bool hasDebugger = false;
|
|
||||||
|
|
||||||
mDebuggerInit(&debugger);
|
mDebuggerInit(&debugger);
|
||||||
#ifdef USE_EDITLINE
|
bool hasDebugger = mArgumentsApplyDebugger(args, renderer->core, &debugger);
|
||||||
if (args->debugCli) {
|
|
||||||
struct mDebuggerModule* module = mDebuggerCreateModule(DEBUGGER_CLI, renderer->core);
|
|
||||||
if (module) {
|
|
||||||
struct CLIDebugger* cliDebugger = (struct CLIDebugger*) module;
|
|
||||||
CLIDebuggerAttachBackend(cliDebugger, CLIDebuggerEditLineBackendCreate());
|
|
||||||
mDebuggerAttachModule(&debugger, module);
|
|
||||||
hasDebugger = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_GDB_STUB
|
|
||||||
if (args->debugGdb) {
|
|
||||||
struct mDebuggerModule* module = mDebuggerCreateModule(DEBUGGER_GDB, renderer->core);
|
|
||||||
if (module) {
|
|
||||||
mDebuggerAttachModule(&debugger, module);
|
|
||||||
hasDebugger = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (hasDebugger) {
|
if (hasDebugger) {
|
||||||
mDebuggerAttach(&debugger, renderer->core);
|
mDebuggerAttach(&debugger, renderer->core);
|
||||||
|
|
Loading…
Reference in New Issue