From f4b88a7dd49bfb6b88ea579410d7e4b59faaf73c Mon Sep 17 00:00:00 2001 From: compudj Date: Fri, 26 Aug 2005 15:57:23 +0000 Subject: [PATCH] add process names git-svn-id: http://ltt.polymtl.ca/svn@1081 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/lttv/state.c | 45 ++++++++- ltt/branches/poly/lttv/lttv/state.h | 9 +- ltt/branches/poly/lttv/lttv/tracecontext.c | 6 +- .../lttv/modules/gui/controlflow/drawing.c | 12 ++- .../lttv/modules/gui/controlflow/eventhooks.c | 99 +++++++++++++++---- .../lttv/modules/gui/controlflow/eventhooks.h | 1 + .../modules/gui/controlflow/processlist.c | 14 ++- .../modules/gui/controlflow/processlist.h | 7 +- .../gui/lttvwindow/lttvwindow/callbacks.c | 4 +- 9 files changed, 162 insertions(+), 35 deletions(-) diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index a59ac339..1fbb627e 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -35,7 +35,8 @@ GQuark LTT_FACILITY_KERNEL, - LTT_FACILITY_PROCESS; + LTT_FACILITY_PROCESS, + LTT_FACILITY_FS; /* Events Quarks */ @@ -49,7 +50,8 @@ GQuark LTT_EVENT_SCHEDCHANGE, LTT_EVENT_FORK, LTT_EVENT_EXIT, - LTT_EVENT_FREE; + LTT_EVENT_FREE, + LTT_EVENT_EXEC; /* Fields Quarks */ @@ -62,7 +64,8 @@ GQuark LTT_FIELD_OUT_STATE, LTT_FIELD_PARENT_PID, LTT_FIELD_CHILD_PID, - LTT_FIELD_PID; + LTT_FIELD_PID, + LTT_FIELD_FILENAME; LttvExecutionMode LTTV_STATE_MODE_UNKNOWN, @@ -1279,6 +1282,28 @@ static gboolean process_free(void *hook_data, void *call_data) return FALSE; } + +static gboolean process_exec(void *hook_data, void *call_data) +{ + LttvTracefileState *s = (LttvTracefileState *)call_data; + LttvTraceState *ts = (LttvTraceState*)s->parent.t_context; + LttEvent *e = ltt_tracefile_get_event(s->parent.tf); + LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; + gchar *name; + guint cpu = ltt_tracefile_num(s->parent.tf); + LttvProcessState *process = ts->running_process[cpu]; + + /* PID of the process to release */ + name = ltt_event_get_string(e, thf->f1); + + process->name = g_quark_from_string(name); + + return FALSE; +} + + + + gint lttv_state_hook_add_event_hooks(void *hook_data, void *call_data) { LttvTracesetState *tss = (LttvTracesetState*)(call_data); @@ -1315,8 +1340,8 @@ void lttv_state_add_event_hooks(LttvTracesetState *self) /* Find the eventtype id for the following events and register the associated by id hooks. */ - hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 10); - hooks = g_array_set_size(hooks, 10); + hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 11); + hooks = g_array_set_size(hooks, 11); ret = lttv_trace_find_hook(ts->parent.t, LTT_FACILITY_KERNEL, LTT_EVENT_SYSCALL_ENTRY, @@ -1378,6 +1403,13 @@ void lttv_state_add_event_hooks(LttvTracesetState *self) process_free, NULL, &g_array_index(hooks, LttvTraceHook, 9)); g_assert(!ret); + ret = lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_FS, LTT_EVENT_EXEC, + LTT_FIELD_FILENAME, 0, 0, + process_exec, NULL, &g_array_index(hooks, LttvTraceHook, 10)); + g_assert(!ret); + + /* Add these hooks to each event_by_id hooks list */ @@ -2009,6 +2041,7 @@ static void module_init() LTT_FACILITY_KERNEL = g_quark_from_string("kernel"); LTT_FACILITY_PROCESS = g_quark_from_string("process"); + LTT_FACILITY_FS = g_quark_from_string("fs"); LTT_EVENT_SYSCALL_ENTRY = g_quark_from_string("syscall_entry"); @@ -2021,6 +2054,7 @@ static void module_init() LTT_EVENT_FORK = g_quark_from_string("fork"); LTT_EVENT_EXIT = g_quark_from_string("exit"); LTT_EVENT_FREE = g_quark_from_string("free"); + LTT_EVENT_EXEC = g_quark_from_string("exec"); LTT_FIELD_SYSCALL_ID = g_quark_from_string("syscall_id"); @@ -2032,6 +2066,7 @@ static void module_init() LTT_FIELD_PARENT_PID = g_quark_from_string("parent_pid"); LTT_FIELD_CHILD_PID = g_quark_from_string("child_pid"); LTT_FIELD_PID = g_quark_from_string("pid"); + LTT_FIELD_FILENAME = g_quark_from_string("filename"); } diff --git a/ltt/branches/poly/lttv/lttv/state.h b/ltt/branches/poly/lttv/lttv/state.h index c37fb032..9d1598b4 100644 --- a/ltt/branches/poly/lttv/lttv/state.h +++ b/ltt/branches/poly/lttv/lttv/state.h @@ -57,7 +57,8 @@ extern GQuark LTT_FACILITY_KERNEL, - LTT_FACILITY_PROCESS; + LTT_FACILITY_PROCESS, + LTT_FACILITY_FS; /* Events Quarks */ @@ -71,7 +72,8 @@ extern GQuark LTT_EVENT_SCHEDCHANGE, LTT_EVENT_FORK, LTT_EVENT_EXIT, - LTT_EVENT_FREE; + LTT_EVENT_FREE, + LTT_EVENT_EXEC; /* Fields Quarks */ @@ -84,7 +86,8 @@ extern GQuark LTT_FIELD_OUT_STATE, LTT_FIELD_PARENT_PID, LTT_FIELD_CHILD_PID, - LTT_FIELD_PID; + LTT_FIELD_PID, + LTT_FIELD_NAME; extern GQuark LTT_EVENT_SYSCALL_ENTRY; diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.c b/ltt/branches/poly/lttv/lttv/tracecontext.c index 58310b40..6f1e7b58 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.c +++ b/ltt/branches/poly/lttv/lttv/tracecontext.c @@ -1007,7 +1007,7 @@ lttv_trace_find_hook(LttTrace *t, GQuark facility, GQuark event, fac_id = g_array_index(facilities, guint, i); f = ltt_trace_get_facility_by_num(t, fac_id); - et = ltt_facility_eventtype_get_by_name(f, ltt_eventtype_name(et)); + et = ltt_facility_eventtype_get_by_name(f, event); if(unlikely(et == NULL)) goto event_error; thf = &g_array_index(th->fac_index, LttvTraceHookByFacility, fac_id); @@ -1037,8 +1037,8 @@ lttv_trace_find_hook(LttTrace *t, GQuark facility, GQuark event, type_error: goto free; event_error: - g_error("Event type %s does not exist", - g_quark_to_string(ltt_eventtype_name(et))); + g_error("Event type does not exist for event %s", + g_quark_to_string(event)); goto free; facility_error: g_error("No %s facility", g_quark_to_string(facility)); diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c index 8bad3e96..0def3154 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c @@ -218,7 +218,7 @@ void drawing_data_request(Drawing_t *drawing, associated by id hooks. */ hooks = g_array_new(FALSE, FALSE, sizeof(LttvTraceHook)); - hooks = g_array_set_size(hooks, 12); + hooks = g_array_set_size(hooks, 13); /* before hooks */ @@ -368,6 +368,14 @@ void drawing_data_request(Drawing_t *drawing, &g_array_index(hooks, LttvTraceHook, 11)); g_assert(!ret); + ret = lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_FS, LTT_EVENT_EXEC, + 0, 0, 0, + after_fs_exec_hook, + events_request, + &g_array_index(hooks, LttvTraceHook, 12)); + g_assert(!ret); + #if 0 @@ -394,7 +402,7 @@ void drawing_data_request(Drawing_t *drawing, } /* add after */ - for(k = 9 ; k < 12 ; k++) { + for(k = 9 ; k < 13 ; k++) { hook = &g_array_index(hooks, LttvTraceHook, k); for(l=0;lfac_list->len;l++) { thf = g_array_index(hook->fac_list, LttvTraceHookByFacility*, l); diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c index 9b96e42d..d6c80459 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c @@ -435,7 +435,6 @@ int before_schedchange_hook(void *hook_data, void *call_data) if(hashed_process_data == NULL) { g_assert(pid_out == 0 || pid_out != process->ppid); - const gchar *name = g_quark_to_string(process->name); /* Process not present */ ProcessInfo *process_info; Drawing_t *drawing = control_flow_data->drawing; @@ -446,7 +445,7 @@ int before_schedchange_hook(void *hook_data, void *call_data) process->ppid, &birth, tfc->t_context->index, - name, + process->name, &pl_height, &process_info, &hashed_process_data); @@ -591,7 +590,6 @@ int before_schedchange_hook(void *hook_data, void *call_data) if(hashed_process_data == NULL) { g_assert(pid_in == 0 || pid_in != process->ppid); - const gchar *name = g_quark_to_string(process->name); /* Process not present */ ProcessInfo *process_info; Drawing_t *drawing = control_flow_data->drawing; @@ -602,7 +600,7 @@ int before_schedchange_hook(void *hook_data, void *call_data) process->ppid, &birth, tfc->t_context->index, - name, + process->name, &pl_height, &process_info, &hashed_process_data); @@ -1395,7 +1393,6 @@ int after_schedchange_hook(void *hook_data, void *call_data) if(hashed_process_data_in == NULL) { g_assert(pid_in == 0 || pid_in != process_in->ppid); - const gchar *name = g_quark_to_string(process_in->name); ProcessInfo *process_info; Drawing_t *drawing = control_flow_data->drawing; /* Process not present */ @@ -1406,7 +1403,7 @@ int after_schedchange_hook(void *hook_data, void *call_data) process_in->ppid, &birth, tfc->t_context->index, - name, + process_in->name, &pl_height, &process_info, &hashed_process_data_in); @@ -2006,7 +2003,6 @@ int before_execmode_hook(void *hook_data, void *call_data) ProcessInfo *process_info; /* Process not present */ Drawing_t *drawing = control_flow_data->drawing; - const gchar *name = g_quark_to_string(process->name); processlist_add(process_list, drawing, pid, @@ -2014,7 +2010,7 @@ int before_execmode_hook(void *hook_data, void *call_data) process->ppid, &birth, tfc->t_context->index, - name, + process->name, &pl_height, &process_info, &hashed_process_data); @@ -2312,7 +2308,6 @@ int before_process_exit_hook(void *hook_data, void *call_data) g_assert(pid == 0 || pid != process->ppid); /* Process not present */ Drawing_t *drawing = control_flow_data->drawing; - const gchar *name = g_quark_to_string(process->name); ProcessInfo *process_info; processlist_add(process_list, drawing, @@ -2321,7 +2316,7 @@ int before_process_exit_hook(void *hook_data, void *call_data) process->ppid, &birth, tfc->t_context->index, - name, + process->name, &pl_height, &process_info, &hashed_process_data); @@ -2507,7 +2502,6 @@ int before_process_release_hook(void *hook_data, void *call_data) g_assert(pid == 0 || pid != process->ppid); /* Process not present */ Drawing_t *drawing = control_flow_data->drawing; - const gchar *name = g_quark_to_string(process->name); ProcessInfo *process_info; processlist_add(process_list, drawing, @@ -2516,7 +2510,7 @@ int before_process_release_hook(void *hook_data, void *call_data) process->ppid, &birth, tfc->t_context->index, - name, + process->name, &pl_height, &process_info, &hashed_process_data); @@ -2868,7 +2862,6 @@ int before_process_hook(void *hook_data, void *call_data) g_assert(pid == 0 || pid != process->ppid); /* Process not present */ Drawing_t *drawing = control_flow_data->drawing; - const gchar *name = g_quark_to_string(process->name); ProcessInfo *process_info; processlist_add(process_list, drawing, @@ -2877,7 +2870,7 @@ int before_process_hook(void *hook_data, void *call_data) process->ppid, &birth, tfc->t_context->index, - name, + process->name, &pl_height, &process_info, &hashed_process_data); @@ -3063,7 +3056,6 @@ int after_process_fork_hook(void *hook_data, void *call_data) g_assert(child_pid == 0 || child_pid != process_child->ppid); /* Process not present */ Drawing_t *drawing = control_flow_data->drawing; - const gchar *name = g_quark_to_string(process_child->name); ProcessInfo *process_info; processlist_add(process_list, drawing, @@ -3072,7 +3064,7 @@ int after_process_fork_hook(void *hook_data, void *call_data) process_child->ppid, &birth, tfc->t_context->index, - name, + process_child->name, &pl_height, &process_info, &hashed_process_data_child); @@ -3182,7 +3174,6 @@ int after_process_exit_hook(void *hook_data, void *call_data) g_assert(pid == 0 || pid != process->ppid); /* Process not present */ Drawing_t *drawing = control_flow_data->drawing; - const gchar *name = g_quark_to_string(process->name); ProcessInfo *process_info; processlist_add(process_list, drawing, @@ -3191,7 +3182,7 @@ int after_process_exit_hook(void *hook_data, void *call_data) process->ppid, &birth, tfc->t_context->index, - name, + process->name, &pl_height, &process_info, &hashed_process_data); @@ -3447,6 +3438,78 @@ int after_process_hook(void *hook_data, void *call_data) } #endif //0 +/* Get the filename of the process to print */ +int after_fs_exec_hook(void *hook_data, void *call_data) +{ + LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data; + EventsRequest *events_request = (EventsRequest*)thf->hook_data; + ControlFlowData *control_flow_data = events_request->viewer_data; + + LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; + + LttvTracefileState *tfs = (LttvTracefileState *)call_data; + + LttvTraceState *ts = (LttvTraceState *)tfc->t_context; + + guint cpu = ltt_tracefile_num(tfc->tf); + LttvProcessState *process = ts->running_process[cpu]; + g_assert(process != NULL); + + guint pid = process->pid; + + /* Well, the process_out existed : we must get it in the process hash + * or add it, and draw its items. + */ + /* Add process to process list (if not present) */ + guint pl_height = 0; + HashedProcessData *hashed_process_data = NULL; + ProcessList *process_list = control_flow_data->process_list; + LttTime birth = process->creation_time; + + if(likely(process_list->current_hash_data[cpu] != NULL)) { + hashed_process_data = process_list->current_hash_data[cpu]; + } else { + hashed_process_data = processlist_get_process_data(process_list, + pid, + process->cpu, + &birth, + tfc->t_context->index); + if(unlikely(hashed_process_data == NULL)) + { + g_assert(pid == 0 || pid != process->ppid); + ProcessInfo *process_info; + /* Process not present */ + Drawing_t *drawing = control_flow_data->drawing; + processlist_add(process_list, + drawing, + pid, + process->cpu, + process->ppid, + &birth, + tfc->t_context->index, + process->name, + &pl_height, + &process_info, + &hashed_process_data); + gtk_widget_set_size_request(drawing->drawing_area, + -1, + pl_height); + gtk_widget_queue_draw(drawing->drawing_area); + } + /* Set the current process */ + process_list->current_hash_data[process->cpu] = + hashed_process_data; + } + + processlist_set_name(process_list, process->name, hashed_process_data); + + return 0; + +} + + + + gint update_time_window_hook(void *hook_data, void *call_data) { ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h index 27ad43f1..d7244129 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h @@ -91,6 +91,7 @@ int before_process_exit_hook(void *hook_data, void *call_data); int before_process_release_hook(void *hook_data, void *call_data); int after_process_exit_hook(void *hook_data, void *call_data); int after_process_fork_hook(void *hook_data, void *call_data); +int after_fs_exec_hook(void *hook_data, void *call_data); #if 0 diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c index c23e0b20..103063ab 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c @@ -512,6 +512,16 @@ void destroy_hash_data(gpointer data) g_free(data); } + +void processlist_set_name(ProcessList *process_list, + GQuark name, + HashedProcessData *hashed_process_data) +{ + gtk_list_store_set ( process_list->list_store, &hashed_process_data->y_iter, + PROCESS_COLUMN, g_quark_to_string(name), + -1); +} + int processlist_add( ProcessList *process_list, Drawing_t *drawing, guint pid, @@ -519,7 +529,7 @@ int processlist_add( ProcessList *process_list, guint ppid, LttTime *birth, guint trace_num, - const gchar *name, + GQuark name, guint *height, ProcessInfo **pm_process_info, HashedProcessData **pm_hashed_process_data) @@ -560,7 +570,7 @@ int processlist_add( ProcessList *process_list, &hashed_process_data->y_iter); gtk_list_store_set ( process_list->list_store, &hashed_process_data->y_iter, - PROCESS_COLUMN, name, + PROCESS_COLUMN, g_quark_to_string(name), PID_COLUMN, pid, PPID_COLUMN, ppid, CPU_COLUMN, cpu, diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h index 1de9b09a..f5844a11 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h @@ -132,13 +132,18 @@ void processlist_clear(ProcessList *process_list); /* CPU num is only used for PID 0 */ int processlist_add(ProcessList *process_list, Drawing_t * drawing, guint pid, guint cpu, guint ppid, - LttTime *birth, guint trace_num, const gchar *name, guint *height, + LttTime *birth, guint trace_num, GQuark name, guint *height, ProcessInfo **process_info, HashedProcessData **hashed_process_data); // out : success (0) and height int processlist_remove(ProcessList *process_list, guint pid, guint cpu, LttTime *birth, guint trace_num); +/* Set the name of a process */ +void processlist_set_name(ProcessList *process_list, + GQuark name, + HashedProcessData *hashed_process_data); + /* Synchronize the list at the left and the drawing */ void update_index_to_pixmap(ProcessList *process_list); diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index 0002a3cc..29c874e1 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -1113,7 +1113,9 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) lttv_process_traceset_middle(tsc, events_request->start_time, G_MAXUINT, NULL); - // g_assert(seek_count < 50000); +#ifdef DEBUG + g_assert(seek_count < LTTV_STATE_SAVE_INTERVAL); +#endif //DEBUG } else { -- 2.34.1