security/nss/lib/util/nssilckt.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 /*
michael@0 6 ** nssilock.h - Instrumented locking functions for NSS
michael@0 7 **
michael@0 8 ** Description:
michael@0 9 ** nssilock provides instrumentation for locks and monitors in
michael@0 10 ** the NSS libraries. The instrumentation, when enabled, causes
michael@0 11 ** each call to the instrumented function to record data about
michael@0 12 ** the call to an external file. The external file
michael@0 13 ** subsequently used to extract performance data and other
michael@0 14 ** statistical information about the operation of locks used in
michael@0 15 ** the nss library.
michael@0 16 **
michael@0 17 ** To enable compilation with instrumentation, build NSS with
michael@0 18 ** the compile time switch NEED_NSS_ILOCK defined.
michael@0 19 **
michael@0 20 ** say: "gmake OS_CFLAGS+=-DNEED_NSS_ILOCK" at make time.
michael@0 21 **
michael@0 22 ** At runtime, to enable recording from nssilock, one or more
michael@0 23 ** environment variables must be set. For each nssILockType to
michael@0 24 ** be recorded, an environment variable of the form NSS_ILOCK_x
michael@0 25 ** must be set to 1. For example:
michael@0 26 **
michael@0 27 ** set NSS_ILOCK_Cert=1
michael@0 28 **
michael@0 29 ** nssilock uses PRLOG is used to record to trace data. The
michael@0 30 ** PRLogModule name associated with nssilock data is: "nssilock".
michael@0 31 ** To enable recording of nssilock data you will need to set the
michael@0 32 ** environment variable NSPR_LOG_MODULES to enable
michael@0 33 ** recording for the nssilock log module. Similarly, you will
michael@0 34 ** need to set the environment variable NSPR_LOG_FILE to specify
michael@0 35 ** the filename to receive the recorded data. See prlog.h for usage.
michael@0 36 ** Example:
michael@0 37 **
michael@0 38 ** export NSPR_LOG_MODULES=nssilock:6
michael@0 39 ** export NSPR_LOG_FILE=xxxLogfile
michael@0 40 **
michael@0 41 ** Operation:
michael@0 42 ** nssilock wraps calls to NSPR's PZLock and PZMonitor functions
michael@0 43 ** with similarly named functions: PZ_NewLock(), etc. When NSS is
michael@0 44 ** built with lock instrumentation enabled, the PZ* functions are
michael@0 45 ** compiled into NSS; when lock instrumentation is disabled,
michael@0 46 ** calls to PZ* functions are directly mapped to PR* functions
michael@0 47 ** and the instrumentation arguments to the PZ* functions are
michael@0 48 ** compiled away.
michael@0 49 **
michael@0 50 **
michael@0 51 ** File Format:
michael@0 52 ** The format of the external file is implementation
michael@0 53 ** dependent. Where NSPR's PR_LOG() function is used, the file
michael@0 54 ** contains data defined for PR_LOG() plus the data written by
michael@0 55 ** the wrapped function. On some platforms and under some
michael@0 56 ** circumstances, platform dependent logging or
michael@0 57 ** instrumentation probes may be used. In any case, the
michael@0 58 ** relevant data provided by the lock instrumentation is:
michael@0 59 **
michael@0 60 ** lockType, func, address, duration, line, file [heldTime]
michael@0 61 **
michael@0 62 ** where:
michael@0 63 **
michael@0 64 ** lockType: a character representation of nssILockType for the
michael@0 65 ** call. e.g. ... "cert"
michael@0 66 **
michael@0 67 ** func: the function doing the tracing. e.g. "NewLock"
michael@0 68 **
michael@0 69 ** address: address of the instrumented lock or monitor
michael@0 70 **
michael@0 71 ** duration: is how long was spent in the instrumented function,
michael@0 72 ** in PRIntervalTime "ticks".
michael@0 73 **
michael@0 74 ** line: the line number within the calling function
michael@0 75 **
michael@0 76 ** file: the file from which the call was made
michael@0 77 **
michael@0 78 ** heldTime: how long the lock/monitor was held. field
michael@0 79 ** present only for PZ_Unlock() and PZ_ExitMonitor().
michael@0 80 **
michael@0 81 ** Design Notes:
michael@0 82 ** The design for lock instrumentation was influenced by the
michael@0 83 ** need to gather performance data on NSS 3.x. It is intended
michael@0 84 ** that the effort to modify NSS to use lock instrumentation
michael@0 85 ** be minimized. Existing calls to locking functions need only
michael@0 86 ** have their names changed to the instrumentation function
michael@0 87 ** names.
michael@0 88 **
michael@0 89 ** Private NSS Interface:
michael@0 90 ** nssilock.h defines a private interface for use by NSS.
michael@0 91 ** nssilock.h is experimental in nature and is subject to
michael@0 92 ** change or revocation without notice. ... Don't mess with
michael@0 93 ** it.
michael@0 94 **
michael@0 95 */
michael@0 96
michael@0 97 /*
michael@0 98 * $Id:
michael@0 99 */
michael@0 100
michael@0 101 #ifndef _NSSILCKT_H_
michael@0 102 #define _NSSILCKT_H_
michael@0 103
michael@0 104 #include "utilrename.h"
michael@0 105 #include "prtypes.h"
michael@0 106 #include "prmon.h"
michael@0 107 #include "prlock.h"
michael@0 108 #include "prcvar.h"
michael@0 109
michael@0 110 typedef enum {
michael@0 111 nssILockArena = 0,
michael@0 112 nssILockSession = 1,
michael@0 113 nssILockObject = 2,
michael@0 114 nssILockRefLock = 3,
michael@0 115 nssILockCert = 4,
michael@0 116 nssILockCertDB = 5,
michael@0 117 nssILockDBM = 6,
michael@0 118 nssILockCache = 7,
michael@0 119 nssILockSSL = 8,
michael@0 120 nssILockList = 9,
michael@0 121 nssILockSlot = 10,
michael@0 122 nssILockFreelist = 11,
michael@0 123 nssILockOID = 12,
michael@0 124 nssILockAttribute = 13,
michael@0 125 nssILockPK11cxt = 14, /* pk11context */
michael@0 126 nssILockRWLock = 15,
michael@0 127 nssILockOther = 16,
michael@0 128 nssILockSelfServ = 17,
michael@0 129 nssILockKeyDB = 18,
michael@0 130 nssILockLast /* don't use this one! */
michael@0 131 } nssILockType;
michael@0 132
michael@0 133 /*
michael@0 134 ** conditionally compile in nssilock features
michael@0 135 */
michael@0 136 #if defined(NEED_NSS_ILOCK)
michael@0 137
michael@0 138 /*
michael@0 139 ** Declare operation type enumerator
michael@0 140 ** enumerations identify the function being performed
michael@0 141 */
michael@0 142 typedef enum {
michael@0 143 FlushTT = 0,
michael@0 144 NewLock = 1,
michael@0 145 Lock = 2,
michael@0 146 Unlock = 3,
michael@0 147 DestroyLock = 4,
michael@0 148 NewCondVar = 5,
michael@0 149 WaitCondVar = 6,
michael@0 150 NotifyCondVar = 7,
michael@0 151 NotifyAllCondVar = 8,
michael@0 152 DestroyCondVar = 9,
michael@0 153 NewMonitor = 10,
michael@0 154 EnterMonitor = 11,
michael@0 155 ExitMonitor = 12,
michael@0 156 Notify = 13,
michael@0 157 NotifyAll = 14,
michael@0 158 Wait = 15,
michael@0 159 DestroyMonitor = 16
michael@0 160 } nssILockOp;
michael@0 161
michael@0 162 /*
michael@0 163 ** Declare the trace record
michael@0 164 */
michael@0 165 struct pzTrace_s {
michael@0 166 PRUint32 threadID; /* PR_GetThreadID() */
michael@0 167 nssILockOp op; /* operation being performed */
michael@0 168 nssILockType ltype; /* lock type identifier */
michael@0 169 PRIntervalTime callTime; /* time spent in function */
michael@0 170 PRIntervalTime heldTime; /* lock held time, or -1 */
michael@0 171 void *lock; /* address of lock structure */
michael@0 172 PRIntn line; /* line number */
michael@0 173 char file[24]; /* filename */
michael@0 174 };
michael@0 175
michael@0 176 /*
michael@0 177 ** declare opaque types. See: nssilock.c
michael@0 178 */
michael@0 179 typedef struct pzlock_s PZLock;
michael@0 180 typedef struct pzcondvar_s PZCondVar;
michael@0 181 typedef struct pzmonitor_s PZMonitor;
michael@0 182
michael@0 183 #else /* NEED_NSS_ILOCK */
michael@0 184
michael@0 185 #define PZLock PRLock
michael@0 186 #define PZCondVar PRCondVar
michael@0 187 #define PZMonitor PRMonitor
michael@0 188
michael@0 189 #endif /* NEED_NSS_ILOCK */
michael@0 190
michael@0 191 #endif /* _NSSILCKT_H_ */

mercurial