]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/jdb/jdb_semaphore.cpp
update
[l4.git] / kernel / fiasco / src / jdb / jdb_semaphore.cpp
1 IMPLEMENTATION:
2
3 #include <climits>
4 #include <cstring>
5 #include <cstdio>
6
7 #include "jdb.h"
8 #include "jdb_core.h"
9 #include "jdb_module.h"
10 #include "jdb_screen.h"
11 #include "jdb_kobject.h"
12 #include "kernel_console.h"
13 #include "keycodes.h"
14 #include "simpleio.h"
15 #include "static_init.h"
16 #include "u_semaphore.h"
17
18 class Jdb_semaphore : public Jdb_kobject_handler
19 {
20 public:
21   Jdb_semaphore() FIASCO_INIT;
22 };
23
24 IMPLEMENT
25 Jdb_semaphore::Jdb_semaphore()
26   : Jdb_kobject_handler(U_semaphore::static_kobj_type)
27 {
28   Jdb_kobject::module()->register_handler(this);
29 }
30
31 PUBLIC
32 bool
33 Jdb_semaphore::show_kobject(Kobject_common *, int )
34 {
35   return true;
36 }
37
38 PUBLIC
39 char const *
40 Jdb_semaphore::kobject_type() const
41 {
42   return JDB_ANSI_COLOR(yellow) "Sem" JDB_ANSI_COLOR(default);
43 }
44
45 PUBLIC
46 int
47 Jdb_semaphore::show_kobject_short(char *buf, int max, Kobject_common *o)
48 {
49   U_semaphore *u = Kobject::dcast<U_semaphore*>(o);
50   Prio_list_elem *p = u->_queue.head();
51
52   if (!p)
53     return snprintf(buf, max, " no waiters");
54
55   int len = snprintf(buf, max, " blocked=");
56   while (p)
57     {
58       Prio_list_elem *s = p->_s_next;
59       do
60         {
61           Thread *t = static_cast<Thread *>(Sender::cast(s));
62           len += snprintf(buf + len, max - len,
63                           "%s%lx", s == p ? "" : ",", t->dbg_info()->dbg_id());
64           s = s->_s_next;
65         } while (s != p);
66       p = p->_p_next;
67     }
68   return len;
69 }
70
71 static Jdb_semaphore jdb_semaphore INIT_PRIORITY(JDB_MODULE_INIT_PRIO);