X-Git-Url: http://git.tdb.fi/?p=gldbg.git;a=blobdiff_plain;f=source%2Fcommandinterpreter.cpp;h=25f004ef32a639497437eaf5709c0b87c64465d5;hp=2a28f69acd6e06a2dc8c523ef2e58a388a62124d;hb=ea3d851aa52e999b1c5a5fa52c97ff5019756c0e;hpb=7642653a18f7464dd093a93a1247b8f18e53cd1a diff --git a/source/commandinterpreter.cpp b/source/commandinterpreter.cpp index 2a28f69..25f004e 100644 --- a/source/commandinterpreter.cpp +++ b/source/commandinterpreter.cpp @@ -11,8 +11,10 @@ Distributed under the GPL #include #include #include +#include "breakpoint.h" #include "commandinterpreter.h" #include "enums.h" +#include "functions.h" #include "gldbg.h" #include "tracer.h" @@ -34,6 +36,19 @@ CommandInterpreter::CommandInterpreter(GlDbg &d): 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) @@ -98,6 +113,36 @@ void CommandInterpreter::cmd_run(const string &) 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");