#include <msp/io/print.h>
#include <msp/strings/lexicalcast.h>
#include <msp/strings/utils.h>
+#include "breakpoint.h"
#include "commandinterpreter.h"
#include "enums.h"
+#include "functions.h"
#include "gldbg.h"
#include "tracer.h"
register_command("run", this, &CommandInterpreter::cmd_run)
.set_help("Starts the program");
+ register_command("break", this, &CommandInterpreter::cmd_break)
+ .set_help("Sets a breakpoint",
+ "break FUNC\n"
+ " Makes program execution stop at FUNC\n");
+ register_command("unbreak", this, &CommandInterpreter::cmd_unbreak)
+ .set_help("Removes a breakpoint",
+ "unbreak FUNC\n"
+ " Makes program execution no longer stop at FUNC\n");
+ register_command("next", this, &CommandInterpreter::cmd_next)
+ .set_help("Resumes program execution until the next function call");
+ commands["step"] = new CommandAlias(commands["next"]);
+ register_command("finish", this, &CommandInterpreter::cmd_finish)
+ .set_help("Resumes program execution until the next function return");
register_command("continue", this, &CommandInterpreter::cmd_continue)
.set_help("Resumes program execution");
register_command("kill", this, &CommandInterpreter::cmd_kill)
gldbg.launch();
}
+void CommandInterpreter::cmd_break(const string &args)
+{
+ unsigned short func = get_function(args.c_str());
+ if(!func)
+ throw InvalidParameterValue("Unknown function");
+
+ gldbg.set_breakpoint(func, BREAK_CALL);
+}
+
+void CommandInterpreter::cmd_unbreak(const string &args)
+{
+ unsigned short func = get_function(args.c_str());
+ if(!func)
+ throw InvalidParameterValue("Unknown function");
+
+ gldbg.clear_breakpoint(func, BREAK_CALL);
+}
+
+void CommandInterpreter::cmd_next(const string &)
+{
+ gldbg.set_breakpoint(0, BREAK_CALL);
+ gldbg.get_process().resume();
+}
+
+void CommandInterpreter::cmd_finish(const string &)
+{
+ gldbg.set_breakpoint(0, BREAK_RETURN);
+ gldbg.get_process().resume();
+}
+
void CommandInterpreter::cmd_continue(const string &)
{
IO::print("Continuing.\n");