Skip to content

Instantly share code, notes, and snippets.

@seansaleh
Forked from kcbarry/WeenixWorkaround
Last active December 16, 2015 20:39
Show Gist options
  • Save seansaleh/5494027 to your computer and use it in GitHub Desktop.
Save seansaleh/5494027 to your computer and use it in GitHub Desktop.
Add this to the end of kernel/test/kshell/kshell.c and declare it in the associated .h
int kshell_test(kshell_t *ksh,char *command)
{
char *args[10];
int argc = 0;
kshell_get_args(ksh, command, args, KSH_MAX_ARGS, &argc);
kshell_command_t *cmd;
if ((cmd = kshell_lookup_command(args[0], strlen(args[0]))) == NULL) {
kprintf(ksh, "kshell: %s not a valid command\n", args[0]);
return -1;
} else {
return cmd->kc_cmd_func(ksh, argc, args);
}
}
Run the command in the kernel/main/kmain.c after we construct the kshell.
Insert the following function call about line 365 (after "panic("init: Couldn't create kernel shell\n");")
char cmd[100];
strcpy(cmd, "ls");
while(1) {
kshell_test(kshell,cmd);
}
Edit init.gdb and add on line 5
break kshell_test
then to run a command in gdb simply
set command "[your comand here]"
Then type c to run it!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment