3 This file is part of gldbg
4 Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions
5 Distributed under the GPL
8 #include <msp/io/file.h>
9 #include <msp/io/print.h>
17 Tracer::Tracer(GlDbg &dbg):
18 glprint(new GlPrint(0, 16384)),
23 dbg.get_command_interpreter().register_command("trace", this, &Tracer::cmd_trace)
24 .set_help("Traces GL function calls",
26 " Send trace output to stdout.\n\n"
28 " Send trace output to FILE (- for stdout).\n\n"
30 " Temporarily suspend or resume trace without closing the file.\n\n"
32 " Terminate trace, closing the file.\n");
42 void Tracer::set_output(IO::Base *o, bool d)
50 void Tracer::decode(const char *data, unsigned len)
55 int ret = glprint->decode(data, len);
58 const char *buf = glprint->get_buffer();
60 IO::print(*out, "%s\n", buf);
64 void Tracer::cmd_trace(const string &args)
66 if(args.empty() || args=="-")
68 set_output(&IO::cout, false);
69 IO::print("Tracing to stdout\n");
74 throw InvalidState("Output is not set");
76 IO::print("Tracing enabled\n");
81 IO::print("Tracing disabled\n");
86 IO::print("Tracing terminated\n");
90 set_output(new IO::File(args, IO::M_WRITE), true);
91 IO::print("Tracing to %s\n", args);