2 * @brief Jdb-Utcb module
4 * This module shows the user tcbs and the vCPU state of a thread/vcpu
14 #include "jdb_kobject.h"
15 #include "jdb_module.h"
17 #include "static_init.h"
18 #include "thread_object.h"
19 #include "thread_state.h"
21 class Jdb_utcb : public Jdb_module
24 Jdb_utcb() FIASCO_INIT;
26 static Kobject *thread;
30 static Jdb_utcb Jdb_utcb INIT_PRIORITY(JDB_MODULE_INIT_PRIO);
32 Kobject *Jdb_utcb::thread;
41 Jdb_utcb::print(Thread *t)
45 printf("\nUtcb-addr: %p\n", t->utcb().kern());
46 t->utcb().kern()->print();
49 if (t->state(false) & Thread_vcpu_enabled)
51 Vcpu_state *v = t->vcpu_state().kern();
52 printf("\nVcpu-state-addr: %p\n", v);
53 printf("state: %x saved-state: %x sticky: %x\n",
54 (unsigned)v->state, (unsigned)v->_saved_state,
55 (unsigned)v->sticky_flags);
56 printf("entry_sp = %lx entry_ip = %lx sp = %lx\n",
57 v->_entry_sp, v->_entry_ip, v->_sp);
63 Jdb_module::Action_code
64 Jdb_utcb::action( int cmd, void *&, char const *&, int &)
69 Thread *t = cxx::dyn_cast<Thread *>(thread);
72 printf(" Invalid thread\n");
83 Jdb_utcb::num_cmds() const
88 const * Jdb_utcb::cmds() const
92 { 0, "z", "z", "%q", "z<thread>\tshow UTCB and vCPU state", &thread }
97 // --------------------------------------------------------------------------
98 // Handler for kobject list
100 class Jdb_kobject_utcb_hdl : public Jdb_kobject_handler
103 virtual bool show_kobject(Kobject_common *, int) { return true; }
104 virtual ~Jdb_kobject_utcb_hdl() {}
107 PUBLIC static FIASCO_INIT
109 Jdb_kobject_utcb_hdl::init()
111 static Jdb_kobject_utcb_hdl hdl;
112 Jdb_kobject::module()->register_handler(&hdl);
117 Jdb_kobject_utcb_hdl::handle_key(Kobject_common *o, int keycode)
121 Thread *t = cxx::dyn_cast<Thread *>(o);
133 STATIC_INITIALIZE(Jdb_kobject_utcb_hdl);