logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

posix_trace_create.3p (13085B)


  1. '\" et
  2. .TH POSIX_TRACE_CREATE "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. posix_trace_create,
  12. posix_trace_create_withlog,
  13. posix_trace_flush,
  14. posix_trace_shutdown
  15. \(em trace stream initialization, flush, and shutdown from a process
  16. (\fBTRACING\fP)
  17. .SH SYNOPSIS
  18. .LP
  19. .nf
  20. #include <sys/types.h>
  21. #include <trace.h>
  22. .P
  23. int posix_trace_create(pid_t \fIpid\fP,
  24. const trace_attr_t *restrict \fIattr\fP,
  25. trace_id_t *restrict \fItrid\fP);
  26. int posix_trace_create_withlog(pid_t \fIpid\fP,
  27. const trace_attr_t *restrict \fIattr\fP, int \fIfile_desc\fP,
  28. trace_id_t *restrict \fItrid\fP);
  29. int posix_trace_flush(trace_id_t \fItrid\fP);
  30. int posix_trace_shutdown(trace_id_t \fItrid\fP);
  31. .fi
  32. .SH DESCRIPTION
  33. The
  34. \fIposix_trace_create\fR()
  35. function shall create an active trace stream. It allocates all the
  36. resources needed by the trace stream being created for tracing the
  37. process specified by
  38. .IR pid
  39. in accordance with the
  40. .IR attr
  41. argument. The
  42. .IR attr
  43. argument represents the initial attributes of the trace stream and
  44. shall have been initialized by the function
  45. \fIposix_trace_attr_init\fR()
  46. prior to the
  47. \fIposix_trace_create\fR()
  48. call. If the argument
  49. .IR attr
  50. is NULL, the default attributes shall be used. The
  51. .IR attr
  52. attributes object shall be manipulated through a set of functions
  53. described in the
  54. .IR posix_trace_attr
  55. family of functions. If the attributes of the object pointed to by
  56. .IR attr
  57. are modified later, the attributes of the trace stream shall not be
  58. affected. The
  59. .IR creation-time
  60. attribute of the newly created trace stream shall be set to the value
  61. of the system clock, if the Timers option is not supported, or to the
  62. value of the CLOCK_REALTIME clock, if the Timers option is supported.
  63. .P
  64. The
  65. .IR pid
  66. argument represents the target process to be traced. If the process
  67. executing this function does not have appropriate privileges to trace
  68. the process identified by
  69. .IR pid ,
  70. an error shall be returned. If the
  71. .IR pid
  72. argument is zero, the calling process shall be traced.
  73. .P
  74. The
  75. \fIposix_trace_create\fR()
  76. function shall store the trace stream identifier of the new trace
  77. stream in the object pointed to by the
  78. .IR trid
  79. argument. This trace stream identifier shall be used in subsequent
  80. calls to control tracing. The
  81. .IR trid
  82. argument may only be used by the following functions:
  83. .TS
  84. tab(!);
  85. l l.
  86. T{
  87. .nf
  88. \fIposix_trace_clear\fR()
  89. \fIposix_trace_eventid_equal\fR()
  90. \fIposix_trace_eventid_get_name\fR()
  91. \fIposix_trace_eventtypelist_getnext_id\fR()
  92. \fIposix_trace_eventtypelist_rewind\fR()
  93. \fIposix_trace_get_attr\fR()
  94. \fIposix_trace_get_status\fR()
  95. T}!T{
  96. .nf
  97. \fIposix_trace_getnext_event\fR()
  98. \fIposix_trace_shutdown\fR()
  99. \fIposix_trace_start\fR()
  100. \fIposix_trace_stop\fR()
  101. \fIposix_trace_timedgetnext_event\fR()
  102. \fIposix_trace_trid_eventid_open\fR()
  103. \fIposix_trace_trygetnext_event\fR()
  104. .fi
  105. T}
  106. .TE
  107. .P
  108. If the Trace Event Filter option is supported, the following additional
  109. functions may use the
  110. .IR trid
  111. argument:
  112. .TS
  113. tab(!);
  114. l l.
  115. T{
  116. \fIposix_trace_get_filter\fR()
  117. T}!T{
  118. \fIposix_trace_set_filter\fR()
  119. T}
  120. .TE
  121. .P
  122. In particular, notice that the operations normally used by a trace
  123. analyzer process, such as
  124. \fIposix_trace_rewind\fR()
  125. or
  126. \fIposix_trace_close\fR(),
  127. cannot be invoked using the trace stream identifier returned by the
  128. \fIposix_trace_create\fR()
  129. function.
  130. .P
  131. A trace stream shall be created in a suspended state.
  132. If the Trace Event Filter option is supported, its trace event type
  133. filter shall be empty.
  134. .P
  135. The
  136. \fIposix_trace_create\fR()
  137. function may be called multiple times from the same or different
  138. processes, with the system-wide limit indicated by the runtime
  139. invariant value
  140. {TRACE_SYS_MAX},
  141. which has the minimum value
  142. {_POSIX_TRACE_SYS_MAX}.
  143. .P
  144. The trace stream identifier returned by the
  145. \fIposix_trace_create\fR()
  146. function in the argument pointed to by
  147. .IR trid
  148. is valid only in the process that made the function call. If it is
  149. used from another process, that is a child process, in functions
  150. defined in POSIX.1\(hy2008, these functions shall return with the error
  151. .BR [EINVAL] .
  152. .P
  153. The
  154. \fIposix_trace_create_withlog\fR()
  155. function shall be equivalent to
  156. \fIposix_trace_create\fR(),
  157. except that it associates a trace log with this stream. The
  158. .IR file_desc
  159. argument shall be the file descriptor designating the trace log
  160. destination. The function shall fail if this file descriptor refers to
  161. a file with a file type that is not compatible with the log policy
  162. associated with the trace log. The list of the appropriate file types
  163. that are compatible with each log policy is implementation-defined.
  164. .P
  165. The
  166. \fIposix_trace_create_withlog\fR()
  167. function shall return in the parameter pointed to by
  168. .IR trid
  169. the trace stream identifier, which uniquely identifies the newly
  170. created trace stream, and shall be used in subsequent calls to control
  171. tracing. The
  172. .IR trid
  173. argument may only be used by the following functions:
  174. .TS
  175. tab(!);
  176. l l.
  177. T{
  178. .nf
  179. \fIposix_trace_clear\fR()
  180. \fIposix_trace_eventid_equal\fR()
  181. \fIposix_trace_eventid_get_name\fR()
  182. \fIposix_trace_eventtypelist_getnext_id\fR()
  183. \fIposix_trace_eventtypelist_rewind\fR()
  184. \fIposix_trace_flush\fR()
  185. \fIposix_trace_get_attr\fR()
  186. T}!T{
  187. .nf
  188. \fIposix_trace_get_status\fR()
  189. \fIposix_trace_getnext_event\fR()
  190. \fIposix_trace_shutdown\fR()
  191. \fIposix_trace_start\fR()
  192. \fIposix_trace_stop\fR()
  193. \fIposix_trace_timedgetnext_event\fR()
  194. \fIposix_trace_trid_eventid_open\fR()
  195. .fi
  196. T}
  197. .TE
  198. .P
  199. If the Trace Event Filter option is supported, the following additional
  200. functions may use the
  201. .IR trid
  202. argument:
  203. .TS
  204. tab(!);
  205. l l.
  206. T{
  207. \fIposix_trace_get_filter\fR()
  208. T}!T{
  209. \fIposix_trace_set_filter\fR()
  210. T}
  211. .TE
  212. .P
  213. In particular, notice that the operations normally used by a trace
  214. analyzer process, such as
  215. \fIposix_trace_rewind\fR()
  216. or
  217. \fIposix_trace_close\fR(),
  218. cannot be invoked using the trace stream identifier returned by the
  219. \fIposix_trace_create_withlog\fR()
  220. function.
  221. .P
  222. The
  223. \fIposix_trace_flush\fR()
  224. function shall initiate a flush operation which copies the contents of
  225. the trace stream identified by the argument
  226. .IR trid
  227. into the trace log associated with the trace stream at the creation
  228. time. If no trace log has been associated with the trace stream
  229. pointed to by
  230. .IR trid ,
  231. this function shall return an error. The termination of the flush
  232. operation can be polled by the
  233. \fIposix_trace_get_status\fR()
  234. function. During the flush operation, it shall be possible to trace
  235. new trace events up to the point when the trace stream becomes full.
  236. After flushing is completed, the space used by the flushed trace events
  237. shall be available for tracing new trace events.
  238. .P
  239. If flushing the trace stream causes the resulting trace log to become
  240. full, the trace log full policy shall be applied. If the trace
  241. .IR log-full-policy
  242. attribute is set, the following occurs:
  243. .IP POSIX_TRACE_UNTIL_FULL 6
  244. .br
  245. The trace events that have not yet been flushed shall be discarded.
  246. .IP POSIX_TRACE_LOOP 6
  247. .br
  248. The trace events that have not yet been flushed shall be written to the
  249. beginning of the trace log, overwriting previous trace events stored
  250. there.
  251. .IP POSIX_TRACE_APPEND 6
  252. .br
  253. The trace events that have not yet been flushed shall be appended to the
  254. trace log.
  255. .P
  256. The
  257. \fIposix_trace_shutdown\fR()
  258. function shall stop the tracing of trace events in the trace stream
  259. identified by
  260. .IR trid ,
  261. as if
  262. \fIposix_trace_stop\fR()
  263. had been invoked. The
  264. \fIposix_trace_shutdown\fR()
  265. function shall free all the resources associated with the trace
  266. stream.
  267. .P
  268. The
  269. \fIposix_trace_shutdown\fR()
  270. function shall not return until all the resources associated with the
  271. trace stream have been freed. When the
  272. \fIposix_trace_shutdown\fR()
  273. function returns, the
  274. .IR trid
  275. argument becomes an invalid trace stream identifier. A call to this
  276. function shall unconditionally deallocate the resources regardless of
  277. whether all trace events have been retrieved by the analyzer process.
  278. Any thread blocked on one of the
  279. \fItrace_getnext_event\fR()
  280. functions (which specified this
  281. .IR trid )
  282. before this call is unblocked with the error
  283. .BR [EINVAL] .
  284. .P
  285. If the process exits, invokes a member of the
  286. .IR exec
  287. family of functions, or is terminated, the trace streams that the
  288. process had created and that have not yet been shut down, shall be
  289. automatically shut down as if an explicit call were made to the
  290. \fIposix_trace_shutdown\fR()
  291. function.
  292. .P
  293. For an active trace stream with log, when the
  294. \fIposix_trace_shutdown\fR()
  295. function is called, all trace events that have not yet been flushed to
  296. the trace log shall be flushed, as in the
  297. \fIposix_trace_flush\fR()
  298. function, and the trace log shall be closed.
  299. .P
  300. When a trace log is closed, all the information that may be retrieved
  301. later from the trace log through the trace interface shall have been
  302. written to the trace log. This information includes the trace
  303. attributes, the list of trace event types (with the mapping between
  304. trace event names and trace event type identifiers), and the trace
  305. status.
  306. .P
  307. In addition, unspecified information shall be written to the trace
  308. log to allow detection of a valid trace log during the
  309. \fIposix_trace_open\fR()
  310. operation.
  311. .P
  312. The
  313. \fIposix_trace_shutdown\fR()
  314. function shall not return until all trace events have been flushed.
  315. .SH "RETURN VALUE"
  316. Upon successful completion, these functions shall return a value of
  317. zero. Otherwise, they shall return the corresponding error number.
  318. .P
  319. The
  320. \fIposix_trace_create\fR()
  321. and
  322. \fIposix_trace_create_withlog\fR()
  323. functions store the trace stream identifier value in the object
  324. pointed to by
  325. .IR trid ,
  326. if successful.
  327. .SH ERRORS
  328. The
  329. \fIposix_trace_create\fR()
  330. and
  331. \fIposix_trace_create_withlog\fR()
  332. functions shall fail if:
  333. .TP
  334. .BR EAGAIN
  335. No more trace streams can be started now.
  336. {TRACE_SYS_MAX}
  337. has been exceeded.
  338. .TP
  339. .BR EINTR
  340. The operation was interrupted by a signal. No trace stream was
  341. created.
  342. .TP
  343. .BR EINVAL
  344. One or more of the trace parameters specified by the
  345. .IR attr
  346. parameter is invalid.
  347. .TP
  348. .BR ENOMEM
  349. The implementation does not currently have sufficient memory to create
  350. the trace stream with the specified parameters.
  351. .TP
  352. .BR EPERM
  353. The caller does not have appropriate privileges to trace the process
  354. specified by
  355. .IR pid .
  356. .TP
  357. .BR ESRCH
  358. The
  359. .IR pid
  360. argument does not refer to an existing process.
  361. .P
  362. The
  363. \fIposix_trace_create_withlog\fR()
  364. function shall fail if:
  365. .TP
  366. .BR EBADF
  367. The
  368. .IR file_desc
  369. argument is not a valid file descriptor open for writing.
  370. .TP
  371. .BR EINVAL
  372. The
  373. .IR file_desc
  374. argument refers to a file with a file type that does not support the
  375. log policy associated with the trace log.
  376. .TP
  377. .BR ENOSPC
  378. No space left on device. The device corresponding to the argument
  379. .IR file_desc
  380. does not contain the space required to create this trace log.
  381. .P
  382. The
  383. \fIposix_trace_flush\fR()
  384. and
  385. \fIposix_trace_shutdown\fR()
  386. functions shall fail if:
  387. .TP
  388. .BR EINVAL
  389. The value of the
  390. .IR trid
  391. argument does not correspond to an active trace stream with log.
  392. .TP
  393. .BR EFBIG
  394. The trace log file has attempted to exceed an implementation-defined
  395. maximum file size.
  396. .TP
  397. .BR ENOSPC
  398. No space left on device.
  399. .LP
  400. .IR "The following sections are informative."
  401. .SH EXAMPLES
  402. None.
  403. .SH "APPLICATION USAGE"
  404. None.
  405. .SH RATIONALE
  406. None.
  407. .SH "FUTURE DIRECTIONS"
  408. The
  409. \fIposix_trace_create\fR(),
  410. \fIposix_trace_create_withlog\fR(),
  411. \fIposix_trace_flush\fR(),
  412. and
  413. \fIposix_trace_shutdown\fR()
  414. functions may be removed in a future version.
  415. .SH "SEE ALSO"
  416. .ad l
  417. .IR "\fIclock_getres\fR\^(\|)",
  418. .IR "\fIexec\fR\^",
  419. .IR "\fIposix_trace_attr_destroy\fR\^(\|)",
  420. .IR "\fIposix_trace_clear\fR\^(\|)",
  421. .IR "\fIposix_trace_close\fR\^(\|)",
  422. .IR "\fIposix_trace_eventid_equal\fR\^(\|)",
  423. .IR "\fIposix_trace_eventtypelist_getnext_id\fR\^(\|)",
  424. .IR "\fIposix_trace_get_attr\fR\^(\|)",
  425. .IR "\fIposix_trace_get_filter\fR\^(\|)",
  426. .IR "\fIposix_trace_getnext_event\fR\^(\|)",
  427. .IR "\fIposix_trace_start\fR\^(\|)",
  428. .IR "\fIposix_trace_start\fR\^(\|)",
  429. .IR "\fItime\fR\^(\|)"
  430. .ad b
  431. .P
  432. The Base Definitions volume of POSIX.1\(hy2017,
  433. .IR "\fB<sys_types.h>\fP",
  434. .IR "\fB<trace.h>\fP"
  435. .\"
  436. .SH COPYRIGHT
  437. Portions of this text are reprinted and reproduced in electronic form
  438. from IEEE Std 1003.1-2017, Standard for Information Technology
  439. -- Portable Operating System Interface (POSIX), The Open Group Base
  440. Specifications Issue 7, 2018 Edition,
  441. Copyright (C) 2018 by the Institute of
  442. Electrical and Electronics Engineers, Inc and The Open Group.
  443. In the event of any discrepancy between this version and the original IEEE and
  444. The Open Group Standard, the original IEEE and The Open Group Standard
  445. is the referee document. The original Standard can be obtained online at
  446. http://www.opengroup.org/unix/online.html .
  447. .PP
  448. Any typographical or formatting errors that appear
  449. in this page are most likely
  450. to have been introduced during the conversion of the source files to
  451. man page format. To report such errors, see
  452. https://www.kernel.org/doc/man-pages/reporting_bugs.html .