summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_shutdown.c
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/kern/kern_shutdown.c
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/kern/kern_shutdown.c')
-rw-r--r--sys/kern/kern_shutdown.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index 001da3d..da041fa 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -233,30 +233,32 @@ print_uptime(void)
printf("%lds\n", (long)ts.tv_sec);
}
-static void
-doadump(void)
+int
+doadump(boolean_t textdump)
{
+ boolean_t coredump;
- /*
- * Sometimes people have to call this from the kernel debugger.
- * (if 'panic' can not dump)
- * Give them a clue as to why they can't dump.
- */
- if (dumper.dumper == NULL) {
- printf("Cannot dump. Device not defined or unavailable.\n");
- return;
- }
+ if (dumping)
+ return (EBUSY);
+ if (dumper.dumper == NULL)
+ return (ENXIO);
savectx(&dumppcb);
dumptid = curthread->td_tid;
dumping++;
+
+ coredump = TRUE;
#ifdef DDB
- if (textdump_pending)
+ if (textdump && textdump_pending) {
+ coredump = FALSE;
textdump_dumpsys(&dumper);
- else
+ }
#endif
+ if (coredump)
dumpsys(&dumper);
+
dumping--;
+ return (0);
}
static int
@@ -425,7 +427,7 @@ kern_reboot(int howto)
EVENTHANDLER_INVOKE(shutdown_post_sync, howto);
if ((howto & (RB_HALT|RB_DUMP)) == RB_DUMP && !cold && !dumping)
- doadump();
+ doadump(TRUE);
/* Now that we're going to really halt the system... */
EVENTHANDLER_INVOKE(shutdown_final, howto);
OpenPOWER on IntegriCloud