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