From d02440f8f61ea93585a7837bb7492600b658cf2b Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Tue, 5 Jan 2016 23:18:56 +0100 Subject: [PATCH] add env variable HERMIT_LOG - if HERMIT_LOG is set, the proxy dumps after the termination of the process the kernel log --- hermit/tools/proxy.c | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/hermit/tools/proxy.c b/hermit/tools/proxy.c index 97b2dd5a9..891229a8e 100644 --- a/hermit/tools/proxy.c +++ b/hermit/tools/proxy.c @@ -139,6 +139,53 @@ static int init_env(void) return 0; } +static void dump_log(void) +{ + char isle_path[MAX_PATH]; + char* str = getenv("HERMIT_VERBOSE"); + FILE* file; + char line[2048]; + + if (!str) + return; + + snprintf(isle_path, MAX_PATH, "/sys/hermit/isle%d/log", isle_nr); + file = fopen(isle_path, "r"); + if (!file) { + perror("fopen"); + return; + } + + puts("\nDump kernel log:"); + puts("================\n"); + + while(fgets(line, 2048, file)) { + printf("%s", line); + } + + fclose(file); +} + +static void stop_kermit(void) +{ +#if 0 + FILE* file; + char isle_path[MAX_PATH]; + + snprintf(isle_path, MAX_PATH, "/sys/hermit/isle%d/cpus", isle_nr); + + file = fopen(isle_path, "w"); + if (!file) { + perror("fopen"); + return; + } + + fprintf(file, "-1"); + + fclose(file); +#endif +} + /* * in principle, HermitCore forwards basic system calls to * this proxy, which mapped these call to Linux system calls. @@ -163,6 +210,10 @@ int handle_syscalls(int s) if (ret < 0) goto out; close(s); + + dump_log(); + stop_kermit(); + exit(arg); break; }