From owner-freebsd-bugs@FreeBSD.ORG Sat Jan 26 03:30:01 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8FE7216A421 for ; Sat, 26 Jan 2008 03:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 6522F13C459 for ; Sat, 26 Jan 2008 03:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m0Q3U1bi027158 for ; Sat, 26 Jan 2008 03:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m0Q3U1r0027154; Sat, 26 Jan 2008 03:30:01 GMT (envelope-from gnats) Resent-Date: Sat, 26 Jan 2008 03:30:01 GMT Resent-Message-Id: <200801260330.m0Q3U1r0027154@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Scot Hetzel Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B3CFB16A418 for ; Sat, 26 Jan 2008 03:22:22 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 9C92313C45A for ; Sat, 26 Jan 2008 03:22:22 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m0Q3KhoT096307 for ; Sat, 26 Jan 2008 03:20:44 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m0Q3KhqA096306; Sat, 26 Jan 2008 03:20:43 GMT (envelope-from nobody) Message-Id: <200801260320.m0Q3KhqA096306@www.freebsd.org> Date: Sat, 26 Jan 2008 03:20:43 GMT From: Scot Hetzel To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/119993: ddb capture buffer too small for textdumps X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Jan 2008 03:30:01 -0000 >Number: 119993 >Category: kern >Synopsis: ddb capture buffer too small for textdumps >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Jan 26 03:30:01 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Scot Hetzel >Release: 8.0-CURRENT >Organization: >Environment: FreeBSD hp010.hetzel.org 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Sat Jan 19 00:03:54 CST 2008 root@hp010.hetzel.org:/usr/src/sys/amd64/compile/DV8135NR amd64 >Description: While trying to debug a kernel panic, I decided to try the new textdump feature and scripted ddb. I increased debug.ddb.capture.bufsize to it's maximum size (512K). When the kerne paniced, the kdb.enter.panic script ran but had its output truncated to 512K. debug.ddb.capture.bufsize: 49152 debug.ddb.capture.maxbufsize: 524288 The problem is that sys/ddb/db_capture.c has fixed DB_CAPTURE_MAXBUFSIZE to 512K. I was able to get the full output by increasing DB_CAPTURE_MAXBUFSIZE to 5M (3M would have been enough, as ddb.txt was only 2.7M). >How-To-Repeat: Add the following to the kernel config file: options DEBUG_VFS_LOCKS options KTR options KTR_COMPILE=(KTR_SPARE2) options KTR_MASK=(KTR_SPARE2) options KTR_ENTRIES=32768 and then build/install the kernel. After the reboot, use ddb to add the following scripts: /sbin/ddb script lockinfo="show locks; show alllocks; show lockedvnods" /sbin/ddb script kdb.enter.panic="textdump set; capture on; show ktr ; run lockinfo ; show pcpu; bt; ps; alltrace; capture off; call doadump; reset" sysctl debug.ddb.capture.bufsize=524288 Then do something that causes the kernel to panic. >Fix: Apply the attached patch which adds two kernel options to allow the capture buffer size to be changed in the kernel config file: options DB_CAPTURE_DEFAULTBUFSIZE=2*1024*1024 options DB_CAPTURE_MAXBUFSIZE=5*1024*1024 Should DB_CAPTURE* be changed to DDB_CAPTURE*? Will require a change in ddb/db_capture.c also. Note: DB_CAPTURE_DEFAULTBUFSIZE can also be set by sysctl. Patch attached with submission follows: Index: conf/options =================================================================== RCS file: /home/ncvs/src/sys/conf/options,v retrieving revision 1.615 diff -u -r1.615 options --- conf/options 7 Jan 2008 21:40:09 -0000 1.615 +++ conf/options 25 Jan 2008 23:52:31 -0000 @@ -49,6 +49,8 @@ # Debugging options. DDB DDB_NUMSYM opt_ddb.h +DB_CAPTURE_DEFAULTBUFSIZE opt_ddb.h +DB_CAPTURE_MAXBUFSIZE opt_ddb.h GDB KDB opt_global.h KDB_TRACE opt_kdb.h Index: ddb/db_capture.c =================================================================== RCS file: /home/ncvs/src/sys/ddb/db_capture.c,v retrieving revision 1.2 diff -u -r1.2 db_capture.c --- ddb/db_capture.c 26 Dec 2007 11:32:32 -0000 1.2 +++ ddb/db_capture.c 25 Jan 2008 23:50:46 -0000 @@ -46,6 +46,8 @@ #include #include +#include + /* * While it would be desirable to use a small block-sized buffer and dump * incrementally to disk in fixed-size blocks, it's not possible to enter @@ -55,8 +57,12 @@ */ static MALLOC_DEFINE(M_DB_CAPTURE, "db_capture", "DDB capture buffer"); +#ifndef DB_CAPTURE_DEFAULTBUFSIZE #define DB_CAPTURE_DEFAULTBUFSIZE 48*1024 +#endif +#ifndef DB_CAPTURE_MAXBUFSIZE #define DB_CAPTURE_MAXBUFSIZE 512*1024 +#endif #define DB_CAPTURE_FILENAME "ddb.txt" /* Captured DDB output. */ static char *db_capture_buf; >Release-Note: >Audit-Trail: >Unformatted: