3 This file is part of gldbg
4 Copyright © 2009-2011 Mikko Rasa, Mikkosoft Productions
5 Distributed under the GPL
15 Tracer::Tracer(GlDbg &dbg):
16 glprint(new GlPrint(0, 16384)),
21 dbg.get_command_interpreter().register_command("trace", this, &Tracer::cmd_trace)
22 .set_help("Traces GL function calls",
24 " Send trace output to stdout.\n\n"
26 " Send trace output to FILE (- for stdout).\n\n"
28 " Temporarily suspend or resume trace without closing the file.\n\n"
30 " Terminate trace, closing the file.\n");
40 void Tracer::set_output(FILE *o, bool d)
48 void Tracer::decode(const char *data, unsigned len)
53 int ret = glprint->decode(data, len);
56 const char *buf = glprint->get_buffer();
58 fprintf(out, "%s\n", buf);
62 void Tracer::cmd_trace(const string &args)
64 if(args.empty() || args=="-")
66 set_output(stdout, false);
67 printf("Tracing to stdout\n");
72 throw runtime_error("Output is not set");
74 printf("Tracing enabled\n");
79 printf("Tracing disabled\n");
84 printf("Tracing terminated\n");
88 FILE *f = fopen(args.c_str(), "w");
90 throw runtime_error("Could not open trace file");
93 printf("Tracing to %s\n", args.c_str());