Changeset View
Changeset View
Standalone View
Standalone View
sys/ddb/db_capture.c
Show All 12 Lines | |||||
static u_int db_capture_bufoff; /* Next location to write in buffer. */ | static u_int db_capture_bufoff; /* Next location to write in buffer. */ | ||||
static u_int db_capture_bufpadding; /* Amount of zero padding. */ | static u_int db_capture_bufpadding; /* Amount of zero padding. */ | ||||
static int db_capture_inpager; /* Suspend capture in pager. */ | static int db_capture_inpager; /* Suspend capture in pager. */ | ||||
static int db_capture_inprogress; /* DDB capture currently in progress. */ | static int db_capture_inprogress; /* DDB capture currently in progress. */ | ||||
struct sx db_capture_sx; /* Lock against user thread races. */ | struct sx db_capture_sx; /* Lock against user thread races. */ | ||||
SX_SYSINIT(db_capture_sx, &db_capture_sx, "db_capture_sx"); | SX_SYSINIT(db_capture_sx, &db_capture_sx, "db_capture_sx"); | ||||
static SYSCTL_NODE(_debug_ddb, OID_AUTO, capture, CTLFLAG_RW, 0, | static SYSCTL_NODE(_debug_ddb, OID_AUTO, capture, | ||||
CTLFLAG_RW | CTLFLAG_MPSAFE, 0, | |||||
"DDB capture options"); | "DDB capture options"); | ||||
SYSCTL_UINT(_debug_ddb_capture, OID_AUTO, bufoff, CTLFLAG_RD, | SYSCTL_UINT(_debug_ddb_capture, OID_AUTO, bufoff, CTLFLAG_RD, | ||||
&db_capture_bufoff, 0, "Bytes of data in DDB capture buffer"); | &db_capture_bufoff, 0, "Bytes of data in DDB capture buffer"); | ||||
SYSCTL_UINT(_debug_ddb_capture, OID_AUTO, maxbufsize, CTLFLAG_RD, | SYSCTL_UINT(_debug_ddb_capture, OID_AUTO, maxbufsize, CTLFLAG_RD, | ||||
&db_capture_maxbufsize, 0, | &db_capture_maxbufsize, 0, | ||||
"Maximum value for debug.ddb.capture.bufsize"); | "Maximum value for debug.ddb.capture.bufsize"); | ||||
Show All 24 Lines | |||||
KASSERT(db_capture_bufoff <= db_capture_bufsize, | KASSERT(db_capture_bufoff <= db_capture_bufsize, | ||||
("sysctl_debug_ddb_capture_bufsize: bufoff > bufsize")); | ("sysctl_debug_ddb_capture_bufsize: bufoff > bufsize")); | ||||
KASSERT(db_capture_bufsize <= db_capture_maxbufsize, | KASSERT(db_capture_bufsize <= db_capture_maxbufsize, | ||||
("sysctl_debug_ddb_capture_maxbufsize: bufsize > maxbufsize")); | ("sysctl_debug_ddb_capture_maxbufsize: bufsize > maxbufsize")); | ||||
return (0); | return (0); | ||||
} | } | ||||
SYSCTL_PROC(_debug_ddb_capture, OID_AUTO, bufsize, CTLTYPE_UINT|CTLFLAG_RW, | SYSCTL_PROC(_debug_ddb_capture, OID_AUTO, bufsize, | ||||
0, 0, sysctl_debug_ddb_capture_bufsize, "IU", | CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, 0, 0, | ||||
sysctl_debug_ddb_capture_bufsize, "IU", | |||||
"Size of DDB capture buffer"); | "Size of DDB capture buffer"); | ||||
/* | /* | ||||
* Sysctl to read out the capture buffer from userspace. We require | * Sysctl to read out the capture buffer from userspace. We require | ||||
* privilege as sensitive process/memory information may be accessed. | * privilege as sensitive process/memory information may be accessed. | ||||
*/ | */ | ||||
static int | static int | ||||
sysctl_debug_ddb_capture_data(SYSCTL_HANDLER_ARGS) | sysctl_debug_ddb_capture_data(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
int error; | int error; | ||||
char ch; | char ch; | ||||
error = priv_check(req->td, PRIV_DDB_CAPTURE); | error = priv_check(req->td, PRIV_DDB_CAPTURE); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
sx_slock(&db_capture_sx); | sx_slock(&db_capture_sx); | ||||
error = SYSCTL_OUT(req, db_capture_buf, db_capture_bufoff); | error = SYSCTL_OUT(req, db_capture_buf, db_capture_bufoff); | ||||
sx_sunlock(&db_capture_sx); | sx_sunlock(&db_capture_sx); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
ch = '\0'; | ch = '\0'; | ||||
return (SYSCTL_OUT(req, &ch, sizeof(ch))); | return (SYSCTL_OUT(req, &ch, sizeof(ch))); | ||||
} | } | ||||
SYSCTL_PROC(_debug_ddb_capture, OID_AUTO, data, CTLTYPE_STRING | CTLFLAG_RD, | SYSCTL_PROC(_debug_ddb_capture, OID_AUTO, data, | ||||
NULL, 0, sysctl_debug_ddb_capture_data, "A", "DDB capture data"); | CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, NULL, 0, | ||||
sysctl_debug_ddb_capture_data, "A", | |||||
"DDB capture data"); | |||||
kib: I think you can safely mark both as mpsafe. | |||||
/* | /* | ||||
* Routines for capturing DDB output into a fixed-size buffer. These are | * Routines for capturing DDB output into a fixed-size buffer. These are | ||||
* invoked from DDB's input and output routines. If we hit the limit on the | * invoked from DDB's input and output routines. If we hit the limit on the | ||||
* buffer, we simply drop further data. | * buffer, we simply drop further data. | ||||
*/ | */ | ||||
void | void | ||||
db_capture_write(char *buffer, u_int buflen) | db_capture_write(char *buffer, u_int buflen) | ||||
Show All 12 Lines |
I think you can safely mark both as mpsafe.