跟踪数据结构

此部分描述了跟踪数据结构。

The <trace.h> header file defines the posix_trace_status_info 结构 and posix_trace_event_info structures.

posix_trace_status_info 结构

为便于控制跟踪流,请调用 posix_trace_get_status 子例程来动态地获取有关活动的跟踪流的当前状态的信息。

The posix_trace_status_info structure defined in the <trace.h> file contains the following members:
成员类型 成员名 描述
整数 posix_stream_status 跟踪流的工作方式。
整数 posix_stream_full_status 跟踪流的完全状态。
整数 posix_stream_overrun_status 指示在跟踪流中是否已丢失跟踪事件。
整数 posix_stream_flush_status 指示是否正在进行清空。
整数 posix_stream_flush_error 指示在最后一次清空操作期间是否有错误发生。
整数 posix_log_overrun_status 指示在跟踪日志中是否已丢失跟踪事件。
整数 posix_log_full_status 跟踪日志的完全状态。
posix_stream_status 成员指示跟踪流的工作方式。 It can have one of the following values defined by the manifest constants in the <trace.h> header:
POSIX_TRACE_RUNNING
正在进行跟踪。 跟踪流正在接受跟踪事件。
POSIX_TRACE_SUSPENDED
跟踪流没有在接受跟踪事件。 跟踪操作尚未启动或已停止,因为随后是 posix_trace_stop 子例程调用或跟踪资源已用尽。
posix_stream_full_status 成员指示跟踪流的完全状态。 It can have one of the following values defined by manifest constants in the <trace.h> header:
POSIX_TRACE_FULL
跟踪事件的跟踪流中的空间已用尽。
POSIX_TRACE_NOT_FULL
跟踪流中的空间不满。
posix_stream_statusposix_stream_full_status 成员共同指示流的实际状态。 可对该状态进行如下解释:
POSIX_TRACE_RUNNING 和 POSIX_TRACE_NOT_FULL
正在进行跟踪,为记录更多跟踪事件提供了空间。
POSIX_TRACE_RUNNING 和 POSIX_TRACE_FULL
正在进行跟踪,跟踪流充满跟踪事件。 如果流完全策略设为 POSIX_TRACE_LOOP,那么可能出现此状态。 跟踪流包含在先前跟踪事件的移动时间窗口期间记录的跟踪事件,并且一些先前的跟踪事件可能会被覆盖或丢失。
POSIX_TRACE_SUSPENDED 和 POSIX_TRACE_NOT_FULL
跟踪尚未启动,posix_trace_stop 子例程已停止跟踪,或 posix_trace_clear 子例程已清除跟踪。
POSIX_TRACE_SUSPENDED 和 POSIX_TRACE_FULL
跟踪停止。 它停止是因为 stream-full-policy 属性设为 POSIX_TRACE_UNTIL_FULL 且跟踪资源已用尽,或者因为在跟踪资源已用尽时调用 posix_trace_stop 子例程。
posix_stream_overrun_status 成员指示在跟踪流中是否已丢失跟踪事件。 This member can have one of the following values that are defined by manifest constants in the <trace.h> header:
POSIX_TRACE_OVERRUN
跟踪流中已丢失且未记录至少一个跟踪事件。
POSIX_TRACE_NO_OVERRUN
没有丢失任何跟踪事件。
在创建相应跟踪流之后,会将 posix_stream_overrun_status 成员设为 POSIX_TRACE_NO_OVERRUN。 当发生过速时,会将状态设为 POSIX_TRACE_OVERRUN。
在下列情况下会发生过速:
  • 策略为 POSIX_TRACE_LOOP 且所记录跟踪事件被覆盖。
  • 策略为 POSIX_TRACE_UNTIL_FULL 且在生成跟踪事件时跟踪流已满。
  • 策略为 POSIX_TRACE_FLUSH 且在将跟踪流清空到跟踪日志时丢失多个跟踪事件。

在读取 posix_stream_overrun_status 成员的值之后会将其重新设为零。

The posix_stream_flush_status member indicates whether a flush operation is being performed and can have one of the following values that the manifest constants in the <trace.h> header file define:
POSIX_TRACE_FLUSHING
正在将跟踪流清空到跟踪日志。
POSIX_TRACE_NOT_FLUSHING
如果没有进行任何清空操作,那么会将 posix_stream_flush_status 成员设为 POSIX_TRACE_NOT_FLUSHING
在下列情况下,会将 posix_stream_flush_status 成员设为 POSIX_TRACE_FLUSHING
  • 正在进行清空操作,因为已调用 posix_trace_flush 子例程。
  • 正在进行清空操作,因为在 stream-full-policy 属性设为 POSIX_TRACE_FLUSH 时跟踪流已满。

