#include <msp/fs/dir.h>
#include <msp/io/print.h>
#include <msp/strings/lexicalcast.h>
+#include "functions.h"
#include "gldbg.h"
#include "gldecoder.h"
+#include "packet.h"
#include "tool.h"
using namespace std;
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)
{
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<Tool *>::iterator i=tools.begin(); i!=tools.end(); ++i)
- (*i)->decode(data, size);
- buf_offset += size;
+ (*i)->decode(data, len);
+ buf_offset += len;
}
if(buf_offset>8192)
{