From 29fa60bd23ed84a470c7ebc7e0b031c136f3cf33 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 13 Sep 2014 01:32:13 +0200 Subject: [PATCH 3/3] ddb: add `kill' command * ddb/db_command.c (db_command_table): Add a `kill' command to terminate tasks. * ddb/db_task_thread.c (db_task_terminate): New function. * ddb/db_task_thread.h (db_task_terminate): New declaration. --- ddb/db_command.c | 1 + ddb/db_task_thread.c | 18 ++++++++++++++++++ ddb/db_task_thread.h | 7 +++++++ 3 files changed, 26 insertions(+) diff --git a/ddb/db_command.c b/ddb/db_command.c index 5651667..74f191b 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -362,6 +362,7 @@ struct db_command db_command_table[] = { { "macro", db_def_macro_cmd, CS_OWN, 0 }, { "dmacro", db_del_macro_cmd, CS_OWN, 0 }, { "show", 0, 0, db_show_cmds }, + { "kill", db_task_terminate, 0, 0 }, { "reset", db_reset_cpu, 0, 0 }, { "reboot", db_reset_cpu, 0, 0 }, { "halt", db_halt_cpu, 0, 0 }, diff --git a/ddb/db_task_thread.c b/ddb/db_task_thread.c index 97c81c8..5309d73 100644 --- a/ddb/db_task_thread.c +++ b/ddb/db_task_thread.c @@ -317,4 +317,22 @@ db_get_task_thread( return; } +/* ARGSUSED */ +void +db_task_terminate(db_expr_t addr, + boolean_t have_addr, + db_expr_t count, + const char *modif) +{ + task_t task = (task_t) addr; + + if (! have_addr) + db_error("No task\n"); + + if (! db_check_task_address_valid(task)) + db_error(0); + + task_terminate(task); +} + #endif /* MACH_KDB */ diff --git a/ddb/db_task_thread.h b/ddb/db_task_thread.h index 18f1957..c095aac 100644 --- a/ddb/db_task_thread.h +++ b/ddb/db_task_thread.h @@ -65,4 +65,11 @@ db_get_task_thread( int flag, db_var_aux_param_t ap); +extern void +db_task_terminate( + db_expr_t addr, + boolean_t have_addr, + db_expr_t count, + const char *modif); + #endif /* _DDB_DB_TASK_THREAD_H_ */ -- 2.1.0