From 0b96b98294901442de8196e21fff7c5fd79750ef Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Sat, 12 Aug 2017 13:29:56 +0200 Subject: ddb: Add magic variable $mapXX. Maps '$mapXX' to a VM map structure address. @var{xx} is a task identification number printed by a @code{show all tasks} command. * ddb/db_task_thread.c (db_get_map): New function. * ddb/db_task_thread.h (db_get_map): New declaration. * ddb/db_variables.c (db_vars): Add new variable. * doc/mach.texi: Document this. --- ddb/db_task_thread.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'ddb/db_task_thread.c') diff --git a/ddb/db_task_thread.c b/ddb/db_task_thread.c index 7927e674..f7fbb805 100644 --- a/ddb/db_task_thread.c +++ b/ddb/db_task_thread.c @@ -303,4 +303,29 @@ db_get_task_thread( return; } +/* + * convert $mapXXX type DDB variable to map address + */ +void +db_get_map(struct db_variable *vp, + db_expr_t *valuep, + int flag, + db_var_aux_param_t ap) +{ + task_t task; + + if (flag != DB_VAR_GET) { + db_error("Cannot set to $map variable\n"); + /* NOTREACHED */ + } + + if ((task = db_lookup_task_id(ap->suffix[0])) == TASK_NULL) { + db_printf("no such map($map%d)\n", ap->suffix[0]); + db_error(0); + /* NOTREACHED */ + } + + *valuep = (db_expr_t) task->map; +} + #endif /* MACH_KDB */ -- cgit v1.2.3