summaryrefslogtreecommitdiffstats
path: root/sys/ddb
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2011-06-07 01:28:12 +0000
committermarcel <marcel@FreeBSD.org>2011-06-07 01:28:12 +0000
commit36b8c5d486fa809443a7d522780bf3c5a6f70393 (patch)
tree123206d93a57192e589e8defa20d16df50330db7 /sys/ddb
parent2bf7ed6fc0e8d175dd13da2f68d538ee3facb919 (diff)
downloadFreeBSD-src-36b8c5d486fa809443a7d522780bf3c5a6f70393.zip
FreeBSD-src-36b8c5d486fa809443a7d522780bf3c5a6f70393.tar.gz
Fix making kernel dumps from the debugger by creating a command
for it. Do not not expect a developer to call doadump(). Calling doadump does not necessarily work when it's declared static. Nor does it necessarily do what was intended in the context of text dumps. The dump command always creates a core dump. Move printing of error messages from doadump to the dump command, now that we don't have to worry about being called from DDB.
Diffstat (limited to 'sys/ddb')
-rw-r--r--sys/ddb/db_command.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c
index 21cb7c5..f2e2c42 100644
--- a/sys/ddb/db_command.c
+++ b/sys/ddb/db_command.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <sys/signalvar.h>
#include <sys/systm.h>
#include <sys/cons.h>
+#include <sys/conf.h>
#include <sys/watchdog.h>
#include <sys/kernel.h>
@@ -64,6 +65,7 @@ db_addr_t db_last_addr;
db_addr_t db_prev;
db_addr_t db_next;
+static db_cmdfcn_t db_dump;
static db_cmdfcn_t db_fncall;
static db_cmdfcn_t db_gdb;
static db_cmdfcn_t db_halt;
@@ -102,6 +104,7 @@ static struct command db_cmds[] = {
{ "w", db_write_cmd, CS_MORE|CS_SET_DOT, 0 },
{ "delete", db_delete_cmd, 0, 0 },
{ "d", db_delete_cmd, 0, 0 },
+ { "dump", db_dump, 0, 0 },
{ "break", db_breakpoint_cmd, 0, 0 },
{ "b", db_breakpoint_cmd, 0, 0 },
{ "dwatch", db_deletewatch_cmd, 0, 0 },
@@ -526,6 +529,27 @@ db_error(s)
kdb_reenter();
}
+static void
+db_dump(db_expr_t dummy, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
+{
+ int error;
+
+ error = doadump(FALSE);
+ if (error) {
+ db_printf("Cannot dump: ");
+ switch (error) {
+ case EBUSY:
+ db_printf("debugger got invoked while dumping.\n");
+ break;
+ case ENXIO:
+ db_printf("no dump device specified.\n");
+ break;
+ default:
+ db_printf("unknown error (error=%d).\n", error);
+ break;
+ }
+ }
+}
/*
* Call random function:
OpenPOWER on IntegriCloud