4 * Implementation of a tiny debugger without any GDB features.
6 * Currently this debugger allows to configure an address in the Romain ini file,
7 * (simplegdb:singlestep). It will then place a breakpoint (0xCC) on this address
8 * and once this BP is hit, start single-stepping from this point on.
10 * (c) 2011-2012 Björn Döbel <doebel@os.inf.tu-dresden.de>,
11 * economic rights: Technische Universität Dresden (Germany)
12 * This file is part of TUD:OS and distributed under the terms of the
13 * GNU General Public License 2.
14 * Please see the COPYING-GPL-2 file for details.
18 #include "../app_loading"
19 #include "../emulation"
20 #include "../configuration"
22 #include "debugging.h"
23 #include "observers.h"
25 Romain::SimpleDebugObserver::SimpleDebugObserver()
28 _bp = new Breakpoint(determine_address());
31 /*****************************************************************
33 *****************************************************************/
34 void Romain::SimpleDebugObserver::startup_notify(Romain::App_instance *i,
36 Romain::Thread_group *,
37 Romain::App_model *am)
39 if (_bp->address() != ~0UL) {
41 DEBUG() << "Activated breakpoint in instance " << i->id()
42 << " @ address " << std::hex << _bp->address();
48 void Romain::SimpleDebugObserver::status() const { }
50 Romain::Observer::ObserverReturnVal
51 Romain::SimpleDebugObserver::notify(Romain::App_instance *i,
52 Romain::App_thread *t,
53 Romain::Thread_group *,
54 Romain::App_model *am)
56 switch(t->vcpu()->r()->trapno) {
58 Romain::InstructionPrinter(am->rm()->remote_to_local(t->vcpu()->r()->ip, 0),
61 t->vcpu()->print_state();
62 INFO() << "INT1 seen: " << _int1_seen;
63 enter_kdebug("single step exception");
66 DEBUG() << "INT3 @ " << std::hex << t->vcpu()->r()->ip
67 << " addr = " << _bp->address();
68 if (_bp->was_hit(t)) {
69 DEBUG() << "refs: " << _bp->refs();
70 t->vcpu()->r()->ip -= 1; // revert int3
71 t->vcpu()->r()->flags |= TrapFlag;
72 _bp->deactivate(i, am);
81 return Romain::Observer::Continue;