]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/plr/server/src/fault_handlers/observers.h
update
[l4.git] / l4 / pkg / plr / server / src / fault_handlers / observers.h
1 #pragma once
2
3 /*
4  * observer.h --
5  *
6  *    Fault observer interface
7  *
8  * (c) 2011-2013 Björn Döbel <doebel@os.inf.tu-dresden.de>,
9  *     economic rights: Technische Universität Dresden (Germany)
10  * This file is part of TUD:OS and distributed under the terms of the
11  * GNU General Public License 2.
12  * Please see the COPYING-GPL-2 file for details.
13  */
14
15
16 #include "../fault_observers"
17 #include "debugging.h" // Breakpoint
18 #if 0
19 #include "../gdb_stub/gdbserver"
20 #include "../gdb_stub/connection"
21 #endif
22 #include "../configuration"
23
24 namespace Romain
25 {
26         /*
27          * Debug observer - can set breakpoint on a single instruction and
28          * single-steps the application after hitting the BP.
29          */
30         class SimpleDebugObserver : public Observer
31         {
32                 private:
33                         Breakpoint *_bp;
34                         l4_umword_t _int1_seen;
35
36                         l4_addr_t determine_address()
37                         {
38                                 l4_addr_t addr = ConfigIntValue("simpledbg:singlestep");
39                                 DEBUG() << "Single step target: 0x"
40                                         << std::hex << addr;
41
42                                 return addr;
43                         }
44
45                         DECLARE_OBSERVER("simple dbg");
46                         SimpleDebugObserver();
47         };
48
49
50         /*
51          * INT3 trap observer (aka JDB emulator)
52          */
53         class TrapObserver : public Observer
54         {
55                 DECLARE_OBSERVER("trap");
56                 static char const * const jdb_out_prefix;
57                 static char const * const jdb_out_suffix;
58         };
59
60
61         /*
62          * Observer that prints VCPU content on every fault.
63          */
64         class PrintVCPUStateObserver : public Observer
65         {
66                 DECLARE_OBSERVER("print vcpu state");
67         };
68
69
70         /*
71          * Observer for handling page faults.
72          */
73         class PageFaultObserver : public Observer
74         {
75                 private:
76                 bool _readonly;
77
78                 DECLARE_OBSERVER("pf");
79                 PageFaultObserver();
80
81                 bool always_readonly() const { return _readonly; }
82         };
83
84
85         /*
86          * System call handling
87          */
88         class SyscallObserver : public Observer
89         {
90                 DECLARE_OBSERVER("syscalls");
91
92                 SyscallObserver()
93                         : _replica_thread_groups()
94                 { }
95
96                 protected:
97
98                 std::map<unsigned, Romain::Thread_group*> _replica_thread_groups;
99
100                 /*******************************************
101                  * Thread-related system calls
102                  *******************************************/
103                 void handle_task(Romain::App_instance*, Romain::App_thread*, Romain::App_model*);
104         };
105
106
107         /*
108          * Limit for the amount of traps handled before exiting
109          *
110          * Debugging feature: for unit tests we want to run an application for a
111          * dedicated amount of system calls until terminating the run, so that the
112          * output becomes reproducible.
113          */
114         class TrapLimitObserver : public Observer
115         {
116                 public:
117                 static TrapLimitObserver *Create();
118         };
119
120
121         /*
122          * Observer monitoring accesses to the clock field in the KIP.
123          *
124          * The KIP is mostly read-only and we may therefore get along with a single copy
125          * that is mapped read-only to all clients. However, the KIP contains a clock field
126          * that is updated on every context switch if the kernel has been compiled with
127          * FINE_GRAIN_CPU_TIME. This field is used by gettimeofday(). In order to let all
128          * replicas see the same time when they use this function, we need to instrument
129          * accesses to the clock field.
130          */
131         class KIPTimeObserver : public Observer
132         {
133                 public:
134                 static KIPTimeObserver *Create();
135         };
136
137
138         /*
139          * Software-Implemented Fault Injection
140          */
141         class SWIFIObserver : public Observer
142         {
143                 public:
144                 static SWIFIObserver* Create();
145         };
146
147
148         class PThreadLockObserver : public Observer
149         {
150                 public:
151                 static PThreadLockObserver* Create();
152         };
153
154
155         class ReplicaLogObserver : public Observer
156         {
157                 DECLARE_OBSERVER("replica::log");
158
159                 public:
160                         ReplicaLogObserver();
161
162                 private:
163                         struct {
164                                 l4_addr_t local_addr;
165                         } buffers[Romain::MAX_REPLICAS];
166
167                         void map_eventlog(Romain::App_instance *i, int logsizeMB);
168                         void dump_eventlog(unsigned id) const;
169         };
170 }