2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2003-10-26 21:30:52 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2003-10-26 21:30:52 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2003-10-26 21:30:52 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-10-26 21:30:52 +00:00
|
|
|
*
|
|
|
|
*/
|
2005-06-24 16:08:31 +00:00
|
|
|
|
2010-11-04 16:09:20 +00:00
|
|
|
// NB: This is really only necessary if USE_READLINE is defined
|
|
|
|
#define FORBIDDEN_SYMBOL_ALLOW_ALL
|
|
|
|
|
2014-05-25 10:29:13 +00:00
|
|
|
#include "common/debug.h"
|
2010-05-04 11:59:22 +00:00
|
|
|
#include "common/debug-channels.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/system.h"
|
2003-10-26 21:30:52 +00:00
|
|
|
|
2014-09-01 17:52:44 +00:00
|
|
|
#ifndef DISABLE_MD5
|
|
|
|
#include "common/md5.h"
|
|
|
|
#include "common/archive.h"
|
2014-09-01 19:19:48 +00:00
|
|
|
#include "common/macresman.h"
|
2014-09-01 17:52:44 +00:00
|
|
|
#include "common/stream.h"
|
|
|
|
#endif
|
|
|
|
|
2010-12-07 18:54:21 +00:00
|
|
|
#include "engines/engine.h"
|
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
#include "gui/debugger.h"
|
2011-05-05 15:32:31 +00:00
|
|
|
#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER
|
2003-10-26 21:30:52 +00:00
|
|
|
#include "gui/console.h"
|
2009-07-25 23:36:24 +00:00
|
|
|
#elif defined(USE_READLINE)
|
|
|
|
#include <readline/readline.h>
|
|
|
|
#include <readline/history.h>
|
2016-04-01 12:46:52 +00:00
|
|
|
#include "common/events.h"
|
2003-10-26 21:30:52 +00:00
|
|
|
#endif
|
|
|
|
|
2009-07-25 23:36:24 +00:00
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
namespace GUI {
|
2003-10-26 21:30:52 +00:00
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
Debugger::Debugger() {
|
2010-07-17 18:38:42 +00:00
|
|
|
_frameCountdown = 0;
|
|
|
|
_isActive = false;
|
2003-10-26 21:30:52 +00:00
|
|
|
_errStr = NULL;
|
|
|
|
_firstTime = true;
|
2011-05-05 15:32:31 +00:00
|
|
|
#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER
|
2009-07-01 20:51:04 +00:00
|
|
|
_debuggerDialog = new GUI::ConsoleDialog(1.0f, 0.67f);
|
2003-10-26 21:30:52 +00:00
|
|
|
_debuggerDialog->setInputCallback(debuggerInputCallback, this);
|
|
|
|
_debuggerDialog->setCompletionCallback(debuggerCompletionCallback, this);
|
2009-07-19 21:06:25 +00:00
|
|
|
#endif
|
2006-02-14 23:31:25 +00:00
|
|
|
|
2010-07-17 18:38:42 +00:00
|
|
|
// Register variables
|
2014-05-27 00:04:07 +00:00
|
|
|
registerVar("debug_countdown", &_frameCountdown, DVAR_INT, 0);
|
2010-07-17 18:38:42 +00:00
|
|
|
|
|
|
|
// Register commands
|
2014-05-27 00:04:08 +00:00
|
|
|
//registerCmd("continue", WRAP_METHOD(Debugger, cmdExit));
|
|
|
|
registerCmd("exit", WRAP_METHOD(Debugger, cmdExit));
|
|
|
|
registerCmd("quit", WRAP_METHOD(Debugger, cmdExit));
|
2006-09-16 16:58:27 +00:00
|
|
|
|
2014-05-27 00:04:08 +00:00
|
|
|
registerCmd("help", WRAP_METHOD(Debugger, cmdHelp));
|
|
|
|
registerCmd("openlog", WRAP_METHOD(Debugger, cmdOpenLog));
|
2014-09-01 17:52:44 +00:00
|
|
|
#ifndef DISABLE_MD5
|
|
|
|
registerCmd("md5", WRAP_METHOD(Debugger, cmdMd5));
|
2014-09-01 19:19:48 +00:00
|
|
|
registerCmd("md5mac", WRAP_METHOD(Debugger, cmdMd5Mac));
|
2014-09-01 17:52:44 +00:00
|
|
|
#endif
|
2006-09-16 16:58:27 +00:00
|
|
|
|
2014-05-27 00:04:08 +00:00
|
|
|
registerCmd("debuglevel", WRAP_METHOD(Debugger, cmdDebugLevel));
|
|
|
|
registerCmd("debugflag_list", WRAP_METHOD(Debugger, cmdDebugFlagsList));
|
|
|
|
registerCmd("debugflag_enable", WRAP_METHOD(Debugger, cmdDebugFlagEnable));
|
|
|
|
registerCmd("debugflag_disable", WRAP_METHOD(Debugger, cmdDebugFlagDisable));
|
2003-10-26 21:30:52 +00:00
|
|
|
}
|
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
Debugger::~Debugger() {
|
2011-05-05 15:32:31 +00:00
|
|
|
#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER
|
2003-10-26 21:30:52 +00:00
|
|
|
delete _debuggerDialog;
|
2009-07-19 21:06:25 +00:00
|
|
|
#endif
|
2003-10-26 21:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Initialisation Functions
|
2015-08-29 16:08:52 +00:00
|
|
|
int Debugger::getCharsPerLine() {
|
|
|
|
#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER
|
|
|
|
const int charsPerLine = _debuggerDialog->getCharsPerLine();
|
|
|
|
#elif defined(USE_READLINE)
|
|
|
|
int charsPerLine, rows;
|
|
|
|
rl_get_screen_size(&rows, &charsPerLine);
|
|
|
|
#else
|
|
|
|
// Can we do better?
|
|
|
|
const int charsPerLine = 80;
|
|
|
|
#endif
|
|
|
|
return charsPerLine;
|
|
|
|
}
|
|
|
|
|
2014-05-27 00:04:07 +00:00
|
|
|
int Debugger::debugPrintf(const char *format, ...) {
|
2003-10-26 21:30:52 +00:00
|
|
|
va_list argptr;
|
|
|
|
|
|
|
|
va_start(argptr, format);
|
|
|
|
int count;
|
2011-05-05 15:32:31 +00:00
|
|
|
#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER
|
2010-11-01 16:03:02 +00:00
|
|
|
count = _debuggerDialog->vprintFormat(1, format, argptr);
|
2003-10-26 21:30:52 +00:00
|
|
|
#else
|
|
|
|
count = ::vprintf(format, argptr);
|
|
|
|
#endif
|
|
|
|
va_end (argptr);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2015-08-29 16:08:52 +00:00
|
|
|
void Debugger::debugPrintColumns(const Common::StringArray &list) {
|
|
|
|
uint maxLength = 0;
|
|
|
|
uint i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < list.size(); i++) {
|
|
|
|
if (list[i].size() > maxLength)
|
|
|
|
maxLength = list[i].size();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint charsPerLine = getCharsPerLine();
|
|
|
|
uint columnWidth = maxLength + 2;
|
|
|
|
uint columns = charsPerLine / columnWidth;
|
|
|
|
|
|
|
|
uint lines = list.size() / columns;
|
|
|
|
|
|
|
|
if (list.size() % columns)
|
|
|
|
lines++;
|
|
|
|
|
2015-08-30 04:49:16 +00:00
|
|
|
// This won't always use all available columns, but even if it did the
|
|
|
|
// number of lines should be the same so that's good enough.
|
2015-08-29 16:08:52 +00:00
|
|
|
for (i = 0; i < lines; i++) {
|
|
|
|
for (j = 0; j < columns; j++) {
|
|
|
|
uint pos = i + j * lines;
|
|
|
|
if (pos < list.size()) {
|
|
|
|
debugPrintf("%*s", -columnWidth, list[pos].c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
debugPrintf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-07 18:54:21 +00:00
|
|
|
void Debugger::preEnter() {
|
|
|
|
g_engine->pauseEngine(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger::postEnter() {
|
|
|
|
g_engine->pauseEngine(false);
|
|
|
|
}
|
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
void Debugger::attach(const char *entry) {
|
2004-02-24 22:39:42 +00:00
|
|
|
g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
|
2003-10-26 21:30:52 +00:00
|
|
|
|
2010-07-17 18:38:42 +00:00
|
|
|
// Set error string (if any)
|
|
|
|
free(_errStr);
|
|
|
|
_errStr = entry ? strdup(entry) : 0;
|
2003-10-26 21:30:52 +00:00
|
|
|
|
2010-07-17 18:38:42 +00:00
|
|
|
// Reset frame countdown (i.e. attach immediately)
|
|
|
|
_frameCountdown = 1;
|
2003-10-26 21:30:52 +00:00
|
|
|
}
|
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
void Debugger::detach() {
|
2004-02-24 22:39:42 +00:00
|
|
|
g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
|
2003-10-26 21:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Temporary execution handler
|
2006-09-16 16:58:27 +00:00
|
|
|
void Debugger::onFrame() {
|
2010-07-17 18:38:42 +00:00
|
|
|
// Count down until 0 is reached
|
|
|
|
if (_frameCountdown > 0) {
|
|
|
|
--_frameCountdown;
|
|
|
|
if (_frameCountdown == 0) {
|
|
|
|
_isActive = true;
|
|
|
|
preEnter();
|
|
|
|
enter();
|
|
|
|
postEnter();
|
|
|
|
_isActive = false;
|
|
|
|
}
|
2003-10-26 21:30:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-05 15:32:31 +00:00
|
|
|
#if defined(USE_TEXT_CONSOLE_FOR_DEBUGGER) && defined(USE_READLINE)
|
2009-07-26 07:07:35 +00:00
|
|
|
namespace {
|
|
|
|
Debugger *g_readline_debugger;
|
2009-07-25 23:36:24 +00:00
|
|
|
|
2009-07-26 07:07:35 +00:00
|
|
|
char *readline_completionFunction(const char *text, int state) {
|
2009-07-25 23:36:24 +00:00
|
|
|
return g_readline_debugger->readlineComplete(text, state);
|
|
|
|
}
|
2014-01-01 23:39:47 +00:00
|
|
|
|
2016-04-01 12:46:52 +00:00
|
|
|
void readline_eventFunction() {
|
|
|
|
Common::EventManager *eventMan = g_system->getEventManager();
|
|
|
|
|
|
|
|
Common::Event event;
|
|
|
|
while (eventMan->pollEvent(event)) {
|
|
|
|
// drop all events
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-01 23:39:47 +00:00
|
|
|
#ifdef USE_READLINE_INT_COMPLETION
|
|
|
|
typedef int RLCompFunc_t(const char *, int);
|
|
|
|
#else
|
|
|
|
typedef char *RLCompFunc_t(const char *, int);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2009-07-26 07:07:35 +00:00
|
|
|
} // end of anonymous namespace
|
2009-07-25 23:36:24 +00:00
|
|
|
#endif
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
// Main Debugger Loop
|
2006-09-16 16:58:27 +00:00
|
|
|
void Debugger::enter() {
|
2009-07-25 23:36:24 +00:00
|
|
|
// TODO: Having three I/O methods #ifdef-ed in this file is not the
|
|
|
|
// cleanest approach to this...
|
|
|
|
|
2011-05-05 15:32:31 +00:00
|
|
|
#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER
|
2003-10-26 21:30:52 +00:00
|
|
|
if (_firstTime) {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Debugger started, type 'exit' to return to the game.\n");
|
|
|
|
debugPrintf("Type 'help' to see a little list of commands and variables.\n");
|
2003-10-26 21:30:52 +00:00
|
|
|
_firstTime = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_errStr) {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("ERROR: %s\n\n", _errStr);
|
2003-10-26 21:30:52 +00:00
|
|
|
free(_errStr);
|
|
|
|
_errStr = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
_debuggerDialog->runModal();
|
|
|
|
#else
|
|
|
|
printf("Debugger entered, please switch to this console for input.\n");
|
|
|
|
|
2009-07-25 23:36:24 +00:00
|
|
|
#ifdef USE_READLINE
|
|
|
|
// TODO: add support for saving/loading history?
|
|
|
|
|
|
|
|
g_readline_debugger = this;
|
2014-01-01 23:39:47 +00:00
|
|
|
rl_completion_entry_function = (RLCompFunc_t *)&readline_completionFunction;
|
2016-04-01 12:46:52 +00:00
|
|
|
rl_event_hook = (rl_hook_func_t *)&readline_eventFunction;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-07-25 23:36:24 +00:00
|
|
|
char *line_read = 0;
|
|
|
|
do {
|
|
|
|
free(line_read);
|
|
|
|
line_read = readline("debug> ");
|
|
|
|
|
|
|
|
if (line_read && line_read[0])
|
|
|
|
add_history(line_read);
|
|
|
|
|
|
|
|
} while (line_read && parseCommand(line_read));
|
|
|
|
|
|
|
|
free(line_read);
|
|
|
|
line_read = 0;
|
|
|
|
|
|
|
|
#else
|
2003-10-26 21:30:52 +00:00
|
|
|
int i;
|
|
|
|
char buf[256];
|
|
|
|
|
|
|
|
do {
|
|
|
|
printf("debug> ");
|
|
|
|
if (!fgets(buf, sizeof(buf), stdin))
|
|
|
|
return;
|
|
|
|
|
|
|
|
i = strlen(buf);
|
|
|
|
while (i > 0 && buf[i - 1] == '\n')
|
|
|
|
buf[--i] = 0;
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
continue;
|
2006-09-16 16:58:27 +00:00
|
|
|
} while (parseCommand(buf));
|
2009-07-25 23:36:24 +00:00
|
|
|
#endif
|
2003-10-26 21:30:52 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
bool Debugger::handleCommand(int argc, const char **argv, bool &result) {
|
2009-05-11 18:02:27 +00:00
|
|
|
if (_cmds.contains(argv[0])) {
|
2012-03-13 13:53:40 +00:00
|
|
|
assert(_cmds[argv[0]]);
|
|
|
|
result = (*_cmds[argv[0]])(argc, argv);
|
2009-05-11 18:02:27 +00:00
|
|
|
return true;
|
2006-09-16 16:58:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
// Command execution loop
|
2006-09-16 16:58:27 +00:00
|
|
|
bool Debugger::parseCommand(const char *inputOrig) {
|
2009-05-11 18:02:27 +00:00
|
|
|
int num_params = 0;
|
2003-10-26 21:30:52 +00:00
|
|
|
const char *param[256];
|
|
|
|
char *input = strdup(inputOrig); // One of the rare occasions using strdup is OK (although avoiding strtok might be more elegant here).
|
|
|
|
|
|
|
|
// Parse out any params
|
|
|
|
char *tok = strtok(input, " ");
|
|
|
|
if (tok) {
|
|
|
|
do {
|
|
|
|
param[num_params++] = tok;
|
|
|
|
} while ((tok = strtok(NULL, " ")) != NULL);
|
|
|
|
} else {
|
|
|
|
param[num_params++] = input;
|
|
|
|
}
|
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
// Handle commands first
|
|
|
|
bool result;
|
|
|
|
if (handleCommand(num_params, param, result)) {
|
|
|
|
free(input);
|
|
|
|
return result;
|
2003-10-26 21:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// It's not a command, so things get a little tricky for variables. Do fuzzy matching to ignore things like subscripts.
|
2014-05-27 00:04:08 +00:00
|
|
|
for (uint i = 0; i < _vars.size(); i++) {
|
|
|
|
if (!strncmp(_vars[i].name.c_str(), param[0], _vars[i].name.size())) {
|
2003-10-26 21:30:52 +00:00
|
|
|
if (num_params > 1) {
|
|
|
|
// Alright, we need to check the TYPE of the variable to deref and stuff... the array stuff is a bit ugly :)
|
2014-05-27 00:04:08 +00:00
|
|
|
switch (_vars[i].type) {
|
2003-10-26 21:30:52 +00:00
|
|
|
// Integer
|
2004-08-08 22:44:15 +00:00
|
|
|
case DVAR_BYTE:
|
2014-05-27 00:04:08 +00:00
|
|
|
*(byte *)_vars[i].variable = atoi(param[1]);
|
|
|
|
debugPrintf("byte%s = %d\n", param[0], *(byte *)_vars[i].variable);
|
2004-08-08 22:44:15 +00:00
|
|
|
break;
|
2003-10-26 21:30:52 +00:00
|
|
|
case DVAR_INT:
|
2014-05-27 00:04:08 +00:00
|
|
|
*(int32 *)_vars[i].variable = atoi(param[1]);
|
|
|
|
debugPrintf("(int)%s = %d\n", param[0], *(int32 *)_vars[i].variable);
|
2004-08-08 22:44:15 +00:00
|
|
|
break;
|
2011-12-05 21:18:36 +00:00
|
|
|
case DVAR_BOOL:
|
2014-05-27 00:04:08 +00:00
|
|
|
if (Common::parseBool(param[1], *(bool *)_vars[i].variable))
|
|
|
|
debugPrintf("(bool)%s = %s\n", param[0], *(bool *)_vars[i].variable ? "true" : "false");
|
2011-12-05 21:18:36 +00:00
|
|
|
else
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Invalid value for boolean variable. Valid values are \"true\", \"false\", \"1\", \"0\", \"yes\", \"no\"\n");
|
2011-12-05 18:31:22 +00:00
|
|
|
break;
|
2003-10-26 21:30:52 +00:00
|
|
|
// Integer Array
|
|
|
|
case DVAR_INTARRAY: {
|
2009-09-06 10:51:20 +00:00
|
|
|
const char *chr = strchr(param[0], '[');
|
2003-10-26 21:30:52 +00:00
|
|
|
if (!chr) {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("You must access this array as %s[element]\n", param[0]);
|
2003-10-26 21:30:52 +00:00
|
|
|
} else {
|
|
|
|
int element = atoi(chr+1);
|
2014-05-27 00:04:08 +00:00
|
|
|
int32 *var = *(int32 **)_vars[i].variable;
|
|
|
|
if (element >= _vars[i].arraySize) {
|
|
|
|
debugPrintf("%s is out of range (array is %d elements big)\n", param[0], _vars[i].arraySize);
|
2003-10-26 21:30:52 +00:00
|
|
|
} else {
|
|
|
|
var[element] = atoi(param[1]);
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("(int)%s = %d\n", param[0], var[element]);
|
2003-10-26 21:30:52 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-08 22:44:15 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-10-26 21:30:52 +00:00
|
|
|
default:
|
2014-05-27 00:04:08 +00:00
|
|
|
debugPrintf("Failed to set variable %s to %s - unknown type\n", _vars[i].name.c_str(), param[1]);
|
2003-10-26 21:30:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// And again, type-dependent prints/defrefs. The array one is still ugly.
|
2014-05-27 00:04:08 +00:00
|
|
|
switch (_vars[i].type) {
|
2003-10-26 21:30:52 +00:00
|
|
|
// Integer
|
2004-08-08 22:44:15 +00:00
|
|
|
case DVAR_BYTE:
|
2014-05-27 00:04:08 +00:00
|
|
|
debugPrintf("(byte)%s = %d\n", param[0], *(const byte *)_vars[i].variable);
|
2004-08-08 22:44:15 +00:00
|
|
|
break;
|
2003-10-26 21:30:52 +00:00
|
|
|
case DVAR_INT:
|
2014-05-27 00:04:08 +00:00
|
|
|
debugPrintf("(int)%s = %d\n", param[0], *(const int32 *)_vars[i].variable);
|
2004-08-08 22:44:15 +00:00
|
|
|
break;
|
2011-12-05 18:31:22 +00:00
|
|
|
case DVAR_BOOL:
|
2014-05-27 00:04:08 +00:00
|
|
|
debugPrintf("(bool)%s = %s\n", param[0], *(const bool *)_vars[i].variable ? "true" : "false");
|
2011-12-05 18:31:22 +00:00
|
|
|
break;
|
2003-10-26 21:30:52 +00:00
|
|
|
// Integer array
|
|
|
|
case DVAR_INTARRAY: {
|
2004-09-04 19:28:30 +00:00
|
|
|
const char *chr = strchr(param[0], '[');
|
2003-10-26 21:30:52 +00:00
|
|
|
if (!chr) {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("You must access this array as %s[element]\n", param[0]);
|
2003-10-26 21:30:52 +00:00
|
|
|
} else {
|
|
|
|
int element = atoi(chr+1);
|
2014-05-27 00:04:08 +00:00
|
|
|
const int32 *var = *(const int32 **)_vars[i].variable;
|
|
|
|
if (element >= _vars[i].arraySize) {
|
|
|
|
debugPrintf("%s is out of range (array is %d elements big)\n", param[0], _vars[i].arraySize);
|
2003-10-26 21:30:52 +00:00
|
|
|
} else {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("(int)%s = %d\n", param[0], var[element]);
|
2003-10-26 21:30:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
// String
|
|
|
|
case DVAR_STRING:
|
2014-05-27 00:04:08 +00:00
|
|
|
debugPrintf("(string)%s = %s\n", param[0], ((Common::String *)_vars[i].variable)->c_str());
|
2003-10-26 21:30:52 +00:00
|
|
|
break;
|
|
|
|
default:
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("%s = (unknown type)\n", param[0]);
|
2003-10-26 21:30:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(input);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Unknown command or variable\n");
|
2003-10-26 21:30:52 +00:00
|
|
|
free(input);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// returns true if something has been completed
|
|
|
|
// completion has to be delete[]-ed then
|
2009-05-11 18:02:27 +00:00
|
|
|
bool Debugger::tabComplete(const char *input, Common::String &completion) const {
|
2003-10-26 21:30:52 +00:00
|
|
|
// very basic tab completion
|
|
|
|
// for now it just supports command completions
|
|
|
|
|
|
|
|
// adding completions of command parameters would be nice (but hard) :-)
|
|
|
|
// maybe also give a list of possible command completions?
|
|
|
|
// (but this will require changes to console)
|
|
|
|
|
|
|
|
if (strchr(input, ' '))
|
|
|
|
return false; // already finished the first word
|
|
|
|
|
2009-05-11 18:02:27 +00:00
|
|
|
const uint inputlen = strlen(input);
|
2003-10-26 21:30:52 +00:00
|
|
|
|
2009-05-11 18:02:27 +00:00
|
|
|
completion.clear();
|
2003-10-26 21:30:52 +00:00
|
|
|
|
2009-05-11 18:02:27 +00:00
|
|
|
CommandsMap::const_iterator i, e = _cmds.end();
|
|
|
|
for (i = _cmds.begin(); i != e; ++i) {
|
|
|
|
if (i->_key.hasPrefix(input)) {
|
|
|
|
uint commandlen = i->_key.size();
|
|
|
|
if (commandlen == inputlen) { // perfect match, so no tab completion possible
|
2003-10-26 21:30:52 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (commandlen > inputlen) { // possible match
|
|
|
|
// no previous match
|
2009-05-11 18:02:27 +00:00
|
|
|
if (completion.empty()) {
|
|
|
|
completion = i->_key.c_str() + inputlen;
|
2003-10-26 21:30:52 +00:00
|
|
|
} else {
|
|
|
|
// take common prefix of previous match and this command
|
2009-05-11 18:02:27 +00:00
|
|
|
for (uint j = 0; j < completion.size(); j++) {
|
2009-07-18 22:17:56 +00:00
|
|
|
if (inputlen + j >= i->_key.size() ||
|
|
|
|
completion[j] != i->_key[inputlen + j]) {
|
2009-05-11 18:02:27 +00:00
|
|
|
completion = Common::String(completion.begin(), completion.begin() + j);
|
|
|
|
// If there is no unambiguous completion, abort
|
|
|
|
if (completion.empty())
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
2003-10-26 21:30:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-05-11 18:02:27 +00:00
|
|
|
if (completion.empty())
|
2003-10-26 21:30:52 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-05-05 15:32:31 +00:00
|
|
|
#if defined(USE_TEXT_CONSOLE_FOR_DEBUGGER) && defined(USE_READLINE)
|
2009-07-26 07:07:35 +00:00
|
|
|
char *Debugger::readlineComplete(const char *input, int state) {
|
2009-07-25 23:36:24 +00:00
|
|
|
static CommandsMap::const_iterator iter;
|
|
|
|
|
|
|
|
// We assume that _cmds isn't changed between calls to readlineComplete,
|
|
|
|
// unless state is 0.
|
|
|
|
if (state == 0) {
|
|
|
|
iter = _cmds.begin();
|
|
|
|
} else {
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; iter != _cmds.end(); ++iter) {
|
|
|
|
if (iter->_key.hasPrefix(input)) {
|
|
|
|
char *ret = (char *)malloc(iter->_key.size() + 1);
|
|
|
|
strcpy(ret, iter->_key.c_str());
|
|
|
|
return ret;
|
2010-01-25 01:39:44 +00:00
|
|
|
}
|
2009-07-25 23:36:24 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
// Variable registration function
|
2014-05-27 00:04:07 +00:00
|
|
|
void Debugger::registerVar(const Common::String &varname, void *pointer, VarType type, int arraySize) {
|
2009-05-11 18:02:27 +00:00
|
|
|
// TODO: Filter out duplicates
|
|
|
|
// TODO: Sort this list? Then we can do binary search later on when doing lookups.
|
|
|
|
assert(pointer);
|
|
|
|
|
2014-05-27 00:04:08 +00:00
|
|
|
Var tmp;
|
2009-05-11 18:02:27 +00:00
|
|
|
tmp.name = varname;
|
|
|
|
tmp.type = type;
|
|
|
|
tmp.variable = pointer;
|
2010-07-17 18:38:42 +00:00
|
|
|
tmp.arraySize = arraySize;
|
2009-05-11 18:02:27 +00:00
|
|
|
|
2014-05-27 00:04:08 +00:00
|
|
|
_vars.push_back(tmp);
|
2003-10-26 21:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Command registration function
|
2014-05-27 00:04:08 +00:00
|
|
|
void Debugger::registerCmd(const Common::String &cmdname, Debuglet *debuglet) {
|
2009-05-11 18:02:27 +00:00
|
|
|
assert(debuglet && debuglet->isValid());
|
|
|
|
_cmds[cmdname] = Common::SharedPtr<Debuglet>(debuglet);
|
2003-10-26 21:30:52 +00:00
|
|
|
}
|
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
|
|
|
|
// Detach ("exit") the debugger
|
2014-05-27 00:04:08 +00:00
|
|
|
bool Debugger::cmdExit(int argc, const char **argv) {
|
2010-07-17 18:38:42 +00:00
|
|
|
detach();
|
2006-09-16 16:58:27 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print a list of all registered commands (and variables, if any),
|
|
|
|
// nicely word-wrapped.
|
2014-05-27 00:04:08 +00:00
|
|
|
bool Debugger::cmdHelp(int argc, const char **argv) {
|
2015-08-29 16:08:52 +00:00
|
|
|
const int charsPerLine = getCharsPerLine();
|
2009-05-11 18:02:27 +00:00
|
|
|
int width, size;
|
|
|
|
uint i;
|
2006-09-16 16:58:27 +00:00
|
|
|
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Commands are:\n");
|
2009-05-11 18:02:27 +00:00
|
|
|
|
|
|
|
// Obtain a list of sorted command names
|
2010-03-18 15:09:24 +00:00
|
|
|
Common::Array<Common::String> cmds;
|
2009-05-11 18:02:27 +00:00
|
|
|
CommandsMap::const_iterator iter, e = _cmds.end();
|
|
|
|
for (iter = _cmds.begin(); iter != e; ++iter) {
|
|
|
|
cmds.push_back(iter->_key);
|
|
|
|
}
|
|
|
|
sort(cmds.begin(), cmds.end());
|
|
|
|
|
|
|
|
// Print them all
|
2006-09-16 16:58:27 +00:00
|
|
|
width = 0;
|
2009-05-11 18:02:27 +00:00
|
|
|
for (i = 0; i < cmds.size(); i++) {
|
|
|
|
size = cmds[i].size() + 1;
|
2006-09-16 16:58:27 +00:00
|
|
|
|
2006-09-16 17:29:43 +00:00
|
|
|
if ((width + size) >= charsPerLine) {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("\n");
|
2006-09-16 16:58:27 +00:00
|
|
|
width = size;
|
|
|
|
} else
|
|
|
|
width += size;
|
|
|
|
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("%s ", cmds[i].c_str());
|
2006-09-16 16:58:27 +00:00
|
|
|
}
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("\n");
|
2006-09-16 16:58:27 +00:00
|
|
|
|
2014-05-27 00:04:08 +00:00
|
|
|
if (!_vars.empty()) {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("\n");
|
|
|
|
debugPrintf("Variables are:\n");
|
2006-09-16 16:58:27 +00:00
|
|
|
width = 0;
|
2014-05-27 00:04:08 +00:00
|
|
|
for (i = 0; i < _vars.size(); i++) {
|
|
|
|
size = _vars[i].name.size() + 1;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-09-16 17:29:43 +00:00
|
|
|
if ((width + size) >= charsPerLine) {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("\n");
|
2006-09-16 16:58:27 +00:00
|
|
|
width = size;
|
|
|
|
} else
|
|
|
|
width += size;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2014-05-27 00:04:08 +00:00
|
|
|
debugPrintf("%s ", _vars[i].name.c_str());
|
2006-09-16 16:58:27 +00:00
|
|
|
}
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("\n");
|
2006-09-16 16:58:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-27 00:04:08 +00:00
|
|
|
bool Debugger::cmdOpenLog(int argc, const char **argv) {
|
2011-06-03 11:35:53 +00:00
|
|
|
if (g_system->hasFeature(OSystem::kFeatureDisplayLogFile))
|
|
|
|
g_system->displayLogFile();
|
|
|
|
else
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Opening the log file not supported on this system\n");
|
2011-06-03 11:35:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-01 17:52:44 +00:00
|
|
|
#ifndef DISABLE_MD5
|
2014-09-07 16:14:50 +00:00
|
|
|
struct ArchiveMemberLess {
|
|
|
|
bool operator()(const Common::ArchiveMemberPtr &x, const Common::ArchiveMemberPtr &y) const {
|
|
|
|
return (*x).getDisplayName().compareToIgnoreCase((*y).getDisplayName()) < 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-09-01 17:52:44 +00:00
|
|
|
bool Debugger::cmdMd5(int argc, const char **argv) {
|
|
|
|
if (argc < 2) {
|
2014-12-28 14:57:00 +00:00
|
|
|
debugPrintf("md5 [-n length] <filename | pattern>\n");
|
2014-09-01 17:52:44 +00:00
|
|
|
} else {
|
2014-12-28 14:57:00 +00:00
|
|
|
uint32 length = 0;
|
|
|
|
uint paramOffset = 0;
|
|
|
|
|
|
|
|
// If the user supplied an -n parameter, set the bytes to read
|
|
|
|
if (!strcmp(argv[1], "-n")) {
|
|
|
|
// Make sure that we have at least two more parameters
|
|
|
|
if (argc < 4) {
|
|
|
|
debugPrintf("md5 [-n length] <filename | pattern>\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
length = atoi(argv[2]);
|
|
|
|
paramOffset = 2;
|
|
|
|
}
|
2016-07-21 05:44:36 +00:00
|
|
|
|
2014-09-01 17:52:44 +00:00
|
|
|
// Assume that spaces are part of a single filename.
|
2014-12-28 14:57:00 +00:00
|
|
|
Common::String filename = argv[1 + paramOffset];
|
|
|
|
for (int i = 2 + paramOffset; i < argc; i++) {
|
2014-09-01 17:52:44 +00:00
|
|
|
filename = filename + " " + argv[i];
|
|
|
|
}
|
|
|
|
Common::ArchiveMemberList list;
|
|
|
|
SearchMan.listMatchingMembers(list, filename);
|
|
|
|
if (list.empty()) {
|
|
|
|
debugPrintf("File '%s' not found\n", filename.c_str());
|
|
|
|
} else {
|
2014-09-07 16:14:50 +00:00
|
|
|
sort(list.begin(), list.end(), ArchiveMemberLess());
|
2014-09-01 17:52:44 +00:00
|
|
|
for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
|
2014-12-28 14:57:00 +00:00
|
|
|
Common::SeekableReadStream *stream = (*iter)->createReadStream();
|
|
|
|
Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
|
|
|
|
debugPrintf("%s %s %d\n", md5.c_str(), (*iter)->getDisplayName().c_str(), stream->size());
|
2014-09-01 17:52:44 +00:00
|
|
|
delete stream;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2014-09-01 19:19:48 +00:00
|
|
|
|
|
|
|
bool Debugger::cmdMd5Mac(int argc, const char **argv) {
|
|
|
|
if (argc < 2) {
|
2014-12-28 14:57:00 +00:00
|
|
|
debugPrintf("md5mac [-n length] <base filename>\n");
|
2014-09-01 19:19:48 +00:00
|
|
|
} else {
|
2014-12-28 14:57:00 +00:00
|
|
|
uint32 length = 0;
|
|
|
|
uint paramOffset = 0;
|
|
|
|
|
|
|
|
// If the user supplied an -n parameter, set the bytes to read
|
|
|
|
if (!strcmp(argv[1], "-n")) {
|
|
|
|
// Make sure that we have at least two more parameters
|
|
|
|
if (argc < 4) {
|
|
|
|
debugPrintf("md5mac [-n length] <base filename>\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
length = atoi(argv[2]);
|
|
|
|
paramOffset = 2;
|
|
|
|
}
|
2016-07-21 05:44:36 +00:00
|
|
|
|
2014-09-01 19:19:48 +00:00
|
|
|
// Assume that spaces are part of a single filename.
|
2014-12-28 14:57:00 +00:00
|
|
|
Common::String filename = argv[1 + paramOffset];
|
|
|
|
for (int i = 2 + paramOffset; i < argc; i++) {
|
2014-09-01 19:19:48 +00:00
|
|
|
filename = filename + " " + argv[i];
|
|
|
|
}
|
|
|
|
Common::MacResManager macResMan;
|
2014-10-31 07:16:33 +00:00
|
|
|
// FIXME: There currently isn't any way to tell the Mac resource
|
|
|
|
// manager to open a specific file. Instead, it takes a "base name"
|
|
|
|
// and constructs a file name out of that. While usually a desirable
|
|
|
|
// thing, it's not ideal here.
|
2014-09-01 19:19:48 +00:00
|
|
|
if (!macResMan.open(filename)) {
|
|
|
|
debugPrintf("Resource file '%s' not found\n", filename.c_str());
|
|
|
|
} else {
|
2014-09-07 16:50:51 +00:00
|
|
|
if (!macResMan.hasResFork() && !macResMan.hasDataFork()) {
|
|
|
|
debugPrintf("'%s' has neither data not resource fork\n", macResMan.getBaseFileName().c_str());
|
2014-09-01 19:19:48 +00:00
|
|
|
} else {
|
2014-09-07 16:50:51 +00:00
|
|
|
// The resource fork is probably the most relevant one.
|
|
|
|
if (macResMan.hasResFork()) {
|
2014-12-28 14:57:00 +00:00
|
|
|
Common::String md5 = macResMan.computeResForkMD5AsString(length);
|
|
|
|
debugPrintf("%s %s (resource) %d\n", md5.c_str(), macResMan.getBaseFileName().c_str(), macResMan.getResForkDataSize());
|
2014-09-07 16:50:51 +00:00
|
|
|
}
|
|
|
|
if (macResMan.hasDataFork()) {
|
2014-12-28 14:57:00 +00:00
|
|
|
Common::SeekableReadStream *stream = macResMan.getDataFork();
|
|
|
|
Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
|
|
|
|
debugPrintf("%s %s (data) %d\n", md5.c_str(), macResMan.getBaseFileName().c_str(), stream->size());
|
2014-09-07 16:50:51 +00:00
|
|
|
}
|
2014-09-01 19:19:48 +00:00
|
|
|
}
|
|
|
|
macResMan.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2014-09-01 17:52:44 +00:00
|
|
|
#endif
|
2011-06-03 11:35:53 +00:00
|
|
|
|
2014-05-27 00:04:08 +00:00
|
|
|
bool Debugger::cmdDebugLevel(int argc, const char **argv) {
|
2014-05-13 18:39:47 +00:00
|
|
|
if (argc == 1) { // print level
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Debugging is currently %s (set at level %d)\n", (gDebugLevel >= 0) ? "enabled" : "disabled", gDebugLevel);
|
|
|
|
debugPrintf("Usage: %s <n> where n is 0 to 10 or -1 to disable debugging\n", argv[0]);
|
2014-05-10 16:08:34 +00:00
|
|
|
} else { // set level
|
|
|
|
gDebugLevel = atoi(argv[1]);
|
|
|
|
if (gDebugLevel >= 0 && gDebugLevel < 11) {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Debug level set to level %d\n", gDebugLevel);
|
2014-05-10 16:08:34 +00:00
|
|
|
} else if (gDebugLevel < 0) {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Debugging is now disabled\n");
|
2014-05-11 23:56:20 +00:00
|
|
|
} else {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Invalid debug level value\n");
|
|
|
|
debugPrintf("Usage: %s <n> where n is 0 to 10 or -1 to disable debugging\n", argv[0]);
|
2014-05-11 23:56:20 +00:00
|
|
|
}
|
2014-05-10 16:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-27 00:04:08 +00:00
|
|
|
bool Debugger::cmdDebugFlagsList(int argc, const char **argv) {
|
2010-04-27 21:40:52 +00:00
|
|
|
const Common::DebugManager::DebugChannelList &debugLevels = DebugMan.listDebugChannels();
|
2006-02-14 23:31:25 +00:00
|
|
|
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Engine debug levels:\n");
|
|
|
|
debugPrintf("--------------------\n");
|
2008-10-12 22:02:24 +00:00
|
|
|
if (debugLevels.empty()) {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("No engine debug levels\n");
|
2006-02-14 23:31:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-04-27 21:40:52 +00:00
|
|
|
for (Common::DebugManager::DebugChannelList::const_iterator i = debugLevels.begin(); i != debugLevels.end(); ++i) {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("%c%s - %s (%s)\n", i->enabled ? '+' : ' ',
|
2009-01-30 04:42:30 +00:00
|
|
|
i->name.c_str(), i->description.c_str(),
|
|
|
|
i->enabled ? "enabled" : "disabled");
|
2006-02-14 23:31:25 +00:00
|
|
|
}
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("\n");
|
2006-02-14 23:31:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-27 00:04:08 +00:00
|
|
|
bool Debugger::cmdDebugFlagEnable(int argc, const char **argv) {
|
2006-02-14 23:31:25 +00:00
|
|
|
if (argc < 2) {
|
2014-06-05 01:17:08 +00:00
|
|
|
debugPrintf("debugflag_enable [<flag> | all]\n");
|
2006-02-14 23:31:25 +00:00
|
|
|
} else {
|
2014-06-05 14:39:35 +00:00
|
|
|
if (!scumm_stricmp(argv[1], "all")) {
|
2014-06-05 01:17:08 +00:00
|
|
|
debugPrintf("Enabled all debug flags\n");
|
|
|
|
DebugMan.enableAllDebugChannels();
|
|
|
|
} else if (DebugMan.enableDebugChannel(argv[1])) {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Enabled debug flag '%s'\n", argv[1]);
|
2006-02-14 23:31:25 +00:00
|
|
|
} else {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Failed to enable debug flag '%s'\n", argv[1]);
|
2006-02-14 23:31:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-27 00:04:08 +00:00
|
|
|
bool Debugger::cmdDebugFlagDisable(int argc, const char **argv) {
|
2006-02-14 23:31:25 +00:00
|
|
|
if (argc < 2) {
|
2014-06-05 01:17:08 +00:00
|
|
|
debugPrintf("debugflag_disable [<flag> | all]\n");
|
2006-02-14 23:31:25 +00:00
|
|
|
} else {
|
2014-06-05 14:39:35 +00:00
|
|
|
if (!scumm_stricmp(argv[1], "all")) {
|
2014-06-05 01:17:08 +00:00
|
|
|
debugPrintf("Disabled all debug flags\n");
|
|
|
|
DebugMan.disableAllDebugChannels();
|
|
|
|
} else if (DebugMan.disableDebugChannel(argv[1])) {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Disabled debug flag '%s'\n", argv[1]);
|
2006-02-14 23:31:25 +00:00
|
|
|
} else {
|
2014-05-27 00:04:07 +00:00
|
|
|
debugPrintf("Failed to disable debug flag '%s'\n", argv[1]);
|
2006-02-14 23:31:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
// Console handler
|
2011-05-05 15:32:31 +00:00
|
|
|
#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER
|
2006-09-16 16:58:27 +00:00
|
|
|
bool Debugger::debuggerInputCallback(GUI::ConsoleDialog *console, const char *input, void *refCon) {
|
2003-10-26 21:30:52 +00:00
|
|
|
Debugger *debugger = (Debugger *)refCon;
|
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
return debugger->parseCommand(input);
|
2003-10-26 21:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-11 18:02:27 +00:00
|
|
|
bool Debugger::debuggerCompletionCallback(GUI::ConsoleDialog *console, const char *input, Common::String &completion, void *refCon) {
|
2003-10-26 21:30:52 +00:00
|
|
|
Debugger *debugger = (Debugger *)refCon;
|
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
return debugger->tabComplete(input, completion);
|
2003-10-26 21:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2013-01-26 18:33:27 +00:00
|
|
|
} // End of namespace GUI
|