diff options
author | 2016-09-04 09:22:28 +0000 | |
---|---|---|
committer | 2016-09-04 09:22:28 +0000 | |
commit | 6950c8e205c43756d30d56ca678aa8205e9896fa (patch) | |
tree | 520bceb313719cacbfa77f438a8dc2fe9bf4a4f0 /sys/ddb/db_usrreq.c | |
parent | sync (diff) | |
download | wireguard-openbsd-6950c8e205c43756d30d56ca678aa8205e9896fa.tar.xz wireguard-openbsd-6950c8e205c43756d30d56ca678aa8205e9896fa.zip |
Introduce Dynamic Profiling, a ddb(4) based & gprof compatible kernel
profiling framework.
Code patching is used to enable probes when entering functions. The
probes will call a mcount()-like function to match the behavior of a
GPROF kernel.
Currently only available on amd64 and guarded under DDBPROF. Support
for other archs will follow soon.
A new sysctl knob, ddb.console, need to be set to 1 in securelevel 0
to be able to use this feature.
Inputs and ok guenther@
Diffstat (limited to 'sys/ddb/db_usrreq.c')
-rw-r--r-- | sys/ddb/db_usrreq.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sys/ddb/db_usrreq.c b/sys/ddb/db_usrreq.c index c574dc24930..40e736d67f4 100644 --- a/sys/ddb/db_usrreq.c +++ b/sys/ddb/db_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_usrreq.c,v 1.17 2015/03/14 03:38:46 jsg Exp $ */ +/* $OpenBSD: db_usrreq.c,v 1.18 2016/09/04 09:22:29 mpi Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff. All rights reserved. @@ -35,6 +35,7 @@ #include <ddb/db_var.h> int db_log = 1; +int db_profile; /* Allow dynamic profiling */ int ddb_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, @@ -101,6 +102,23 @@ ddb_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (ENODEV); } return (sysctl_rdint(oldp, oldlenp, newp, 0)); +#if defined(DDBPROF) + case DBCTL_PROFILE: + if (securelevel > 0) + return (sysctl_int_lower(oldp, oldlenp, newp, newlen, + &db_profile)); + else { + ctlval = db_profile; + if ((error = sysctl_int(oldp, oldlenp, newp, newlen, + &ctlval)) || newp == NULL) + return (error); + if (ctlval != 1 && ctlval != 0) + return (EINVAL); + db_profile = ctlval; + return (0); + } + break; +#endif /* DDBPROF */ default: return (EOPNOTSUPP); } |