X-Git-Url: http://git.tdb.fi/?p=gldbg.git;a=blobdiff_plain;f=source%2Fprocess.cpp;fp=source%2Fprocess.cpp;h=e198df2d10e63d6914a61b23cdb2b5f36b7b861e;hp=0fc9e98f6410e0b6657a50106a1d2459385d594e;hb=81f1ddee977603293d0c5710f2db69130dac6a96;hpb=a51c2557622ea93944e24f58845609526eb46ec1 diff --git a/source/process.cpp b/source/process.cpp index 0fc9e98..e198df2 100644 --- a/source/process.cpp +++ b/source/process.cpp @@ -1,20 +1,20 @@ /* $Id$ This file is part of gldbg -Copyright © 2009 Mikko Rasa, Mikkosoft Productions +Copyright © 2009, 2011 Mikko Rasa, Mikkosoft Productions Distributed under the GPL */ +#include #include #include #include #include #include -#include #include "process.h" +#include "strformat.h" using namespace std; -using namespace Msp; Process::Process(const vector &a): args(a), @@ -30,7 +30,7 @@ void Process::setenv(const string &key, const string &value) void Process::launch() { if(state!=INACTIVE) - throw InvalidState("Program is already running"); + throw logic_error("Program is already running"); pid = fork(); if(pid==0) @@ -48,7 +48,7 @@ void Process::launch() else if(pid>0) state = STARTING; else - throw SystemError("Could not launch process", errno); + throw runtime_error(strformat("Could not launch process: %s", strerror(errno))); } int Process::check() @@ -90,7 +90,7 @@ int Process::check() void Process::resume(int sig) { if(state!=STOPPED) - throw InvalidState("Program is not stopped"); + throw logic_error("Program is not stopped"); ptrace(PTRACE_CONT, 0, (void *)sig); state = RUNNING; } @@ -98,7 +98,7 @@ void Process::resume(int sig) void Process::kill() { if(state==INACTIVE) - throw InvalidState("Program is not running"); + throw logic_error("Program is not running"); ptrace(PTRACE_KILL, 0, 0); // Make the debugger wait() for us state = RUNNING; @@ -108,6 +108,6 @@ long Process::ptrace(int req, void *addr, void *data) { int ret = ::ptrace((__ptrace_request)req, pid, addr, data); if(ret==-1 && ((req!=PTRACE_PEEKTEXT && req!=PTRACE_PEEKDATA && req!=PTRACE_PEEKUSER) || errno)) - throw SystemError("ptrace error", errno); + throw runtime_error(strformat("ptrace error: %s", strerror(errno))); return ret; }