6 * Fault observer interface
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.
16 #include "../fault_observers"
17 #include "debugging.h" // Breakpoint
19 #include "../gdb_stub/gdbserver"
20 #include "../gdb_stub/connection"
22 #include "../configuration"
27 * Debug observer - can set breakpoint on a single instruction and
28 * single-steps the application after hitting the BP.
30 class SimpleDebugObserver : public Observer
34 l4_umword_t _int1_seen;
36 l4_addr_t determine_address()
38 l4_addr_t addr = ConfigIntValue("simpledbg:singlestep");
39 DEBUG() << "Single step target: 0x"
45 DECLARE_OBSERVER("simple dbg");
46 SimpleDebugObserver();
51 * INT3 trap observer (aka JDB emulator)
53 class TrapObserver : public Observer
55 DECLARE_OBSERVER("trap");
56 static char const * const jdb_out_prefix;
57 static char const * const jdb_out_suffix;
62 * Observer that prints VCPU content on every fault.
64 class PrintVCPUStateObserver : public Observer
66 DECLARE_OBSERVER("print vcpu state");
71 * Observer for handling page faults.
73 class PageFaultObserver : public Observer
78 DECLARE_OBSERVER("pf");
81 bool always_readonly() const { return _readonly; }
86 * System call handling
88 class SyscallObserver : public Observer
90 DECLARE_OBSERVER("syscalls");
93 : _replica_thread_groups()
98 std::map<unsigned, Romain::Thread_group*> _replica_thread_groups;
100 /*******************************************
101 * Thread-related system calls
102 *******************************************/
103 void handle_task(Romain::App_instance*, Romain::App_thread*, Romain::App_model*);
108 * Limit for the amount of traps handled before exiting
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.
114 class TrapLimitObserver : public Observer
117 static TrapLimitObserver *Create();
122 * Observer monitoring accesses to the clock field in the KIP.
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.
131 class KIPTimeObserver : public Observer
134 static KIPTimeObserver *Create();
139 * Software-Implemented Fault Injection
141 class SWIFIObserver : public Observer
144 static SWIFIObserver* Create();
148 class PThreadLockObserver : public Observer
151 static PThreadLockObserver* Create();
155 class ReplicaLogObserver : public Observer
157 DECLARE_OBSERVER("replica::log");
160 ReplicaLogObserver();
164 l4_addr_t local_addr;
165 } buffers[Romain::MAX_REPLICAS];
167 void map_eventlog(Romain::App_instance *i, int logsizeMB);
168 void dump_eventlog(unsigned id) const;