]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/plr/server/src/fault_handlers/observers.h
d02d0d25bf83302d7556c07dc9d6e8e772afd118
[l4.git] / l4 / pkg / plr / server / src / fault_handlers / observers.h
1 #pragma once
2
3 #include "../fault_observers"
4 #include "debugging.h" // Breakpoint
5 #if 0
6 #include "../gdb_stub/gdbserver"
7 #include "../gdb_stub/connection"
8 #endif
9 #include "../configuration"
10
11 namespace Romain
12 {
13         /*
14          * Debug observer - can set breakpoint on a single instruction and
15          * single-steps the application after hitting the BP.
16          */
17         class SimpleDebugObserver : public Observer
18         {
19                 private:
20                         Breakpoint *_bp;
21                         l4_umword_t _int1_seen;
22
23                         l4_addr_t determine_address()
24                         {
25                                 l4_addr_t addr = ConfigIntValue("simpledbg:singlestep");
26                                 DEBUG() << "Single step target: 0x"
27                                         << std::hex << addr;
28
29                                 return addr;
30                         }
31
32                         DECLARE_OBSERVER("simple dbg");
33                         SimpleDebugObserver();
34         };
35
36
37         /*
38          * INT3 trap observer (aka JDB emulator)
39          */
40         class TrapObserver : public Observer
41         {
42                 DECLARE_OBSERVER("trap");
43                 static char const * const jdb_out_prefix;
44                 static char const * const jdb_out_suffix;
45         };
46
47
48         /*
49          * Observer that prints VCPU content on every fault.
50          */
51         class PrintVCPUStateObserver : public Observer
52         {
53                 DECLARE_OBSERVER("print vcpu state");
54         };
55
56
57         /*
58          * Observer for handling page faults.
59          */
60         class PageFaultObserver : public Observer
61         {
62                 private:
63                 bool _readonly;
64
65                 DECLARE_OBSERVER("pf");
66                 PageFaultObserver();
67
68                 bool always_readonly() const { return _readonly; }
69         };
70
71
72         /*
73          * System call handling
74          */
75         class SyscallObserver : public Observer
76         {
77                 DECLARE_OBSERVER("syscalls");
78
79                 protected:
80
81                 /*
82                  * Store UTCB from orig to backup.
83                  */
84                 void store_utcb(char *orig, char *backup) { memcpy(backup, orig, L4_UTCB_OFFSET); }
85
86                 /*******************************************
87                  * Perform system call redirection.
88                  *******************************************/
89                 void do_proxy_syscall(Romain::App_instance*, Romain::App_thread*, Romain::App_model*);
90
91                 /*******************************************
92                  * Memory-management-related system calls.
93                  *******************************************/
94                 void handle_rm(Romain::App_instance*, Romain::App_thread*, Romain::App_model*);
95
96                 /*******************************************
97                  * Thread-related system calls
98                  *******************************************/
99                 void handle_thread(Romain::App_instance*, Romain::App_thread*, Romain::App_model*);
100                 void handle_task(Romain::App_instance*, Romain::App_thread*, Romain::App_model*);
101                 /*
102                  * gdt setup system calls
103                  */
104                 void handle_thread_gdt(Romain::App_thread*, l4_utcb_t *u);
105         };
106
107
108         /*
109          * Limit for the amount of traps handled before exiting
110          *
111          * Debugging feature: for unit tests we want to run an application for a
112          * dedicated amount of system calls until terminating the run, so that the
113          * output becomes reproducible.
114          */
115         class TrapLimitObserver : public Observer
116         {
117                 public:
118                 static TrapLimitObserver *Create();
119         };
120
121
122         /*
123          * Observer monitoring accesses to the clock field in the KIP.
124          *
125          * The KIP is mostly read-only and we may therefore get along with a single copy
126          * that is mapped read-only to all clients. However, the KIP contains a clock field
127          * that is updated on every context switch if the kernel has been compiled with
128          * FINE_GRAIN_CPU_TIME. This field is used by gettimeofday(). In order to let all
129          * replicas see the same time when they use this function, we need to instrument
130          * accesses to the clock field.
131          */
132         class KIPTimeObserver : public Observer
133         {
134                 public:
135                 static KIPTimeObserver *Create();
136         };
137
138
139         /*
140          * Software-Implemented Fault Injection
141          */
142         class SWIFIObserver : public Observer
143         {
144                 public:
145                 static SWIFIObserver* Create();
146         };
147 }