X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgldbg.cpp;h=7990fabae61f6f9ed4b1daef344b5715ded4004f;hb=7bd7fc784a6f6cff69f79914a445bc2115a7e768;hp=c91e00a79ec8171dd6672fbc8a1b9333209fa7e4;hpb=0be9f22fa27bfca77f494489fce0e62b66882e5b;p=gldbg.git diff --git a/source/gldbg.cpp b/source/gldbg.cpp index c91e00a..7990fab 100644 --- a/source/gldbg.cpp +++ b/source/gldbg.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of gldbg -Copyright © 2009 Mikko Rasa, Mikkosoft Productions +Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions Distributed under the GPL */ @@ -16,7 +16,8 @@ Distributed under the GPL #include #include #include "gldbg.h" -#include "glprint.h" +#include "gldecoder.h" +#include "tool.h" using namespace std; using namespace Msp; @@ -26,11 +27,22 @@ Application::RegApp GlDbg::reg; GlDbg::GlDbg(int argc, char **argv): cmd_interp(*this), process(vector(argv+1, argv+argc)), + buf_offset(0), flushing(false), got_sigchld(false) { FS::Path libdir = FS::get_sys_lib_dir(argv[0], "gldbg"); process.setenv("LD_PRELOAD", (libdir/"glwrap.so").str().c_str()); + + const list &factories = Tool::get_factories(); + for(list::const_iterator i=factories.begin(); i!=factories.end(); ++i) + tools.push_back((*i)->create(*this)); +} + +GlDbg::~GlDbg() +{ + for(list::iterator i=tools.begin(); i!=tools.end(); ++i) + delete *i; } int GlDbg::main() @@ -40,10 +52,12 @@ int GlDbg::main() set_loop_mode(TICK_BUSY); IO::print("GLdbg 0.0\n"); - IO::print("Copyright © 2009 Mikkosoft Productions\n"); + IO::print("Copyright © 2009-2010 Mikkosoft Productions\n"); IO::print("Type \"help\" for a list of commands\n"); Application::main(); + + return 0; } void GlDbg::launch() @@ -63,9 +77,9 @@ void GlDbg::launch() close(fds[1]); } -void GlDbg::quit() +void GlDbg::quit(bool force) { - if(process.get_state()!=Process::INACTIVE) + if(!force && process.get_state()!=Process::INACTIVE) throw InvalidState("Program is still running"); exit(0); } @@ -130,13 +144,14 @@ void GlDbg::read_stream() int size = gldecoder_decode(0, data, len); if(size<0) break; - tracer.decode(data, len); + for(list::iterator i=tools.begin(); i!=tools.end(); ++i) + (*i)->decode(data, size); buf_offset += size; } if(buf_offset>8192) { buffer.erase(0, buf_offset); - buf_offset=0; + buf_offset = 0; } } }