diff options
| author | Robert Watson <rwatson@FreeBSD.org> | 2008-01-26 22:32:23 +0000 |
|---|---|---|
| committer | Robert Watson <rwatson@FreeBSD.org> | 2008-01-26 22:32:23 +0000 |
| commit | f33dc69dfb388185754e6eeef7f1b30369e4ee44 (patch) | |
| tree | 2592f60045e0184007a696997b310c248d65ee54 /sys/ddb | |
| parent | 877729518e4b4e8474cf3b5edd7a06dd87e236b6 (diff) | |
Notes
Diffstat (limited to 'sys/ddb')
| -rw-r--r-- | sys/ddb/db_capture.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/sys/ddb/db_capture.c b/sys/ddb/db_capture.c index 5a4cb37a9bc11..75da64edd11a7 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); |
