]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/jdb/jdb-thread.cpp
update
[l4.git] / kernel / fiasco / src / jdb / jdb-thread.cpp
1 INTERFACE:
2
3 class Space;
4
5 EXTENSION class Jdb
6 {
7 public:
8   /**
9    * Deliver Thread object which was active at entry of kernel debugger.
10    * If we came from the kernel itself, return Thread with id 0.0
11    */
12   static Thread *get_thread(unsigned cpu);
13 };
14
15 //---------------------------------------------------------------------------
16 IMPLEMENTATION:
17
18 #include "jdb_prompt_ext.h"
19 #include "jdb.h"
20 #include "thread.h"
21
22 class Jdb_tid_ext : public Jdb_prompt_ext
23 {
24 public:
25   void ext();
26   void update();
27 };
28
29 IMPLEMENT
30 void
31 Jdb_tid_ext::ext()
32 {
33   if (Jdb::get_current_active())
34     printf("(%p) ", Jdb::get_current_active());
35 }
36
37 IMPLEMENT
38 void
39 Jdb_tid_ext::update()
40 {
41   Jdb::get_current(Jdb::current_cpu);
42 }
43
44 //static Jdb_tid_ext jdb_tid_ext INIT_PRIORITY(JDB_MODULE_INIT_PRIO);
45
46 //---------------------------------------------------------------------------
47 IMPLEMENTATION [arm || ux || ppc32 || sparc]:
48
49 #include "mem_layout.h"
50
51 IMPLEMENT
52 Thread *
53 Jdb::get_thread(unsigned cpu)
54 {
55   Jdb_entry_frame *c = get_entry_frame(cpu);
56
57   return static_cast<Thread*>(context_of(c));
58 }
59
60 //---------------------------------------------------------------------------
61 IMPLEMENTATION:
62
63 #include "jdb.h"
64 #include "thread.h"
65
66 PUBLIC
67 static void
68 Jdb::get_current(unsigned cpu)
69 {
70   current_active = get_thread(cpu);
71 }
72
73 PUBLIC static inline NEEDS["thread.h"]
74 Space*
75 Jdb::get_current_space()
76 {
77   return current_active ? current_active->space() : 0;
78 }