summaryrefslogtreecommitdiffstats
path: root/sys/ddb
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2008-01-26 22:32:23 +0000
committerrwatson <rwatson@FreeBSD.org>2008-01-26 22:32:23 +0000
commitdb8d5a7a3dab94330ab892cb2be5828c2959b5bf (patch)
tree2592f60045e0184007a696997b310c248d65ee54 /sys/ddb
parent81169af72ac63878d02728ffa78cbe72e62b51e4 (diff)
downloadFreeBSD-src-db8d5a7a3dab94330ab892cb2be5828c2959b5bf.zip
FreeBSD-src-db8d5a7a3dab94330ab892cb2be5828c2959b5bf.tar.gz
Allow DDB_CAPTURE_DEFAULTBUFSIZE and DDB_CAPTURE_MAXBUFSIZE to be
overridden at compile-time using kernel options of the same names. Rather than doing a compile-time CTASSERT of buffer sizes being even multiples of block sizes, just adjust them at boottime, as the failure mode is more user-friendly. MFC after: 2 months PR: 119993 Suggested by: Scot Hetzel <swhetzel at gmail dot com>
Diffstat (limited to 'sys/ddb')
-rw-r--r--sys/ddb/db_capture.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/sys/ddb/db_capture.c b/sys/ddb/db_capture.c
index 5a4cb37..75da64e 100644
--- a/sys/ddb/db_capture.c
+++ b/sys/ddb/db_capture.c
@@ -32,6 +32,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_ddb.h"
+
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/kernel.h>
@@ -52,11 +54,19 @@ __FBSDID("$FreeBSD$");
* kernel dumper routines without restarting the kernel, which is undesirable
* in the midst of debugging. Instead, we maintain a large static global
* buffer that we fill from DDB's output routines.
+ *
+ * We enforce an invariant at runtime that buffer sizes are even multiples of
+ * the textdump block size, which is a design choice that we might want to
+ * reconsider.
*/
static MALLOC_DEFINE(M_DDB_CAPTURE, "ddb_capture", "DDB capture buffer");
+#ifndef DDB_CAPTURE_DEFAULTBUFSIZE
#define DDB_CAPTURE_DEFAULTBUFSIZE 48*1024
+#endif
+#ifndef DDB_CAPTURE_MAXBUFSIZE
#define DDB_CAPTURE_MAXBUFSIZE 512*1024
+#endif
#define DDB_CAPTURE_FILENAME "ddb.txt" /* Captured DDB output. */
static char *db_capture_buf;
@@ -81,24 +91,19 @@ SYSCTL_UINT(_debug_ddb_capture, OID_AUTO, maxbufsize, CTLFLAG_RD,
"Maximum value for debug.ddb.capture.bufsize");
/*
- * Various compile-time assertions: defaults must be even multiples of
- * textdump block size. We also perform run-time checking of
- * user-configurable values.
- */
-CTASSERT(DDB_CAPTURE_DEFAULTBUFSIZE % TEXTDUMP_BLOCKSIZE == 0);
-CTASSERT(DDB_CAPTURE_MAXBUFSIZE % TEXTDUMP_BLOCKSIZE == 0);
-
-/*
- * Boot-time allocation of the DDB capture buffer, if any.
+ * Boot-time allocation of the DDB capture buffer, if any. Force all buffer
+ * sizes, including the maximum size, to be rounded to block sizes.
*/
static void
db_capture_sysinit(__unused void *dummy)
{
TUNABLE_INT_FETCH("debug.ddb.capture.bufsize", &db_capture_bufsize);
+ db_capture_maxbufsize = roundup(db_capture_maxbufsize,
+ TEXTDUMP_BLOCKSIZE);
db_capture_bufsize = roundup(db_capture_bufsize, TEXTDUMP_BLOCKSIZE);
- if (db_capture_bufsize > DDB_CAPTURE_MAXBUFSIZE)
- db_capture_bufsize = DDB_CAPTURE_MAXBUFSIZE;
+ if (db_capture_bufsize > db_capture_maxbufsize)
+ db_capture_bufsize = db_capture_maxbufsize;
if (db_capture_bufsize != 0)
db_capture_buf = malloc(db_capture_bufsize, M_DDB_CAPTURE,
M_WAITOK);
@@ -121,7 +126,7 @@ sysctl_debug_ddb_capture_bufsize(SYSCTL_HANDLER_ARGS)
if (error || req->newptr == NULL)
return (error);
size = roundup(size, TEXTDUMP_BLOCKSIZE);
- if (size > DDB_CAPTURE_MAXBUFSIZE)
+ if (size > db_capture_maxbufsize)
return (EINVAL);
sx_xlock(&db_capture_sx);
if (size != 0) {
@@ -150,7 +155,7 @@ sysctl_debug_ddb_capture_bufsize(SYSCTL_HANDLER_ARGS)
KASSERT(db_capture_bufoff <= db_capture_bufsize,
("sysctl_debug_ddb_capture_bufsize: bufoff > bufsize"));
- KASSERT(db_capture_bufsize <= DDB_CAPTURE_MAXBUFSIZE,
+ KASSERT(db_capture_bufsize <= db_capture_maxbufsize,
("sysctl_debug_ddb_capture_maxbufsize: bufsize > maxbufsize"));
return (0);
OpenPOWER on IntegriCloud