]> git.tdb.fi Git - gldbg.git/blobdiff - source/gldbg.cpp
Add framework necessary to support more modular tools
[gldbg.git] / source / gldbg.cpp
index d18ff51bba753b9c2ccbb97cb510d48169fa957a..bc621ce490e2679c91e30e6ca11348616559011d 100644 (file)
@@ -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
 */
 
@@ -17,6 +17,7 @@ Distributed under the GPL
 #include <msp/strings/lexicalcast.h>
 #include "gldbg.h"
 #include "glprint.h"
+#include "tool.h"
 
 using namespace std;
 using namespace Msp;
@@ -32,6 +33,10 @@ GlDbg::GlDbg(int argc, char **argv):
 {
        FS::Path libdir = FS::get_sys_lib_dir(argv[0], "gldbg");
        process.setenv("LD_PRELOAD", (libdir/"glwrap.so").str().c_str());
+
+       const list<Tool::Factory *> &factories = Tool::get_factories();
+       for(list<Tool::Factory *>::const_iterator i=factories.begin(); i!=factories.end(); ++i)
+               tools.push_back((*i)->create(*this));
 }
 
 int GlDbg::main()
@@ -133,6 +138,8 @@ void GlDbg::read_stream()
                                int size = gldecoder_decode(0, data, len);
                                if(size<0)
                                        break;
+                               for(list<Tool *>::iterator i=tools.begin(); i!=tools.end(); ++i)
+                                       (*i)->decode(data, size);
                                tracer.decode(data, len);
                                glstate.decode(data, len);
                                profiler.decode(data, len);
@@ -141,7 +148,7 @@ void GlDbg::read_stream()
                        if(buf_offset>8192)
                        {
                                buffer.erase(0, buf_offset);
-                               buf_offset=0;
+                               buf_offset = 0;
                        }
                }
        }