]> git.tdb.fi Git - gldbg.git/blobdiff - source/gldbg.h
Retain user-set breakpoints and send them to the process on startup
[gldbg.git] / source / gldbg.h
index 5654715c41845ffca052bbef67f936b86846ec68..3a2bcd1a718535fdba44b00f6d2018f423df74a3 100644 (file)
@@ -1,51 +1,74 @@
-/* $Id$
-
-This file is part of gldbg
-Copyright © 2009  Mikko Rasa, Mikkosoft Productions
-Distributed under the GPL
-*/
-
 #ifndef GLDBG_H_
 #define GLDBG_H_
 
+#include <list>
 #include <string>
 #include <vector>
-#include <msp/core/application.h>
-#include <msp/fs/path.h>
 #include "commandinterpreter.h"
-#include "glstate.h"
+#include "packet.h"
 #include "process.h"
-#include "tracer.h"
 
-class GlDbg: public Msp::Application
+class Tool;
+
+class GlDbg
 {
 private:
+       typedef std::list<Tool *> ToolList;
+
+       struct Breakpoint
+       {
+               unsigned short function;
+               unsigned char flag;
+               ToolList owners;
+
+               Breakpoint(unsigned short, unsigned char);
+
+               void add_owner(Tool *);
+               bool has_owner(Tool *) const;
+               void remove_owner(Tool *);
+       };
+
+       typedef std::list<Breakpoint> BreakList;
+
        CommandInterpreter cmd_interp;
        Process process;
        int sock_fd;
        std::string buffer;
        unsigned buf_offset;
        bool flushing;
-       Tracer tracer;
-       GlState glstate;
+       ToolList tools;
        bool got_sigchld;
+       int stop_reason;
+       BreakList breakpoints;
+       const Breakpoint *current_break;
+       ToolList break_holders;
 
-       static RegApp<GlDbg> reg;
+       static GlDbg *instance;
 
 public:
        GlDbg(int, char **);
+       ~GlDbg();
+
        int main();
-       Tracer &get_tracer() { return tracer; }
-       GlState &get_glstate() { return glstate; }
+       CommandInterpreter &get_command_interpreter() { return cmd_interp; }
        Process &get_process() { return process; }
        void launch();
+       void send(GlPacket *);
+       void hold();
+private:
+       void send_breakpoint(unsigned short, unsigned char, unsigned char);
+public:
+       void set_breakpoint(unsigned short, unsigned char, Tool *);
+       void clear_breakpoint(unsigned short, unsigned char, Tool *);
+       void resume_from_break(Tool *);
        void quit(bool);
 private:
        void tick();
        void check_child();
        void read_stream();
-       long ptrace(int, void *, void *);
-       virtual void sighandler(int);
+       Breakpoint *get_breakpoint(unsigned short, unsigned char);
+
+       static void sighandler(int);
 };
 
 #endif