GUI: added new debugger command to execute a file line by line

This commit is contained in:
Martin Gerhardy 2020-12-14 17:23:46 +01:00
parent 09859f0e34
commit 2d42bcfb62
2 changed files with 25 additions and 0 deletions

View File

@ -23,6 +23,7 @@
// NB: This is really only necessary if USE_READLINE is defined // NB: This is really only necessary if USE_READLINE is defined
#define FORBIDDEN_SYMBOL_ALLOW_ALL #define FORBIDDEN_SYMBOL_ALLOW_ALL
#include "common/file.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/debug-channels.h" #include "common/debug-channels.h"
#include "common/system.h" #include "common/system.h"
@ -72,6 +73,7 @@ Debugger::Debugger() {
registerCmd("md5", WRAP_METHOD(Debugger, cmdMd5)); registerCmd("md5", WRAP_METHOD(Debugger, cmdMd5));
registerCmd("md5mac", WRAP_METHOD(Debugger, cmdMd5Mac)); registerCmd("md5mac", WRAP_METHOD(Debugger, cmdMd5Mac));
#endif #endif
registerCmd("exec", WRAP_METHOD(Debugger, cmdExecFile));
registerCmd("debuglevel", WRAP_METHOD(Debugger, cmdDebugLevel)); registerCmd("debuglevel", WRAP_METHOD(Debugger, cmdDebugLevel));
registerCmd("debugflag_list", WRAP_METHOD(Debugger, cmdDebugFlagsList)); registerCmd("debugflag_list", WRAP_METHOD(Debugger, cmdDebugFlagsList));
@ -764,6 +766,28 @@ bool Debugger::cmdDebugFlagEnable(int argc, const char **argv) {
return true; return true;
} }
bool Debugger::cmdExecFile(int argc, const char **argv) {
if (argc <= 1) {
debugPrintf("Expected to get the file with debug commands\n");
return false;
}
const Common::String filename(argv[1]);
Common::File file;
if (!file.open(filename)) {
debugPrintf("Can't open file %s\n", filename.c_str());
return false;
}
for (;;) {
const Common::String &line = file.readLine();
if (line.empty()) {
break;
}
parseCommand(line.c_str());
}
return true;
}
bool Debugger::cmdDebugFlagDisable(int argc, const char **argv) { bool Debugger::cmdDebugFlagDisable(int argc, const char **argv) {
if (argc < 2) { if (argc < 2) {
debugPrintf("debugflag_disable [<flag> | all]\n"); debugPrintf("debugflag_disable [<flag> | all]\n");

View File

@ -242,6 +242,7 @@ protected:
bool cmdDebugFlagsList(int argc, const char **argv); bool cmdDebugFlagsList(int argc, const char **argv);
bool cmdDebugFlagEnable(int argc, const char **argv); bool cmdDebugFlagEnable(int argc, const char **argv);
bool cmdDebugFlagDisable(int argc, const char **argv); bool cmdDebugFlagDisable(int argc, const char **argv);
bool cmdExecFile(int argc, const char **argv);
#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER #ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER
private: private: