7 * (c) 2011-2013 Björn Döbel <doebel@os.inf.tu-dresden.de>,
8 * economic rights: Technische Universität Dresden (Germany)
9 * This file is part of TUD:OS and distributed under the terms of the
10 * GNU General Public License 2.
11 * Please see the COPYING-GPL-2 file for details.
17 #include "../app_loading"
22 BREAK_INSTRUCTION = 0xCC,
26 l4_umword_t _orig_code;
30 Breakpoint(l4_addr_t addr)
31 : _address(addr), _orig_code(0), _refcnt(0)
39 void activate(Romain::App_instance *i, Romain::App_model *m)
42 l4_addr_t local = m->rm()->remote_to_local(address(), i->id());
43 DEBUG() << "Setting BP @ 0x" << std::hex << address()
44 << " -> local 0x" << local;
45 _orig_code = *(l4_umword_t*)local;
46 *(unsigned char*)local = BREAK_INSTRUCTION;
47 DEBUG() << "addr @ " << std::hex << &_address;
51 void deactivate(Romain::App_instance *i, Romain::App_model *m)
54 DEBUG() << "Deactivating bp @ " << std::hex << address()
55 << " in instance " << i->id();
56 DEBUG() << "(addr == " << &_address << ")";
57 l4_addr_t local = m->rm()->remote_to_local(address(), i->id());
58 *(l4_umword_t*)local = _orig_code;
62 l4_addr_t address() { return _address; }
63 l4_umword_t orig() { return _orig_code; }
64 unsigned refs() const { return _refcnt; }
66 bool was_hit(Romain::App_thread *t)
68 return (t->vcpu()->r()->ip - 1) == _address;