version 1.172.4.1, 2019/06/10 22:09:03 |
version 1.172.4.2, 2020/04/08 14:08:51 |
|
|
/* $NetBSD$ */ |
/* $NetBSD$ */ |
|
|
/*- |
/*- |
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. |
* Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc. |
* All rights reserved. |
* All rights reserved. |
* |
* |
* This code is derived from software contributed to The NetBSD Foundation |
* This code is derived from software contributed to The NetBSD Foundation |
Line 146 static void ktrace_thread(void *); |
|
Line 146 static void ktrace_thread(void *); |
|
static int ktrderefall(struct ktr_desc *, int); |
static int ktrderefall(struct ktr_desc *, int); |
|
|
/* |
/* |
* Default vaules. |
* Default values. |
*/ |
*/ |
#define KTD_MAXENTRY 1000 /* XXX: tune */ |
#define KTD_MAXENTRY 1000 /* XXX: tune */ |
#define KTD_TIMEOUT 5 /* XXX: tune */ |
#define KTD_TIMEOUT 5 /* XXX: tune */ |
Line 225 ktrace_listener_cb(kauth_cred_t cred, ka |
|
Line 225 ktrace_listener_cb(kauth_cred_t cred, ka |
|
if (action != KAUTH_PROCESS_KTRACE) |
if (action != KAUTH_PROCESS_KTRACE) |
return result; |
return result; |
|
|
req = (enum kauth_process_req)(unsigned long)arg1; |
req = (enum kauth_process_req)(uintptr_t)arg1; |
|
|
/* Privileged; secmodel should handle these. */ |
/* Privileged; secmodel should handle these. */ |
if (req == KAUTH_REQ_PROCESS_KTRACE_PERSISTENT) |
if (req == KAUTH_REQ_PROCESS_KTRACE_PERSISTENT) |
Line 528 ktealloc(struct ktrace_entry **ktep, voi |
|
Line 528 ktealloc(struct ktrace_entry **ktep, voi |
|
|
|
void |
void |
ktesethdrlen(struct ktrace_entry *kte, size_t l) |
ktesethdrlen(struct ktrace_entry *kte, size_t l) |
{ |
{ |
kte->kte_kth.ktr_len = l; |
kte->kte_kth.ktr_len = l; |
} |
} |
|
|
Line 720 ktr_io(lwp_t *l, int fd, enum uio_rw rw, |
|
Line 720 ktr_io(lwp_t *l, int fd, enum uio_rw rw, |
|
*/ |
*/ |
ktraddentry(l, kte, KTA_WAITOK | KTA_LARGE); |
ktraddentry(l, kte, KTA_WAITOK | KTA_LARGE); |
if (resid > 0) { |
if (resid > 0) { |
if (curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD) { |
if (preempt_needed()) { |
(void)ktrenter(l); |
(void)ktrenter(l); |
preempt(); |
preempt(); |
ktrexit(l); |
ktrexit(l); |
Line 818 ktr_csw(int out, int user) |
|
Line 818 ktr_csw(int out, int user) |
|
return; |
return; |
|
|
/* |
/* |
* Don't record context switches resulting from blocking on |
* Don't record context switches resulting from blocking on |
* locks; it's too easy to get duff results. |
* locks; it's too easy to get duff results. |
*/ |
*/ |
if (l->l_syncobj == &mutex_syncobj || l->l_syncobj == &rw_syncobj) |
if (l->l_syncobj == &mutex_syncobj || l->l_syncobj == &rw_syncobj) |
Line 831 ktr_csw(int out, int user) |
|
Line 831 ktr_csw(int out, int user) |
|
* XXX This is not ideal: it would be better to maintain a pool |
* XXX This is not ideal: it would be better to maintain a pool |
* of ktes and actually push this to the kthread when context |
* of ktes and actually push this to the kthread when context |
* switch happens, however given the points where we are called |
* switch happens, however given the points where we are called |
* from that is difficult to do. |
* from that is difficult to do. |
*/ |
*/ |
if (out) { |
if (out) { |
if (ktrenter(l)) |
if (ktrenter(l)) |
Line 868 ktr_csw(int out, int user) |
|
Line 868 ktr_csw(int out, int user) |
|
kte->kte_kth.ktr_otv.tv_sec = ts->tv_sec; |
kte->kte_kth.ktr_otv.tv_sec = ts->tv_sec; |
kte->kte_kth.ktr_otv.tv_usec = ts->tv_nsec / 1000; |
kte->kte_kth.ktr_otv.tv_usec = ts->tv_nsec / 1000; |
break; |
break; |
case 1: |
case 1: |
kte->kte_kth.ktr_ots.tv_sec = ts->tv_sec; |
kte->kte_kth.ktr_ots.tv_sec = ts->tv_sec; |
kte->kte_kth.ktr_ots.tv_nsec = ts->tv_nsec; |
kte->kte_kth.ktr_ots.tv_nsec = ts->tv_nsec; |
break; |
break; |
|
|
*/ |
*/ |
/* ARGSUSED */ |
/* ARGSUSED */ |
int |
int |
sys_fktrace(struct lwp *l, const struct sys_fktrace_args *uap, register_t *retval) |
sys_fktrace(struct lwp *l, const struct sys_fktrace_args *uap, |
|
register_t *retval) |
{ |
{ |
/* { |
/* { |
syscallarg(int) fd; |
syscallarg(int) fd; |
Line 1224 ktrops(lwp_t *curl, struct proc *p, int |
|
Line 1225 ktrops(lwp_t *curl, struct proc *p, int |
|
#endif |
#endif |
|
|
out: |
out: |
mutex_exit(&ktrace_lock); |
mutex_exit(&ktrace_lock); |
mutex_exit(p->p_lock); |
mutex_exit(p->p_lock); |
|
|
return error ? 0 : 1; |
return error ? 0 : 1; |
} |
} |