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 +++ b/include/mach/gnumach.defs @@ -27,6 +27,7 @@ subsystem #include #include +#include type vm_cache_statistics_data_t = struct[11] of integer_t; @@ -63,3 +64,11 @@ simpleroutine thread_terminate_release( reply_port : mach_port_name_t; address : vm_address_t; size : vm_size_t); + +/* + * Set the name of task TASK to NAME. This is a debugging aid. + * NAME will be used in error messages printed by the kernel. + */ +simpleroutine task_set_name( + task : task_t; + name : kernel_debug_name_t); diff --git a/kern/task.c b/kern/task.c index 0b5a6f7..66eb25c 100644 --- a/kern/task.c +++ b/kern/task.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -1071,6 +1072,22 @@ task_priority( } /* + * task_set_name + * + * Set the name of task TASK to NAME. This is a debugging aid. + * NAME will be used in error messages printed by the kernel. + */ +kern_return_t +task_set_name( + task_t task, + kernel_debug_name_t name) +{ + strncpy(task->name, name, sizeof task->name - 1); + task->name[sizeof task->name - 1] = '\0'; + return KERN_SUCCESS; +} + +/* * task_collect_scan: * * Attempt to free resources owned by tasks. diff --git a/kern/task.h b/kern/task.h index 7ae10cd..3c10dc0 100644 --- a/kern/task.h +++ b/kern/task.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -169,6 +170,9 @@ extern kern_return_t task_assign( extern kern_return_t task_assign_default( task_t task, boolean_t assign_threads); +extern kern_return_t task_set_name( + task_t task, + kernel_debug_name_t name); extern void consider_task_collect(void); /*