summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2017-08-12 13:29:56 +0200
committerJustus Winter <justus@gnupg.org>2017-08-12 13:29:56 +0200
commit0b96b98294901442de8196e21fff7c5fd79750ef (patch)
tree984ca7c720f9f22eb24e94452f3bed1a37935c85
parent2996a4cfe987e6feb7c705354908ae2e59366d65 (diff)
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.
-rw-r--r--ddb/db_task_thread.c25
-rw-r--r--ddb/db_task_thread.h6
-rw-r--r--ddb/db_variables.c2
-rw-r--r--doc/mach.texi5
4 files changed, 38 insertions, 0 deletions
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 */
diff --git a/ddb/db_task_thread.h b/ddb/db_task_thread.h
index cbb36802..55ab4f53 100644
--- a/ddb/db_task_thread.h
+++ b/ddb/db_task_thread.h
@@ -64,4 +64,10 @@ db_get_task_thread(
int flag,
db_var_aux_param_t ap);
+extern void
+db_get_map(struct db_variable *vp,
+ db_expr_t *valuep,
+ int flag,
+ db_var_aux_param_t ap);
+
#endif /* _DDB_DB_TASK_THREAD_H_ */
diff --git a/ddb/db_variables.c b/ddb/db_variables.c
index 4442ccbc..0fd9bad0 100644
--- a/ddb/db_variables.c
+++ b/ddb/db_variables.c
@@ -61,6 +61,8 @@ struct db_variable db_vars[] = {
{ "thread", 0, db_set_default_thread },
{ "task", 0, db_get_task_thread,
1, 2, -1, -1 },
+ { "map", 0, db_get_map,
+ 1, 1, -1, -1 },
{ "work", &db_work[0], FCN_NULL,
1, 1, 0, DB_NWORK-1 },
{ "arg", 0, db_arg_variable,
diff --git a/doc/mach.texi b/doc/mach.texi
index b2357b81..913e8bbd 100644
--- a/doc/mach.texi
+++ b/doc/mach.texi
@@ -7155,6 +7155,11 @@ Task or thread structure address. @var{xx} and @var{yy} are task and
thread identification numbers printed by a @code{show all threads}
command respectively. This variable is read only.
+@item map@var{xx}
+VM map structure address. @var{xx} is a task identification number
+printed by a @code{show all tasks} command. This variable is read
+only.
+
@item thread
The default target thread. The value is used when @code{t} option is
specified without explicit thread structure address parameter in command