commit 69a54ed402c9a818198cc6e7b06596ccfef75e84
parent bbd348c95804d6e2bf84beb8081a2fb6aef98b54
Author: Dimitris Papastamos <dimitris.papastamos@arm.com>
Date: Wed, 7 Nov 2018 16:25:42 +0000
[debuglang] Add exit command
Change-Id: Ifce82c69ed6bf5f2ad719b54567a105304ad27f8
Signed-off-by: Dimitris Papastamos <dimitris.papastamos@arm.com>
Diffstat:
4 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/arch/amd64/ram.c b/arch/amd64/ram.c
@@ -4,6 +4,5 @@ int
main(int argc, char *argv[])
{
bss->fp = &(struct trapframe) {0};
- debug();
- return 0;
+ return debug();
}
diff --git a/arch/amd64/rom.c b/arch/amd64/rom.c
@@ -4,6 +4,5 @@ int
main(int argc, char *argv[])
{
bss->fp = &(struct trapframe) {0};
- debug();
- return 0;
+ return debug();
}
diff --git a/include/rcode.h b/include/rcode.h
@@ -160,7 +160,7 @@ extern void printk(const char * restrict fmt, ...) PRINTKFMT;
extern void rmc(Rmucmd *cmd);
extern _Noreturn void doswtch(struct trapframe *fp);
extern _Noreturn void swtch(struct trapframe *fp);
-extern void debug(void);
+extern int debug(void);
/* architectural functions */
extern _Noreturn void halt(void);
diff --git a/src/debuglang/debuglang.c b/src/debuglang/debuglang.c
@@ -17,6 +17,7 @@
struct args {
char *argv[NR_ARGC_MAX];
int argc;
+ int status;
};
struct cmd {
@@ -244,7 +245,23 @@ do_rmc(struct args *args)
}
static int
-do_help(char **argv, int argc)
+do_exit(struct args *args)
+{
+ switch (args->argc) {
+ case 2:
+ args->status = estrtoull(args->argv[1], 0);
+ break;
+ case 1:
+ args->status = 0;
+ break;
+ default:
+ error("usage: exit [status]");
+ }
+ return -1;
+}
+
+static int
+do_help(struct args *args)
{
const struct cmd *cmd;
@@ -299,7 +316,7 @@ run(struct args *args)
return -1;
}
-void
+int
debug(void)
{
struct args args;
@@ -311,8 +328,7 @@ debug(void)
printf("begin debug language interface\n");
setjmp(bss->dbgrecover);
-
- for (ready(); run(&args) == 0; ready())
+ for (ready(); !run(&args); ready())
;
if (ferror(stdout))
@@ -320,6 +336,7 @@ debug(void)
if (ferror(stdin))
puts("debug language interface: error reading from stdin");
printf("end debug language interface\n");
+ return args.status;
}
/*
@@ -352,6 +369,11 @@ static const struct cmd cmds[] = {
.helpmsg = "Call RMC handler: rmc",
},
{
+ .name = "exit",
+ .eval = do_exit,
+ .helpmsg = "Exit debug environment: exit",
+ },
+ {
.name = "help",
.eval = do_help,
.helpmsg = "Print this help menu: help",