prtrace.h 20 KB

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