6.828: Operating System Engineering (22)
ええと monitor にコマンド盛り込め、とあります。
monitor な REPL 実装が以下。
void monitor(struct Trapframe *tf) { char *buf; cprintf("Welcome to the JOS kernel monitor!\n"); cprintf("Type 'help' for a list of commands.\n"); while (1) { buf = readline("K> "); if (buf != NULL) if (runcmd(buf, tf) < 0) break; } }
runcmd の中の詳細はスルーとして最終的に apply されるのは以下らしい。
return commands[i].func(argc, argv, tf);
commands という配列の定義周辺が以下な模様。
struct Command { const char *name; const char *desc; // return -1 to force monitor to exit int (*func)(int argc, char** argv, struct Trapframe* tf); }; static struct Command commands[] = { { "help", "Display this list of commands", mon_help }, { "kerninfo", "Display information about the kernel", mon_kerninfo }, };
struct Trapframe って何だ。って monitor.h で以下な定義。
struct Trapframe;
うーん。コマンドをタタいた時点の eip ってどこになるのかなぁ。mon_backtrace が runcmd の直後に定義されるカンジなのかなぁ。
場所は良いとしてどう wrap すれば良いのでしょうか。って mon_backtrace はスデに書いてますね。どう書きかえれば良いのだろうかというあたりは明日ってことでw