]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/plr/server/src/fault_handlers/observer.cc
update: sync
[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-2012 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
36 #if 0
37         if (strcmp(name, "gdb") == 0) {
38                 int port = ConfigIntValue("gdbstub:port");
39                 if (port > 0) { // want TCP connection
40                         return new Romain::GDBServerObserver(new Romain::TCPConnection(port));
41                 } else { // want serial line
42                         return new Romain::GDBServerObserver(new Romain::SerialConnection());
43                 }
44         }
45 #endif
46
47         enter_kdebug("no observer found.");
48         return NULL;
49
50 #undef CASE
51 }
52
53
54 bool Romain::Observer::entry_reason_is_int3(L4vcpu::Vcpu* vcpu,
55                                             Romain::App_instance *,
56                                             Romain::App_model *am)
57 {
58         /*
59          * Some other debugger component might already have
60          * replaced the opcode with sth. different (e.g., for emulating
61          * a breakpoint. In this case everything has become invalid
62          * right now and we skip, too.
63          */
64         l4_addr_t remote = vcpu->r()->ip - 1;
65         unsigned char op = *(unsigned char*)am->rm()->remote_to_local(remote, 0);
66         return (vcpu->r()->trapno == 3) && (op == 0xCC);
67 }
68
69