From owner-svn-src-user@FreeBSD.ORG Thu Nov 1 17:33:53 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 32AB04DB; Thu, 1 Nov 2012 17:33:53 +0000 (UTC) (envelope-from alfred@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 19C6C8FC0C; Thu, 1 Nov 2012 17:33:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id qA1HXqvc042973; Thu, 1 Nov 2012 17:33:52 GMT (envelope-from alfred@svn.freebsd.org) Received: (from alfred@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id qA1HXqqR042966; Thu, 1 Nov 2012 17:33:52 GMT (envelope-from alfred@svn.freebsd.org) Message-Id: <201211011733.qA1HXqqR042966@svn.freebsd.org> From: Alfred Perlstein Date: Thu, 1 Nov 2012 17:33:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r242446 - in user/alfred/9-alfred: share/man/man4 sys/conf sys/ddb X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Nov 2012 17:33:53 -0000 Author: alfred Date: Thu Nov 1 17:33:52 2012 New Revision: 242446 URL: http://svn.freebsd.org/changeset/base/242446 Log: re-do: Merge textdump enhancements from head. svn merge -c 242424,242427,242428,242440 ^/head/share/man/man4 svn merge -c 242424,242427,242428,242440 ^/head/sys Modified: user/alfred/9-alfred/share/man/man4/ddb.4 user/alfred/9-alfred/share/man/man4/textdump.4 user/alfred/9-alfred/sys/conf/NOTES user/alfred/9-alfred/sys/conf/options user/alfred/9-alfred/sys/ddb/db_command.c user/alfred/9-alfred/sys/ddb/db_textdump.c Directory Properties: user/alfred/9-alfred/share/man/man4/ (props changed) user/alfred/9-alfred/sys/ (props changed) user/alfred/9-alfred/sys/conf/ (props changed) Modified: user/alfred/9-alfred/share/man/man4/ddb.4 ============================================================================== --- user/alfred/9-alfred/share/man/man4/ddb.4 Thu Nov 1 17:30:33 2012 (r242445) +++ user/alfred/9-alfred/share/man/man4/ddb.4 Thu Nov 1 17:33:52 2012 (r242446) @@ -1176,6 +1176,7 @@ section for more information on the scri .It Ic textdump set .It Ic textdump status .It Ic textdump unset +.It Ic textdump dump The .Ic textdump set command may be used to force the next kernel core dump to be a textdump @@ -1184,6 +1185,9 @@ rather than a traditional memory dump or reports whether a textdump has been scheduled. .Ic textdump unset cancels a request to perform a textdump as the next kernel core dump. +Use the +.Ic textdump dump +command to immediately perform a textdump. More information may be found in .Xr textdump 4 . .El Modified: user/alfred/9-alfred/share/man/man4/textdump.4 ============================================================================== --- user/alfred/9-alfred/share/man/man4/textdump.4 Thu Nov 1 17:30:33 2012 (r242445) +++ user/alfred/9-alfred/share/man/man4/textdump.4 Thu Nov 1 17:33:52 2012 (r242446) @@ -36,6 +36,9 @@ .Sh SYNOPSIS .Cd options KDB .Cd options DDB +.Pp +.Cd options TEXTDUMP_VERBOSE +.Cd options TEXTDUMP_PREFERRED .Sh DESCRIPTION The .Nm @@ -115,7 +118,11 @@ or by setting the .Dv debug.ddb.textdump.pending sysctl to 1 using .Xr sysctl 8 , -it is possible to request that the next dump be a textdump. +it is possible to request that the next dump be a textdump. One can +also directly trigger a textdump in +.Xr ddb 4 +by running the command +.Ic textdump dump . .Pp If at the .Xr ddb 4 @@ -125,10 +132,30 @@ command line, the commands and .Ic textdump unset may be used to set, query, and clear the textdump pending flag. +The command +.Ic textdump dump +can be used to immediately trigger a textdump. .Pp As with regular kernel dumps, a dump partition must be automatically or manually configured using .Xr dumpon 8 . +.Pp +Additional kernel +.Xr config 8 +options: +.Bl -tag -width TEXTDUMP_PREFERRED +.It Cd TEXTDUMP_PREFERRED +sets textdumps to be the default manner of doing dumps. This means there +will be no need to +.Xr sysctl 8 +or use the +.Ic textdump set +.Xr ddb 8 +commands. +.It Cd TEXTDUMP_VERBOSE +will have the textdump facility be more verbose about each file it is emitting +as well as other diagnostics useful to debug the textdump facility itself. +.El .Sh EXAMPLES In the following example, the script .Dv kdb.enter.panic Modified: user/alfred/9-alfred/sys/conf/NOTES ============================================================================== --- user/alfred/9-alfred/sys/conf/NOTES Thu Nov 1 17:30:33 2012 (r242445) +++ user/alfred/9-alfred/sys/conf/NOTES Thu Nov 1 17:33:52 2012 (r242446) @@ -389,6 +389,16 @@ options GDB options SYSCTL_DEBUG # +# Enable textdump by default, this disables kernel core dumps. +# +options TEXTDUMP_PREFERRED + +# +# Enable extra debug messages while performing textdumps. +# +options TEXTDUMP_VERBOSE + +# # NO_SYSCTL_DESCR omits the sysctl node descriptions to save space in the # resulting kernel. options NO_SYSCTL_DESCR Modified: user/alfred/9-alfred/sys/conf/options ============================================================================== --- user/alfred/9-alfred/sys/conf/options Thu Nov 1 17:30:33 2012 (r242445) +++ user/alfred/9-alfred/sys/conf/options Thu Nov 1 17:33:52 2012 (r242446) @@ -60,6 +60,8 @@ KDB opt_global.h KDB_TRACE opt_kdb.h KDB_UNATTENDED opt_kdb.h SYSCTL_DEBUG opt_sysctl.h +TEXTDUMP_PREFERRED opt_ddb.h +TEXTDUMP_VERBOSE opt_ddb.h # Miscellaneous options. ADAPTIVE_LOCKMGRS Modified: user/alfred/9-alfred/sys/ddb/db_command.c ============================================================================== --- user/alfred/9-alfred/sys/ddb/db_command.c Thu Nov 1 17:30:33 2012 (r242445) +++ user/alfred/9-alfred/sys/ddb/db_command.c Thu Nov 1 17:33:52 2012 (r242446) @@ -535,6 +535,11 @@ db_dump(db_expr_t dummy, boolean_t dummy { int error; + if (textdump_pending) { + db_printf("textdump_pending set.\n" + "run \"textdump unset\" first or \"textdump dump\" for a textdump.\n"); + return; + } error = doadump(FALSE); if (error) { db_printf("Cannot dump: "); Modified: user/alfred/9-alfred/sys/ddb/db_textdump.c ============================================================================== --- user/alfred/9-alfred/sys/ddb/db_textdump.c Thu Nov 1 17:30:33 2012 (r242445) +++ user/alfred/9-alfred/sys/ddb/db_textdump.c Thu Nov 1 17:33:52 2012 (r242446) @@ -61,6 +61,8 @@ __FBSDID("$FreeBSD$"); #include "opt_config.h" +#include "opt_ddb.h" + #include #include #include @@ -118,7 +120,11 @@ CTASSERT(sizeof(struct ustar_header) == * Is a textdump scheduled? If so, the shutdown code will invoke our dumpsys * routine instead of the machine-dependent kernel dump routine. */ -int textdump_pending; +#ifdef TEXTDUMP_PREFERRED +int textdump_pending = 1; +#else +int textdump_pending = 0; +#endif SYSCTL_INT(_debug_ddb_textdump, OID_AUTO, pending, CTLFLAG_RW, &textdump_pending, 0, "Perform textdump instead of regular kernel dump."); @@ -201,6 +207,10 @@ textdump_mkustar(char *block_buffer, con { struct ustar_header *uhp; +#ifdef TEXTDUMP_VERBOSE + if (textdump_error == 0) + printf("textdump: creating '%s'.\n", filename); +#endif uhp = (struct ustar_header *)block_buffer; bzero(uhp, sizeof(*uhp)); strlcpy(uhp->uh_filename, filename, sizeof(uhp->uh_filename)); @@ -237,6 +247,9 @@ textdump_writeblock(struct dumperinfo *d return (ENOSPC); textdump_error = dump_write(di, buffer, 0, offset + di->mediaoffset, TEXTDUMP_BLOCKSIZE); + if (textdump_error) + printf("textdump_writeblock: offset %jd, error %d\n", (intmax_t)offset, + textdump_error); return (textdump_error); } @@ -430,7 +443,7 @@ textdump_dumpsys(struct dumperinfo *di) * of data. */ if (di->mediasize < SIZEOF_METADATA + 2 * sizeof(kdh)) { - printf("Insufficient space on dump partition.\n"); + printf("Insufficient space on dump partition for minimal textdump.\n"); return; } textdump_error = 0; @@ -480,9 +493,9 @@ textdump_dumpsys(struct dumperinfo *di) if (textdump_error == 0) (void)dump_write(di, NULL, 0, 0, 0); if (textdump_error == ENOSPC) - printf("Insufficient space on dump partition\n"); + printf("Textdump: Insufficient space on dump partition\n"); else if (textdump_error != 0) - printf("Error %d writing dump\n", textdump_error); + printf("Textdump: Error %d writing dump\n", textdump_error); else printf("Textdump complete.\n"); textdump_pending = 0; @@ -499,7 +512,7 @@ static void db_textdump_usage(void) { - db_printf("textdump [unset|set|status]\n"); + db_printf("textdump [unset|set|status|dump]\n"); } void @@ -528,6 +541,10 @@ db_textdump_cmd(db_expr_t addr, boolean_ } else if (strcmp(db_tok_string, "unset") == 0) { textdump_pending = 0; db_printf("textdump unset\n"); - } else + } else if (strcmp(db_tok_string, "dump") == 0) { + textdump_pending = 1; + doadump(TRUE); + } else { db_textdump_usage(); + } }