1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
** nssilock.h - Instrumented locking functions for NSS
9
** nssilock provides instrumentation for locks and monitors in
10
** the NSS libraries. The instrumentation, when enabled, causes
11
** each call to the instrumented function to record data about
12
** the call to an external file. The external file
13
** subsequently used to extract performance data and other
14
** statistical information about the operation of locks used in
17
** To enable compilation with instrumentation, build NSS with
18
** the compile time switch NEED_NSS_ILOCK defined.
20
** say: "gmake OS_CFLAGS+=-DNEED_NSS_ILOCK" at make time.
22
** At runtime, to enable recording from nssilock, one or more
23
** environment variables must be set. For each nssILockType to
24
** be recorded, an environment variable of the form NSS_ILOCK_x
25
** must be set to 1. For example:
27
** set NSS_ILOCK_Cert=1
29
** nssilock uses PRLOG is used to record to trace data. The
30
** PRLogModule name associated with nssilock data is: "nssilock".
31
** To enable recording of nssilock data you will need to set the
32
** environment variable NSPR_LOG_MODULES to enable
33
** recording for the nssilock log module. Similarly, you will
34
** need to set the environment variable NSPR_LOG_FILE to specify
35
** the filename to receive the recorded data. See prlog.h for usage.
38
** export NSPR_LOG_MODULES=nssilock:6
39
** export NSPR_LOG_FILE=xxxLogfile
42
** nssilock wraps calls to NSPR's PZLock and PZMonitor functions
43
** with similarly named functions: PZ_NewLock(), etc. When NSS is
44
** built with lock instrumentation enabled, the PZ* functions are
45
** compiled into NSS; when lock instrumentation is disabled,
46
** calls to PZ* functions are directly mapped to PR* functions
47
** and the instrumentation arguments to the PZ* functions are
52
** The format of the external file is implementation
53
** dependent. Where NSPR's PR_LOG() function is used, the file
54
** contains data defined for PR_LOG() plus the data written by
55
** the wrapped function. On some platforms and under some
56
** circumstances, platform dependent logging or
57
** instrumentation probes may be used. In any case, the
58
** relevant data provided by the lock instrumentation is:
60
** lockType, func, address, duration, line, file [heldTime]
64
** lockType: a character representation of nssILockType for the
65
** call. e.g. ... "cert"
67
** func: the function doing the tracing. e.g. "NewLock"
69
** address: address of the instrumented lock or monitor
71
** duration: is how long was spent in the instrumented function,
72
** in PRIntervalTime "ticks".
74
** line: the line number within the calling function
76
** file: the file from which the call was made
78
** heldTime: how long the lock/monitor was held. field
79
** present only for PZ_Unlock() and PZ_ExitMonitor().
82
** The design for lock instrumentation was influenced by the
83
** need to gather performance data on NSS 3.x. It is intended
84
** that the effort to modify NSS to use lock instrumentation
85
** be minimized. Existing calls to locking functions need only
86
** have their names changed to the instrumentation function
89
** Private NSS Interface:
90
** nssilock.h defines a private interface for use by NSS.
91
** nssilock.h is experimental in nature and is subject to
92
** change or revocation without notice. ... Don't mess with
104
#include "utilrename.h"
122
nssILockFreelist = 11,
124
nssILockAttribute = 13,
125
nssILockPK11cxt = 14, /* pk11context */
128
nssILockSelfServ = 17,
130
nssILockLast /* don't use this one! */
134
** conditionally compile in nssilock features
136
#if defined(NEED_NSS_ILOCK)
139
** Declare operation type enumerator
140
** enumerations identify the function being performed
151
NotifyAllCondVar = 8,
163
** Declare the trace record
166
PRUint32 threadID; /* PR_GetThreadID() */
167
nssILockOp op; /* operation being performed */
168
nssILockType ltype; /* lock type identifier */
169
PRIntervalTime callTime; /* time spent in function */
170
PRIntervalTime heldTime; /* lock held time, or -1 */
171
void *lock; /* address of lock structure */
172
PRIntn line; /* line number */
173
char file[24]; /* filename */
177
** declare opaque types. See: nssilock.c
179
typedef struct pzlock_s PZLock;
180
typedef struct pzcondvar_s PZCondVar;
181
typedef struct pzmonitor_s PZMonitor;
183
#else /* NEED_NSS_ILOCK */
185
#define PZLock PRLock
186
#define PZCondVar PRCondVar
187
#define PZMonitor PRMonitor
189
#endif /* NEED_NSS_ILOCK */
191
#endif /* _NSSILCKT_H_ */