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