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