X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgldbg.cpp;h=9da31ea85917f76731126188690ee1727b0058dc;hb=7cc7ebcdb800bd4d88e4fccff8459003599e71d7;hp=dd0476d4168db408f8a990792f94cc0e436c466a;hpb=e6f542d42b566193f55bb6727834f709ac6c1762;p=gldbg.git diff --git a/source/gldbg.cpp b/source/gldbg.cpp index dd0476d..9da31ea 100644 --- a/source/gldbg.cpp +++ b/source/gldbg.cpp @@ -20,8 +20,10 @@ using namespace std; GlDbg *GlDbg::instance = 0; GlDbg::GlDbg(int argc, char **argv): + done(false), cmd_interp(*this), process(vector(argv+1, argv+argc)), + sock_fd(-1), buf_offset(0), flushing(false), got_sigchld(false), @@ -56,7 +58,7 @@ int GlDbg::main() printf("Copyright © 2009-2010 Mikkosoft Productions\n"); printf("Type \"help\" for a list of commands\n"); - while(1) + while(!done) tick(); return 0; @@ -98,6 +100,9 @@ void GlDbg::launch() void GlDbg::send(GlPacket *pkt) { + if(process.get_state()==Process::INACTIVE) + throw runtime_error("Program is not running"); + packet_send(pkt, sock_fd); } @@ -129,7 +134,7 @@ void GlDbg::set_breakpoint(unsigned short func, unsigned char flag, Tool *owner) breakpoints.back().add_owner(owner); } - if(process.get_state()>=Process::RUNNING) + if(process.get_state()!=Process::INACTIVE) send_breakpoint(func, flag, 0); } } @@ -153,7 +158,7 @@ void GlDbg::clear_breakpoint(unsigned short func, unsigned char flag, Tool *owne break; } - if(process.get_state()>=Process::RUNNING) + if(process.get_state()!=Process::INACTIVE) send_breakpoint(func, 0, flag); } } @@ -176,7 +181,7 @@ void GlDbg::quit(bool force) { if(!force && process.get_state()!=Process::INACTIVE) throw runtime_error("Program is still running"); - exit(0); + done = true; } void GlDbg::tick() @@ -222,7 +227,7 @@ void GlDbg::tick() free(line); } else if(pstate==Process::INACTIVE) - exit(0); + done = true; } }