summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2017-04-02 00:13:56 +0200
committerJustus Winter <justus@gnupg.org>2017-08-05 17:08:36 +0200
commite8b45fe8b5c6801f60e2825d09a2bda22e80372a (patch)
tree3a2c1ebf8d9e5deb402f491776f9617ca4b6a4cc
parentc9f2f450f92528f04ee00ead0a3fd79b475f2d2c (diff)
ddb: debug traps and port references
* ddb/db_command.c (db_debug_all_traps_cmd): New declaration and function. (db_debug_port_references_cmd): Likewise. * doc/mach.texi: Describe new commands. * i386/i386/db_interface.h (db_debug_all_traps): New declaration. * i386/i386/trap.c (db_debug_all_traps): New function. * ipc/mach_port.c (db_debug_port_references): New function. * ipc/mach_port.h (db_debug_port_references): New declaration.
-rw-r--r--ddb/db_command.c46
-rw-r--r--doc/mach.texi8
-rw-r--r--i386/i386/db_interface.h2
-rw-r--r--i386/i386/trap.c10
-rw-r--r--ipc/mach_port.c10
-rw-r--r--ipc/mach_port.h4
6 files changed, 80 insertions, 0 deletions
diff --git a/ddb/db_command.c b/ddb/db_command.c
index 721f04fe..11bca7ac 100644
--- a/ddb/db_command.c
+++ b/ddb/db_command.c
@@ -332,6 +332,23 @@ struct db_command db_show_cmds[] = {
{ (char *)0, }
};
+void
+db_debug_all_traps_cmd(db_expr_t addr,
+ int have_addr,
+ db_expr_t count,
+ const char *modif);
+void
+db_debug_port_references_cmd(db_expr_t addr,
+ int have_addr,
+ db_expr_t count,
+ const char *modif);
+
+struct db_command db_debug_cmds[] = {
+ { "traps", db_debug_all_traps_cmd, 0, 0 },
+ { "references", db_debug_port_references_cmd, 0, 0 },
+ { (char *)0, }
+};
+
struct db_command db_command_table[] = {
#ifdef DB_MACHINE_COMMANDS
/* this must be the first entry, if it exists */
@@ -364,6 +381,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 },
+ { "debug", 0, 0, db_debug_cmds },
{ "reset", db_reset_cpu, 0, 0 },
{ "reboot", db_reset_cpu, 0, 0 },
{ "halt", db_halt_cpu, 0, 0 },
@@ -538,4 +556,32 @@ db_option(modif, option)
return(FALSE);
}
+void
+db_debug_all_traps_cmd(db_expr_t addr,
+ int have_addr,
+ db_expr_t count,
+ const char *modif)
+{
+ if (strcmp (modif, "on") == 0)
+ db_debug_all_traps (TRUE);
+ else if (strcmp (modif, "off") == 0)
+ db_debug_all_traps (FALSE);
+ else
+ db_error ("debug traps /on|/off\n");
+}
+
+void
+db_debug_port_references_cmd(db_expr_t addr,
+ int have_addr,
+ db_expr_t count,
+ const char *modif)
+{
+ if (strcmp (modif, "on") == 0)
+ db_debug_port_references (TRUE);
+ else if (strcmp (modif, "off") == 0)
+ db_debug_port_references (FALSE);
+ else
+ db_error ("debug references /on|/off\n");
+}
+
#endif /* MACH_KDB */
diff --git a/doc/mach.texi b/doc/mach.texi
index 1f13b12c..b2357b81 100644
--- a/doc/mach.texi
+++ b/doc/mach.texi
@@ -7125,6 +7125,14 @@ If you want to clear a watch point in user space, specify @code{T} and
parameter is omitted, a task of the default target thread or a current
task is assumed. If you specify a wrong space address, the request is
rejected with an error message.
+
+@item debug traps /on|/off
+Enables or disables debugging of all traps with @code{ddb}.
+
+@item debug references /on|/off
+Enables or disables debugging of all port reference counting errors
+with @code{ddb}.
+
@end table
diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h
index 8d7daeae..9ffb6a60 100644
--- a/i386/i386/db_interface.h
+++ b/i386/i386/db_interface.h
@@ -129,4 +129,6 @@ db_write_bytes_user_space(
char *data,
task_t task);
+void db_debug_all_traps (boolean_t enable);
+
#endif /* _I386_DB_INTERFACE_H_ */
diff --git a/i386/i386/trap.c b/i386/i386/trap.c
index d4bdc7f2..d3f61314 100644
--- a/i386/i386/trap.c
+++ b/i386/i386/trap.c
@@ -626,3 +626,13 @@ interrupted_pc(t)
return iss->eip;
}
#endif /* MACH_PCSAMPLE > 0 */
+
+#if MACH_KDB
+
+void
+db_debug_all_traps (boolean_t enable)
+{
+ debug_all_traps_with_kdb = enable;
+}
+
+#endif /* MACH_KDB */
diff --git a/ipc/mach_port.c b/ipc/mach_port.c
index 5cc39984..b30dcd6c 100644
--- a/ipc/mach_port.c
+++ b/ipc/mach_port.c
@@ -1566,3 +1566,13 @@ mach_port_clear_protected_payload(
ip_unlock(port);
return KERN_SUCCESS;
}
+
+#if MACH_KDB
+
+void
+db_debug_port_references (boolean_t enable)
+{
+ mach_port_deallocate_debug = enable;
+}
+
+#endif /* MACH_KDB */
diff --git a/ipc/mach_port.h b/ipc/mach_port.h
index c4d9a1c3..073f7946 100644
--- a/ipc/mach_port.h
+++ b/ipc/mach_port.h
@@ -65,4 +65,8 @@ mach_port_get_receive_status(
mach_port_t name,
mach_port_status_t *statusp);
+#if MACH_KDB
+void db_debug_port_references (boolean_t enable);
+#endif /* MACH_KDB */
+
#endif /* _IPC_MACH_PORT_H_ */