]> git.tdb.fi Git - gldbg.git/blob - source/gldbg.h
dd6d60c6d8f1a97c13078d6da3fe51e82498228a
[gldbg.git] / source / gldbg.h
1 /* $Id$
2
3 This file is part of gldbg
4 Copyright © 2009-2011  Mikko Rasa, Mikkosoft Productions
5 Distributed under the GPL
6 */
7
8 #ifndef GLDBG_H_
9 #define GLDBG_H_
10
11 #include <list>
12 #include <string>
13 #include <vector>
14 #include "commandinterpreter.h"
15 #include "packet.h"
16 #include "process.h"
17
18 class Tool;
19
20 class GlDbg
21 {
22 private:
23         typedef std::list<Tool *> ToolList;
24
25         struct Breakpoint
26         {
27                 unsigned short function;
28                 unsigned char flag;
29                 ToolList owners;
30
31                 Breakpoint(unsigned short, unsigned char);
32
33                 void add_owner(Tool *);
34                 bool has_owner(Tool *) const;
35                 void remove_owner(Tool *);
36         };
37
38         typedef std::list<Breakpoint> BreakList;
39
40         CommandInterpreter cmd_interp;
41         Process process;
42         int sock_fd;
43         std::string buffer;
44         unsigned buf_offset;
45         bool flushing;
46         ToolList tools;
47         bool got_sigchld;
48         int stop_reason;
49         BreakList breakpoints;
50         const Breakpoint *current_break;
51         ToolList break_holders;
52
53         static GlDbg *instance;
54
55 public:
56         GlDbg(int, char **);
57         ~GlDbg();
58
59         int main();
60         CommandInterpreter &get_command_interpreter() { return cmd_interp; }
61         Process &get_process() { return process; }
62         void launch();
63         void send(GlPacket *);
64         void hold();
65         void set_breakpoint(unsigned short, unsigned char, Tool *);
66         void clear_breakpoint(unsigned short, unsigned char, Tool *);
67         void resume_from_break(Tool *);
68         void quit(bool);
69 private:
70         void tick();
71         void check_child();
72         void read_stream();
73         Breakpoint *get_breakpoint(unsigned short, unsigned char);
74
75         static void sighandler(int);
76 };
77
78 #endif