static LttvProcessState *create_process(LttvTracefileState *tfs,
LttvProcessState *parent, guint pid);
-static LttvProcessState *create_process_from_trace(LttvTraceState *ts,
- LttvProcessState *parent, guint pid);
-
void lttv_state_save(LttvTraceState *self, LttvAttribute *container)
{
LTTV_TRACE_STATE_GET_CLASS(self)->state_save(self, container);
return process;
}
-static LttvProcessState *create_process_from_trace(LttvTraceState *tcs,
- LttvProcessState *parent, guint pid)
-{
- LttvProcessState *process = g_new(LttvProcessState, 1);
-
- LttvExecutionState *es;
-
- LttvTraceContext *tc = (LttvTraceContext *)tcs;
-
- char buffer[128];
-
- g_hash_table_insert(tcs->processes, GUINT_TO_POINTER(pid), process);
- process->pid = pid;
-
- if(parent) {
- process->ppid = parent->pid;
- process->name = parent->name;
- }
- else {
- process->ppid = 0;
- process->name = LTTV_STATE_UNNAMED;
- }
-
- //FIXME timestamp should come from trace
- process->creation_time.tv_sec = 0;
- process->creation_time.tv_nsec = 0;
- sprintf(buffer,"%d-%lu.%lu",pid, process->creation_time.tv_sec,
- process->creation_time.tv_nsec);
- process->pid_time = g_quark_from_string(buffer);
- process->execution_stack = g_array_new(FALSE, FALSE,
- sizeof(LttvExecutionState));
- g_array_set_size(process->execution_stack, 1);
- es = process->state = &g_array_index(process->execution_stack,
- LttvExecutionState, 0);
- es->t = LTTV_STATE_USER_MODE;
- es->n = LTTV_STATE_SUBMODE_NONE;
- //FIXME es->entry = tfs->parent.timestamp;
- es->entry.tv_sec = 0;
- es->entry.tv_nsec = 0;
- //FIXME es->change = tfs->parent.timestamp;
- es->change.tv_sec = 0;
- es->change.tv_nsec = 0;
- es->s = LTTV_STATE_WAIT_FORK;
-
- return process;
-}
-
-
-
LttvProcessState *lttv_state_find_process(LttvTracefileState *tfs,
guint pid)
{
{
LttvProcessState *process = g_hash_table_lookup(ts->processes,
GUINT_TO_POINTER(pid));
-
- if(process == NULL) process = create_process_from_trace(ts, NULL, pid);
+ //We do not create a process at this level, because we can be called
+ //from outside of state.c, and therefore cannot assume a tracefile
+ //exists.
+ //if(process == NULL) process = create_process_from_trace(ts, NULL, pid);
return process;
}
draw_context->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
gdk_gc_copy(draw_context->gc, widget->style->black_gc);
- if(process->state->s == LTTV_STATE_RUN)
+ if(process != NULL && process->state->s == LTTV_STATE_RUN)
{
PropertiesBG prop_bg;
prop_bg.color = g_new(GdkColor,1);
prop_line.position = MIDDLE;
/* color of line : status of the process */
- if(process->state->s == LTTV_STATE_UNNAMED)
+ if(process != NULL)
{
- prop_line.color->red = 0xffff;
- prop_line.color->green = 0xffff;
- prop_line.color->blue = 0xffff;
- }
- else if(process->state->s == LTTV_STATE_WAIT_FORK)
- {
- prop_line.color->red = 0x0fff;
- prop_line.color->green = 0xffff;
- prop_line.color->blue = 0xfff0;
- }
- else if(process->state->s == LTTV_STATE_WAIT_CPU)
- {
- prop_line.color->red = 0xffff;
- prop_line.color->green = 0xffff;
- prop_line.color->blue = 0x0000;
- }
- else if(process->state->s == LTTV_STATE_EXIT)
- {
- prop_line.color->red = 0xffff;
- prop_line.color->green = 0x0000;
- prop_line.color->blue = 0xffff;
- }
- else if(process->state->s == LTTV_STATE_WAIT)
- {
- prop_line.color->red = 0xffff;
- prop_line.color->green = 0x0000;
- prop_line.color->blue = 0x0000;
- }
- else if(process->state->s == LTTV_STATE_RUN)
- {
- prop_line.color->red = 0x0000;
- prop_line.color->green = 0xffff;
- prop_line.color->blue = 0x0000;
+ if(process->state->s == LTTV_STATE_UNNAMED)
+ {
+ prop_line.color->red = 0xffff;
+ prop_line.color->green = 0xffff;
+ prop_line.color->blue = 0xffff;
+ }
+ else if(process->state->s == LTTV_STATE_WAIT_FORK)
+ {
+ prop_line.color->red = 0x0fff;
+ prop_line.color->green = 0xffff;
+ prop_line.color->blue = 0xfff0;
+ }
+ else if(process->state->s == LTTV_STATE_WAIT_CPU)
+ {
+ prop_line.color->red = 0xffff;
+ prop_line.color->green = 0xffff;
+ prop_line.color->blue = 0x0000;
+ }
+ else if(process->state->s == LTTV_STATE_EXIT)
+ {
+ prop_line.color->red = 0xffff;
+ prop_line.color->green = 0x0000;
+ prop_line.color->blue = 0xffff;
+ }
+ else if(process->state->s == LTTV_STATE_WAIT)
+ {
+ prop_line.color->red = 0xffff;
+ prop_line.color->green = 0x0000;
+ prop_line.color->blue = 0x0000;
+ }
+ else if(process->state->s == LTTV_STATE_RUN)
+ {
+ prop_line.color->red = 0x0000;
+ prop_line.color->green = 0xffff;
+ prop_line.color->blue = 0x0000;
+ }
+ else
+ {
+ prop_line.color->red = 0xffff;
+ prop_line.color->green = 0xffff;
+ prop_line.color->blue = 0xffff;
+ }
+
}
else
{
- prop_line.color->red = 0xffff;
- prop_line.color->green = 0xffff;
- prop_line.color->blue = 0xffff;
+ prop_line.color->red = 0xffff;
+ prop_line.color->green = 0xffff;
+ prop_line.color->blue = 0xffff;
}
draw_line((void*)&prop_line, (void*)draw_context);