| 1 | /* |
| 2 | * LinuxEvents.h |
| 3 | * |
| 4 | * Copyright (C) 2000, 2001, 2002 Karim Yaghmour (karym@opersys.com). |
| 5 | * |
| 6 | * This header is distributed under GPL. |
| 7 | * |
| 8 | * Linux events being traced. |
| 9 | * |
| 10 | * History : |
| 11 | * K.Y., 31/05/1999, Initial typing. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #ifndef __TRACE_TOOLKIT_LINUX_HEADER__ |
| 16 | #define __TRACE_TOOLKIT_LINUX_HEADER__ |
| 17 | |
| 18 | #include "LTTTypes.h" |
| 19 | |
| 20 | /* Traced events */ |
| 21 | #define TRACE_START 0 /* This is to mark the trace's start */ |
| 22 | #define TRACE_SYSCALL_ENTRY 1 /* Entry in a given system call */ |
| 23 | #define TRACE_SYSCALL_EXIT 2 /* Exit from a given system call */ |
| 24 | #define TRACE_TRAP_ENTRY 3 /* Entry in a trap */ |
| 25 | #define TRACE_TRAP_EXIT 4 /* Exit from a trap */ |
| 26 | #define TRACE_IRQ_ENTRY 5 /* Entry in an irq */ |
| 27 | #define TRACE_IRQ_EXIT 6 /* Exit from an irq */ |
| 28 | #define TRACE_SCHEDCHANGE 7 /* Scheduling change */ |
| 29 | #define TRACE_KERNEL_TIMER 8 /* The kernel timer routine has been called */ |
| 30 | #define TRACE_SOFT_IRQ 9 /* Hit key part of soft-irq management */ |
| 31 | #define TRACE_PROCESS 10 /* Hit key part of process management */ |
| 32 | #define TRACE_FILE_SYSTEM 11 /* Hit key part of file system */ |
| 33 | #define TRACE_TIMER 12 /* Hit key part of timer management */ |
| 34 | #define TRACE_MEMORY 13 /* Hit key part of memory management */ |
| 35 | #define TRACE_SOCKET 14 /* Hit key part of socket communication */ |
| 36 | #define TRACE_IPC 15 /* Hit key part of inter-process communication */ |
| 37 | #define TRACE_NETWORK 16 /* Hit key part of network communication */ |
| 38 | |
| 39 | #define TRACE_BUFFER_START 17 /* Mark the begining of a trace buffer */ |
| 40 | #define TRACE_BUFFER_END 18 /* Mark the ending of a trace buffer */ |
| 41 | #define TRACE_NEW_EVENT 19 /* New event type */ |
| 42 | #define TRACE_CUSTOM 20 /* Custom event */ |
| 43 | |
| 44 | #define TRACE_CHANGE_MASK 21 /* Change in event mask */ |
| 45 | #define TRACE_HEARTBEAT 22 /* Heartbeat event */ |
| 46 | |
| 47 | /* Number of traced events */ |
| 48 | #define TRACE_MAX TRACE_HEARTBEAT |
| 49 | |
| 50 | /* Architecture types */ |
| 51 | #define TRACE_ARCH_TYPE_I386 1 /* i386 system */ |
| 52 | #define TRACE_ARCH_TYPE_PPC 2 /* PPC system */ |
| 53 | #define TRACE_ARCH_TYPE_SH 3 /* SH system */ |
| 54 | #define TRACE_ARCH_TYPE_S390 4 /* S/390 system */ |
| 55 | #define TRACE_ARCH_TYPE_MIPS 5 /* MIPS system */ |
| 56 | #define TRACE_ARCH_TYPE_ARM 6 /* ARM system */ |
| 57 | |
| 58 | /* Standard definitions for variants */ |
| 59 | #define TRACE_ARCH_VARIANT_NONE 0 /* Main architecture implementation */ |
| 60 | |
| 61 | /* PowerPC variants */ |
| 62 | #define TRACE_ARCH_VARIANT_PPC_4xx 1 /* 4xx systems (IBM embedded series) */ |
| 63 | #define TRACE_ARCH_VARIANT_PPC_6xx 2 /* 6xx/7xx/74xx/8260/POWER3 systems (desktop flavor) */ |
| 64 | #define TRACE_ARCH_VARIANT_PPC_8xx 3 /* 8xx system (Motoral embedded series) */ |
| 65 | #define TRACE_ARCH_VARIANT_PPC_ISERIES 4 /* 8xx system (iSeries) */ |
| 66 | |
| 67 | /* System types */ |
| 68 | #define TRACE_SYS_TYPE_VANILLA_LINUX 1 /* Vanilla linux kernel */ |
| 69 | #define TRACE_SYS_TYPE_RTAI_LINUX 2 /* RTAI patched linux kernel */ |
| 70 | |
| 71 | /* The information logged when the tracing is started */ |
| 72 | #define TRACER_MAGIC_NUMBER 0x00D6B7ED /* That day marks an important historical event ... */ |
| 73 | #define TRACER_SUP_VERSION_MAJOR 2 /* Major version number */ |
| 74 | |
| 75 | /* Minimum information contained in any trace start event */ |
| 76 | typedef struct _trace_start_any |
| 77 | { |
| 78 | uint32_t MagicNumber; /* Magic number to identify a trace */ |
| 79 | uint32_t ArchType; /* Type of architecture */ |
| 80 | uint32_t ArchVariant; /* Variant of the given type of architecture */ |
| 81 | uint32_t SystemType; /* Operating system type */ |
| 82 | uint8_t MajorVersion; /* Major version of trace */ |
| 83 | uint8_t MinorVersion; /* Minor version of trace */ |
| 84 | |
| 85 | } LTT_PACKED_STRUCT trace_start_any; |
| 86 | |
| 87 | typedef struct _trace_start_2_2 |
| 88 | { |
| 89 | uint32_t MagicNumber; /* Magic number to identify a trace */ |
| 90 | uint32_t ArchType; /* Type of architecture */ |
| 91 | uint32_t ArchVariant; /* Variant of the given type of architecture */ |
| 92 | uint32_t SystemType; /* Operating system type */ |
| 93 | uint8_t MajorVersion; /* Major version of trace */ |
| 94 | uint8_t MinorVersion; /* Minor version of trace */ |
| 95 | |
| 96 | uint32_t BufferSize; /* Size of buffers */ |
| 97 | trace_event_mask EventMask; /* The event mask */ |
| 98 | trace_event_mask DetailsMask; /* Are the event details logged */ |
| 99 | uint8_t LogCPUID; /* Is the CPUID logged */ |
| 100 | uint8_t UseTSC; /* Are we using TSCs or time deltas */ |
| 101 | |
| 102 | } LTT_PACKED_STRUCT trace_start_2_2; |
| 103 | |
| 104 | typedef struct _trace_start_2_3 |
| 105 | { |
| 106 | uint32_t MagicNumber; /* Magic number to identify a trace */ |
| 107 | uint32_t ArchType; /* Type of architecture */ |
| 108 | uint32_t ArchVariant; /* Variant of the given type of architecture */ |
| 109 | uint32_t SystemType; /* Operating system type */ |
| 110 | uint8_t MajorVersion; /* Major version of trace */ |
| 111 | uint8_t MinorVersion; /* Minor version of trace */ |
| 112 | |
| 113 | uint32_t BufferSize; /* Size of buffers */ |
| 114 | trace_event_mask EventMask; /* The event mask */ |
| 115 | trace_event_mask DetailsMask; /* Are the event details logged */ |
| 116 | uint8_t LogCPUID; /* Is the CPUID logged */ |
| 117 | uint8_t UseTSC; /* Are we using TSCs or time deltas */ |
| 118 | |
| 119 | uint8_t FlightRecorder; /* Is this a flight recorder trace ? */ |
| 120 | } LTT_PACKED_STRUCT trace_start_2_3; |
| 121 | |
| 122 | /* TRACE_SYSCALL_ENTRY */ |
| 123 | typedef struct _trace_syscall_entry |
| 124 | { |
| 125 | uint8_t syscall_id; /* Syscall entry number in entry.S */ |
| 126 | uint32_t address; /* Address from which call was made */ |
| 127 | } LTT_PACKED_STRUCT trace_syscall_entry; |
| 128 | #define SYSCALL_EVENT(X) ((trace_syscall_entry*)X) |
| 129 | |
| 130 | /* TRACE_TRAP_ENTRY */ |
| 131 | typedef struct _trace_trap_entry |
| 132 | { |
| 133 | uint16_t trap_id; /* Trap number */ |
| 134 | uint32_t address; /* Address where trap occured */ |
| 135 | } LTT_PACKED_STRUCT trace_trap_entry; |
| 136 | typedef struct _trace_trap_entry_s390 |
| 137 | { |
| 138 | uint64_t trap_id; /* Trap number */ |
| 139 | uint32_t address; /* Address where trap occured */ |
| 140 | } LTT_PACKED_STRUCT trace_trap_entry_s390; |
| 141 | #define TRAP_EVENT(X) ((trace_trap_entry*)X) |
| 142 | #define TRAP_EVENT_S390(X) ((trace_trap_entry_s390*)X) |
| 143 | |
| 144 | /* TRACE_IRQ_ENTRY */ |
| 145 | typedef struct _trace_irq_entry |
| 146 | { |
| 147 | uint8_t irq_id; /* IRQ number */ |
| 148 | uint8_t kernel; /* Are we executing kernel code */ |
| 149 | } LTT_PACKED_STRUCT trace_irq_entry; |
| 150 | #define IRQ_EVENT(X) ((trace_irq_entry*)X) |
| 151 | |
| 152 | /* TRACE_SCHEDCHANGE */ |
| 153 | typedef struct _trace_schedchange |
| 154 | { |
| 155 | uint32_t out; /* Outgoing process */ |
| 156 | uint32_t in; /* Incoming process */ |
| 157 | uint32_t out_state; /* Outgoing process' state */ |
| 158 | } LTT_PACKED_STRUCT trace_schedchange; |
| 159 | #define SCHED_EVENT(X) ((trace_schedchange*)X) |
| 160 | |
| 161 | /* TRACE_SOFT_IRQ */ |
| 162 | #define TRACE_SOFT_IRQ_BOTTOM_HALF 1 /* Conventional bottom-half */ |
| 163 | #define TRACE_SOFT_IRQ_SOFT_IRQ 2 /* Real soft-irq */ |
| 164 | #define TRACE_SOFT_IRQ_TASKLET_ACTION 3 /* Tasklet action */ |
| 165 | #define TRACE_SOFT_IRQ_TASKLET_HI_ACTION 4 /* Tasklet hi-action */ |
| 166 | typedef struct _trace_soft_irq |
| 167 | { |
| 168 | uint8_t event_sub_id; /* Soft-irq event Id */ |
| 169 | uint32_t event_data; /* Data associated with event */ |
| 170 | } LTT_PACKED_STRUCT trace_soft_irq; |
| 171 | #define SOFT_IRQ_EVENT(X) ((trace_soft_irq*)X) |
| 172 | |
| 173 | /* TRACE_PROCESS */ |
| 174 | #define TRACE_PROCESS_KTHREAD 1 /* Creation of a kernel thread */ |
| 175 | #define TRACE_PROCESS_FORK 2 /* A fork or clone occured */ |
| 176 | #define TRACE_PROCESS_EXIT 3 /* An exit occured */ |
| 177 | #define TRACE_PROCESS_WAIT 4 /* A wait occured */ |
| 178 | #define TRACE_PROCESS_SIGNAL 5 /* A signal has been sent */ |
| 179 | #define TRACE_PROCESS_WAKEUP 6 /* Wake up a process */ |
| 180 | typedef struct _trace_process |
| 181 | { |
| 182 | uint8_t event_sub_id; /* Process event ID */ |
| 183 | uint32_t event_data1; /* Data associated with event */ |
| 184 | uint32_t event_data2; |
| 185 | } LTT_PACKED_STRUCT trace_process; |
| 186 | #define PROC_EVENT(X) ((trace_process*)X) |
| 187 | |
| 188 | /* TRACE_FILE_SYSTEM */ |
| 189 | #define TRACE_FILE_SYSTEM_BUF_WAIT_START 1 /* Starting to wait for a data buffer */ |
| 190 | #define TRACE_FILE_SYSTEM_BUF_WAIT_END 2 /* End to wait for a data buffer */ |
| 191 | #define TRACE_FILE_SYSTEM_EXEC 3 /* An exec occured */ |
| 192 | #define TRACE_FILE_SYSTEM_OPEN 4 /* An open occured */ |
| 193 | #define TRACE_FILE_SYSTEM_CLOSE 5 /* A close occured */ |
| 194 | #define TRACE_FILE_SYSTEM_READ 6 /* A read occured */ |
| 195 | #define TRACE_FILE_SYSTEM_WRITE 7 /* A write occured */ |
| 196 | #define TRACE_FILE_SYSTEM_SEEK 8 /* A seek occured */ |
| 197 | #define TRACE_FILE_SYSTEM_IOCTL 9 /* An ioctl occured */ |
| 198 | #define TRACE_FILE_SYSTEM_SELECT 10 /* A select occured */ |
| 199 | #define TRACE_FILE_SYSTEM_POLL 11 /* A poll occured */ |
| 200 | typedef struct _trace_file_system |
| 201 | { |
| 202 | uint8_t event_sub_id; /* File system event ID */ |
| 203 | uint32_t event_data1; /* Event data */ |
| 204 | uint32_t event_data2; /* Event data 2 */ |
| 205 | char* file_name; /* Name of file operated on */ |
| 206 | } LTT_PACKED_STRUCT trace_file_system; |
| 207 | #define FS_EVENT(X) ((trace_file_system*)X) |
| 208 | #define FS_EVENT_FILENAME(X) ((char*) ((X) + sizeof(trace_file_system))) |
| 209 | |
| 210 | /* TRACE_TIMER */ |
| 211 | #define TRACE_TIMER_EXPIRED 1 /* Timer expired */ |
| 212 | #define TRACE_TIMER_SETITIMER 2 /* Setting itimer occurred */ |
| 213 | #define TRACE_TIMER_SETTIMEOUT 3 /* Setting sched timeout occurred */ |
| 214 | typedef struct _trace_timer |
| 215 | { |
| 216 | uint8_t event_sub_id; /* Timer event ID */ |
| 217 | uint8_t event_sdata; /* Short data */ |
| 218 | uint32_t event_data1; /* Data associated with event */ |
| 219 | uint32_t event_data2; |
| 220 | } LTT_PACKED_STRUCT trace_timer; |
| 221 | #define TIMER_EVENT(X) ((trace_timer*)X) |
| 222 | |
| 223 | /* TRACE_MEMORY */ |
| 224 | #define TRACE_MEMORY_PAGE_ALLOC 1 /* Allocating pages */ |
| 225 | #define TRACE_MEMORY_PAGE_FREE 2 /* Freing pages */ |
| 226 | #define TRACE_MEMORY_SWAP_IN 3 /* Swaping pages in */ |
| 227 | #define TRACE_MEMORY_SWAP_OUT 4 /* Swaping pages out */ |
| 228 | #define TRACE_MEMORY_PAGE_WAIT_START 5 /* Start to wait for page */ |
| 229 | #define TRACE_MEMORY_PAGE_WAIT_END 6 /* End to wait for page */ |
| 230 | typedef struct _trace_memory |
| 231 | { |
| 232 | uint8_t event_sub_id; /* Memory event ID */ |
| 233 | unsigned long event_data; /* Data associated with event */ |
| 234 | } LTT_PACKED_STRUCT trace_memory; |
| 235 | #define MEM_EVENT(X) ((trace_memory*)X) |
| 236 | |
| 237 | /* TRACE_SOCKET */ |
| 238 | #define TRACE_SOCKET_CALL 1 /* A socket call occured */ |
| 239 | #define TRACE_SOCKET_CREATE 2 /* A socket has been created */ |
| 240 | #define TRACE_SOCKET_SEND 3 /* Data was sent to a socket */ |
| 241 | #define TRACE_SOCKET_RECEIVE 4 /* Data was read from a socket */ |
| 242 | typedef struct _trace_socket |
| 243 | { |
| 244 | uint8_t event_sub_id; /* Socket event ID */ |
| 245 | uint32_t event_data1; /* Data associated with event */ |
| 246 | uint32_t event_data2; /* Data associated with event */ |
| 247 | } LTT_PACKED_STRUCT trace_socket; |
| 248 | #define SOCKET_EVENT(X) ((trace_socket*)X) |
| 249 | |
| 250 | /* TRACE_IPC */ |
| 251 | #define TRACE_IPC_CALL 1 /* A System V IPC call occured */ |
| 252 | #define TRACE_IPC_MSG_CREATE 2 /* A message queue has been created */ |
| 253 | #define TRACE_IPC_SEM_CREATE 3 /* A semaphore was created */ |
| 254 | #define TRACE_IPC_SHM_CREATE 4 /* A shared memory segment has been created */ |
| 255 | typedef struct _trace_ipc |
| 256 | { |
| 257 | uint8_t event_sub_id; /* IPC event ID */ |
| 258 | uint32_t event_data1; /* Data associated with event */ |
| 259 | uint32_t event_data2; /* Data associated with event */ |
| 260 | } LTT_PACKED_STRUCT trace_ipc; |
| 261 | #define IPC_EVENT(X) ((trace_ipc*)X) |
| 262 | |
| 263 | /* TRACE_NETWORK */ |
| 264 | #define TRACE_NETWORK_PACKET_IN 1 /* A packet came in */ |
| 265 | #define TRACE_NETWORK_PACKET_OUT 2 /* A packet was sent */ |
| 266 | typedef struct _trace_network |
| 267 | { |
| 268 | uint8_t event_sub_id; /* Network event ID */ |
| 269 | uint32_t event_data; /* Event data */ |
| 270 | } LTT_PACKED_STRUCT trace_network; |
| 271 | #define NET_EVENT(X) ((trace_network*)X) |
| 272 | |
| 273 | /* Start of trace buffer information */ |
| 274 | typedef struct _trace_buffer_start |
| 275 | { |
| 276 | struct timeval Time; /* Time stamp of this buffer */ |
| 277 | uint32_t TSC; /* TSC of this buffer, if applicable */ |
| 278 | uint32_t ID; /* Unique buffer ID */ |
| 279 | } LTT_PACKED_STRUCT trace_buffer_start; |
| 280 | |
| 281 | /* End of trace buffer information */ |
| 282 | typedef struct _trace_buffer_end |
| 283 | { |
| 284 | struct timeval Time; /* Time stamp of this buffer */ |
| 285 | uint32_t TSC; /* TSC of this buffer, if applicable */ |
| 286 | } LTT_PACKED_STRUCT trace_buffer_end; |
| 287 | |
| 288 | /* Maximal size a custom event can have */ |
| 289 | #define CUSTOM_EVENT_MAX_SIZE 8192 |
| 290 | |
| 291 | /* String length limits for custom events creation */ |
| 292 | #define CUSTOM_EVENT_TYPE_STR_LEN 20 |
| 293 | #define CUSTOM_EVENT_DESC_STR_LEN 100 |
| 294 | #define CUSTOM_EVENT_FORM_STR_LEN 256 |
| 295 | |
| 296 | /* Type of custom event formats */ |
| 297 | #define CUSTOM_EVENT_FORMAT_TYPE_NONE 0 |
| 298 | #define CUSTOM_EVENT_FORMAT_TYPE_STR 1 |
| 299 | #define CUSTOM_EVENT_FORMAT_TYPE_HEX 2 |
| 300 | #define CUSTOM_EVENT_FORMAT_TYPE_XML 3 |
| 301 | #define CUSTOM_EVENT_FORMAT_TYPE_IBM 4 |
| 302 | |
| 303 | typedef struct _trace_new_event |
| 304 | { |
| 305 | /* Basics */ |
| 306 | uint32_t id; /* Custom event ID */ |
| 307 | char type[CUSTOM_EVENT_TYPE_STR_LEN]; /* Event type description */ |
| 308 | char desc[CUSTOM_EVENT_DESC_STR_LEN]; /* Detailed event description */ |
| 309 | |
| 310 | /* Custom formatting */ |
| 311 | uint32_t format_type; /* Type of formatting */ |
| 312 | char form[CUSTOM_EVENT_FORM_STR_LEN]; /* Data specific to format */ |
| 313 | } LTT_PACKED_STRUCT trace_new_event; |
| 314 | #define NEW_EVENT(X) ((trace_new_event*) X) |
| 315 | |
| 316 | typedef struct _trace_custom |
| 317 | { |
| 318 | uint32_t id; /* Event ID */ |
| 319 | uint32_t data_size; /* Size of data recorded by event */ |
| 320 | void* data; /* Data recorded by event */ |
| 321 | } LTT_PACKED_STRUCT trace_custom; |
| 322 | #define CUSTOM_EVENT(X) ((trace_custom*) X) |
| 323 | |
| 324 | /* TRACE_CHANGE_MASK */ |
| 325 | typedef struct _trace_change_mask |
| 326 | { |
| 327 | trace_event_mask mask; /* Event mask */ |
| 328 | } LTT_PACKED_STRUCT trace_change_mask; |
| 329 | #define CHMASK_EVENT(X) ((trace_change_mask*) X) |
| 330 | |
| 331 | #endif /* __TRACE_TOOLKIT_LINUX_HEADER__ */ |