diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-02-02 13:52:32 +0100 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-02-02 13:52:32 +0100 |
commit | 65858b52a568b1f2776806fba2fbec6c83a962fd (patch) | |
tree | 29b3e4ec84ef3b2eaacd5fd0d6ac98fdebca90e5 | |
parent | fc0e3e88b94d2a02877ad2dccd5b2725ebe7e7bf (diff) |
update feature-task-name.patch
-rw-r--r-- | debian/patches/feature-task-name.patch | 175 |
1 files changed, 28 insertions, 147 deletions
diff --git a/debian/patches/feature-task-name.patch b/debian/patches/feature-task-name.patch index 77ee2ca..22f2788 100644 --- a/debian/patches/feature-task-name.patch +++ b/debian/patches/feature-task-name.patch @@ -1,3 +1,25 @@ +diff --git a/doc/mach.texi b/doc/mach.texi +index 9ad9e70..d089224 100644 +--- a/doc/mach.texi ++++ b/doc/mach.texi +@@ -5037,6 +5037,17 @@ total system run time for live threads + This is a pointer to a @code{struct task_thread_times_info}. + @end deftp + ++@deftypefun kern_return_t task_set_name (@w{task_t @var{target_task}}, @w{kernel_debug_name_t @var{name}}) ++ ++The function @code{task_set_name} sets the name of @var{target_task} ++to @var{name}, truncating it if necessary. ++ ++This is a debugging aid. The name is used in diagnostic messages ++printed by the kernel. ++ ++The function returns @code{KERN_SUCCESS} if the call succeeded. ++@end deftypefun ++ + + @node Task Execution + @subsection Task Execution diff --git a/include/mach/gnumach.defs b/include/mach/gnumach.defs index 12c4e99..6cfbb0d 100644 --- a/include/mach/gnumach.defs @@ -22,110 +44,8 @@ index 12c4e99..6cfbb0d 100644 +simpleroutine task_set_name( + task : task_t; + name : kernel_debug_name_t); -diff --git a/include/mach_debug/mach_debug_types.defs b/include/mach_debug/mach_debug_types.defs -index f60125a..d24b6f9 100644 ---- a/include/mach_debug/mach_debug_types.defs -+++ b/include/mach_debug/mach_debug_types.defs -@@ -57,6 +57,8 @@ type vm_page_info_array_t = array[] of vm_page_info_t; - - type symtab_name_t = (MACH_MSG_TYPE_STRING_C, 8*32); - -+type kernel_debug_name_t = c_string[*: 64]; -+ - import <mach_debug/mach_debug_types.h>; - - #endif /* _MACH_DEBUG_MACH_DEBUG_TYPES_DEFS_ */ -diff --git a/include/mach_debug/mach_debug_types.h b/include/mach_debug/mach_debug_types.h -index 5d4efcd..9c7d1fd 100644 ---- a/include/mach_debug/mach_debug_types.h -+++ b/include/mach_debug/mach_debug_types.h -@@ -37,4 +37,15 @@ - - typedef char symtab_name_t[32]; - -+/* -+ * A fixed-length string data type intended for names given to -+ * kernel objects. -+ * -+ * Note that it is not guaranteed that the in-kernel data -+ * structure will hold KERNEL_DEBUG_NAME_MAX bytes. The given -+ * name will be truncated to fit into the target data structure. -+ */ -+#define KERNEL_DEBUG_NAME_MAX (64) -+typedef char kernel_debug_name_t[KERNEL_DEBUG_NAME_MAX]; -+ - #endif /* _MACH_DEBUG_MACH_DEBUG_TYPES_H_ */ -diff --git a/ipc/mach_port.c b/ipc/mach_port.c -index fbc5e69..891d2f2 100644 ---- a/ipc/mach_port.c -+++ b/ipc/mach_port.c -@@ -571,7 +571,7 @@ mach_port_destroy( - kr = ipc_right_lookup_write(space, name, &entry); - if (kr != KERN_SUCCESS) { - if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD && space == current_space()) { -- printf("task %p destroying an invalid port %lu, most probably a bug.\n", current_task(), name); -+ printf("task %.*s destroying an invalid port %lu, most probably a bug.\n", TASK_NAME_SIZE, current_task()->name, name); - if (mach_port_deallocate_debug) - SoftDebugger("mach_port_deallocate"); - } -@@ -615,7 +615,7 @@ mach_port_deallocate( - kr = ipc_right_lookup_write(space, name, &entry); - if (kr != KERN_SUCCESS) { - if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD && space == current_space()) { -- printf("task %p deallocating an invalid port %lu, most probably a bug.\n", current_task(), name); -+ printf("task %.*s deallocating an invalid port %lu, most probably a bug.\n", TASK_NAME_SIZE, current_task()->name, name); - if (mach_port_deallocate_debug) - SoftDebugger("mach_port_deallocate"); - } -diff --git a/kern/printf.c b/kern/printf.c -index af59d5a..ea78d48 100644 ---- a/kern/printf.c -+++ b/kern/printf.c -@@ -615,6 +615,16 @@ vsnprintf(char *buf, size_t size, const char *fmt, va_list args) - return cookie.index; - } - -+int -+snprintf(char *buf, size_t size, const char *fmt, ...) -+{ -+ int written; -+ va_list listp; -+ va_start(listp, fmt); -+ written = vsnprintf(buf, size, fmt, listp); -+ va_end(listp); -+ return written; -+} - - void safe_gets(str, maxlen) - char *str; -diff --git a/kern/printf.h b/kern/printf.h -index 8b4e760..0f8b328 100644 ---- a/kern/printf.h -+++ b/kern/printf.h -@@ -40,6 +40,7 @@ extern void printnum (unsigned long u, int base, - vm_offset_t putc_arg); - - extern int sprintf (char *buf, const char *fmt, ...); -+extern int snprintf (char *buf, size_t size, const char *fmt, ...); - extern int vsnprintf (char *buf, size_t size, const char *fmt, va_list args); - - extern int printf (const char *fmt, ...); -diff --git a/kern/slab.c b/kern/slab.c -index d1e3632..3fc95b6 100644 ---- a/kern/slab.c -+++ b/kern/slab.c -@@ -662,7 +662,8 @@ static void kmem_cache_error(struct kmem_cache *cache, void *buf, int error, - { - struct kmem_buftag *buftag; - -- kmem_error("cache: %s, buffer: %p", cache->name, (void *)buf); -+ kmem_error("cache: %.*s, buffer: %p", KMEM_CACHE_NAME_SIZE, cache->name, -+ (void *)buf); - - switch(error) { - case KMEM_ERR_INVALID: diff --git a/kern/task.c b/kern/task.c -index 13b3c76..82848b2 100644 +index 0b5a6f7..66eb25c 100644 --- a/kern/task.c +++ b/kern/task.c @@ -37,6 +37,7 @@ @@ -136,24 +56,7 @@ index 13b3c76..82848b2 100644 #include <ipc/ipc_space.h> #include <ipc/ipc_types.h> #include <kern/debug.h> -@@ -45,6 +46,7 @@ - #include <kern/slab.h> - #include <kern/kalloc.h> - #include <kern/processor.h> -+#include <kern/printf.h> - #include <kern/sched_prim.h> /* for thread_wakeup */ - #include <kern/ipc_tt.h> - #include <kern/syscall_emulation.h> -@@ -164,6 +166,8 @@ kern_return_t task_create( - } - #endif /* FAST_TAS */ - -+ snprintf (new_task->name, TASK_NAME_SIZE, "%p", new_task); -+ - ipc_task_enable(new_task); - - *child_task = new_task; -@@ -1068,6 +1072,21 @@ task_priority( +@@ -1071,6 +1072,22 @@ task_priority( } /* @@ -167,7 +70,8 @@ index 13b3c76..82848b2 100644 + task_t task, + kernel_debug_name_t name) +{ -+ strncpy(task->name, name, sizeof task->name); ++ strncpy(task->name, name, sizeof task->name - 1); ++ task->name[sizeof task->name - 1] = '\0'; + return KERN_SUCCESS; +} + @@ -176,7 +80,7 @@ index 13b3c76..82848b2 100644 * * Attempt to free resources owned by tasks. diff --git a/kern/task.h b/kern/task.h -index e852033..3c10dc0 100644 +index 7ae10cd..3c10dc0 100644 --- a/kern/task.h +++ b/kern/task.h @@ -39,6 +39,7 @@ @@ -187,30 +91,7 @@ index e852033..3c10dc0 100644 #include <kern/kern_types.h> #include <kern/lock.h> #include <kern/queue.h> -@@ -48,6 +49,13 @@ - #include <vm/vm_types.h> - #include <machine/task.h> - -+/* -+ * Task name buffer size. The size is chosen so that struct task fits -+ * into three cache lines. The size of a cache line on a typical CPU -+ * is 64 bytes. -+ */ -+#define TASK_NAME_SIZE 32 -+ - struct task { - /* Synchronization/destruction information */ - decl_simple_lock_data(,lock) /* Task's lock */ -@@ -113,6 +121,8 @@ struct task { - natural_t cow_faults; /* copy-on-write faults counter */ - natural_t messages_sent; /* messages sent counter */ - natural_t messages_received; /* messages received counter */ -+ -+ char name[TASK_NAME_SIZE]; - }; - - #define task_lock(task) simple_lock(&(task)->lock) -@@ -160,6 +170,9 @@ extern kern_return_t task_assign( +@@ -169,6 +170,9 @@ extern kern_return_t task_assign( extern kern_return_t task_assign_default( task_t task, boolean_t assign_threads); |