FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/eventhandler.h>
#include <sys/kcov.h>
#include <sys/kernel.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mman.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/rwlock.h>
#include <sys/sysctl.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_extern.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_pager.h>
#include <vm/vm_param.h>
Go to the source code of this file.
Data Structures | |
struct | kcov_info |
Macros | |
#define | KCOV_ELEMENT_SIZE sizeof(uint64_t) |
Enumerations | |
enum | kcov_state_t { KCOV_STATE_INVALID , KCOV_STATE_OPEN , KCOV_STATE_READY , KCOV_STATE_RUNNING , KCOV_STATE_DYING } |
Functions | |
__FBSDID ("$FreeBSD$") | |
MALLOC_DEFINE (M_KCOV_INFO, "kcovinfo", "KCOV info type") | |
static int | kcov_alloc (struct kcov_info *info, size_t entries) |
static void | kcov_free (struct kcov_info *info) |
static void | kcov_init (const void *unused) |
SYSCTL_NODE (_kern, OID_AUTO, kcov, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "Kernel coverage") | |
SYSCTL_UINT (_kern_kcov, OID_AUTO, max_entries, CTLFLAG_RW, &kcov_max_entries, 0, "Maximum number of entries in the kcov buffer") | |
static struct kcov_info *__nosanitizeaddress __nosanitizememory | get_kinfo (struct thread *td) |
static void __nosanitizeaddress __nosanitizememory | trace_pc (uintptr_t ret) |
static bool __nosanitizeaddress __nosanitizememory | trace_cmp (uint64_t type, uint64_t arg1, uint64_t arg2, uint64_t ret) |
static void | kcov_mmap_cleanup (void *arg) |
static int | kcov_open (struct cdev *dev, int oflags, int devtype, struct thread *td) |
static int | kcov_close (struct cdev *dev, int fflag, int devtype, struct thread *td) |
static int | kcov_mmap_single (struct cdev *dev, vm_ooffset_t *offset, vm_size_t size, struct vm_object **object, int nprot) |
static int | kcov_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int fflag __unused, struct thread *td) |
static void | kcov_thread_dtor (void *arg __unused, struct thread *td) |
SYSINIT (kcovdev, SI_SUB_LAST, SI_ORDER_ANY, kcov_init, NULL) | |
Variables | |
static d_open_t | kcov_open |
static d_close_t | kcov_close |
static d_mmap_single_t | kcov_mmap_single |
static d_ioctl_t | kcov_ioctl |
static struct cdevsw | kcov_cdevsw |
static u_int | kcov_max_entries = KCOV_MAXENTRIES |
static struct mtx | kcov_lock |
static int | active_count |
#define KCOV_ELEMENT_SIZE sizeof(uint64_t) |
Definition at line 71 of file kern_kcov.c.
enum kcov_state_t |
Enumerator | |
---|---|
KCOV_STATE_INVALID | |
KCOV_STATE_OPEN | |
KCOV_STATE_READY | |
KCOV_STATE_RUNNING | |
KCOV_STATE_DYING |
Definition at line 112 of file kern_kcov.c.
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
Definition at line 169 of file kern_kcov.c.
References KCOV_STATE_RUNNING, and kcov_info::state.
Referenced by trace_cmp(), and trace_pc().
|
static |
Definition at line 364 of file kern_kcov.c.
References kcov_info::bufobj, kcov_info::bufsize, kcov_info::entries, KCOV_ELEMENT_SIZE, kcov_max_entries, KCOV_STATE_OPEN, kcov_info::kvaddr, and kcov_info::state.
Referenced by kcov_ioctl().
|
static |
Definition at line 323 of file kern_kcov.c.
References KCOV_STATE_RUNNING, and kcov_info::state.
|
static |
Definition at line 402 of file kern_kcov.c.
References kcov_info::bufobj, kcov_info::bufsize, free(), and kcov_info::kvaddr.
Referenced by kcov_mmap_cleanup(), and kcov_thread_dtor().
|
static |
Definition at line 561 of file kern_kcov.c.
References kcov_cdevsw, kcov_lock, kcov_thread_dtor(), make_dev_s(), printf(), and thread_dtor().
|
static |
Definition at line 425 of file kern_kcov.c.
References active_count, cov_register_cmp(), cov_register_pc(), cov_unregister_cmp(), cov_unregister_pc(), data, kcov_alloc(), kcov_lock, KCOV_STATE_OPEN, KCOV_STATE_READY, KCOV_STATE_RUNNING, kcov_info::mode, mode, kcov_info::state, kcov_info::thread, trace_cmp(), and trace_pc().
|
static |
Definition at line 273 of file kern_kcov.c.
References kcov_free(), kcov_lock, KCOV_STATE_DYING, kcov_info::state, and kcov_info::thread.
Referenced by kcov_open().
|
static |
Definition at line 341 of file kern_kcov.c.
References kcov_info::bufobj, kcov_info::entries, KCOV_ELEMENT_SIZE, and kcov_info::kvaddr.
|
static |
Definition at line 306 of file kern_kcov.c.
References kcov_mmap_cleanup(), KCOV_STATE_OPEN, malloc(), kcov_info::mode, kcov_info::state, and kcov_info::thread.
|
static |
Definition at line 519 of file kern_kcov.c.
References active_count, cov_unregister_cmp(), cov_unregister_pc(), kcov_free(), kcov_lock, KCOV_STATE_DYING, KCOV_STATE_READY, kcov_info::state, and kcov_info::thread.
Referenced by kcov_init().
MALLOC_DEFINE | ( | M_KCOV_INFO | , |
"kcovinfo" | , | ||
"KCOV info type" | |||
) |
SYSCTL_NODE | ( | _kern | , |
OID_AUTO | , | ||
kcov | , | ||
CTLFLAG_RW| | CTLFLAG_MPSAFE, | ||
0 | , | ||
"Kernel coverage" | |||
) |
SYSCTL_UINT | ( | _kern_kcov | , |
OID_AUTO | , | ||
max_entries | , | ||
CTLFLAG_RW | , | ||
& | kcov_max_entries, | ||
0 | , | ||
"Maximum number of entries in the kcov buffer" | |||
) |
SYSINIT | ( | kcovdev | , |
SI_SUB_LAST | , | ||
SI_ORDER_ANY | , | ||
kcov_init | , | ||
NULL | |||
) |
|
static |
Definition at line 227 of file kern_kcov.c.
References atomic_cmpset_64(), buf, kcov_info::entries, get_kinfo(), kcov_info::kvaddr, kcov_info::mode, and type.
Referenced by __sanitizer_cov_trace_cmp1(), __sanitizer_cov_trace_cmp2(), __sanitizer_cov_trace_cmp4(), __sanitizer_cov_trace_cmp8(), __sanitizer_cov_trace_const_cmp1(), __sanitizer_cov_trace_const_cmp2(), __sanitizer_cov_trace_const_cmp4(), __sanitizer_cov_trace_const_cmp8(), __sanitizer_cov_trace_switch(), cov_register_cmp(), and kcov_ioctl().
|
static |
Definition at line 196 of file kern_kcov.c.
References buf, kcov_info::entries, get_kinfo(), kcov_info::kvaddr, and kcov_info::mode.
Referenced by __sanitizer_cov_trace_pc(), cov_register_pc(), and kcov_ioctl().
|
static |
Definition at line 166 of file kern_kcov.c.
Referenced by kcov_ioctl(), and kcov_thread_dtor().
|
static |
Definition at line 148 of file kern_kcov.c.
Referenced by kcov_init().
|
static |
Definition at line 140 of file kern_kcov.c.
|
static |
Definition at line 142 of file kern_kcov.c.
|
static |
Definition at line 165 of file kern_kcov.c.
Referenced by kcov_init(), kcov_ioctl(), kcov_mmap_cleanup(), and kcov_thread_dtor().
|
static |
Definition at line 160 of file kern_kcov.c.
Referenced by kcov_alloc().
|
static |
Definition at line 141 of file kern_kcov.c.
|
static |
Definition at line 139 of file kern_kcov.c.