home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-e.zip / nspr30-e / include / prtrace.h < prev    next >
C/C++ Source or Header  |  1998-09-25  |  23KB  |  636 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  * 
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  * 
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef prtrace_h___
  20. #define prtrace_h___
  21. /*
  22. ** prtrace.h -- NSPR's Trace Facility.                     
  23. **                                                                                  
  24. ** The Trace Facility provides a means to trace application                           
  25. ** program events within a process. When implementing an                            
  26. ** application program an engineer may insert a "Trace" function                    
  27. ** call, passing arguments to be traced. The "Trace" function                        
  28. ** combines the user trace data with identifying data and                           
  29. ** writes this data in time ordered sequence into a circular                        
  30. ** in-memory buffer; when the buffer fills, it wraps.
  31. **                                                                                  
  32. ** Functions are provided to set and/or re-configure the size of                   
  33. ** the trace buffer, control what events are recorded in the                       
  34. ** buffer, enable and disable tracing based on specific user                       
  35. ** supplied data and other control functions. Methods are provided                   
  36. ** to record the trace entries in the in-memory trace buffer to
  37. ** a file.
  38. **                                                                                  
  39. ** Tracing may cause a performance degredation to the application                   
  40. ** depending on the number and placement of calls to the tracing                   
  41. ** facility. When tracing is compiled in and all tracing is                           
  42. ** disabled via the runtime controls, the overhead should be                       
  43. ** minimal. ... Famous last words, eh?                                               
  44. **                                                                                    
  45. ** When DEBUG is defined at compile time, the Trace Facility is                    
  46. ** compiled as part of NSPR and any application using NSPR's                       
  47. ** header files will have tracing compiled in. When DEBUG is not                   
  48. ** defined, the Trace Facility is not compiled into NSPR nor                       
  49. ** exported in its header files.  If the Trace Facility is                         
  50. ** desired in a non-debug build, then FORCE_NSPR_TRACE may be                      
  51. ** defined at compile time for both the optimized build of NSPR                    
  52. ** and the application. NSPR and any application using  NSPR's                     
  53. ** Trace Facility must be compiled with the same level of trace                    
  54. ** conditioning or unresolved references may be realized at link                   
  55. ** time.                                                                           
  56. **                                                                                 
  57. ** For any of the Trace Facility methods that requires a trace                     
  58. ** handle as an input argument, the caller must ensure that the                    
  59. ** trace handle argument is valid. An invalid trace handle                         
  60. ** argument may cause unpredictable results.                                       
  61. **                                                                                 
  62. ** Trace Facility methods are thread-safe and SMP safe.                            
  63. **                                                                                 
  64. ** Users of the Trace Facility should use the defined macros to                     
  65. ** invoke trace methods, not the function calls directly. e.g.                      
  66. ** PR_TRACE( h1,0,1,2, ...); not PR_Trace(h1,0,1,2, ...);
  67. **                                                                                  
  68. ** Application designers should be aware of the effects of
  69. ** debug and optimized build differences when using result of the
  70. ** Trace Facility macros in expressions.
  71. ** 
  72. ** See Also: prcountr.h                                                                                 
  73. **                                                                                  
  74. ** /lth. 08-Jun-1998.                                                                                  
  75. */
  76.  
  77. #include "prtypes.h"
  78. #include "prthread.h"
  79. #include "prtime.h"
  80.  
  81. PR_BEGIN_EXTERN_C
  82.  
  83. /*
  84. ** Opaque type for the trace handle 
  85. ** ... Don't even think about looking in here.
  86. **
  87. */
  88. typedef void *  PRTraceHandle;
  89.  
  90. #if defined (DEBUG) || defined (FORCE_NSPR_TRACE)
  91. /*
  92. ** PRTraceEntry -- A trace entry in the in-memory trace buffer
  93. ** looks like this.
  94. **
  95. */
  96. typedef struct PRTraceEntry
  97. {
  98.     PRThread        *thread;        /* The thread creating the trace entry */
  99.     PRTraceHandle   handle;         /* PRTraceHandle creating the trace entry */
  100.     PRTime          time;           /* Value of PR_Now() at time of trace entry */
  101.     PRUint32        userData[8];    /* user supplied trace data */
  102. } PRTraceEntry;
  103.  
  104. /*
  105. ** PRTraceOption -- command operands to
  106. ** PR_[Set|Get]TraceOption(). See descriptive meanings there.
  107. **
  108. */
  109. typedef enum PRTraceOption
  110. {
  111.     PRTraceBufSize,
  112.     PRTraceEnable,              
  113.     PRTraceDisable,
  114.     PRTraceSuspend,
  115.     PRTraceResume,
  116.     PRTraceSuspendRecording,
  117.     PRTraceResumeRecording,
  118.     PRTraceLockHandles,
  119.     PRTraceUnLockHandles,
  120.     PRTraceStopRecording
  121. } PRTraceOption;
  122.  
  123. /* -----------------------------------------------------------------------
  124. ** FUNCTION: PR_DEFINE_TRACE() -- Define a PRTraceHandle
  125. ** 
  126. ** DESCRIPTION: PR_DEFINE_TRACE() is used to define a trace
  127. ** handle.
  128. ** 
  129. */
  130. #define PR_DEFINE_TRACE(name) PRTraceHandle name
  131.  
  132. /* -----------------------------------------------------------------------
  133. ** FUNCTION: PR_INIT_TRACE_HANDLE() -- Set the value of a PRTraceHandle
  134. ** 
  135. ** DESCRIPTION: 
  136. ** PR_INIT_TRACE_HANDLE() sets the value of a PRTraceHandle
  137. ** to value. e.g. PR_INIT_TRACE_HANDLE( myHandle, NULL );
  138. ** 
  139. */
  140. #define PR_INIT_TRACE_HANDLE(handle,value)\
  141.     (handle) = (PRCounterHandle)(value)
  142.  
  143.  
  144. /* -----------------------------------------------------------------------
  145. ** FUNCTION: PR_CreateTrace() -- Create a trace handle
  146. ** 
  147. ** DESCRIPTION:
  148. **  PR_CreateTrace() creates a new trace handle. Tracing is
  149. **  enabled for this handle when it is created. The trace handle
  150. **  is intended for use in other Trace Facility calls.
  151. **  
  152. **  PR_CreateTrace() registers the QName, RName and description
  153. **  data so that this data can be retrieved later.
  154. ** 
  155. ** INPUTS: 
  156. **  qName: pointer to string. QName for this trace handle. 
  157. ** 
  158. **  rName: pointer to string. RName for this trace handle. 
  159. ** 
  160. **  description: pointer to string. Descriptive data about this
  161. **  trace handle.
  162. **
  163. ** OUTPUTS:
  164. **  Creates the trace handle. 
  165. **  Registers the QName and RName with the trace facility.
  166. ** 
  167. ** RETURNS: 
  168. **  PRTraceHandle
  169. ** 
  170. ** RESTRICTIONS:
  171. **  qName is limited to 31 characters.
  172. **  rName is limited to 31 characters.
  173. **  description is limited to 255 characters.
  174. ** 
  175. */
  176. #define PRTRACE_NAME_MAX 31
  177. #define PRTRACE_DESC_MAX 255
  178.  
  179. #define PR_CREATE_TRACE(handle,qName,rName,description)\
  180.     (handle) = PR_CreateTrace((qName),(rName),(description))
  181.  
  182. PR_EXTERN(PRTraceHandle)
  183.     PR_CreateTrace( 
  184.         const char *qName,          /* QName for this trace handle */
  185.         const char *rName,          /* RName for this trace handle */
  186.         const char *description     /* description for this trace handle */
  187. );
  188.  
  189.  
  190. /* -----------------------------------------------------------------------
  191. ** FUNCTION: PR_DestroyTrace() -- Destroy a trace handle
  192. ** 
  193. ** DESCRIPTION: 
  194. **  PR_DestroyTrace() removes the referenced trace handle and
  195. ** associated QName, RName and description data from the Trace
  196. ** Facility.
  197. ** 
  198. ** INPUTS: handle. A PRTraceHandle
  199. ** 
  200. ** OUTPUTS: 
  201. **  The trace handle is unregistered.
  202. **  The QName, RName and description are removed.
  203. ** 
  204. ** RETURNS: void
  205. ** 
  206. ** RESTRICTIONS:
  207. ** 
  208. */
  209. #define PR_DESTROY_TRACE(handle)\
  210.     PR_DestroyTrace((handle))
  211.  
  212. PR_EXTERN(void) 
  213.     PR_DestroyTrace( 
  214.         PRTraceHandle handle    /* Handle to be destroyed */
  215. );
  216.  
  217.  
  218. /* -----------------------------------------------------------------------
  219. ** FUNCTION: PR_Trace() -- Make a trace entry in the in-memory trace
  220. ** 
  221. ** DESCRIPTION:
  222. ** PR_Trace() makes an entry in the in-memory trace buffer for
  223. ** the referenced trace handle. The next logically available
  224. ** PRTraceEntry is used; when the next trace entry would overflow
  225. ** the trace table, the table wraps.
  226. **
  227. ** PR_Trace() for a specific trace handle may be disabled by
  228. ** calling PR_SetTraceOption() specifying PRTraceDisable for the
  229. ** trace handle to be disabled.
  230. ** 
  231. ** INPUTS:
  232. ** handle: PRTraceHandle. The trace handle for this trace.
  233. ** 
  234. ** userData[0..7]: unsigned 32bit integers. user supplied data
  235. ** that is copied into the PRTraceEntry
  236. ** 
  237. ** OUTPUTS:
  238. **  A PRTraceEntry is (conditionally) formatted in the in-memory
  239. ** trace buffer.
  240. ** 
  241. ** RETURNS: void.
  242. ** 
  243. ** RESTRICTIONS:
  244. ** 
  245. */
  246. #define PR_TRACE(handle,ud0,ud1,ud2,ud3,ud4,ud5,ud6,ud7)\
  247.     PR_Trace((handle),(ud0),(ud1),(ud2),(ud3),(ud4),(ud5),(ud6),(ud7))
  248.  
  249. PR_EXTERN(void) 
  250.     PR_Trace( 
  251.         PRTraceHandle handle,       /* use this trace handle */
  252.         PRUint32    userData0,      /* User supplied data word 0 */
  253.         PRUint32    userData1,      /* User supplied data word 1 */
  254.         PRUint32    userData2,      /* User supplied data word 2 */
  255.         PRUint32    userData3,      /* User supplied data word 3 */
  256.         PRUint32    userData4,      /* User supplied data word 4 */
  257.         PRUint32    userData5,      /* User supplied data word 5 */
  258.         PRUint32    userData6,      /* User supplied data word 6 */
  259.         PRUint32    userData7       /* User supplied data word 7 */
  260. );
  261.  
  262. /* -----------------------------------------------------------------------
  263. ** FUNCTION: PR_SetTraceOption() -- Control the Trace Facility
  264. ** 
  265. ** DESCRIPTION:
  266. ** PR_SetTraceOption() controls the Trace Facility. Depending on
  267. ** command and value, attributes of the Trace Facility may be
  268. ** changed.
  269. ** 
  270. ** INPUTS:
  271. **  command: An enumerated value in the set of PRTraceOption.
  272. **  value: pointer to the data to be set. Type of the data is
  273. **  dependent on command; for each value of command, the type
  274. **  and meaning of dereferenced value is shown.
  275. **
  276. **  PRTraceBufSize: unsigned long: the size of the trace buffer,
  277. ** in bytes.
  278. ** 
  279. **  PRTraceEnable: PRTraceHandle. The trace handle to be
  280. ** enabled.
  281. ** 
  282. **  PRTraceDisable: PRTraceHandle. The trace handle to be
  283. ** disabled.
  284. ** 
  285. **  PRTraceSuspend: void. value must be NULL. All tracing is
  286. ** suspended.
  287. ** 
  288. **  PRTraceResume: void. value must be NULL. Tracing for all
  289. ** previously enabled, prior to a PRTraceSuspend, is resumed.
  290. ** 
  291. **  PRTraceStopRecording: void. value must be NULL. If recording
  292. ** (see: ** PR_RecordTraceEntries()) is being done, 
  293. ** PRTraceStopRecording causes PR_RecordTraceEntries() to return
  294. ** to its caller. If recording is not being done, this function
  295. ** has no effect.
  296. ** 
  297. **  PRTraceSuspendRecording: void. Must be NULL. If recording is
  298. ** being done, PRTraceSuspendRecording causes further writes to
  299. ** the trace file to be suspended. Data in the in-memory
  300. ** trace buffer that would ordinarily be written to the
  301. ** trace file will not be written. Trace entries will continue
  302. ** to be entered in the in-memory buffer. If the Trace Facility
  303. ** recording is already in a suspended state, the call has no
  304. ** effect.
  305. ** 
  306. **  PRTraceResumeRecording: void. value must be NULL. If
  307. ** recording for the Trace Facility has been previously been
  308. ** suspended, this causes recording to resume. Recording resumes
  309. ** with the next in-memory buffer segment that would be written
  310. ** if trace recording had not been suspended. If recording is
  311. ** not currently suspended, the call has no effect.
  312. ** 
  313. **  PRTraceLockHandles: void. value must be NULL. Locks the
  314. ** trace handle lock. While the trace handle lock is held,
  315. ** calls to PR_CreateTrace() will block until the lock is
  316. ** released.
  317. ** 
  318. **  PRTraceUnlockHandles: void. value must be NULL. Unlocks the
  319. ** trace handle lock.
  320. ** 
  321. ** OUTPUTS:
  322. **  The operation of the Trace Facility may be changed.
  323. ** 
  324. ** RETURNS: void
  325. ** 
  326. ** RESTRICTIONS:
  327. ** 
  328. */
  329. #define PR_SET_TRACE_OPTION(command,value)\
  330.     PR_SetTraceOption((command),(value))
  331.  
  332. PR_EXTERN(void) 
  333.     PR_SetTraceOption( 
  334.         PRTraceOption command,  /* One of the enumerated values */
  335.         void *value             /* command value or NULL */
  336. );
  337.  
  338.  
  339. /* -----------------------------------------------------------------------
  340. ** FUNCTION: PR_GetTraceOption() -- Retrieve settings from the Trace Facility
  341. ** 
  342. ** DESCRIPTION:
  343. ** PR_GetTraceOption() retrieves the current setting of the
  344. ** Trace Facility control depending on command.
  345. ** 
  346. ** 
  347. **  PRTraceBufSize: unsigned long: the size of the trace buffer,
  348. ** in bytes.
  349. ** 
  350. ** 
  351. ** INPUTS:
  352. **  command: one of the enumerated values in PRTraceOptions
  353. ** valid for PR_GetTraceOption().
  354. ** 
  355. ** OUTPUTS:
  356. **  dependent on command.
  357. ** 
  358. ** RETURNS: void
  359. ** 
  360. ** RESTRICTIONS:
  361. ** 
  362. */
  363. #define PR_GET_TRACE_OPTION(command,value)\
  364.     PR_GetTraceOption((command),(value))
  365.  
  366. PR_EXTERN(void) 
  367.     PR_GetTraceOption( 
  368.         PRTraceOption command,  /* One of the enumerated values */
  369.         void *value             /* command value or NULL */
  370. );
  371.  
  372. /* -----------------------------------------------------------------------
  373. ** FUNCTION: PR_GetTraceHandleFromName() -- Retrieve an existing
  374. ** handle by name.
  375. ** 
  376. ** DESCRIPTION:
  377. ** PR_GetTraceHandleFromName() retreives an existing tracehandle
  378. ** using the name specified by qName and rName.
  379. ** 
  380. ** INPUTS:
  381. **  qName: pointer to string. QName for this trace handle. 
  382. ** 
  383. **  rName: pointer to string. RName for this trace handle. 
  384. ** 
  385. ** 
  386. ** OUTPUTS: returned.
  387. ** 
  388. ** RETURNS: 
  389. **  PRTraceHandle associated with qName and rName or NULL when
  390. ** there is no match.
  391. ** 
  392. ** RESTRICTIONS:
  393. ** 
  394. */
  395. #define PR_GET_TRACE_HANDLE_FROM_NAME(handle,qName,rName)\
  396.     (handle) = PR_GetTraceHandleFromName((qName),(rName))
  397.  
  398. PR_EXTERN(PRTraceHandle) 
  399.     PR_GetTraceHandleFromName( 
  400.         const char *qName,      /* QName search argument */
  401.         const char *rName       /* RName search argument */
  402. );
  403.  
  404. /* -----------------------------------------------------------------------
  405. ** FUNCTION: PR_GetTraceNameFromHandle() -- Retreive trace name
  406. ** by bandle.
  407. ** 
  408. ** DESCRIPTION:
  409. ** PR_GetTraceNameFromHandle() retreives the existing qName,
  410. ** rName, and description for the referenced trace handle.
  411. ** 
  412. ** INPUTS: handle: PRTraceHandle.
  413. ** 
  414. ** OUTPUTS: pointers to the Trace Facility's copy of qName,
  415. ** rName and description. ... Don't mess with these values.
  416. ** They're mine.
  417. ** 
  418. ** RETURNS: void
  419. ** 
  420. ** RESTRICTIONS:
  421. ** 
  422. */
  423. #define PR_GET_TRACE_NAME_FROM_HANDLE(handle,qName,rName,description)\
  424.     PR_GetTraceNameFromHandle((handle),(qName),(rName),(description))
  425.  
  426. PR_EXTERN(void) 
  427.     PR_GetTraceNameFromHandle( 
  428.         PRTraceHandle handle,       /* handle as search argument */
  429.         const char **qName,         /* pointer to associated QName */
  430.         const char **rName,         /* pointer to associated RName */
  431.         const char **description    /* pointer to associated description */
  432. );
  433.  
  434. /* -----------------------------------------------------------------------
  435. ** FUNCTION: PR_FindNextTraceQname() -- Retrieive a QName handle
  436. ** iterator.
  437. ** 
  438. ** DESCRIPTION:
  439. ** PR_FindNextTraceQname() retreives the first or next trace
  440. ** QName handle, depending on the value of handle, from the trace
  441. ** database. The PRTraceHandle returned can be used as an
  442. ** iterator to traverse the QName handles in the Trace database.
  443. ** 
  444. ** INPUTS:
  445. **  handle: When NULL, PR_FindNextQname() returns the first QName
  446. ** handle. When a handle is a valid PRTraceHandle previously
  447. ** retreived using PR_FindNextQname() the next QName handle is
  448. ** retreived.
  449. ** 
  450. ** OUTPUTS: returned.
  451. ** 
  452. ** RETURNS: 
  453. **  PRTraceHandle or NULL when there are no trace handles.
  454. ** 
  455. ** RESTRICTIONS:
  456. **  Iterating thru the trace handles via FindFirst/FindNext
  457. ** should be done under protection of the trace handle lock.
  458. ** See: PR_SetTraceOption( PRLockTraceHandles ).
  459. ** 
  460. */
  461. #define PR_FIND_NEXT_TRACE_QNAME(next,handle)\
  462.     (next) = PR_FindNextTraceQname((handle))
  463.  
  464. PR_EXTERN(PRTraceHandle) 
  465.     PR_FindNextTraceQname( 
  466.         PRTraceHandle handle
  467. );
  468.  
  469.  
  470. /* -----------------------------------------------------------------------
  471. ** FUNCTION: PR_FindNextTraceRname() -- Retrieive an RName handle
  472. ** iterator.
  473. ** 
  474. ** DESCRIPTION:
  475. ** PR_FindNextTraceRname() retreives the first or next trace
  476. ** RName handle, depending on the value of handle, from the trace
  477. ** database. The PRTraceHandle returned can be used as an
  478. ** iterator to traverse the RName handles in the Trace database.
  479. ** 
  480. ** INPUTS:
  481. **  rhandle: When NULL, PR_FindNextRname() returns the first
  482. ** RName handle. When a handle is a valid PRTraceHandle
  483. ** previously retreived using PR_FindNextRname() the next RName
  484. ** handle is retreived.
  485. **  qhandle: A valid PRTraceHandle retruned from a previous call
  486. ** to PR_FIND_NEXT_TRACE_QNAME().
  487. ** 
  488. ** OUTPUTS: returned.
  489. ** 
  490. ** RETURNS: 
  491. **  PRTraceHandle or NULL when there are no trace handles.
  492. ** 
  493. ** RESTRICTIONS:
  494. **  Iterating thru the trace handles via FindNext should be done
  495. ** under protection of the trace handle lock. See: (
  496. ** PR_SetTraceOption( PRLockTraceHandles ).
  497. ** 
  498. */
  499. #define PR_FIND_NEXT_TRACE_RNAME(next,rhandle,qhandle)\
  500.     (next) = PR_FindNextTraceRname((rhandle),(qhandle))
  501.  
  502. PR_EXTERN(PRTraceHandle) 
  503.     PR_FindNextTraceRname( 
  504.         PRTraceHandle rhandle,
  505.         PRTraceHandle qhandle
  506. );
  507.  
  508. /* -----------------------------------------------------------------------
  509. ** FUNCTION: PR_RecordTraceEntries() -- Write trace entries to external media
  510. ** 
  511. ** DESCRIPTION:
  512. ** PR_RecordTraceEntries() causes entries in the in-memory trace
  513. ** buffer to be written to external media.
  514. **
  515. ** When PR_RecordTraceEntries() is called from an application
  516. ** thread, the function appears to block until another thread
  517. ** calls PR_SetTraceOption() with the PRTraceStopRecording
  518. ** option. This suggests that PR_RecordTraceEntries() should be
  519. ** called from a user supplied thread whose only job is to
  520. ** record trace entries. 
  521. ** 
  522. ** The environment variable NSPR_TRACE_LOG controls the operation
  523. ** of this function. When NSPR_TRACE_LOG is not defined in the
  524. ** environment, no recording of trace entries occurs. When
  525. ** NSPR_TRACE_LOG is defined, the value of its definition must be
  526. ** the filename of the file to receive the trace entry buffer.
  527. **
  528. ** PR_RecordTraceEntries() attempts to record the in-memory
  529. ** buffer to a file, subject to the setting of the environment
  530. ** variable NSPR_TRACE_LOG. It is possible because of system
  531. ** load, the thread priority of the recording thread, number of
  532. ** active trace records being written over time, and other
  533. ** variables that some trace records can be lost. ... In other
  534. ** words: don't bet the farm on getting everything.
  535. ** 
  536. ** INPUTS: none
  537. ** 
  538. ** OUTPUTS: none
  539. ** 
  540. ** RETURNS: PR_STATUS
  541. **    PR_SUCCESS no errors were found.
  542. **    PR_FAILURE errors were found.
  543. ** 
  544. ** RESTRICTIONS:
  545. ** Only one thread can call PR_RecordTraceEntries() within a
  546. ** process.
  547. ** 
  548. ** On error, PR_RecordTraceEntries() may return prematurely.
  549. ** 
  550. */
  551. #define PR_RECORD_TRACE_ENTRIES()\
  552.     PR_RecordTraceEntries()
  553.     
  554. PR_EXTERN(void)
  555.     PR_RecordTraceEntries(
  556.         void 
  557. );
  558.  
  559. /* -----------------------------------------------------------------------
  560. ** FUNCTION: PR_GetTraceEntries() -- Retreive trace entries from
  561. ** the Trace Facility
  562. ** 
  563. ** DESCRIPTION:
  564. ** PR_GetTraceEntries() retreives trace entries from the Trace
  565. ** Facility. Up to count trace entries are copied from the Trace
  566. ** Facility into buffer. Only those trace entries that have not
  567. ** been copied via a previous call to PR_GetTraceEntries() are
  568. ** copied. The actual number copied is placed in the PRInt32
  569. ** variable pointed to by found.
  570. **
  571. ** If more than count trace entries have entered the Trace
  572. ** Facility since the last call to PR_GetTraceEntries() 
  573. ** a lost data condition is returned. In this case, the most
  574. ** recent count trace entries are copied into buffer and found is
  575. ** set to count.
  576. ** 
  577. ** INPUTS:
  578. **  count. The number of trace entries to be copied into buffer.
  579. ** 
  580. ** 
  581. ** OUTPUTS:
  582. **  buffer. An array of PRTraceEntries. The buffer is supplied
  583. ** by the caller.
  584. ** 
  585. ** found: 32bit signed integer. The number of PRTraceEntries
  586. ** actually copied. found is always less than or equal to count.
  587. ** 
  588. ** RETURNS: 
  589. **  zero when there is no lost data.
  590. **  non-zero when some PRTraceEntries have been lost.
  591. ** 
  592. ** RESTRICTIONS:
  593. ** This is a real performance pig. The copy out operation is bad
  594. ** enough, but depending on then frequency of calls to the
  595. ** function, serious performance impact to the operating
  596. ** application may be realized. ... YMMV.
  597. ** 
  598. */
  599. #define PR_GET_TRACE_ENTRIES(buffer,count,found)\
  600.         PR_GetTraceEntries((buffer),(count),(found))
  601.  
  602.  
  603. PR_EXTERN(PRIntn)
  604.     PR_GetTraceEntries(
  605.         PRTraceEntry    *buffer,    /* where to write output */
  606.         PRInt32         count,      /* number to get */
  607.         PRInt32         *found      /* number you got */
  608. );
  609.  
  610. #else /* !(defined (DEBUG) || defined (FORCE_NSPR_TRACE)) */
  611. /*
  612. ** Define the Trace Facility macros as No-Ops for when the trace
  613. ** facility is to be compiled-out of the application.
  614. **
  615. */
  616. #define PR_DEFINE_TRACE(name) PRTraceHandle name
  617. #define PR_INIT_TRACE_HANDLE(handle,value)
  618. #define PR_CREATE_TRACE(handle,qName,rName,description)
  619. #define PR_DESTROY_TRACE(handle)
  620. #define PR_TRACE(handle,ud0,ud1,ud2,ud3,ud4,ud5,ud6,ud7)
  621. #define PR_SET_TRACE_OPTION(command,value)
  622. #define PR_GET_TRACE_OPTION(command,value)
  623. #define PR_GET_TRACE_HANDLE_FROM_NAME(handle,qName,rName)
  624. #define PR_GET_TRACE_NAME_FROM_HANDLE(handle,qName,rName,description)
  625. #define PR_FIND_NEXT_TRACE_QNAME(next,handle)
  626. #define PR_FIND_NEXT_TRACE_RNAME(next,rhandle,qhandle)
  627. #define PR_GET_TRACE_ENTRIES(buffer,count,found)
  628. #define PR_RECORD_TRACE_ENTRIES()
  629.  
  630. #endif /* !(defined (DEBUG) || defined (FORCE_NSPR_TRACE)) */
  631.  
  632. PR_END_EXTERN_C
  633.  
  634. #endif /* prtrace_h___ */
  635.  
  636.