X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgldbg.cpp;h=43827378f4faed462e35efe2be4b3a2ca2dfffcb;hb=ea3d851aa52e999b1c5a5fa52c97ff5019756c0e;hp=bc621ce490e2679c91e30e6ca11348616559011d;hpb=de6ac03ffc36843bbbb0d496007b3046a4422ee1;p=gldbg.git diff --git a/source/gldbg.cpp b/source/gldbg.cpp index bc621ce..4382737 100644 --- a/source/gldbg.cpp +++ b/source/gldbg.cpp @@ -15,8 +15,10 @@ Distributed under the GPL #include #include #include +#include "functions.h" #include "gldbg.h" -#include "glprint.h" +#include "gldecoder.h" +#include "packet.h" #include "tool.h" using namespace std; @@ -39,6 +41,12 @@ GlDbg::GlDbg(int argc, char **argv): tools.push_back((*i)->create(*this)); } +GlDbg::~GlDbg() +{ + for(list::iterator i=tools.begin(); i!=tools.end(); ++i) + delete *i; +} + int GlDbg::main() { catch_signal(SIGINT); @@ -46,7 +54,7 @@ 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(); @@ -67,10 +75,29 @@ void GlDbg::launch() fcntl(sock_fd, F_SETFD, flags|FD_CLOEXEC); process.setenv("GLWRAP_FD", lexical_cast(fds[1])); + process.setenv("GLWRAP_CTRL_FD", lexical_cast(fds[1])); process.launch(); close(fds[1]); } - + +void GlDbg::set_breakpoint(unsigned short func, char flag) +{ + GlPacket *pkt = packet_begin(FUNC_GLDBREAK); + packet_write_short(pkt, func); + packet_write_char(pkt, flag); + packet_write_char(pkt, 0); + packet_send(pkt, sock_fd); +} + +void GlDbg::clear_breakpoint(unsigned short func, char flag) +{ + GlPacket *pkt = packet_begin(FUNC_GLDBREAK); + packet_write_short(pkt, func); + packet_write_char(pkt, 0); + packet_write_char(pkt, flag); + packet_send(pkt, sock_fd); +} + void GlDbg::quit(bool force) { if(!force && process.get_state()!=Process::INACTIVE) @@ -135,15 +162,21 @@ void GlDbg::read_stream() { const char *data = buffer.data()+buf_offset; unsigned len = buffer.size()-buf_offset; - int size = gldecoder_decode(0, data, len); - if(size<0) + GlPacket *pkt = packet_receive_str(data, &len); + if(!pkt) break; + + unsigned short func; + packet_read_short(pkt, (short *)&func); + if(func==FUNC_GLDBREAK) + { + packet_read_short(pkt, (short *)&func); + IO::print("Breakpoint: %s\n", get_function_name(func)); + } + for(list::iterator i=tools.begin(); i!=tools.end(); ++i) - (*i)->decode(data, size); - tracer.decode(data, len); - glstate.decode(data, len); - profiler.decode(data, len); - buf_offset += size; + (*i)->decode(data, len); + buf_offset += len; } if(buf_offset>8192) {