如果清空期间没有发生错误,那么会将 posix_stream_flush_error 成员设置零。 如果先前清空操作期间发生错误,那么会将 posix_stream_flush_error 成员设为发生的第一个错误的值。 如果在清空操作期间发生多个错误,那么会使用第一个错误的值,而弃用其他错误的值。 在读取 posix_stream_flush_error 成员的值之后会将其重新设为零。

posix_log_overrun_status 成员指示在跟踪日志中是否已丢失跟踪事件。 This member can have one of the following values that the manifest constants in the <trace.h> header defines:
POSIX_TRACE_OVERRUN
已丢失至少一个跟踪事件。
POSIX_TRACE_NO_OVERRUN
没有丢失任何跟踪事件。
每当发生过速时,都会将 posix_log_overrun_status 成员设为 POSIX_TRACE_OVERRUN。 在创建相应跟踪流之后,会将 posix_log_overrun_status 成员设为 POSIX_TRACE_NO_OVERRUN。

在读取 posix_log_overrun_status 成员的值之后会将其重新设为零。

如果活动的跟踪流由 posix_trace_create 子例程创建并且它没有日志,那么会将 posix_log_overrun_status 成员设为 POSIX_TRACE_NO_OVERRUN。

The posix_log_full_status member indicates the full status of the trace log, and it can have one of the following values defined by manifest constants in the <trace.h> header:
POSIX_TRACE_FULL
跟踪日志中的空间已满。
POSIX_TRACE_NOT_FULL
跟踪日志中的空间不满。

仅当 log-full-policy 属性为 POSIX_TRACE_UNTIL_FULL 或 POSIX_TRACE_LOOP 时,posix_log_full_status 成员才有意义。

如果活动的跟踪流由 posix_trace_create 子例程创建并且它没有日志,那么会将 posix_log_full_status 成员设为 POSIX_TRACE_NOT_FULL。

posix_trace_event_info 结构

跟踪事件结构 posix_trace_event_info 包含针对所记录跟踪事件的信息。 posix_trace_getnext_eventposix_trace_timedgetnext_eventposix_trace_trygetnext_event 子例程返回此子例程。

The posix_trace_event_info structure that is defined in the <trace.h> header file contains the following members:
成员类型 成员名 描述
跟踪事件标识 posix_event_id 跟踪事件类型标识。
pid_t 位置标识 生成跟踪事件的进程的进程标识。
void* posix_进步地址 确定调用跟踪点的位置。
INT posix_trun阳离子 _status 与此跟踪事件相关联的数据的截断状态。
结构时间间隔 (struct timespec) posix_timestamp 生成跟踪事件的时间。
PTHREAD_T posix_thread_id 生成跟踪事件的线程的标识。
posix_event_id 成员表示跟踪事件类型的标识。 无法直接定义该成员的值。 要返回该标识,请运行下列其中一个子例程:
  • posix_trace_trid_eventid_open
  • posix_trace_eventtypelist_getnext_id
  • posix_trace_eventid_open

要获取跟踪事件类型的名称,请运行 posix_trace_eventid_get_name 子例程。

posix_pid 是生成跟踪事件的所跟踪进程的进程标识。 如果 posix_event_id 成员是某个系统跟踪事件并且该跟踪事件没有与任何进程相关联,那么会将 posix_pid 成员设为零。

对于用户跟踪事件,posix_prog_address 成员是进程的映射地址,并且会确定对 posix_trace_event 子例程进行相关联调用的点。

posix_truncation_status 成员定义与跟踪事件相关联的数据的截断状态。 The posix_trun阳离子 _status member can have one of the following values that the manifest constants in the <trace.h> header define:
POSIX_TRACE_NOT_TRUNCATED
所有已跟踪数据都可用。
POSIX_TRACE_TRUNCATED_RECORD
生成跟踪事件时会截断数据。
POSIX_TRACE_TRUNCATED_READ
从跟踪流或跟踪日志中读取跟踪事件时会截断数据。 此截断状态会覆盖 POSIX_TRACE_TRUNCATED_RECORD 状态。

posix_timestamp 成员定义生成跟踪事件的时间。 使用的时钟为 CLOCK_REALTIME。 要检索此时钟的解决方法,请调用 posix_trace_attr_getclockres 子例程。

posix_thread_id 成员是生成跟踪事件的线程的标识。 如果 posix_event_id 成员是某个系统跟踪事件并且该跟踪事件没有与任何线程相关联,那么会将 posix_thread_id 成员设为零。