| 1 | /* This file is part of the Linux Trace Toolkit viewer |
| 2 | * Copyright (C) 2003-2004 Michel Dagenais |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License Version 2 as |
| 6 | * published by the Free Software Foundation; |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 16 | * MA 02111-1307, USA. |
| 17 | */ |
| 18 | |
| 19 | #ifndef STATE_H |
| 20 | #define STATE_H |
| 21 | |
| 22 | #include <glib.h> |
| 23 | #include <lttv/tracecontext.h> |
| 24 | #include <stdio.h> |
| 25 | |
| 26 | /* The operating system state, kept during the trace analysis, |
| 27 | contains a subset of the real operating system state, |
| 28 | sufficient for the analysis, and possibly organized quite differently. |
| 29 | |
| 30 | The state information is added to LttvTracesetContext, LttvTraceContext |
| 31 | and LttvTracefileContext objects, used by process_traceset, through |
| 32 | subtyping. The context objects already reflect the multiple tracefiles |
| 33 | (one per cpu) per trace and multiple traces per trace set. The state |
| 34 | objects defined here simply add fields to the relevant context objects. |
| 35 | |
| 36 | There is no traceset specific state yet. It may eventually contains such |
| 37 | things as clock differences over time. |
| 38 | |
| 39 | The trace state currently consists in a process table. |
| 40 | |
| 41 | The tracefile level state relates to the associated cpu. It contains the |
| 42 | position of the current event in the tracefile (since the state depends on |
| 43 | which events have been processed) and a pointer to the current process, |
| 44 | in the process table, being run on that cpu. |
| 45 | |
| 46 | For each process in the process table, various informations such as exec |
| 47 | file name, pid, ppid and creation time are stored. Each process state also |
| 48 | contains an execution mode stack (e.g. irq within system call, called |
| 49 | from user mode). */ |
| 50 | |
| 51 | /* Priority of state hooks */ |
| 52 | #define LTTV_PRIO_STATE 25 |
| 53 | |
| 54 | #define LTTV_STATE_SAVE_INTERVAL 50000 |
| 55 | |
| 56 | /* Facilities Quarks */ |
| 57 | |
| 58 | extern GQuark |
| 59 | LTT_FACILITY_KERNEL, |
| 60 | LTT_FACILITY_KERNEL_ARCH, |
| 61 | LTT_FACILITY_PROCESS, |
| 62 | LTT_FACILITY_FS, |
| 63 | LTT_FACILITY_STATEDUMP, |
| 64 | LTT_FACILITY_USER_GENERIC, |
| 65 | /**************************************************** |
| 66 | * JOV - XenoLTT - 2006-09-27 |
| 67 | * New facility XenoLTT |
| 68 | ****************************************************/ |
| 69 | LTT_FACILITY_XENOLTT; |
| 70 | |
| 71 | /* Events Quarks */ |
| 72 | |
| 73 | extern GQuark |
| 74 | LTT_EVENT_SYSCALL_ENTRY, |
| 75 | LTT_EVENT_SYSCALL_EXIT, |
| 76 | LTT_EVENT_TRAP_ENTRY, |
| 77 | LTT_EVENT_TRAP_EXIT, |
| 78 | LTT_EVENT_IRQ_ENTRY, |
| 79 | LTT_EVENT_IRQ_EXIT, |
| 80 | LTT_EVENT_SOFT_IRQ_ENTRY, |
| 81 | LTT_EVENT_SOFT_IRQ_EXIT, |
| 82 | LTT_EVENT_SCHEDCHANGE, |
| 83 | LTT_EVENT_FORK, |
| 84 | LTT_EVENT_KERNEL_THREAD, |
| 85 | LTT_EVENT_EXIT, |
| 86 | LTT_EVENT_FREE, |
| 87 | LTT_EVENT_EXEC, |
| 88 | LTT_EVENT_ENUM_PROCESS_STATE, |
| 89 | LTT_EVENT_FUNCTION_ENTRY, |
| 90 | LTT_EVENT_FUNCTION_EXIT, |
| 91 | LTT_EVENT_THREAD_BRAND, |
| 92 | /**************************************************** |
| 93 | * JOV - XenoLTT - 2006-09-27 |
| 94 | * New events for facility XenoLTT |
| 95 | ****************************************************/ |
| 96 | LTT_EVENT_XENOLTT_THREAD_INIT, |
| 97 | LTT_EVENT_XENOLTT_THREAD_SET_PERIOD, |
| 98 | LTT_EVENT_XENOLTT_THREAD_WAIT_PERIOD, |
| 99 | LTT_EVENT_XENOLTT_THREAD_MISSED_PERIOD, |
| 100 | LTT_EVENT_XENOLTT_THREAD_SUSPEND, |
| 101 | LTT_EVENT_XENOLTT_THREAD_START, |
| 102 | LTT_EVENT_XENOLTT_THREAD_RESUME, |
| 103 | LTT_EVENT_XENOLTT_THREAD_DELETE, |
| 104 | LTT_EVENT_XENOLTT_THREAD_UNBLOCK, |
| 105 | LTT_EVENT_XENOLTT_THREAD_RENICE, |
| 106 | LTT_EVENT_XENOLTT_TIMER_TICK, |
| 107 | LTT_EVENT_XENOLTT_SYNCH_SET_OWNER, |
| 108 | LTT_EVENT_XENOLTT_SYNCH_UNLOCK, |
| 109 | LTT_EVENT_XENOLTT_SYNCH_WAKEUP1, |
| 110 | LTT_EVENT_XENOLTT_SYNCH_WAKEUPX, |
| 111 | LTT_EVENT_XENOLTT_SYNCH_SLEEP_ON, |
| 112 | LTT_EVENT_XENOLTT_SYNCH_FLUSH, |
| 113 | LTT_EVENT_XENOLTT_SYNCH_FORGET, |
| 114 | LTT_EVENT_XENOLTT_THREAD_SWITCH; |
| 115 | |
| 116 | /* Fields Quarks */ |
| 117 | |
| 118 | extern GQuark |
| 119 | LTT_FIELD_SYSCALL_ID, |
| 120 | LTT_FIELD_TRAP_ID, |
| 121 | LTT_FIELD_IRQ_ID, |
| 122 | LTT_FIELD_SOFT_IRQ_ID, |
| 123 | LTT_FIELD_OUT, |
| 124 | LTT_FIELD_IN, |
| 125 | LTT_FIELD_OUT_STATE, |
| 126 | LTT_FIELD_PARENT_PID, |
| 127 | LTT_FIELD_CHILD_PID, |
| 128 | LTT_FIELD_PID, |
| 129 | LTT_FIELD_TGID, |
| 130 | LTT_FIELD_FILENAME, |
| 131 | LTT_FIELD_NAME, |
| 132 | LTT_FIELD_TYPE, |
| 133 | LTT_FIELD_MODE, |
| 134 | LTT_FIELD_SUBMODE, |
| 135 | LTT_FIELD_STATUS, |
| 136 | LTT_FIELD_THIS_FN, |
| 137 | LTT_FIELD_CALL_SITE, |
| 138 | /**************************************************** |
| 139 | * JOV - XenoLTT - 2006-09-27 |
| 140 | * New fields for XenoLTT events |
| 141 | ****************************************************/ |
| 142 | LTT_FIELD_XENOLTT_NAME, |
| 143 | LTT_FIELD_XENOLTT_ADDRESS, |
| 144 | LTT_FIELD_XENOLTT_FLAGS, |
| 145 | LTT_FIELD_XENOLTT_PRIO, |
| 146 | LTT_FIELD_XENOLTT_PERIOD, |
| 147 | LTT_FIELD_XENOLTT_IDATE, |
| 148 | LTT_FIELD_XENOLTT_SYNCH, |
| 149 | LTT_FIELD_XENOLTT_TIMER_ADDRESS, |
| 150 | LTT_FIELD_XENOLTT_OVERRUNS, |
| 151 | LTT_FIELD_XENOLTT_NAME_OUT, |
| 152 | LTT_FIELD_XENOLTT_ADDRESS_OUT; |
| 153 | |
| 154 | |
| 155 | |
| 156 | typedef struct _LttvTracesetState LttvTracesetState; |
| 157 | typedef struct _LttvTracesetStateClass LttvTracesetStateClass; |
| 158 | |
| 159 | typedef struct _LttvTraceState LttvTraceState; |
| 160 | typedef struct _LttvTraceStateClass LttvTraceStateClass; |
| 161 | |
| 162 | typedef struct _LttvTracefileState LttvTracefileState; |
| 163 | typedef struct _LttvTracefileStateClass LttvTracefileStateClass; |
| 164 | |
| 165 | gint lttv_state_hook_add_event_hooks(void *hook_data, void *call_data); |
| 166 | void lttv_state_add_event_hooks(LttvTracesetState *self); |
| 167 | |
| 168 | gint lttv_state_hook_remove_event_hooks(void *hook_data, void *call_data); |
| 169 | void lttv_state_remove_event_hooks(LttvTracesetState *self); |
| 170 | |
| 171 | void lttv_state_save_add_event_hooks(LttvTracesetState *self); |
| 172 | // Hook wrapper. call_data is a trace context. |
| 173 | gint lttv_state_save_hook_add_event_hooks(void *hook_data, void *call_data); |
| 174 | |
| 175 | void lttv_state_save_remove_event_hooks(LttvTracesetState *self); |
| 176 | // Hook wrapper. call_data is a trace context. |
| 177 | gint lttv_state_save_hook_remove_event_hooks(void *hook_data, void *call_data); |
| 178 | |
| 179 | void lttv_state_traceset_seek_time_closest(LttvTracesetState *self, LttTime t); |
| 180 | |
| 181 | /* The LttvProcessState structure defines the current state for each process. |
| 182 | A process can make system calls (in some rare cases nested) and receive |
| 183 | interrupts/faults. For instance, a process may issue a system call, |
| 184 | generate a page fault while reading an argument from user space, and |
| 185 | get caught by an interrupt. To represent these nested states, an |
| 186 | execution mode stack is maintained. The stack bottom is normal user mode |
| 187 | and the top of stack is the current execution mode. |
| 188 | |
| 189 | The execution mode stack tells about the process status, execution mode and |
| 190 | submode (interrupt, system call or IRQ number). All these could be |
| 191 | defined as enumerations but may need extensions (e.g. new process state). |
| 192 | GQuark are thus used. They are as easy to manipulate as integers but have |
| 193 | a string associated, just like enumerations. |
| 194 | |
| 195 | The execution mode is one of "user mode", "kernel thread", "system call", |
| 196 | "interrupt request", "fault". */ |
| 197 | |
| 198 | typedef GQuark LttvExecutionMode; |
| 199 | |
| 200 | extern LttvExecutionMode |
| 201 | LTTV_STATE_USER_MODE, |
| 202 | LTTV_STATE_SYSCALL, |
| 203 | LTTV_STATE_TRAP, |
| 204 | LTTV_STATE_IRQ, |
| 205 | LTTV_STATE_SOFT_IRQ, |
| 206 | LTTV_STATE_MODE_UNKNOWN; |
| 207 | |
| 208 | |
| 209 | /* The submode number depends on the execution mode. For user mode or kernel |
| 210 | thread, which are the normal mode (execution mode stack bottom), |
| 211 | it is set to "none". For interrupt requests, faults and system calls, |
| 212 | it is set respectively to the interrupt name (e.g. "timer"), fault name |
| 213 | (e.g. "page fault"), and system call name (e.g. "select"). */ |
| 214 | |
| 215 | typedef GQuark LttvExecutionSubmode; |
| 216 | |
| 217 | extern LttvExecutionSubmode |
| 218 | LTTV_STATE_SUBMODE_NONE, |
| 219 | LTTV_STATE_SUBMODE_UNKNOWN; |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | typedef GQuark LttvXenoExecutionMode; |
| 225 | |
| 226 | extern LttvXenoExecutionMode |
| 227 | LTTV_XENO_MODE_UNKNOWN, |
| 228 | LTTV_XENO_MODE_NORMAL, |
| 229 | LTTV_XENO_MODE_OVERRUN; |
| 230 | |
| 231 | |
| 232 | /* The process status is one of "running", "wait-cpu" (runnable), or "wait-*" |
| 233 | where "*" describes the resource waited for (e.g. timer, process, |
| 234 | disk...). */ |
| 235 | |
| 236 | typedef GQuark LttvProcessStatus; |
| 237 | |
| 238 | extern LttvProcessStatus |
| 239 | LTTV_STATE_UNNAMED, |
| 240 | LTTV_STATE_UNBRANDED, |
| 241 | LTTV_STATE_WAIT_FORK, |
| 242 | LTTV_STATE_WAIT_CPU, |
| 243 | LTTV_STATE_EXIT, |
| 244 | LTTV_STATE_ZOMBIE, |
| 245 | LTTV_STATE_WAIT, |
| 246 | LTTV_STATE_RUN, |
| 247 | LTTV_STATE_DEAD; |
| 248 | |
| 249 | /**************************************************** |
| 250 | * JOV - XenoLTT - 2006-09-27 |
| 251 | * New status XenoLTT |
| 252 | ****************************************************/ |
| 253 | typedef GQuark LttvXenoThreadStatus; |
| 254 | |
| 255 | extern LttvXenoThreadStatus |
| 256 | LTTV_XENO_STATE_INIT, |
| 257 | LTTV_XENO_STATE_UNNAMED, |
| 258 | LTTV_XENO_STATE_RUN, |
| 259 | LTTV_XENO_STATE_SUSPEND, |
| 260 | LTTV_XENO_STATE_DEAD, |
| 261 | LTTV_XENO_STATE_WAIT_PERIOD, |
| 262 | LTTV_XENO_STATE_START, |
| 263 | LTTV_XENO_STATE_READY; |
| 264 | |
| 265 | |
| 266 | typedef GQuark LttvProcessType; |
| 267 | |
| 268 | extern LttvProcessType |
| 269 | LTTV_STATE_USER_THREAD, |
| 270 | LTTV_STATE_KERNEL_THREAD; |
| 271 | |
| 272 | typedef struct _LttvExecutionState { |
| 273 | LttvExecutionMode t; |
| 274 | LttvExecutionSubmode n; |
| 275 | LttTime entry; |
| 276 | LttTime change; |
| 277 | LttTime cum_cpu_time; |
| 278 | LttvProcessStatus s; |
| 279 | } LttvExecutionState; |
| 280 | |
| 281 | |
| 282 | typedef struct _LttvXenoExecutionState { |
| 283 | LttvXenoExecutionMode mode; |
| 284 | LttTime entry; |
| 285 | LttTime change; |
| 286 | LttTime cum_cpu_time; |
| 287 | LttvXenoThreadStatus status; |
| 288 | gboolean started; /* the task has started */ |
| 289 | LttTime overrun_start; |
| 290 | gboolean running; |
| 291 | } LttvXenoExecutionState; |
| 292 | |
| 293 | typedef struct _LttvProcessState { |
| 294 | guint pid; |
| 295 | guint tgid; |
| 296 | guint ppid; |
| 297 | LttTime creation_time; |
| 298 | LttTime insertion_time; |
| 299 | GQuark name; |
| 300 | GQuark brand; |
| 301 | GQuark pid_time; |
| 302 | GArray *execution_stack; /* Array of LttvExecutionState */ |
| 303 | LttvExecutionState *state; /* Top of interrupt stack */ |
| 304 | /* WARNING : each time the execution_stack size is modified, the state |
| 305 | * must be reget : g_array_set_size can have to move the array. |
| 306 | * (Mathieu) */ |
| 307 | guint cpu; /* CPU where process is scheduled (being either in |
| 308 | the active or inactive runqueue)*/ |
| 309 | // guint last_tracefile_index; /* index in the trace for cpu tracefile */ |
| 310 | LttvTracefileState *usertrace; /* Associated usertrace */ |
| 311 | /* opened file descriptors, address map?... */ |
| 312 | GArray *user_stack; /* User space function call stack */ |
| 313 | guint64 current_function; |
| 314 | LttvProcessType type; /* kernel thread or user space ? */ |
| 315 | guint target_pid; /* target PID of the current event. */ |
| 316 | } LttvProcessState; |
| 317 | |
| 318 | |
| 319 | /************************************************************** |
| 320 | * JOV - XenoLTT - 2006-09-26 |
| 321 | * Xenomai Thread Structure |
| 322 | **************************************************************/ |
| 323 | typedef struct _LttvXenoThreadState { |
| 324 | guint address; |
| 325 | guint prio; |
| 326 | guint period; |
| 327 | guint timer_address; |
| 328 | LttTime creation_time; |
| 329 | LttTime insertion_time; |
| 330 | GQuark name; |
| 331 | GArray *execution_stack; /* Array of LttvXenoExecutionState */ |
| 332 | LttvXenoExecutionState *state; |
| 333 | guint cpu; /* CPU where process is scheduled */ |
| 334 | LttvTracefileState *usertrace; /* Associated usertrace */ |
| 335 | gboolean wait_period_call; /* has already called wait-period */ |
| 336 | LttTime start_wait_synch; |
| 337 | } LttvXenoThreadState; |
| 338 | |
| 339 | |
| 340 | typedef struct _LttvXenoExecutionSynch { |
| 341 | LttvXenoThreadState *owner; |
| 342 | LttTime start_time; |
| 343 | GArray *waiting_threads; |
| 344 | } LttvXenoExecutionSynch; |
| 345 | |
| 346 | typedef struct _LttvXenoSynchState { |
| 347 | guint address; |
| 348 | LttTime creation_time; |
| 349 | GArray *execution_stack; |
| 350 | LttvXenoExecutionSynch *state; |
| 351 | } LttvXenoSynchState; |
| 352 | |
| 353 | |
| 354 | #define ANY_CPU 0 /* For clarity sake : a call to lttv_state_find_process for |
| 355 | a PID != 0 will search on any cpu automatically. */ |
| 356 | |
| 357 | LttvProcessState * |
| 358 | lttv_state_find_process(LttvTraceState *ts, guint cpu, guint pid); |
| 359 | |
| 360 | LttvProcessState * |
| 361 | lttv_state_find_process_or_create(LttvTraceState *ts, guint cpu, guint pid, |
| 362 | const LttTime *timestamp); |
| 363 | |
| 364 | LttvProcessState * |
| 365 | lttv_state_create_process(LttvTraceState *tcs, LttvProcessState *parent, |
| 366 | guint cpu, guint pid, guint tgid, GQuark name, const LttTime *timestamp); |
| 367 | |
| 368 | void lttv_state_write(LttvTraceState *self, LttTime t, FILE *fp); |
| 369 | void lttv_state_write_raw(LttvTraceState *self, LttTime t, FILE *fp); |
| 370 | |
| 371 | /* The LttvTracesetState, LttvTraceState and LttvTracefileState types |
| 372 | inherit from the corresponding Context objects defined in processTrace. */ |
| 373 | |
| 374 | #define LTTV_TRACESET_STATE_TYPE (lttv_traceset_state_get_type ()) |
| 375 | #define LTTV_TRACESET_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACESET_STATE_TYPE, LttvTracesetState)) |
| 376 | #define LTTV_TRACESET_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACESET_STATE_TYPE, LttvTracesetStateClass)) |
| 377 | #define LTTV_IS_TRACESET_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACESET_STATE_TYPE)) |
| 378 | #define LTTV_IS_TRACESET_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACESET_STATE_TYPE)) |
| 379 | #define LTTV_TRACESET_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACESET_STATE_TYPE, LttvTracesetStateClass)) |
| 380 | |
| 381 | struct _LttvTracesetState { |
| 382 | LttvTracesetContext parent; |
| 383 | }; |
| 384 | |
| 385 | struct _LttvTracesetStateClass { |
| 386 | LttvTracesetContextClass parent; |
| 387 | }; |
| 388 | |
| 389 | GType lttv_traceset_state_get_type (void); |
| 390 | |
| 391 | |
| 392 | #define LTTV_TRACE_STATE_TYPE (lttv_trace_state_get_type ()) |
| 393 | #define LTTV_TRACE_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACE_STATE_TYPE, LttvTraceState)) |
| 394 | #define LTTV_TRACE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACE_STATE_TYPE, LttvTraceStateClass)) |
| 395 | #define LTTV_IS_TRACE_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACE_STATE_TYPE)) |
| 396 | #define LTTV_IS_TRACE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACE_STATE_TYPE)) |
| 397 | #define LTTV_TRACE_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACE_STATE_TYPE, LttvTraceStateClass)) |
| 398 | |
| 399 | struct _LttvTraceState { |
| 400 | LttvTraceContext parent; |
| 401 | |
| 402 | GHashTable *processes; /* LttvProcessState objects indexed by pid and |
| 403 | last_cpu */ |
| 404 | GHashTable *usertraces; /* GPtrArray objects indexed by pid, containing |
| 405 | pointers to LttvTracefileState objects. */ |
| 406 | guint nb_event, save_interval; |
| 407 | /* Block/char devices, locks, memory pages... */ |
| 408 | GQuark *eventtype_names; |
| 409 | GQuark *syscall_names; |
| 410 | guint nb_syscalls; |
| 411 | GQuark *trap_names; |
| 412 | guint nb_traps; |
| 413 | GQuark *irq_names; |
| 414 | GQuark *soft_irq_names; |
| 415 | LttTime *max_time_state_recomputed_in_seek; |
| 416 | |
| 417 | /* Array of per cpu running process */ |
| 418 | LttvProcessState **running_process; |
| 419 | gboolean has_precomputed_states; |
| 420 | |
| 421 | GHashTable *threads; /* LttvXenoState objects indexed by address and last_cpu */ |
| 422 | LttvXenoThreadState **running_thread; /* Array of per cpu running thread */ |
| 423 | |
| 424 | GHashTable *synchs; /* LttvXenoSynchState objects */ |
| 425 | |
| 426 | }; |
| 427 | |
| 428 | struct _LttvTraceStateClass { |
| 429 | LttvTraceContextClass parent; |
| 430 | |
| 431 | void (*state_save) (LttvTraceState *self, LttvAttribute *container); |
| 432 | void (*state_restore) (LttvTraceState *self, LttvAttribute *container); |
| 433 | void (*state_saved_free) (LttvTraceState *self, LttvAttribute *container); |
| 434 | }; |
| 435 | |
| 436 | GType lttv_trace_state_get_type (void); |
| 437 | |
| 438 | void lttv_state_save(LttvTraceState *self, LttvAttribute *container); |
| 439 | |
| 440 | void lttv_state_restore(LttvTraceState *self, LttvAttribute *container); |
| 441 | |
| 442 | void lttv_state_state_saved_free(LttvTraceState *self, |
| 443 | LttvAttribute *container); |
| 444 | |
| 445 | int lttv_state_pop_state_cleanup(LttvProcessState *process, |
| 446 | LttvTracefileState *tfs); |
| 447 | |
| 448 | #define LTTV_TRACEFILE_STATE_TYPE (lttv_tracefile_state_get_type ()) |
| 449 | #define LTTV_TRACEFILE_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACEFILE_STATE_TYPE, LttvTracefileState)) |
| 450 | #define LTTV_TRACEFILE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACEFILE_STATE_TYPE, LttvTracefileStateClass)) |
| 451 | #define LTTV_IS_TRACEFILE_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACEFILE_STATE_TYPE)) |
| 452 | #define LTTV_IS_TRACEFILE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACEFILE_STATE_TYPE)) |
| 453 | #define LTTV_TRACEFILE_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACEFILE_STATE_TYPE, LttvTracefileStateClass)) |
| 454 | |
| 455 | struct _LttvTracefileState { |
| 456 | LttvTracefileContext parent; |
| 457 | |
| 458 | //LttvProcessState *process; |
| 459 | GQuark tracefile_name; |
| 460 | guint cpu; /* Current cpu of the tracefile */ |
| 461 | // guint saved_position; |
| 462 | }; |
| 463 | |
| 464 | struct _LttvTracefileStateClass { |
| 465 | LttvTracefileContextClass parent; |
| 466 | }; |
| 467 | |
| 468 | GType lttv_tracefile_state_get_type (void); |
| 469 | |
| 470 | static inline guint lttv_state_get_target_pid(LttvTracefileState *tfs) |
| 471 | { |
| 472 | LttvTraceState *ts = (LttvTraceState*)tfs->parent.t_context; |
| 473 | guint cpu = tfs->cpu; |
| 474 | LttvProcessState *process = ts->running_process[cpu]; |
| 475 | |
| 476 | if(tfs->parent.target_pid >= 0) return tfs->parent.target_pid; |
| 477 | else return process->pid; |
| 478 | } |
| 479 | |
| 480 | |
| 481 | #define HDR_PROCESS 0 |
| 482 | #define HDR_ES 1 |
| 483 | #define HDR_USER_STACK 2 |
| 484 | #define HDR_USERTRACE 3 |
| 485 | #define HDR_PROCESS_STATE 4 |
| 486 | #define HDR_CPU 5 |
| 487 | #define HDR_TRACEFILE 6 |
| 488 | #define HDR_TRACESET 7 |
| 489 | #define HDR_TRACE 8 |
| 490 | #define HDR_QUARKS 9 |
| 491 | #define HDR_QUARK 10 |
| 492 | |
| 493 | |
| 494 | LttvXenoThreadState *lttv_xeno_state_create_thread(LttvTraceState *tcs, guint cpu, guint address, guint prio, GQuark name, const LttTime *timestamp); |
| 495 | LttvXenoThreadState *lttv_xeno_state_find_thread(LttvTraceState *ts, guint cpu, guint address); |
| 496 | LttvXenoThreadState *lttv_xeno_state_find_thread_from_timer(LttvTraceState *ts, guint cpu, guint timer_address); |
| 497 | |
| 498 | LttvXenoSynchState *lttv_xeno_state_create_synch(LttvTraceState *tcs, guint address, const LttTime *timestamp); |
| 499 | LttvXenoSynchState *lttv_xeno_state_find_synch(LttvTraceState *ts, guint address); |
| 500 | gboolean lttv_xeno_thread_synch_owner(LttvTraceState *ts, LttvXenoThreadState* thread); |
| 501 | |
| 502 | #endif // STATE_H |