]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/plr/server/src/fault_handlers/observer.cc
update
[l4.git] / l4 / pkg / plr / server / src / fault_handlers / observer.cc
1 /*
2  * observer.cc --
3  *
4  *    General fault observer functions
5  *
6  * (c) 2011-2013 Björn Döbel <doebel@os.inf.tu-dresden.de>,
7  *     economic rights: Technische Universität Dresden (Germany)
8  * This file is part of TUD:OS and distributed under the terms of the
9  * GNU General Public License 2.
10  * Please see the COPYING-GPL-2 file for details.
11  */
12
13 #include "observers.h"
14 #include "../configuration"
15
16 Romain::Observer* 
17 Romain::ObserverFactory::CreateObserver(char const *name)
18 {
19 #define CASE(string, object) \
20         do { \
21                 if (strcmp(name, string) == 0) { \
22                         return object; \
23                 } \
24         } while (0)
25
26         CASE("simple",     new SimpleDebugObserver());
27         CASE("trap",       new TrapObserver());
28         CASE("vcpu_state", new PrintVCPUStateObserver());
29         CASE("pagefaults", new PageFaultObserver());
30         CASE("syscalls",   new SyscallObserver());
31         CASE("swifi",      SWIFIObserver::Create());
32         CASE("kip-time",   KIPTimeObserver::Create());
33         CASE("trap_limit", TrapLimitObserver::Create());
34         CASE("threads",    PThreadLockObserver::Create());
35         CASE("replicalog", new ReplicaLogObserver());
36
37 #if 0
38         if (strcmp(name, "gdb") == 0) {
39                 int port = ConfigIntValue("gdbstub:port");
40                 if (port > 0) { // want TCP connection
41                         return new Romain::GDBServerObserver(new Romain::TCPConnection(port));
42                 } else { // want serial line
43                         return new Romain::GDBServerObserver(new Romain::SerialConnection());
44                 }
45         }
46 #endif
47
48         enter_kdebug("no observer found.");
49         return NULL;
50
51 #undef CASE
52 }
53
54
55 bool Romain::Observer::entry_reason_is_int3(L4vcpu::Vcpu* vcpu,
56                                             Romain::App_instance *,
57                                             Romain::App_model *am)
58 {
59         /*
60          * Some other debugger component might already have
61          * replaced the opcode with sth. different (e.g., for emulating
62          * a breakpoint. In this case everything has become invalid
63          * right now and we skip, too.
64          */
65         l4_addr_t remote = vcpu->r()->ip - 1;
66         unsigned char op = *(unsigned char*)am->rm()->remote_to_local(remote, 0);
67         return (vcpu->r()->trapno == 3) && (op == 0xCC);
68 }
69
70