use state seek closest, incomplete data ok
[lttv.git] / ltt / branches / poly / lttv / main / state.c
CommitLineData
9c312311 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
dc877563 19
20#include <lttv/state.h>
ba576a78 21#include <ltt/facility.h>
22#include <ltt/trace.h>
308711e5 23#include <ltt/event.h>
a5dcde2f 24#include <ltt/type.h>
dc877563 25
b445142a 26LttvExecutionMode
27 LTTV_STATE_MODE_UNKNOWN,
ffd54a90 28 LTTV_STATE_USER_MODE,
29 LTTV_STATE_SYSCALL,
30 LTTV_STATE_TRAP,
31 LTTV_STATE_IRQ;
32
b445142a 33LttvExecutionSubmode
34 LTTV_STATE_SUBMODE_UNKNOWN,
35 LTTV_STATE_SUBMODE_NONE;
ffd54a90 36
37LttvProcessStatus
38 LTTV_STATE_UNNAMED,
39 LTTV_STATE_WAIT_FORK,
40 LTTV_STATE_WAIT_CPU,
41 LTTV_STATE_EXIT,
42 LTTV_STATE_WAIT,
43 LTTV_STATE_RUN;
44
ba576a78 45static GQuark
308711e5 46 LTTV_STATE_TRACEFILES,
47 LTTV_STATE_PROCESSES,
48 LTTV_STATE_PROCESS,
49 LTTV_STATE_EVENT,
50 LTTV_STATE_SAVED_STATES,
51 LTTV_STATE_TIME,
ba576a78 52 LTTV_STATE_HOOKS;
53
b445142a 54
55static void fill_name_tables(LttvTraceState *tcs);
56
57static void free_name_tables(LttvTraceState *tcs);
58
308711e5 59static void lttv_state_free_process_table(GHashTable *processes);
ba576a78 60
308711e5 61static LttvProcessState *create_process(LttvTracefileState *tfs,
3d27549e 62 LttvProcessState *parent, guint pid);
dc877563 63
308711e5 64void lttv_state_save(LttvTraceState *self, LttvAttribute *container)
65{
66 LTTV_TRACE_STATE_GET_CLASS(self)->state_save(self, container);
67}
68
69
70void lttv_state_restore(LttvTraceState *self, LttvAttribute *container)
71{
72 LTTV_TRACE_STATE_GET_CLASS(self)->state_restore(self, container);
73}
74
75
76void lttv_state_saved_state_free(LttvTraceState *self,
77 LttvAttribute *container)
78{
79 LTTV_TRACE_STATE_GET_CLASS(self)->state_restore(self, container);
80}
81
82
83static void
84restore_init_state(LttvTraceState *self)
85{
86 guint i, nb_control, nb_per_cpu, nb_tracefile;
87
88 LttvTracefileState *tfcs;
89
90 LttTime null_time = {0,0};
91
92 if(self->processes != NULL) lttv_state_free_process_table(self->processes);
93 self->processes = g_hash_table_new(g_direct_hash, g_direct_equal);
94 self->nb_event = 0;
95
96 nb_control = ltt_trace_control_tracefile_number(self->parent.t);
97 nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->parent.t);
98 nb_tracefile = nb_control + nb_per_cpu;
99 for(i = 0 ; i < nb_tracefile ; i++) {
100 if(i < nb_control) {
101 tfcs = LTTV_TRACEFILE_STATE(self->parent.control_tracefiles[i]);
102 }
103 else {
104 tfcs = LTTV_TRACEFILE_STATE(self->parent.per_cpu_tracefiles[i - nb_control]);
105 }
106
107 tfcs->parent.timestamp = null_time;
108 tfcs->saved_position = 0;
109 tfcs->process = create_process(tfcs, NULL,0);
110 }
111}
112
113
dc877563 114static void
115init(LttvTracesetState *self, LttvTraceset *ts)
116{
b445142a 117 guint i, j, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
dc877563 118
ffd54a90 119 LttvTraceContext *tc;
dc877563 120
ffd54a90 121 LttvTraceState *tcs;
122
ffd54a90 123 LttvTracefileState *tfcs;
3d27549e 124
b445142a 125 LTTV_TRACESET_CONTEXT_CLASS(g_type_class_peek(LTTV_TRACESET_CONTEXT_TYPE))->
126 init((LttvTracesetContext *)self, ts);
dc877563 127
128 nb_trace = lttv_traceset_number(ts);
129 for(i = 0 ; i < nb_trace ; i++) {
b445142a 130 tc = self->parent.traces[i];
131 tcs = (LttvTraceState *)tc;
308711e5 132 tcs->save_interval = 100000;
dd025f91 133 tcs->recompute_state_in_seek = false;
134 tcs->saved_state_ready = false;
b445142a 135 fill_name_tables(tcs);
dc877563 136
b445142a 137 nb_control = ltt_trace_control_tracefile_number(tc->t);
138 nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
139 nb_tracefile = nb_control + nb_per_cpu;
dc877563 140 for(j = 0 ; j < nb_tracefile ; j++) {
b445142a 141 if(j < nb_control) {
142 tfcs = LTTV_TRACEFILE_STATE(tc->control_tracefiles[j]);
143 }
144 else {
145 tfcs = LTTV_TRACEFILE_STATE(tc->per_cpu_tracefiles[j - nb_control]);
146 }
b445142a 147 tfcs->cpu_name= g_quark_from_string(ltt_tracefile_name(tfcs->parent.tf));
dc877563 148 }
308711e5 149 tcs->processes = NULL;
150 restore_init_state(tcs);
dc877563 151 }
152}
153
154
155static void
156fini(LttvTracesetState *self)
157{
158 guint i, j, nb_trace, nb_tracefile;
159
ffd54a90 160 LttvTraceState *tcs;
dc877563 161
ffd54a90 162 LttvTracefileState *tfcs;
dc877563 163
ffd54a90 164 nb_trace = lttv_traceset_number(LTTV_TRACESET_CONTEXT(self)->ts);
dc877563 165 for(i = 0 ; i < nb_trace ; i++) {
ffd54a90 166 tcs = (LttvTraceState *)(LTTV_TRACESET_CONTEXT(self)->traces[i]);
308711e5 167 lttv_state_free_process_table(tcs->processes);
168 tcs->processes = NULL;
b445142a 169 free_name_tables(tcs);
dc877563 170 }
b445142a 171 LTTV_TRACESET_CONTEXT_CLASS(g_type_class_peek(LTTV_TRACESET_CONTEXT_TYPE))->
172 fini((LttvTracesetContext *)self);
dc877563 173}
174
175
c432246e 176static LttvTracesetContext *
dc877563 177new_traceset_context(LttvTracesetContext *self)
178{
ffd54a90 179 return LTTV_TRACESET_CONTEXT(g_object_new(LTTV_TRACESET_STATE_TYPE, NULL));
dc877563 180}
181
182
c432246e 183static LttvTraceContext *
dc877563 184new_trace_context(LttvTracesetContext *self)
185{
ffd54a90 186 return LTTV_TRACE_CONTEXT(g_object_new(LTTV_TRACE_STATE_TYPE, NULL));
dc877563 187}
188
189
c432246e 190static LttvTracefileContext *
dc877563 191new_tracefile_context(LttvTracesetContext *self)
192{
ffd54a90 193 return LTTV_TRACEFILE_CONTEXT(g_object_new(LTTV_TRACEFILE_STATE_TYPE, NULL));
194}
195
196
308711e5 197static void copy_process_state(gpointer key, gpointer value,gpointer user_data)
ffd54a90 198{
308711e5 199 LttvProcessState *process, *new_process;
ffd54a90 200
308711e5 201 GHashTable *new_processes = (GHashTable *)user_data;
ffd54a90 202
308711e5 203 guint i;
204
205 process = (LttvProcessState *)value;
206 new_process = g_new(LttvProcessState, 1);
207 *new_process = *process;
208 new_process->execution_stack = g_array_new(FALSE, FALSE,
209 sizeof(LttvExecutionState));
210 g_array_set_size(new_process->execution_stack,process->execution_stack->len);
211 for(i = 0 ; i < process->execution_stack->len; i++) {
212 g_array_index(new_process->execution_stack, LttvExecutionState, i) =
213 g_array_index(process->execution_stack, LttvExecutionState, i);
214 }
215 new_process->state = &g_array_index(new_process->execution_stack,
216 LttvExecutionState, new_process->execution_stack->len - 1);
217 g_hash_table_insert(new_processes, GUINT_TO_POINTER(new_process->pid),
218 new_process);
ffd54a90 219}
220
221
308711e5 222static GHashTable *lttv_state_copy_process_table(GHashTable *processes)
ffd54a90 223{
308711e5 224 GHashTable *new_processes = g_hash_table_new(g_direct_hash, g_direct_equal);
ffd54a90 225
308711e5 226 g_hash_table_foreach(processes, copy_process_state, new_processes);
227 return new_processes;
dc877563 228}
229
230
308711e5 231/* The saved state for each trace contains a member "processes", which
232 stores a copy of the process table, and a member "tracefiles" with
233 one entry per tracefile. Each tracefile has a "process" member pointing
234 to the current process and a "position" member storing the tracefile
235 position (needed to seek to the current "next" event. */
236
237static void state_save(LttvTraceState *self, LttvAttribute *container)
dc877563 238{
308711e5 239 guint i, nb_control, nb_per_cpu, nb_tracefile;
dc877563 240
308711e5 241 LttvTracefileState *tfcs;
242
243 LttvAttribute *tracefiles_tree, *tracefile_tree;
244
245 LttvAttributeType type;
246
247 LttvAttributeValue value;
248
249 LttvAttributeName name;
250
251 LttEventPosition *ep;
252
253 tracefiles_tree = lttv_attribute_find_subdir(container,
254 LTTV_STATE_TRACEFILES);
255
256 value = lttv_attribute_add(container, LTTV_STATE_PROCESSES,
257 LTTV_POINTER);
258 *(value.v_pointer) = lttv_state_copy_process_table(self->processes);
259
260 nb_control = ltt_trace_control_tracefile_number(self->parent.t);
261 nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->parent.t);
262 nb_tracefile = nb_control + nb_per_cpu;
263
264 for(i = 0 ; i < nb_tracefile ; i++) {
265 if(i < nb_control)
266 tfcs = (LttvTracefileState *)self->parent.control_tracefiles[i];
267 else tfcs = (LttvTracefileState *)
268 self->parent.per_cpu_tracefiles[i - nb_control];
269
270 tracefile_tree = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
271 value = lttv_attribute_add(tracefiles_tree, i,
272 LTTV_GOBJECT);
273 *(value.v_gobject) = (GObject *)tracefile_tree;
274 value = lttv_attribute_add(tracefile_tree, LTTV_STATE_PROCESS,
275 LTTV_UINT);
276 *(value.v_uint) = tfcs->process->pid;
277 value = lttv_attribute_add(tracefile_tree, LTTV_STATE_EVENT,
278 LTTV_POINTER);
279 if(tfcs->parent.e == NULL) *(value.v_pointer) = NULL;
280 else {
a5dcde2f 281 ep = ltt_event_position_new();
308711e5 282 ltt_event_position(tfcs->parent.e, ep);
283 *(value.v_pointer) = ep;
284 }
dc877563 285 }
dc877563 286}
287
288
308711e5 289static void state_restore(LttvTraceState *self, LttvAttribute *container)
dc877563 290{
308711e5 291 guint i, nb_control, nb_per_cpu, nb_tracefile;
dc877563 292
308711e5 293 LttvTracefileState *tfcs;
dc877563 294
308711e5 295 LttvAttribute *tracefiles_tree, *tracefile_tree;
dc877563 296
308711e5 297 LttvAttributeType type;
dc877563 298
308711e5 299 LttvAttributeValue value;
dc877563 300
308711e5 301 LttvAttributeName name;
dc877563 302
308711e5 303 LttEventPosition *ep;
dc877563 304
308711e5 305 tracefiles_tree = lttv_attribute_find_subdir(container,
306 LTTV_STATE_TRACEFILES);
dc877563 307
308711e5 308 type = lttv_attribute_get_by_name(container, LTTV_STATE_PROCESSES,
309 &value);
310 g_assert(type == LTTV_POINTER);
311 lttv_state_free_process_table(self->processes);
312 self->processes = lttv_state_copy_process_table(*(value.v_pointer));
313
314 nb_control = ltt_trace_control_tracefile_number(self->parent.t);
315 nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->parent.t);
316 nb_tracefile = nb_control + nb_per_cpu;
317
318 for(i = 0 ; i < nb_tracefile ; i++) {
319 if(i < nb_control) tfcs = (LttvTracefileState *)
320 self->parent.control_tracefiles[i];
321 else tfcs = (LttvTracefileState *)
322 self->parent.per_cpu_tracefiles[i - nb_control];
323
324 type = lttv_attribute_get(tracefiles_tree, i, &name, &value);
325 g_assert(type == LTTV_GOBJECT);
326 tracefile_tree = *((LttvAttribute **)(value.v_gobject));
327
328 type = lttv_attribute_get_by_name(tracefile_tree, LTTV_STATE_PROCESS,
329 &value);
330 g_assert(type == LTTV_UINT);
331 tfcs->process = lttv_state_find_process(tfcs, *(value.v_uint));
332 type = lttv_attribute_get_by_name(tracefile_tree, LTTV_STATE_EVENT,
333 &value);
334 g_assert(type == LTTV_POINTER);
335 if(*(value.v_pointer) == NULL) tfcs->parent.e = NULL;
336 else {
337 ep = *(value.v_pointer);
338 ltt_tracefile_seek_position(tfcs->parent.tf, ep);
339 tfcs->parent.e = ltt_tracefile_read(tfcs->parent.tf);
340 tfcs->parent.timestamp = ltt_event_time(tfcs->parent.e);
341 }
dc877563 342 }
dc877563 343}
344
345
308711e5 346static void state_saved_free(LttvTraceState *self, LttvAttribute *container)
dc877563 347{
308711e5 348 guint i, nb_control, nb_per_cpu, nb_tracefile;
dc877563 349
308711e5 350 LttvTracefileState *tfcs;
dc877563 351
308711e5 352 LttvAttribute *tracefiles_tree, *tracefile_tree;
dc877563 353
308711e5 354 LttvAttributeType type;
dc877563 355
308711e5 356 LttvAttributeValue value;
dc877563 357
308711e5 358 LttvAttributeName name;
dc877563 359
308711e5 360 LttEventPosition *ep;
dc877563 361
308711e5 362 tracefiles_tree = lttv_attribute_find_subdir(container,
363 LTTV_STATE_TRACEFILES);
364 lttv_attribute_remove_by_name(container, LTTV_STATE_TRACEFILES);
dc877563 365
308711e5 366 type = lttv_attribute_get_by_name(container, LTTV_STATE_PROCESSES,
367 &value);
368 g_assert(type == LTTV_POINTER);
369 lttv_state_free_process_table(*(value.v_pointer));
370 *(value.v_pointer) = NULL;
371 lttv_attribute_remove_by_name(container, LTTV_STATE_PROCESSES);
372
373 nb_control = ltt_trace_control_tracefile_number(self->parent.t);
374 nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->parent.t);
375 nb_tracefile = nb_control + nb_per_cpu;
376
377 for(i = 0 ; i < nb_tracefile ; i++) {
378 if(i < nb_control) tfcs = (LttvTracefileState *)
379 self->parent.control_tracefiles[i];
380 else tfcs = (LttvTracefileState *)
381 self->parent.per_cpu_tracefiles[i - nb_control];
382
383 type = lttv_attribute_get(tracefiles_tree, i, &name, &value);
384 g_assert(type == LTTV_GOBJECT);
385 tracefile_tree = *((LttvAttribute **)(value.v_gobject));
386
387 type = lttv_attribute_get_by_name(tracefile_tree, LTTV_STATE_EVENT,
388 &value);
389 g_assert(type == LTTV_POINTER);
390 if(*(value.v_pointer) != NULL) g_free(*(value.v_pointer));
dc877563 391 }
308711e5 392 lttv_attribute_recursive_free(tracefiles_tree);
dc877563 393}
394
395
b445142a 396static void
397fill_name_tables(LttvTraceState *tcs)
398{
399 int i, nb;
dc877563 400
b445142a 401 char *f_name, *e_name;
dc877563 402
b445142a 403 LttvTraceHook h;
404
405 LttEventType *et;
406
407 LttType *t;
408
409 GString *fe_name = g_string_new("");
410
411 nb = ltt_trace_eventtype_number(tcs->parent.t);
412 tcs->eventtype_names = g_new(GQuark, nb);
413 for(i = 0 ; i < nb ; i++) {
414 et = ltt_trace_eventtype_get(tcs->parent.t, i);
415 e_name = ltt_eventtype_name(et);
416 f_name = ltt_facility_name(ltt_eventtype_facility(et));
417 g_string_printf(fe_name, "%s.%s", f_name, e_name);
418 tcs->eventtype_names[i] = g_quark_from_string(fe_name->str);
419 }
dc877563 420
b445142a 421 lttv_trace_find_hook(tcs->parent.t, "core", "syscall_entry",
422 "syscall_id", NULL, NULL, NULL, &h);
423 t = ltt_field_type(h.f1);
424 nb = ltt_type_element_number(t);
425
426 /* CHECK syscalls should be an emun but currently are not!
427 tcs->syscall_names = g_new(GQuark, nb);
428
429 for(i = 0 ; i < nb ; i++) {
430 tcs->syscall_names[i] = g_quark_from_string(ltt_enum_string_get(t, i));
431 }
432 */
433
434 tcs->syscall_names = g_new(GQuark, 256);
435 for(i = 0 ; i < 256 ; i++) {
436 g_string_printf(fe_name, "syscall %d", i);
437 tcs->syscall_names[i] = g_quark_from_string(fe_name->str);
438 }
439
440 lttv_trace_find_hook(tcs->parent.t, "core", "trap_entry",
441 "trap_id", NULL, NULL, NULL, &h);
442 t = ltt_field_type(h.f1);
443 nb = ltt_type_element_number(t);
444
445 /*
446 tcs->trap_names = g_new(GQuark, nb);
447 for(i = 0 ; i < nb ; i++) {
448 tcs->trap_names[i] = g_quark_from_string(ltt_enum_string_get(t, i));
449 }
450 */
451
452 tcs->trap_names = g_new(GQuark, 256);
453 for(i = 0 ; i < 256 ; i++) {
454 g_string_printf(fe_name, "trap %d", i);
455 tcs->trap_names[i] = g_quark_from_string(fe_name->str);
456 }
457
458 lttv_trace_find_hook(tcs->parent.t, "core", "irq_entry",
459 "irq_id", NULL, NULL, NULL, &h);
460 t = ltt_field_type(h.f1);
461 nb = ltt_type_element_number(t);
462
463 /*
464 tcs->irq_names = g_new(GQuark, nb);
465 for(i = 0 ; i < nb ; i++) {
466 tcs->irq_names[i] = g_quark_from_string(ltt_enum_string_get(t, i));
467 }
468 */
469
470 tcs->irq_names = g_new(GQuark, 256);
471 for(i = 0 ; i < 256 ; i++) {
472 g_string_printf(fe_name, "irq %d", i);
473 tcs->irq_names[i] = g_quark_from_string(fe_name->str);
474 }
475
476 g_string_free(fe_name, TRUE);
477}
478
479
480static void
481free_name_tables(LttvTraceState *tcs)
482{
483 g_free(tcs->eventtype_names);
484 g_free(tcs->syscall_names);
485 g_free(tcs->trap_names);
486 g_free(tcs->irq_names);
487}
dc877563 488
b445142a 489
490static void push_state(LttvTracefileState *tfs, LttvExecutionMode t,
ffd54a90 491 guint state_id)
dc877563 492{
b445142a 493 LttvExecutionState *es;
dc877563 494
495 LttvProcessState *process = tfs->process;
496
b445142a 497 guint depth = process->execution_stack->len;
dc877563 498
b445142a 499 g_array_set_size(process->execution_stack, depth + 1);
500 es = &g_array_index(process->execution_stack, LttvExecutionState, depth);
501 es->t = t;
502 es->n = state_id;
503 es->entry = es->change = tfs->parent.timestamp;
504 es->s = process->state->s;
505 process->state = es;
dc877563 506}
507
508
b445142a 509static void pop_state(LttvTracefileState *tfs, LttvExecutionMode t)
dc877563 510{
511 LttvProcessState *process = tfs->process;
512
b445142a 513 guint depth = process->execution_stack->len - 1;
dc877563 514
3d27549e 515 if(process->state->t != t){
b445142a 516 g_warning("Different execution mode type (%d.%09d): ignore it\n",
517 tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec);
8e8e6b64 518 g_warning("process state has %s when pop_int is %s\n",
519 g_quark_to_string(process->state->t),
520 g_quark_to_string(t));
521 g_warning("{ %u, %u, %s, %s }\n",
522 process->pid,
523 process->ppid,
524 g_quark_to_string(process->name),
525 g_quark_to_string(process->state->s));
3d27549e 526 return;
527 }
b445142a 528
529 if(depth == 0){
530 g_warning("Trying to pop last state on stack (%d.%09d): ignore it\n",
531 tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec);
532 return;
533 }
534
535 g_array_remove_index(process->execution_stack, depth);
dc877563 536 depth--;
b445142a 537 process->state = &g_array_index(process->execution_stack, LttvExecutionState,
dc877563 538 depth);
b445142a 539 process->state->change = tfs->parent.timestamp;
dc877563 540}
541
542
308711e5 543static LttvProcessState *create_process(LttvTracefileState *tfs,
ffd54a90 544 LttvProcessState *parent, guint pid)
dc877563 545{
546 LttvProcessState *process = g_new(LttvProcessState, 1);
547
b445142a 548 LttvExecutionState *es;
dc877563 549
ffd54a90 550 LttvTraceContext *tc;
551
ba576a78 552 LttvTraceState *tcs;
553
b445142a 554 char buffer[128];
ffd54a90 555
b445142a 556 tcs = (LttvTraceState *)tc = tfs->parent.t_context;
60b53e4f 557
ffd54a90 558 g_hash_table_insert(tcs->processes, GUINT_TO_POINTER(pid), process);
dc877563 559 process->pid = pid;
b445142a 560
561 if(parent) {
562 process->ppid = parent->pid;
563 process->name = parent->name;
564 }
565 else {
566 process->ppid = 0;
567 process->name = LTTV_STATE_UNNAMED;
568 }
569
570 process->creation_time = tfs->parent.timestamp;
571 sprintf(buffer,"%d-%lu.%lu",pid, process->creation_time.tv_sec,
572 process->creation_time.tv_nsec);
573 process->pid_time = g_quark_from_string(buffer);
574 process->execution_stack = g_array_new(FALSE, FALSE,
575 sizeof(LttvExecutionState));
576 g_array_set_size(process->execution_stack, 1);
577 es = process->state = &g_array_index(process->execution_stack,
578 LttvExecutionState, 0);
579 es->t = LTTV_STATE_USER_MODE;
580 es->n = LTTV_STATE_SUBMODE_NONE;
581 es->entry = tfs->parent.timestamp;
582 es->change = tfs->parent.timestamp;
583 es->s = LTTV_STATE_WAIT_FORK;
cbe7c836 584
585 return process;
dc877563 586}
587
588
308711e5 589LttvProcessState *lttv_state_find_process(LttvTracefileState *tfs,
590 guint pid)
dc877563 591{
ba576a78 592 LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context;
593 LttvProcessState *process = g_hash_table_lookup(ts->processes,
594 GUINT_TO_POINTER(pid));
dc877563 595 if(process == NULL) process = create_process(tfs, NULL, pid);
596 return process;
597}
598
599
b445142a 600static void exit_process(LttvTracefileState *tfs, LttvProcessState *process)
dc877563 601{
ba576a78 602 LttvTraceState *ts = LTTV_TRACE_STATE(tfs->parent.t_context);
603
604 g_hash_table_remove(ts->processes, GUINT_TO_POINTER(process->pid));
b445142a 605 g_array_free(process->execution_stack, TRUE);
dc877563 606 g_free(process);
607}
608
609
b445142a 610static void free_process_state(gpointer key, gpointer value,gpointer user_data)
dc877563 611{
b445142a 612 g_array_free(((LttvProcessState *)value)->execution_stack, TRUE);
dc877563 613 g_free(value);
614}
615
616
308711e5 617static void lttv_state_free_process_table(GHashTable *processes)
dc877563 618{
619 g_hash_table_foreach(processes, free_process_state, NULL);
308711e5 620 g_hash_table_destroy(processes);
dc877563 621}
622
623
b445142a 624static gboolean syscall_entry(void *hook_data, void *call_data)
dc877563 625{
b445142a 626 LttField *f = ((LttvTraceHook *)hook_data)->f1;
dc877563 627
ba576a78 628 LttvTracefileState *s = (LttvTracefileState *)call_data;
dc877563 629
b445142a 630 LttvExecutionSubmode submode;
631
632 submode = ((LttvTraceState *)(s->parent.t_context))->syscall_names[
633 ltt_event_get_unsigned(s->parent.e, f)];
634 push_state(s, LTTV_STATE_SYSCALL, submode);
dc877563 635 return FALSE;
636}
637
638
b445142a 639static gboolean syscall_exit(void *hook_data, void *call_data)
dc877563 640{
ba576a78 641 LttvTracefileState *s = (LttvTracefileState *)call_data;
dc877563 642
ffd54a90 643 pop_state(s, LTTV_STATE_SYSCALL);
dc877563 644 return FALSE;
645}
646
647
b445142a 648static gboolean trap_entry(void *hook_data, void *call_data)
dc877563 649{
b445142a 650 LttField *f = ((LttvTraceHook *)hook_data)->f1;
dc877563 651
ba576a78 652 LttvTracefileState *s = (LttvTracefileState *)call_data;
dc877563 653
b445142a 654 LttvExecutionSubmode submode;
655
656 submode = ((LttvTraceState *)(s->parent.t_context))->trap_names[
657 ltt_event_get_unsigned(s->parent.e, f)];
658 push_state(s, LTTV_STATE_TRAP, submode);
dc877563 659 return FALSE;
660}
661
662
b445142a 663static gboolean trap_exit(void *hook_data, void *call_data)
dc877563 664{
ba576a78 665 LttvTracefileState *s = (LttvTracefileState *)call_data;
dc877563 666
ffd54a90 667 pop_state(s, LTTV_STATE_TRAP);
dc877563 668 return FALSE;
669}
670
671
b445142a 672static gboolean irq_entry(void *hook_data, void *call_data)
dc877563 673{
b445142a 674 LttField *f = ((LttvTraceHook *)hook_data)->f1;
dc877563 675
ba576a78 676 LttvTracefileState *s = (LttvTracefileState *)call_data;
dc877563 677
b445142a 678 LttvExecutionSubmode submode;
679
680 submode = ((LttvTraceState *)(s->parent.t_context))->irq_names[
681 ltt_event_get_unsigned(s->parent.e, f)];
682
dc877563 683 /* Do something with the info about being in user or system mode when int? */
b445142a 684 push_state(s, LTTV_STATE_IRQ, submode);
dc877563 685 return FALSE;
686}
687
688
b445142a 689static gboolean irq_exit(void *hook_data, void *call_data)
dc877563 690{
ba576a78 691 LttvTracefileState *s = (LttvTracefileState *)call_data;
dc877563 692
ffd54a90 693 pop_state(s, LTTV_STATE_IRQ);
dc877563 694 return FALSE;
695}
696
697
b445142a 698static gboolean schedchange(void *hook_data, void *call_data)
dc877563 699{
b445142a 700 LttvTraceHook *h = (LttvTraceHook *)hook_data;
dc877563 701
ba576a78 702 LttvTracefileState *s = (LttvTracefileState *)call_data;
dc877563 703
704 guint pid_in, pid_out, state_out;
705
3d27549e 706 pid_in = ltt_event_get_unsigned(s->parent.e, h->f1);
707 pid_out = ltt_event_get_unsigned(s->parent.e, h->f2);
708 state_out = ltt_event_get_unsigned(s->parent.e, h->f3);
b445142a 709
dc877563 710 if(s->process != NULL) {
b445142a 711
ffd54a90 712 if(state_out == 0) s->process->state->s = LTTV_STATE_WAIT_CPU;
713 else if(s->process->state->s == LTTV_STATE_EXIT)
ba576a78 714 exit_process(s, s->process);
ffd54a90 715 else s->process->state->s = LTTV_STATE_WAIT;
3d27549e 716
717 if(s->process->pid == 0)
90ffd2ad 718 s->process->pid = pid_out;
b445142a 719
720 s->process->state->change = s->parent.timestamp;
dc877563 721 }
b445142a 722 s->process = lttv_state_find_process(s, pid_in);
ffd54a90 723 s->process->state->s = LTTV_STATE_RUN;
b445142a 724 s->process->state->change = s->parent.timestamp;
dc877563 725 return FALSE;
726}
727
728
b445142a 729static gboolean process_fork(void *hook_data, void *call_data)
dc877563 730{
b445142a 731 LttField *f = ((LttvTraceHook *)hook_data)->f1;
dc877563 732
ba576a78 733 LttvTracefileState *s = (LttvTracefileState *)call_data;
dc877563 734
735 guint child_pid;
736
3d27549e 737 child_pid = ltt_event_get_unsigned(s->parent.e, f);
ba576a78 738 create_process(s, s->process, child_pid);
dc877563 739 return FALSE;
740}
741
742
b445142a 743static gboolean process_exit(void *hook_data, void *call_data)
dc877563 744{
ba576a78 745 LttvTracefileState *s = (LttvTracefileState *)call_data;
dc877563 746
747 if(s->process != NULL) {
ffd54a90 748 s->process->state->s = LTTV_STATE_EXIT;
dc877563 749 }
750 return FALSE;
751}
752
753
308711e5 754void lttv_state_add_event_hooks(LttvTracesetState *self)
dc877563 755{
ba576a78 756 LttvTraceset *traceset = self->parent.ts;
dc877563 757
ba576a78 758 guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
dc877563 759
ba576a78 760 LttvTraceState *ts;
dc877563 761
ba576a78 762 LttvTracefileState *tfs;
dc877563 763
dc877563 764 GArray *hooks;
765
b445142a 766 LttvTraceHook hook;
dc877563 767
768 LttvAttributeValue val;
769
ba576a78 770 nb_trace = lttv_traceset_number(traceset);
dc877563 771 for(i = 0 ; i < nb_trace ; i++) {
ba576a78 772 ts = (LttvTraceState *)self->parent.traces[i];
dc877563 773
774 /* Find the eventtype id for the following events and register the
775 associated by id hooks. */
776
b445142a 777 hooks = g_array_new(FALSE, FALSE, sizeof(LttvTraceHook));
778 g_array_set_size(hooks, 9);
779
780 lttv_trace_find_hook(ts->parent.t, "core","syscall_entry","syscall_id",
781 NULL, NULL, syscall_entry, &g_array_index(hooks, LttvTraceHook, 0));
cbe7c836 782
b445142a 783 lttv_trace_find_hook(ts->parent.t, "core", "syscall_exit", NULL, NULL,
784 NULL, syscall_exit, &g_array_index(hooks, LttvTraceHook, 1));
cbe7c836 785
b445142a 786 lttv_trace_find_hook(ts->parent.t, "core", "trap_entry", "trap_id",
787 NULL, NULL, trap_entry, &g_array_index(hooks, LttvTraceHook, 2));
cbe7c836 788
b445142a 789 lttv_trace_find_hook(ts->parent.t, "core", "trap_exit", NULL, NULL, NULL,
790 trap_exit, &g_array_index(hooks, LttvTraceHook, 3));
cbe7c836 791
b445142a 792 lttv_trace_find_hook(ts->parent.t, "core", "irq_entry", "irq_id", NULL,
793 NULL, irq_entry, &g_array_index(hooks, LttvTraceHook, 4));
cbe7c836 794
b445142a 795 lttv_trace_find_hook(ts->parent.t, "core", "irq_exit", NULL, NULL, NULL,
796 irq_exit, &g_array_index(hooks, LttvTraceHook, 5));
cbe7c836 797
b445142a 798 lttv_trace_find_hook(ts->parent.t, "core", "schedchange", "in", "out",
799 "out_state", schedchange, &g_array_index(hooks, LttvTraceHook, 6));
cbe7c836 800
b445142a 801 lttv_trace_find_hook(ts->parent.t, "core", "process_fork", "child_pid",
802 NULL, NULL, process_fork, &g_array_index(hooks, LttvTraceHook, 7));
cbe7c836 803
b445142a 804 lttv_trace_find_hook(ts->parent.t, "core", "process_exit", NULL, NULL,
805 NULL, process_exit, &g_array_index(hooks, LttvTraceHook, 8));
dc877563 806
807 /* Add these hooks to each before_event_by_id hooks list */
808
ba576a78 809 nb_control = ltt_trace_control_tracefile_number(ts->parent.t);
cbe7c836 810 nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.t);
dc877563 811 nb_tracefile = nb_control + nb_per_cpu;
812 for(j = 0 ; j < nb_tracefile ; j++) {
813 if(j < nb_control) {
ba576a78 814 tfs = LTTV_TRACEFILE_STATE(ts->parent.control_tracefiles[j]);
dc877563 815 }
816 else {
cbe7c836 817 tfs = LTTV_TRACEFILE_STATE(ts->parent.per_cpu_tracefiles[j-nb_control]);
dc877563 818 }
819
820 for(k = 0 ; k < hooks->len ; k++) {
b445142a 821 hook = g_array_index(hooks, LttvTraceHook, k);
822 lttv_hooks_add(lttv_hooks_by_id_find(tfs->parent.after_event_by_id,
823 hook.id), hook.h, &g_array_index(hooks, LttvTraceHook, k));
ffd54a90 824 }
dc877563 825 }
ba576a78 826 lttv_attribute_find(self->parent.a, LTTV_STATE_HOOKS, LTTV_POINTER, &val);
827 *(val.v_pointer) = hooks;
dc877563 828 }
829}
830
831
308711e5 832void lttv_state_remove_event_hooks(LttvTracesetState *self)
dc877563 833{
ba576a78 834 LttvTraceset *traceset = self->parent.ts;
dc877563 835
ba576a78 836 guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
dc877563 837
ba576a78 838 LttvTraceState *ts;
dc877563 839
ba576a78 840 LttvTracefileState *tfs;
dc877563 841
dc877563 842 GArray *hooks;
843
b445142a 844 LttvTraceHook hook;
dc877563 845
846 LttvAttributeValue val;
847
ba576a78 848 nb_trace = lttv_traceset_number(traceset);
dc877563 849 for(i = 0 ; i < nb_trace ; i++) {
ba576a78 850 ts = LTTV_TRACE_STATE(self->parent.traces[i]);
851 lttv_attribute_find(self->parent.a, LTTV_STATE_HOOKS, LTTV_POINTER, &val);
852 hooks = *(val.v_pointer);
dc877563 853
854 /* Add these hooks to each before_event_by_id hooks list */
855
ba576a78 856 nb_control = ltt_trace_control_tracefile_number(ts->parent.t);
cbe7c836 857 nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.t);
dc877563 858 nb_tracefile = nb_control + nb_per_cpu;
859 for(j = 0 ; j < nb_tracefile ; j++) {
860 if(j < nb_control) {
ba576a78 861 tfs = LTTV_TRACEFILE_STATE(ts->parent.control_tracefiles[j]);
dc877563 862 }
863 else {
cbe7c836 864 tfs = LTTV_TRACEFILE_STATE(ts->parent.per_cpu_tracefiles[j-nb_control]);
dc877563 865 }
866
867 for(k = 0 ; k < hooks->len ; k++) {
b445142a 868 hook = g_array_index(hooks, LttvTraceHook, k);
ba576a78 869 lttv_hooks_remove_data(
b445142a 870 lttv_hooks_by_id_find(tfs->parent.after_event_by_id,
871 hook.id), hook.h, &g_array_index(hooks, LttvTraceHook, k));
ffd54a90 872 }
dc877563 873 }
874 g_array_free(hooks, TRUE);
875 }
876}
877
878
308711e5 879static gboolean block_end(void *hook_data, void *call_data)
880{
881 LttvTracefileState *tfcs = (LttvTracefileState *)call_data;
882
883 LttvTraceState *tcs = (LttvTraceState *)(tfcs->parent.t_context);
884
a5dcde2f 885 LttEventPosition *ep = ltt_event_position_new();
308711e5 886
887 guint nb_block, nb_event;
888
889 LttTracefile *tf;
890
891 LttvAttribute *saved_states_tree, *saved_state_tree;
892
893 LttvAttributeValue value;
894
a5dcde2f 895 ltt_event_position(tfcs->parent.e, ep);
308711e5 896
a5dcde2f 897 ltt_event_position_get(ep, &nb_block, &nb_event, &tf);
308711e5 898 tcs->nb_event += nb_event - tfcs->saved_position;
899 tfcs->saved_position = 0;
900 if(tcs->nb_event >= tcs->save_interval) {
901 saved_states_tree = lttv_attribute_find_subdir(tcs->parent.t_a,
902 LTTV_STATE_SAVED_STATES);
903 saved_state_tree = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
904 value = lttv_attribute_add(saved_states_tree,
905 lttv_attribute_get_number(saved_states_tree), LTTV_GOBJECT);
906 *(value.v_gobject) = (GObject *)saved_state_tree;
907 value = lttv_attribute_add(saved_state_tree, LTTV_STATE_TIME, LTTV_TIME);
908 *(value.v_time) = tfcs->parent.timestamp;
909 lttv_state_save(tcs, saved_state_tree);
910 tcs->nb_event = 0;
911 }
912 return FALSE;
913}
914
915
916void lttv_state_save_add_event_hooks(LttvTracesetState *self)
917{
918 LttvTraceset *traceset = self->parent.ts;
919
920 guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
921
922 LttvTraceState *ts;
923
924 LttvTracefileState *tfs;
925
926 LttvTraceHook hook;
927
928 nb_trace = lttv_traceset_number(traceset);
929 for(i = 0 ; i < nb_trace ; i++) {
930 ts = (LttvTraceState *)self->parent.traces[i];
931 lttv_trace_find_hook(ts->parent.t, "core","block_end",NULL,
932 NULL, NULL, block_end, &hook);
933
934 nb_control = ltt_trace_control_tracefile_number(ts->parent.t);
935 nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.t);
936 nb_tracefile = nb_control + nb_per_cpu;
937 for(j = 0 ; j < nb_tracefile ; j++) {
938 if(j < nb_control) {
939 tfs = LTTV_TRACEFILE_STATE(ts->parent.control_tracefiles[j]);
940 }
941 else {
942 tfs =LTTV_TRACEFILE_STATE(ts->parent.per_cpu_tracefiles[j-nb_control]);
943 }
944
945 lttv_hooks_add(lttv_hooks_by_id_find(tfs->parent.after_event_by_id,
946 hook.id), hook.h, NULL);
947 }
948 }
949}
950
951
952void lttv_state_save_remove_event_hooks(LttvTracesetState *self)
953{
954 LttvTraceset *traceset = self->parent.ts;
955
956 guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
957
958 LttvTraceState *ts;
959
960 LttvTracefileState *tfs;
961
962 LttvTraceHook hook;
963
964 nb_trace = lttv_traceset_number(traceset);
965 for(i = 0 ; i < nb_trace ; i++) {
966 ts = LTTV_TRACE_STATE(self->parent.traces[i]);
967 lttv_trace_find_hook(ts->parent.t, "core","block_end",NULL,
968 NULL, NULL, block_end, &hook);
969
970 nb_control = ltt_trace_control_tracefile_number(ts->parent.t);
971 nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.t);
972 nb_tracefile = nb_control + nb_per_cpu;
973 for(j = 0 ; j < nb_tracefile ; j++) {
974 if(j < nb_control) {
975 tfs = LTTV_TRACEFILE_STATE(ts->parent.control_tracefiles[j]);
976 }
977 else {
978 tfs =LTTV_TRACEFILE_STATE(ts->parent.per_cpu_tracefiles[j-nb_control]);
979 }
980
981 lttv_hooks_remove_data(lttv_hooks_by_id_find(
982 tfs->parent.after_event_by_id, hook.id), hook.h, NULL);
983 }
984 }
985}
986
987
dd025f91 988void lttv_state_traceset_seek_time_closest(LttvTracesetState *self, LttTime t)
308711e5 989{
990 LttvTraceset *traceset = self->parent.ts;
991
992 guint i, j, nb_trace, nb_saved_state;
993
994 int min_pos, mid_pos, max_pos;
995
996 LttvTraceState *tcs;
997
998 LttvAttributeValue value;
999
1000 LttvAttributeType type;
1001
1002 LttvAttributeName name;
1003
1004 LttvAttribute *saved_states_tree, *saved_state_tree, *closest_tree;
1005
1006 nb_trace = lttv_traceset_number(traceset);
1007 for(i = 0 ; i < nb_trace ; i++) {
1008 tcs = (LttvTraceState *)self->parent.traces[i];
1009
dd025f91 1010 if(tcs->recompute_state_in_seek) {
1011 if(tcs->saved_state_available) {
1012 saved_states_tree = lttv_attribute_find_subdir(tcs->parent.t_a,
1013 LTTV_STATE_SAVED_STATES);
1014 min_pos = -1;
1015 max_pos = lttv_attribute_get_number(saved_states_tree) - 1;
1016 mid_pos = max_pos / 2;
1017 while(min_pos < max_pos) {
1018 type = lttv_attribute_get(saved_states_tree, mid_pos, &name, &value);
1019 g_assert(type == LTTV_GOBJECT);
1020 saved_state_tree = *((LttvAttribute **)(value.v_gobject));
1021 type = lttv_attribute_get_by_name(saved_state_tree, LTTV_STATE_TIME,
1022 &value);
1023 g_assert(type == LTTV_TIME);
1024 if(ltt_time_compare(*(value.v_time), t) < 0) {
1025 min_pos = mid_pos;
1026 closest_tree = saved_state_tree;
1027 }
1028 else max_pos = mid_pos - 1;
1029
1030 mid_pos = (min_pos + max_pos + 1) / 2;
1031 }
1032
1033 /* restore the closest earlier saved state */
1034 if(min_pos != -1) lttv_state_restore(tcs, closest_tree);
1035
1036 /* there is no earlier saved state, restart at T0 */
1037 else {
1038 restore_init_state(tcs);
1039 lttv_process_trace_seek_time(&(tcs->parent), ltt_time_zero);
1040 }
1041
1042 /* There is no saved state yet we want to have it. Restart at T0 */
1043 else {
1044 restore_init_state(tcs);
1045 lttv_process_trace_seek_time(&(tcs->parent), ltt_time_zero);
308711e5 1046 }
308711e5 1047
dd025f91 1048 /* We want to seek quickly without restoring/updating the state */
1049 else {
308711e5 1050 restore_init_state(tcs);
dd025f91 1051 lttv_process_trace_seek_time(&(tcs->parent), t);
308711e5 1052 }
308711e5 1053 }
1054}
1055
1056
1057static void
1058traceset_state_instance_init (GTypeInstance *instance, gpointer g_class)
1059{
1060}
1061
1062
1063static void
1064traceset_state_finalize (LttvTracesetState *self)
1065{
1066 G_OBJECT_CLASS(g_type_class_peek(LTTV_TRACESET_CONTEXT_TYPE))->
1067 finalize(G_OBJECT(self));
1068}
1069
1070
1071static void
1072traceset_state_class_init (LttvTracesetContextClass *klass)
1073{
1074 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
1075
1076 gobject_class->finalize = (void (*)(GObject *self)) traceset_state_finalize;
1077 klass->init = (void (*)(LttvTracesetContext *self, LttvTraceset *ts))init;
1078 klass->fini = (void (*)(LttvTracesetContext *self))fini;
1079 klass->new_traceset_context = new_traceset_context;
1080 klass->new_trace_context = new_trace_context;
1081 klass->new_tracefile_context = new_tracefile_context;
1082}
1083
1084
1085GType
1086lttv_traceset_state_get_type(void)
1087{
1088 static GType type = 0;
1089 if (type == 0) {
1090 static const GTypeInfo info = {
1091 sizeof (LttvTracesetStateClass),
1092 NULL, /* base_init */
1093 NULL, /* base_finalize */
1094 (GClassInitFunc) traceset_state_class_init, /* class_init */
1095 NULL, /* class_finalize */
1096 NULL, /* class_data */
1097 sizeof (LttvTracesetContext),
1098 0, /* n_preallocs */
1099 (GInstanceInitFunc) traceset_state_instance_init /* instance_init */
1100 };
1101
1102 type = g_type_register_static (LTTV_TRACESET_CONTEXT_TYPE, "LttvTracesetStateType",
1103 &info, 0);
1104 }
1105 return type;
1106}
1107
1108
1109static void
1110trace_state_instance_init (GTypeInstance *instance, gpointer g_class)
1111{
1112}
1113
1114
1115static void
1116trace_state_finalize (LttvTraceState *self)
1117{
1118 G_OBJECT_CLASS(g_type_class_peek(LTTV_TRACE_CONTEXT_TYPE))->
1119 finalize(G_OBJECT(self));
1120}
1121
1122
1123static void
1124trace_state_class_init (LttvTraceStateClass *klass)
1125{
1126 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
1127
1128 gobject_class->finalize = (void (*)(GObject *self)) trace_state_finalize;
1129 klass->state_save = state_save;
1130 klass->state_restore = state_restore;
1131 klass->state_saved_free = state_saved_free;
1132}
1133
1134
1135GType
1136lttv_trace_state_get_type(void)
1137{
1138 static GType type = 0;
1139 if (type == 0) {
1140 static const GTypeInfo info = {
1141 sizeof (LttvTraceStateClass),
1142 NULL, /* base_init */
1143 NULL, /* base_finalize */
1144 (GClassInitFunc) trace_state_class_init, /* class_init */
1145 NULL, /* class_finalize */
1146 NULL, /* class_data */
1147 sizeof (LttvTraceState),
1148 0, /* n_preallocs */
1149 (GInstanceInitFunc) trace_state_instance_init /* instance_init */
1150 };
1151
1152 type = g_type_register_static (LTTV_TRACE_CONTEXT_TYPE,
1153 "LttvTraceStateType", &info, 0);
1154 }
1155 return type;
1156}
1157
1158
1159static void
1160tracefile_state_instance_init (GTypeInstance *instance, gpointer g_class)
1161{
1162}
1163
1164
1165static void
1166tracefile_state_finalize (LttvTracefileState *self)
1167{
1168 G_OBJECT_CLASS(g_type_class_peek(LTTV_TRACEFILE_CONTEXT_TYPE))->
1169 finalize(G_OBJECT(self));
1170}
1171
1172
1173static void
1174tracefile_state_class_init (LttvTracefileStateClass *klass)
1175{
1176 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
1177
1178 gobject_class->finalize = (void (*)(GObject *self)) tracefile_state_finalize;
1179}
1180
1181
1182GType
1183lttv_tracefile_state_get_type(void)
1184{
1185 static GType type = 0;
1186 if (type == 0) {
1187 static const GTypeInfo info = {
1188 sizeof (LttvTracefileStateClass),
1189 NULL, /* base_init */
1190 NULL, /* base_finalize */
1191 (GClassInitFunc) tracefile_state_class_init, /* class_init */
1192 NULL, /* class_finalize */
1193 NULL, /* class_data */
1194 sizeof (LttvTracefileState),
1195 0, /* n_preallocs */
1196 (GInstanceInitFunc) tracefile_state_instance_init /* instance_init */
1197 };
1198
1199 type = g_type_register_static (LTTV_TRACEFILE_CONTEXT_TYPE,
1200 "LttvTracefileStateType", &info, 0);
1201 }
1202 return type;
1203}
1204
1205
ffd54a90 1206void lttv_state_init(int argc, char **argv)
1207{
1208 LTTV_STATE_UNNAMED = g_quark_from_string("unnamed");
b445142a 1209 LTTV_STATE_MODE_UNKNOWN = g_quark_from_string("unknown execution mode");
ffd54a90 1210 LTTV_STATE_USER_MODE = g_quark_from_string("user mode");
1211 LTTV_STATE_WAIT_FORK = g_quark_from_string("wait fork");
1212 LTTV_STATE_SYSCALL = g_quark_from_string("system call");
1213 LTTV_STATE_TRAP = g_quark_from_string("trap");
1214 LTTV_STATE_IRQ = g_quark_from_string("irq");
b445142a 1215 LTTV_STATE_SUBMODE_UNKNOWN = g_quark_from_string("unknown submode");
1216 LTTV_STATE_SUBMODE_NONE = g_quark_from_string("(no submode)");
ffd54a90 1217 LTTV_STATE_WAIT_CPU = g_quark_from_string("wait for cpu");
1218 LTTV_STATE_EXIT = g_quark_from_string("exiting");
1219 LTTV_STATE_WAIT = g_quark_from_string("wait for I/O");
1220 LTTV_STATE_RUN = g_quark_from_string("running");
308711e5 1221 LTTV_STATE_TRACEFILES = g_quark_from_string("tracefiles");
1222 LTTV_STATE_PROCESSES = g_quark_from_string("processes");
1223 LTTV_STATE_PROCESS = g_quark_from_string("process");
1224 LTTV_STATE_EVENT = g_quark_from_string("event");
1225 LTTV_STATE_SAVED_STATES = g_quark_from_string("saved states");
1226 LTTV_STATE_TIME = g_quark_from_string("time");
ffd54a90 1227 LTTV_STATE_HOOKS = g_quark_from_string("saved state hooks");
1228}
dc877563 1229
ffd54a90 1230void lttv_state_destroy()
1231{
1232}
dc877563 1233
1234
1235
1236
This page took 0.10167 seconds and 4 git commands to generate.