From e62e7f3a20cc94539fab3595f8aec3b6f4fce304 Mon Sep 17 00:00:00 2001 From: compudj Date: Tue, 2 May 2006 05:11:57 +0000 Subject: [PATCH] update state dump git-svn-id: http://ltt.polymtl.ca/svn@1781 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/configure.in | 2 +- ltt/branches/poly/lttv/lttv/state.c | 65 +++++++++++++++++++---------- ltt/branches/poly/lttv/lttv/state.h | 8 +++- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/ltt/branches/poly/configure.in b/ltt/branches/poly/configure.in index 89acf83f..703a70bf 100644 --- a/ltt/branches/poly/configure.in +++ b/ltt/branches/poly/configure.in @@ -23,7 +23,7 @@ AC_PREREQ(2.57) AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS) #AC_WITH_LTDL # not needed ? -AM_INIT_AUTOMAKE(LinuxTraceToolkitViewer,0.8.38-29042006) +AM_INIT_AUTOMAKE(LinuxTraceToolkitViewer,0.8.39-01052006) AM_CONFIG_HEADER(config.h) AM_PROG_LIBTOOL diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index 3084b429..1369be5e 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -78,6 +78,7 @@ GQuark LTT_FIELD_PID, LTT_FIELD_FILENAME, LTT_FIELD_NAME, + LTT_FIELD_TYPE, LTT_FIELD_MODE, LTT_FIELD_SUBMODE, LTT_FIELD_STATUS, @@ -106,6 +107,10 @@ LttvProcessStatus LTTV_STATE_RUN, LTTV_STATE_DEAD; +LttvProcessType + LTTV_STATE_USER_THREAD, + LTTV_STATE_KERNEL_THREAD; + static GQuark LTTV_STATE_TRACEFILES, LTTV_STATE_PROCESSES, @@ -412,8 +417,9 @@ static void write_process_state(gpointer key, gpointer value, process = (LttvProcessState *)value; fprintf(fp, -" \n", - process, process->pid, process->ppid, process->creation_time.tv_sec, +" \n", + process, process->pid, process->ppid, g_quark_to_string(process->type), + process->creation_time.tv_sec, process->creation_time.tv_nsec, g_quark_to_string(process->name), process->cpu); @@ -1183,7 +1189,7 @@ lttv_state_create_process(LttvTraceState *tcs, LttvProcessState *parent, process->name = name; //process->last_cpu = tfs->cpu_name; //process->last_cpu_index = ltt_tracefile_num(((LttvTracefileContext*)tfs)->tf); - process->kernel_thread = 0; + process->type = LTTV_STATE_USER_THREAD; process->usertrace = ltt_state_usertrace_find(tcs, pid, timestamp); process->current_function = 0; //function 0x0 by default. @@ -1655,7 +1661,7 @@ static gboolean process_kernel_thread(void *hook_data, void *call_data) process = lttv_state_find_process(ts, ANY_CPU, pid); es = &g_array_index(process->execution_stack, LttvExecutionState, 0); es->t = LTTV_STATE_SYSCALL; - process->kernel_thread = 1; + process->type = LTTV_STATE_KERNEL_THREAD; return FALSE; } @@ -1769,8 +1775,9 @@ static gboolean enum_process_state(void *hook_data, void *call_data) LttvTraceState *ts = (LttvTraceState*)s->parent.t_context; LttvProcessState *process = ts->running_process[cpu]; LttvProcessState *parent_process; - LttField *f4, *f5, *f6; - GQuark mode, submode, status; + LttField *f4, *f5, *f6, *f7; + GQuark type, mode, submode, status; + LttvExecutionState *es; /* PID */ pid = ltt_event_get_unsigned(e, thf->f1); @@ -1781,21 +1788,26 @@ static gboolean enum_process_state(void *hook_data, void *call_data) /* Command name */ command = ltt_event_get_string(e, thf->f3); - /* mode */ - f4 = ltt_eventtype_field_by_name(et, LTT_FIELD_MODE); - mode = ltt_enum_string_get(ltt_field_type(f4), + /* type */ + f4 = ltt_eventtype_field_by_name(et, LTT_FIELD_TYPE); + type = ltt_enum_string_get(ltt_field_type(f4), ltt_event_get_unsigned(e, f4)); - /* submode */ - f5 = ltt_eventtype_field_by_name(et, LTT_FIELD_SUBMODE); - submode = ltt_enum_string_get(ltt_field_type(f5), + /* mode */ + f5 = ltt_eventtype_field_by_name(et, LTT_FIELD_MODE); + mode = ltt_enum_string_get(ltt_field_type(f5), ltt_event_get_unsigned(e, f5)); - /* status */ - f6 = ltt_eventtype_field_by_name(et, LTT_FIELD_STATUS); - status = ltt_enum_string_get(ltt_field_type(f6), + /* submode */ + f6 = ltt_eventtype_field_by_name(et, LTT_FIELD_SUBMODE); + submode = ltt_enum_string_get(ltt_field_type(f6), ltt_event_get_unsigned(e, f6)); + /* status */ + f7 = ltt_eventtype_field_by_name(et, LTT_FIELD_STATUS); + status = ltt_enum_string_get(ltt_field_type(f7), + ltt_event_get_unsigned(e, f7)); + /* The process might exist if a process was forked while performing the sate dump. */ process = lttv_state_find_process(ts, ANY_CPU, pid); if(process == NULL) { @@ -1805,38 +1817,44 @@ static gboolean enum_process_state(void *hook_data, void *call_data) &s->parent.timestamp); /* Keep the stack bottom : a running user mode */ -#if 0 /* Disabled because of inconsistencies in the current statedump states. */ - if(mode == LTTV_STATE_USER_MODE) { + if(type == LTTV_STATE_KERNEL_THREAD) { /* Only keep the bottom */ process->execution_stack = g_array_set_size(process->execution_stack, 1); + es = process->state = &g_array_index(process->execution_stack, + LttvExecutionState, 0); + es->t = LTTV_STATE_SYSCALL; + es->s = status; + es->n = submode; } else { /* On top of it : */ - LttvExecutionState *es; es = process->state = &g_array_index(process->execution_stack, LttvExecutionState, 1); - es->t = mode; + es->t = LTTV_STATE_USER_MODE; es->s = status; es->n = submode; } -#endif //0 - +#if 0 /* UNKNOWN STATE */ { - LttvExecutionState *es; es = process->state = &g_array_index(process->execution_stack, LttvExecutionState, 1); es->t = LTTV_STATE_MODE_UNKNOWN; es->s = LTTV_STATE_UNNAMED; es->n = LTTV_STATE_SUBMODE_UNKNOWN; } +#endif //0 } else { /* The process has already been created : * Probably was forked while dumping the process state or * was simply scheduled in prior to get the state dump event. + * We know for sure if it is a user space thread. */ process->ppid = parent_pid; process->name = g_quark_from_string(command); + es = &g_array_index(process->execution_stack, LttvExecutionState, 0); + if(type != LTTV_STATE_KERNEL_THREAD) + es->t = LTTV_STATE_USER_MODE; /* Don't mess around with the stack, it will eventually become * ok after the end of state dump. */ } @@ -2638,6 +2656,8 @@ static void module_init() LTTV_STATE_WAIT = g_quark_from_string("WAIT"); LTTV_STATE_RUN = g_quark_from_string("RUN"); LTTV_STATE_DEAD = g_quark_from_string("DEAD"); + LTTV_STATE_USER_THREAD = g_quark_from_string("USER_THREAD"); + LTTV_STATE_KERNEL_THREAD = g_quark_from_string("KERNEL_THREAD"); LTTV_STATE_TRACEFILES = g_quark_from_string("tracefiles"); LTTV_STATE_PROCESSES = g_quark_from_string("processes"); LTTV_STATE_PROCESS = g_quark_from_string("process"); @@ -2691,6 +2711,7 @@ static void module_init() LTT_FIELD_PID = g_quark_from_string("pid"); LTT_FIELD_FILENAME = g_quark_from_string("filename"); LTT_FIELD_NAME = g_quark_from_string("name"); + LTT_FIELD_TYPE = g_quark_from_string("type"); LTT_FIELD_MODE = g_quark_from_string("mode"); LTT_FIELD_SUBMODE = g_quark_from_string("submode"); LTT_FIELD_STATUS = g_quark_from_string("status"); diff --git a/ltt/branches/poly/lttv/lttv/state.h b/ltt/branches/poly/lttv/lttv/state.h index 85ff1894..3b9dda4a 100644 --- a/ltt/branches/poly/lttv/lttv/state.h +++ b/ltt/branches/poly/lttv/lttv/state.h @@ -99,6 +99,7 @@ extern GQuark LTT_FIELD_PID, LTT_FIELD_FILENAME, LTT_FIELD_NAME, + LTT_FIELD_TYPE, LTT_FIELD_MODE, LTT_FIELD_SUBMODE, LTT_FIELD_STATUS, @@ -186,6 +187,11 @@ extern LttvProcessStatus LTTV_STATE_RUN, LTTV_STATE_DEAD; +typedef GQuark LttvProcessType; + +extern LttvProcessType + LTTV_STATE_USER_THREAD, + LTTV_STATE_KERNEL_THREAD; typedef struct _LttvExecutionState { LttvExecutionMode t; @@ -210,12 +216,12 @@ typedef struct _LttvProcessState { * (Mathieu) */ guint cpu; /* CPU where process is scheduled (being either in the active or inactive runqueue)*/ - gboolean kernel_thread; /* Is this thread a kernel_thread ? */ // guint last_tracefile_index; /* index in the trace for cpu tracefile */ LttvTracefileState *usertrace; /* Associated usertrace */ /* opened file descriptors, address map?... */ GArray *user_stack; /* User space function call stack */ guint64 current_function; + LttvProcessType type; /* kernel thread or user space ? */ } LttvProcessState; #define ANY_CPU 0 /* For clarity sake : a call to lttv_state_find_process for -- 2.34.1