diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-11-01 12:36:19 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-11-01 12:36:19 +0000 |
commit | efbbbf570d70bf488555019bfe0db2207aa12c44 (patch) | |
tree | d577bd050cdecd540920ae5dc3001f5b5b3c7c30 | |
parent | 4db4b8a4b938d4f570c40147aa895aeed162f339 (diff) | |
download | FreeBSD-src-efbbbf570d70bf488555019bfe0db2207aa12c44.zip FreeBSD-src-efbbbf570d70bf488555019bfe0db2207aa12c44.tar.gz |
Replace ktr_buffer pointer in struct ktr_header with a ktr_unused
intptr_t. The buffer length needs to be written to disk as part
of the trace log, but the kernel pointer for the buffer does not.
Add a new ktr_buffer pointer to the kernel-only ktrace request
structure to hold that pointer. This frees up an integer in the
ktrace record format that can be used to hold the threadid,
although older ktrace files will have a garbage ktr_buffer field
(or more accurately, a kernel pointer value).
MFC after: 2 weeks
Space requested by: davidxu
-rw-r--r-- | sys/kern/kern_ktrace.c | 20 | ||||
-rw-r--r-- | sys/sys/ktrace.h | 2 |
2 files changed, 12 insertions, 10 deletions
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 850e9b0..e4b4b5c 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -64,6 +64,7 @@ static MALLOC_DEFINE(M_KTRACE, "KTRACE", "KTRACE"); struct ktr_request { struct ktr_header ktr_header; + void *ktr_buffer; struct ucred *ktr_cred; struct vnode *ktr_vp; union { @@ -237,7 +238,8 @@ ktr_getrequest(int type) microtime(&req->ktr_header.ktr_time); req->ktr_header.ktr_pid = p->p_pid; bcopy(p->p_comm, req->ktr_header.ktr_comm, MAXCOMLEN + 1); - req->ktr_header.ktr_buffer = NULL; + req->ktr_header.ktr_unused = 0; + req->ktr_buffer = NULL; req->ktr_header.ktr_len = 0; } else { p->p_traceflag |= KTRFAC_DROP; @@ -272,8 +274,8 @@ ktr_freerequest(struct ktr_request *req) vrele(req->ktr_vp); mtx_unlock(&Giant); } - if (req->ktr_header.ktr_buffer != NULL) - free(req->ktr_header.ktr_buffer, M_KTRACE); + if (req->ktr_buffer != NULL) + free(req->ktr_buffer, M_KTRACE); mtx_lock(&ktrace_mtx); STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list); mtx_unlock(&ktrace_mtx); @@ -340,7 +342,7 @@ ktrsyscall(code, narg, args) ktp->ktr_narg = narg; if (buflen > 0) { req->ktr_header.ktr_len = buflen; - req->ktr_header.ktr_buffer = buf; + req->ktr_buffer = buf; } ktr_submitrequest(req); } @@ -387,7 +389,7 @@ ktrnamei(path) } if (namelen > 0) { req->ktr_header.ktr_len = namelen; - req->ktr_header.ktr_buffer = buf; + req->ktr_buffer = buf; } ktr_submitrequest(req); } @@ -436,7 +438,7 @@ ktrgenio(fd, rw, uio, error) ktg->ktr_fd = fd; ktg->ktr_rw = rw; req->ktr_header.ktr_len = datalen; - req->ktr_header.ktr_buffer = buf; + req->ktr_buffer = buf; ktr_submitrequest(req); } @@ -684,7 +686,7 @@ utrace(td, uap) free(cp, M_KTRACE); return (ENOMEM); } - req->ktr_header.ktr_buffer = cp; + req->ktr_buffer = cp; req->ktr_header.ktr_len = uap->len; ktr_submitrequest(req); return (0); @@ -827,8 +829,8 @@ ktr_writerequest(struct ktr_request *req) kth->ktr_len += datalen; } if (buflen != 0) { - KASSERT(kth->ktr_buffer != NULL, ("ktrace: nothing to write")); - aiov[auio.uio_iovcnt].iov_base = kth->ktr_buffer; + KASSERT(req->ktr_buffer != NULL, ("ktrace: nothing to write")); + aiov[auio.uio_iovcnt].iov_base = req->ktr_buffer; aiov[auio.uio_iovcnt].iov_len = buflen; auio.uio_resid += buflen; auio.uio_iovcnt++; diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h index e281516..eb0cfc7 100644 --- a/sys/sys/ktrace.h +++ b/sys/sys/ktrace.h @@ -54,7 +54,7 @@ struct ktr_header { pid_t ktr_pid; /* process id */ char ktr_comm[MAXCOMLEN+1]; /* command name */ struct timeval ktr_time; /* timestamp */ - void *ktr_buffer; + intptr_t ktr_unused; /* was ktr_buffer */ }; /* |