00001
00002
00003 #ifndef jdb_tcb_i_h
00004 #define jdb_tcb_i_h
00005
00006 #include <cstdio>
00007 #include "entry_frame.h"
00008 #include "jdb.h"
00009 #include "jdb_input.h"
00010 #include "jdb_module.h"
00011 #include "jdb_screen.h"
00012 #include "kernel_console.h"
00013 #include "keycodes.h"
00014 #include "l4_types.h"
00015 #include "mem_layout.h"
00016 #include "push_console.h"
00017 #include "simpleio.h"
00018 #include "static_init.h"
00019 #include "thread.h"
00020 #include "types.h"
00021
00022 class Jdb_tcb : public Jdb_module
00023 {
00024 static L4_uid threadid;
00025 static Address address;
00026 static char first_char;
00027 static char auto_tcb;
00028
00029 public:
00030 Jdb_tcb();
00031
00032 static Jdb_module::Action_code show(L4_uid tid, int level);
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 Jdb_module::Action_code action(int cmd, void *&args, char const *&fmt, int &next_char);
00062
00063 Jdb_module::Cmd const *const cmds() const;
00064
00065 int const num_cmds() const;
00066
00067 private:
00068 static void at_jdb_enter();
00069
00070 static Address search_bt_start(Address tcb, Mword *ksp, bool is_current_thread);
00071
00072 static void print_entry_frame_regs(Task_num task);
00073
00074 static void info_thread_state(Thread *t, Jdb::Guessed_thread_state state);
00075
00076 static void print_regs_invalid_tid();
00077
00078 static inline void print_thread_uid_raw(Thread *t);
00079 };
00080
00081 class Jdb_tcb_ptr
00082 {
00083 public:
00084 Jdb_tcb_ptr(Address addr)
00085 : _base(addr & ~(Config::thread_block_size-1)),
00086 _offs(addr & (Config::thread_block_size-1))
00087 {}
00088
00089 Jdb_tcb_ptr(Jdb_tcb_ptr &p)
00090 : _base(p.base()), _offs(p.offs())
00091 {}
00092
00093 inline bool valid(Address base)
00094 {
00095 return _base == base &&
00096 _offs <= Config::thread_block_size-sizeof(Mword);
00097 }
00098
00099 bool operator > (int offs)
00100 {
00101 return offs < 0 ? _offs > Config::thread_block_size + offs*sizeof(Mword)
00102 : _offs > offs*sizeof(Mword);
00103 }
00104
00105 Jdb_tcb_ptr &operator += (int offs)
00106 { _offs += offs*sizeof(Mword); return *this; }
00107
00108 inline Address addr()
00109 { return _base + _offs; }
00110
00111 inline Mword value()
00112 { return *(Mword*)(_base + _offs); }
00113
00114 inline void value(Mword v)
00115 { *(Mword*)(_base + _offs) = v; }
00116
00117 inline bool is_user_value()
00118 { return _offs >= Config::thread_block_size - 5*sizeof(Mword); }
00119
00120 inline Mword top_value(int offs)
00121 { return *((Mword*)(_base + Config::thread_block_size) + offs); }
00122
00123 inline Address base()
00124 { return _base; }
00125
00126 inline Address offs()
00127 { return _offs; }
00128
00129 inline void offs(Address offs)
00130 { _offs = offs; }
00131
00132 private:
00133 Address _base;
00134 Address _offs;
00135
00136 public:
00137 bool in_backtrace(Address bt_start, Address tcb);
00138 };
00139
00140
00141
00142
00143
00144
00145
00146
00147 inline void
00148 Jdb_tcb::print_thread_uid_raw(Thread *t)
00149 {
00150 printf(" <%08x %08x>",
00151 (Unsigned32)(t->id().raw() >> 32), (Unsigned32)(t->id().raw()));
00152 }
00153
00154 #endif // jdb_tcb_i_h