]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/jdb/jdb_trap_state.cpp
4ada7aab1227cff3cc335520c6fa07174611dcc2
[l4.git] / kernel / fiasco / src / jdb / jdb_trap_state.cpp
1 IMPLEMENTATION:
2
3 #include <cstdio>
4 #include "simpleio.h"
5
6 #include "jdb.h"
7 #include "jdb_module.h"
8 #include "static_init.h"
9 #include "types.h"
10
11
12 /**
13  * Private 'exit' module.
14  * 
15  * This module handles the 'exit' or '^' command that
16  * makes a call to exit() and virtually reboots the system.
17  */
18 class Jdb_trap_state_module : public Jdb_module
19 {
20 public:
21   Jdb_trap_state_module() FIASCO_INIT;
22 };
23
24 static Jdb_trap_state_module jdb_trap_state_module INIT_PRIORITY(JDB_MODULE_INIT_PRIO);
25
26
27 PRIVATE static
28 void
29 Jdb_trap_state_module::print_trap_state(unsigned cpu)
30 {
31   Jdb_entry_frame *ef = Jdb::entry_frame.cpu(cpu);
32   if (!Jdb::cpu_in_jdb(cpu) || !ef)
33     printf("CPU %u has not entered JDB\n", cpu);
34   else
35     {
36       printf("Registers of CPU %u (before entering JDB)\n", cpu);
37       ef->dump();
38     }
39 }
40
41 PUBLIC
42 Jdb_module::Action_code
43 Jdb_trap_state_module::action (int cmd, void *&argbuf, char const *&fmt, int &next)
44 {
45   char const *c = (char const *)argbuf;
46   static unsigned cpu;
47
48   if (cmd != 0)
49     return NOTHING;
50
51   if (argbuf != &cpu)
52     {
53       if (*c == 'a')
54         Jdb::foreach_cpu(&print_trap_state);
55       else if (*c >= '0' && *c <= '9')
56         {
57           next = *c; argbuf = &cpu; fmt = "%i";
58           return EXTRA_INPUT_WITH_NEXTCHAR;
59         }
60     }
61   else
62     print_trap_state(cpu);
63
64   return NOTHING;
65 }
66
67 PUBLIC
68 int
69 Jdb_trap_state_module::num_cmds() const
70 {
71   return 1;
72 }
73
74 PUBLIC
75 Jdb_module::Cmd const *
76 Jdb_trap_state_module::cmds() const
77 {
78   static char c;
79   static Cmd cs[] =
80     { { 0, "", "cpustate", "%C", "cpustate all|<cpunum>\tdump state of CPU", &c } };
81
82   return cs;
83 }
84
85 IMPLEMENT
86 Jdb_trap_state_module::Jdb_trap_state_module()
87   : Jdb_module("INFO")
88 {}