3 #include "../fault_observers"
4 #include "debugging.h" // Breakpoint
6 #include "../gdb_stub/gdbserver"
7 #include "../gdb_stub/connection"
9 #include "../configuration"
14 * Debug observer - can set breakpoint on a single instruction and
15 * single-steps the application after hitting the BP.
17 class SimpleDebugObserver : public Observer
21 l4_umword_t _int1_seen;
23 l4_addr_t determine_address()
25 l4_addr_t addr = ConfigIntValue("simpledbg:singlestep");
26 DEBUG() << "Single step target: 0x"
32 DECLARE_OBSERVER("simple dbg");
33 SimpleDebugObserver();
38 * INT3 trap observer (aka JDB emulator)
40 class TrapObserver : public Observer
42 DECLARE_OBSERVER("trap");
43 static char const * const jdb_out_prefix;
44 static char const * const jdb_out_suffix;
49 * Observer that prints VCPU content on every fault.
51 class PrintVCPUStateObserver : public Observer
53 DECLARE_OBSERVER("print vcpu state");
58 * Observer for handling page faults.
60 class PageFaultObserver : public Observer
65 DECLARE_OBSERVER("pf");
68 bool always_readonly() const { return _readonly; }
73 * System call handling
75 class SyscallObserver : public Observer
77 DECLARE_OBSERVER("syscalls");
82 * Store UTCB from orig to backup.
84 void store_utcb(char *orig, char *backup) { memcpy(backup, orig, L4_UTCB_OFFSET); }
86 /*******************************************
87 * Perform system call redirection.
88 *******************************************/
89 void do_proxy_syscall(Romain::App_instance*, Romain::App_thread*, Romain::App_model*);
91 /*******************************************
92 * Memory-management-related system calls.
93 *******************************************/
94 void handle_rm(Romain::App_instance*, Romain::App_thread*, Romain::App_model*);
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*);
102 * gdt setup system calls
104 void handle_thread_gdt(Romain::App_thread*, l4_utcb_t *u);
109 * Limit for the amount of traps handled before exiting
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.
115 class TrapLimitObserver : public Observer
118 static TrapLimitObserver *Create();
123 * Observer monitoring accesses to the clock field in the KIP.
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.
132 class KIPTimeObserver : public Observer
135 static KIPTimeObserver *Create();
140 * Software-Implemented Fault Injection
142 class SWIFIObserver : public Observer
145 static SWIFIObserver* Create();