7 #include "jdb_screen.h"
9 #include "jdb_kobject.h"
10 #include "kernel_console.h"
15 #include "thread_object.h"
16 #include "static_init.h"
20 class Jdb_obj_space : public Jdb_table, public Jdb_kobject_handler
35 bool show_kobject(Kobject_common *, int) { return false; }
41 operator ++ (Jdb_obj_space::Mode &m)
45 if (_m >= Jdb_obj_space::End_mode)
48 m = Jdb_obj_space::Mode(_m);
53 //char Jdb_obj_space_m::first_char;
56 Jdb_obj_space::Jdb_obj_space(Address base = 0, int level = 0)
57 : Jdb_kobject_handler(0),
63 Jdb_kobject::module()->register_handler(this);
68 Jdb_obj_space::col_width(unsigned column) const
71 return Jdb_screen::Col_head_size;
78 Jdb_obj_space::cols() const
85 Jdb_obj_space::rows() const
86 { return Obj_space::Map_max_address / (cols()-1); }
90 Jdb_obj_space::print_statline(unsigned long row, unsigned long col)
95 Kobject_iface *o = item(index(row,col), &rights);
98 Jdb::printf_statline("objs", "<Space>=mode", "%lx: -- INVALID --",
103 unsigned len = Jdb_kobject::obj_description(buf, sizeof(buf), true, o->dbg_info());
104 Jdb::printf_statline("objs", "<Space>=mode",
105 "%lx: %-*s", index(row,col), len, buf);
110 Jdb_obj_space::print_entry(Address entry)
113 Kobject_iface *o = item(entry, &rights);
125 case L4_fpage::WX: r = '*'; break;
126 case L4_fpage::W: r = 'w'; break;
127 case L4_fpage::X: r = 'x'; break;
129 printf("%05lx%c %-*s", o->dbg_info()->dbg_id(), r, 9, Jdb_kobject::kobject_type(o));
133 printf("%16lx", Mword(o) | rights);
141 Jdb_obj_space::draw_entry(unsigned long row, unsigned long col)
144 printf("%06lx ", index(row, 1));
146 print_entry(index(row, col));
151 Jdb_obj_space::index(unsigned long row, unsigned long col)
153 Mword e = (col-1) + (row * (cols()-1));
159 Jdb_obj_space::handle_user_keys(int c, Kobject_iface *o)
164 bool handled = false;
165 for (Jdb_kobject::Handler_iter h = Jdb_kobject::module()->global_handlers.begin();
166 h != Jdb_kobject::module()->global_handlers.end(); ++h)
167 handled |= h->handle_key(o, c);
169 if (Jdb_kobject_handler *h = Jdb_kobject::module()->find_handler(o))
170 handled |= h->handle_key(o, c);
178 Jdb_obj_space::key_pressed(int c, unsigned long &row, unsigned long &col)
185 if (handle_user_keys(c, item(index(row, col), &rights)))
190 case KEY_CURSOR_HOME: // return to previous or go home
201 Jdb_obj_space::handle_key(Kobject_common *o, int code)
206 Space *t = Kobject::dcast<Task*>(o);
209 Thread *th = Kobject::dcast<Thread_object *>(o);
210 if (!th || !th->space())
222 static Jdb_obj_space jdb_obj_space INIT_PRIORITY(JDB_MODULE_INIT_PRIO);
224 // ------------------------------------------------------------------------
225 IMPLEMENTATION [obj_space_virt]:
229 Jdb_obj_space::item(Address entry, unsigned *rights)
232 Obj_space::Capability *c = _task->cap_virt(entry);
236 Mword mapped = Jdb::peek((Mword*)c, _task, dummy);
241 Kobject_iface *o = (Kobject_iface*)(dummy & ~3UL);
247 // ------------------------------------------------------------------------
248 IMPLEMENTATION [obj_space_phys]:
251 Jdb_obj_space::item(Address entry, unsigned *rights)
253 Obj_space::Capability *c = _task->get_cap(entry);
258 Kobject_iface *o = c->obj();
259 *rights = c->rights();