From bd4b19f8a7ca6cfc125c5e8072ad114242494e6e Mon Sep 17 00:00:00 2001 From: Gerard Wagener Date: Mon, 18 Jan 2010 16:13:21 +0100 Subject: [PATCH] Kernel logs when thread ends --- arch/um/include/shared/aha.h | 2 ++ arch/um/kernel/aha.c | 30 ++++++++++++++++++++++++++++++ arch/um/kernel/process.c | 2 ++ 3 files changed, 34 insertions(+) diff --git a/arch/um/include/shared/aha.h b/arch/um/include/shared/aha.h index f3f36b673e9..51688dbf30e 100644 --- a/arch/um/include/shared/aha.h +++ b/arch/um/include/shared/aha.h @@ -17,6 +17,7 @@ struct ReplyMessage{ #define EXECVE_MESSAGE 1 #define CLONE_MESSAGE 2 +#define EXIT_MESSAGE 3 #ifdef AHA_DEBUG #define AHA_PRINTK(args...) printk(args) #else @@ -30,4 +31,5 @@ void aha_handle_insult_messages(struct ReplyMessage *msg, char __user* file,\ char __user* __user* argv); void aha_get_reply_message(char* key, struct ReplyMessage *msg); void aha_record_sys_clone(int pid, int ppid); +void aha_dump_exits(void); #endif diff --git a/arch/um/kernel/aha.c b/arch/um/kernel/aha.c index d21a611ecef..0aa62eb9de2 100644 --- a/arch/um/kernel/aha.c +++ b/arch/um/kernel/aha.c @@ -232,3 +232,33 @@ void aha_record_sys_clone(int pid, int ppid) #undef buf__size } +/* Tracks if a thread exits, aiming to free up pids in the process trees + * Process trees are internally read fronm task_struct + */ +void aha_dump_exits(void) +{ + int mode = 0644; + int fd; + struct openflags flg; + char filename[32]; + char qn[64]; + char buf[16]; + flg.w = 1; + flg.c = 1; + if (aha_create_filename((char*)&filename,32)>0){ + /* Put message in output queue */ + if (snprintf((char*)&qn,64,"out/%s",filename)>0){ + if ((fd = os_open_file(qn,flg,mode))>0){ + __aha_set_type_tag(fd,(char*)&buf,16,EXIT_MESSAGE); + __aha_dump_pid_ppids(fd,(char*)&buf,16); + __aha_set_done_tag (fd,(char*)&buf,16); + os_close_file(fd); + } + }else{ + AHA_PRINTK("record-exit: Could not put filename in output queue\n"); + } + }else{ + AHA_PRINTK("record-exit: No filename could be generated\n"); + } +} + diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index 2f910a1b745..299a3338b52 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c @@ -26,6 +26,7 @@ #include "os.h" #include "skas.h" #include "tlb.h" +#include "shared/aha.h" /* * This is a per-cpu array. A processor only modifies its entry and it only @@ -123,6 +124,7 @@ void interrupt_end(void) void exit_thread(void) { + aha_dump_exits(); } void *get_current(void)