From: compudj Date: Mon, 13 Oct 2003 04:50:53 +0000 (+0000) Subject: mega modif by Mathieu Desnoyers. Independant main windows, multiple tracesets, contro... X-Git-Tag: v0.12.20~3191 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f7afe191fd58f0bf4bab9c9514c261535b99d32b;p=lttv.git mega modif by Mathieu Desnoyers. Independant main windows, multiple tracesets, control flow viewer in progress, see email for details git-svn-id: http://ltt.polymtl.ca/svn@298 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/include/ltt/ltt.h b/ltt/branches/poly/include/ltt/ltt.h index 74cbaceb..15855362 100644 --- a/ltt/branches/poly/include/ltt/ltt.h +++ b/ltt/branches/poly/include/ltt/ltt.h @@ -80,6 +80,13 @@ typedef struct _LttTime { unsigned long tv_nsec; } LttTime; + +typedef struct _TimeInterval{ + LttTime startTime; + LttTime endTime; +} TimeInterval; + + typedef uint64_t LttCycleCount; #define NANSECOND_CONST 1000000000 diff --git a/ltt/branches/poly/include/ltt/trace.h b/ltt/branches/poly/include/ltt/trace.h index 18ef016c..aa5cb6ba 100644 --- a/ltt/branches/poly/include/ltt/trace.h +++ b/ltt/branches/poly/include/ltt/trace.h @@ -10,7 +10,10 @@ When a trace is closed, all the associated facilities, types and fields are released as well. */ -LttTrace *ltt_trace_open(char *pathname); +LttTrace *ltt_trace_open(const char *pathname); + +/* copy reopens a trace */ +LttTrace *ltt_trace_copy(LttTrace *self); void ltt_trace_close(LttTrace *t); diff --git a/ltt/branches/poly/include/lttv/common.h b/ltt/branches/poly/include/lttv/common.h index 1af0790c..22057a96 100644 --- a/ltt/branches/poly/include/lttv/common.h +++ b/ltt/branches/poly/include/lttv/common.h @@ -6,18 +6,12 @@ #include typedef struct _mainWindow mainWindow; -typedef struct _systemView systemView; +//typedef struct _systemView systemView; typedef struct _tab tab; -typedef struct _TimeInterval TimeInterval; /* constructor of the viewer */ typedef GtkWidget * (*lttv_constructor)(mainWindow * main_window); typedef lttv_constructor view_constructor; -struct _TimeInterval{ - LttTime startTime; - LttTime endTime; -}; - #endif // COMMON_H diff --git a/ltt/branches/poly/include/lttv/gtkTraceSet.h b/ltt/branches/poly/include/lttv/gtkTraceSet.h index 6dd9ccd4..5454758e 100644 --- a/ltt/branches/poly/include/lttv/gtkTraceSet.h +++ b/ltt/branches/poly/include/lttv/gtkTraceSet.h @@ -15,6 +15,7 @@ #include #include #include +#include /** * Function to register a view constructor so that main window can generate @@ -97,15 +98,15 @@ void UpdateStatus(mainWindow *main_win, char *info); /** - * Function to get the current time interval of the current tab. + * Function to get the current time window of the current tab. * It will be called by a viewer's hook function to update the - * time interval of the viewer and also be called by the constructor + * time window of the viewer and also be called by the constructor * of the viewer. * @param main_win the main window the viewer belongs to. * @param time_interval a pointer where time interval will be stored. */ -void GetTimeInterval(mainWindow *main_win, TimeInterval *time_interval); +void GetTimeWindow(mainWindow *main_win, TimeWindow *Time_Window); /** @@ -116,8 +117,12 @@ void GetTimeInterval(mainWindow *main_win, TimeInterval *time_interval); * @param time_interval a pointer where time interval is stored. */ -void SetTimeInterval(mainWindow *main_win, TimeInterval *time_interval); +void SetTimeWindow(mainWindow *main_win, TimeWindow *Time_Window); +/** + * Function to get the time span of the main window's traceset. + */ +void GetTracesetTimeSpan(mainWindow *main_win, TimeInterval *Time_Interval); /** * Function to get the current time/event of the current tab. @@ -167,7 +172,7 @@ void SetCurrentTime(mainWindow *main_win, LttTime *time); * Function to register a hook function for a viewer to set/update its * time interval. * It will be called by the constructor of the viewer. - * @param hook hook function of the viewer. + * @param hook hook function of the viewer. Takes a TimeInterval* as call_data. * @param hook_data hook data associated with the hook function. * @param main_win the main window the viewer belongs to. */ @@ -180,7 +185,7 @@ void RegUpdateTimeInterval(LttvHook hook, gpointer hook_data, * Function to unregister a viewer's hook function which is used to * set/update the time interval of the viewer. * It will be called by the destructor of the viewer. - * @param hook hook function of the viewer. + * @param hook hook function of the viewer. Takes a TimeInterval as call_data. * @param hook_data hook data associated with the hook function. * @param main_win the main window the viewer belongs to. */ @@ -378,7 +383,7 @@ void contextRemoveHooks(mainWindow *main_win , * @param end end time of the traceset. */ -void getTracesetTimeSpan(mainWindow *main_win, LttTime * start, LttTime* end); +void getTracesetTimeSpan(mainWindow *main_win, TimeInterval *time_span); /** diff --git a/ltt/branches/poly/include/lttv/mainWindow.h b/ltt/branches/poly/include/lttv/mainWindow.h index 391cef0f..0a43bfa5 100644 --- a/ltt/branches/poly/include/lttv/mainWindow.h +++ b/ltt/branches/poly/include/lttv/mainWindow.h @@ -10,15 +10,39 @@ #include #include +#include +#include typedef struct _WindowCreationData { int argc; char ** argv; } WindowCreationData; +typedef struct _TimeWindow { + LttTime startTime; + LttTime Time_Width; +} TimeWindow; + +typedef struct _TracesetInfo { + gchar* path; + LttvHooks + *before_traceset, + *after_traceset, + *before_trace, + *after_trace, + *before_tracefile, + *after_tracefile, + *before_event, + *after_event; + //FIXME? TracesetContext and stats in same or different variable ? + LttvTracesetStats * TracesetContext; + LttvTraceset * traceset; +} TracesetInfo ; + + struct _mainWindow{ GtkWidget* MWindow; /* Main Window */ - systemView * SystemView; /* System view displayed in this window*/ +// systemView * SystemView; /* System view displayed in this window*/ /* Status bar information */ // guint MainSBarContextID; /* Context ID of main status bar */ @@ -33,35 +57,47 @@ struct _mainWindow{ GtkWidget* HelpContents;/* Window to display help contents */ GtkWidget* AboutBox; /* Window about information */ - LttvTracesetContext * traceset_context; - LttvTraceset * traceset; /* trace set associated with the window */ + //LttvTracesetContext * traceset_context; + //LttvTraceset * traceset; /* trace set associated with the window */ // lttv_trace_filter * filter; /* trace filter associated with the window */ - + /* Traceset related information */ + TracesetInfo * Traceset_Info; + /* Attributes for trace reading hooks local to the main window */ + LttvIAttribute * Attributes; + tab * Tab; tab * CurrentTab; - LttvIAttribute * Attributes; WindowCreationData * winCreationData; }; -struct _systemView{ - gpointer EventDB; - gpointer SystemInfo; - gpointer Options; - mainWindow * Window; - struct _systemView * Next; -}; +//struct _systemView{ +// gpointer EventDB; +// gpointer SystemInfo; +// gpointer Options; +// mainWindow * Window; +// struct _systemView * Next; +//}; struct _tab{ GtkWidget * label; GtkCustom * custom; - LttTime traceStartTime; - LttTime traceEndTime; - LttTime startTime; - LttTime endTime; + + // Will have to read directly at the main window level, as we want + // to be able to modify a traceset on the fly. + //LttTime traceStartTime; + //LttTime traceEndTime; + + // startTime is the left of the visible area. Corresponds to the scrollbar + // value. + // Time_Width is a zoom dependant value (corresponding to page size) + TimeWindow Time_Window; + + // The current time is the time selected in the visible area by the user, + // not the scrollbar value. LttTime currentTime; LttvIAttribute * Attributes; diff --git a/ltt/branches/poly/include/lttv/processTrace.h b/ltt/branches/poly/include/lttv/processTrace.h index 08b28e35..610000cb 100644 --- a/ltt/branches/poly/include/lttv/processTrace.h +++ b/ltt/branches/poly/include/lttv/processTrace.h @@ -71,6 +71,7 @@ struct _LttvTracesetContext { LttvHooks *after; LttvTraceContext **traces; LttvAttribute *a; + TimeInterval *Time_Span; }; struct _LttvTracesetContextClass { diff --git a/ltt/branches/poly/include/lttv/traceset.h b/ltt/branches/poly/include/lttv/traceset.h index 65fedbd8..ecf10461 100644 --- a/ltt/branches/poly/include/lttv/traceset.h +++ b/ltt/branches/poly/include/lttv/traceset.h @@ -14,6 +14,12 @@ typedef struct _LttvTraceset LttvTraceset; LttvTraceset *lttv_traceset_new(); +LttvTraceset *lttv_traceset_copy(LttvTraceset *s_orig); + +LttvTraceset *lttv_traceset_load(const gchar *filename); + +gint lttv_traceset_save(LttvTraceset *s); + void lttv_traceset_destroy(LttvTraceset *s); void lttv_traceset_add(LttvTraceset *s, LttTrace *t); @@ -24,7 +30,6 @@ LttTrace *lttv_traceset_get(LttvTraceset *s, unsigned i); void lttv_traceset_remove(LttvTraceset *s, unsigned i); - /* An attributes table is attached to the set and to each trace in the set. */ LttvAttribute *lttv_traceset_attribute(LttvTraceset *s); @@ -32,6 +37,5 @@ LttvAttribute *lttv_traceset_attribute(LttvTraceset *s); LttvAttribute *lttv_traceset_trace_attribute(LttvTraceset *s, unsigned i); - #endif // TRACESET_H diff --git a/ltt/branches/poly/ltt/convert/sysInfo b/ltt/branches/poly/ltt/convert/sysInfo index 1a81012e..fdd7b596 100755 --- a/ltt/branches/poly/ltt/convert/sysInfo +++ b/ltt/branches/poly/ltt/convert/sysInfo @@ -23,9 +23,12 @@ echo "kernel_version="$KERNEL_VERSION >> $outputFile MACHINE="`uname -m`" echo "machine="$MACHINE >> $outputFile + +# not available anymore in uname version 5 and newer PROCESSOR="`uname -p`" echo "processor="$PROCESSOR >> $outputFile +# not available anymore in uname version 5 and newer HARDWARE_PLATFORM="`uname -i`" echo "hardware_platform="$HARDWARE_PLATFORM >> $outputFile diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index e3829fbf..a2f7bbad 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -404,7 +404,7 @@ void getCpuFileInfo(LttTrace *t, char* cpu) *are released as well. ****************************************************************************/ -LttTrace *ltt_trace_open(char *pathname) +LttTrace *ltt_trace_open(const char *pathname) { LttTrace * t; LttSystemDescription * sys_description; @@ -463,6 +463,16 @@ LttTrace *ltt_trace_open(char *pathname) return t; } +/****************************************************************************** + * When we copy a trace, we want all the opening actions to happen again : + * the trace will be reopened and totally independant from the original. + * That's why we call ltt_trace_open. + *****************************************************************************/ +LttTrace *ltt_trace_copy(LttTrace *self) +{ + return ltt_trace_open(self->pathname); +} + void ltt_trace_close(LttTrace *t) { int i; diff --git a/ltt/branches/poly/lttv/attribute.c b/ltt/branches/poly/lttv/attribute.c index 648beee4..59241fb3 100644 --- a/ltt/branches/poly/lttv/attribute.c +++ b/ltt/branches/poly/lttv/attribute.c @@ -335,6 +335,7 @@ static void attribute_finalize (LttvAttribute *self) { g_hash_table_destroy(self->names); + g_critical("attribute_finalize()"); g_array_free(self->attributes, TRUE); G_OBJECT_CLASS(g_type_class_peek_parent( g_type_class_peek(LTTV_ATTRIBUTE_TYPE)))->finalize(G_OBJECT(self)); diff --git a/ltt/branches/poly/lttv/hook.c b/ltt/branches/poly/lttv/hook.c index dc9b3ac8..8edbb2af 100644 --- a/ltt/branches/poly/lttv/hook.c +++ b/ltt/branches/poly/lttv/hook.c @@ -16,6 +16,7 @@ LttvHooks *lttv_hooks_new() void lttv_hooks_destroy(LttvHooks *h) { + g_critical("lttv_hooks_destroy()"); g_array_free(h, TRUE); } diff --git a/ltt/branches/poly/lttv/modules/gui/API/gtkTraceSet.c b/ltt/branches/poly/lttv/modules/gui/API/gtkTraceSet.c index 336e1f8b..3c681a97 100644 --- a/ltt/branches/poly/lttv/modules/gui/API/gtkTraceSet.c +++ b/ltt/branches/poly/lttv/modules/gui/API/gtkTraceSet.c @@ -202,7 +202,23 @@ void UpdateStatus(mainWindow *main_win, char *info) /** - * Function to get the current time interval of the current tab. + * Function to get the current time interval shown on the current tab. + * It will be called by a viewer's hook function to update the + * shown time interval of the viewer and also be called by the constructor + * of the viewer. + * @param main_win the main window the viewer belongs to. + * @param time_interval a pointer where time interval will be stored. + */ + +void GetTimeWindow(mainWindow *main_win, TimeWindow *Time_Window) +{ + //Time_Window->startTime = main_win->CurrentTab->Time_Window.startTime; + //Time_Window->Time_Width = main_win->CurrentTab->Time_Window.Time_Width; + *Time_Window = main_win->CurrentTab->Time_Window; +} + +/** + * Function to get the current time interval of the current traceset. * It will be called by a viewer's hook function to update the * time interval of the viewer and also be called by the constructor * of the viewer. @@ -210,13 +226,15 @@ void UpdateStatus(mainWindow *main_win, char *info) * @param time_interval a pointer where time interval will be stored. */ -void GetTimeInterval(mainWindow *main_win, TimeInterval *time_interval) +void getTracesetTimeSpan(mainWindow *main_win, TimeInterval *Time_Interval) { - time_interval->startTime = main_win->CurrentTab->startTime; - time_interval->endTime = main_win->CurrentTab->endTime; + //Time_Window->startTime = main_win->CurrentTab->Time_Window.startTime; + //Time_Window->Time_Width = main_win->CurrentTab->Time_Window.Time_Width; + *Time_Interval = *(LTTV_TRACESET_CONTEXT(main_win->Traceset_Info->TracesetContext)->Time_Span); } + /** * Function to set the time interval of the current tab. * It will be called by a viewer's signal handle associated with @@ -225,17 +243,16 @@ void GetTimeInterval(mainWindow *main_win, TimeInterval *time_interval) * @param time_interval a pointer where time interval is stored. */ -void SetTimeInterval(mainWindow *main_win, TimeInterval *time_interval) +void SetTimeWindow(mainWindow *main_win, TimeWindow *Time_Window) { LttvAttributeValue value; LttvHooks * tmp; - main_win->CurrentTab->startTime = time_interval->startTime; - main_win->CurrentTab->endTime = time_interval->endTime; + main_win->CurrentTab->Time_Window = *Time_Window; g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, - "hooks/updatetimeinterval", LTTV_POINTER, &value)); + "hooks/updatetimewindow", LTTV_POINTER, &value)); tmp = (LttvHooks*)*(value.v_pointer); - if(tmp == NULL)return; - lttv_hooks_call(tmp, time_interval); + if(tmp == NULL) return; + lttv_hooks_call(tmp, Time_Window); } @@ -310,13 +327,13 @@ void GetFilter(mainWindow *main_win, Filter *filter) * @param main_win the main window the viewer belongs to. */ -void RegUpdateTimeInterval(LttvHook hook, gpointer hook_data, +void RegUpdateTimeWindow(LttvHook hook, gpointer hook_data, mainWindow * main_win) { LttvAttributeValue value; LttvHooks * tmp; g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, - "hooks/updatetimeinterval", LTTV_POINTER, &value)); + "hooks/updatetimewindow", LTTV_POINTER, &value)); tmp = (LttvHooks*)*(value.v_pointer); if(tmp == NULL){ tmp = lttv_hooks_new(); @@ -335,13 +352,13 @@ void RegUpdateTimeInterval(LttvHook hook, gpointer hook_data, * @param main_win the main window the viewer belongs to. */ -void UnregUpdateTimeInterval(LttvHook hook, gpointer hook_data, +void UnregUpdateTimeWindow(LttvHook hook, gpointer hook_data, mainWindow * main_win) { LttvAttributeValue value; LttvHooks * tmp; g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, - "hooks/updatetimeinterval", LTTV_POINTER, &value)); + "hooks/updatetimewindow", LTTV_POINTER, &value)); tmp = (LttvHooks*)*(value.v_pointer); if(tmp == NULL) return; lttv_hooks_remove_data(tmp, hook, hook_data); @@ -581,8 +598,9 @@ void SetHPaneDividor(mainWindow *main_win, gint position) void processTraceset(mainWindow *main_win, LttTime start, LttTime end, unsigned maxNumEvents) { - lttv_process_trace(start, end, main_win->traceset, - main_win->traceset_context, maxNumEvents); + lttv_process_trace(start, end, main_win->Traceset_Info->traceset, + LTTV_TRACESET_CONTEXT(main_win->Traceset_Info->TracesetContext), + maxNumEvents); } /** @@ -606,7 +624,8 @@ void contextAddHooks(mainWindow *main_win , LttvHooks *before_event, LttvHooks *after_event) { - LttvTracesetContext * tsc = main_win->traceset_context; + LttvTracesetContext * tsc = + LTTV_TRACESET_CONTEXT(main_win->Traceset_Info->TracesetContext); lttv_traceset_context_add_hooks(tsc,before_traceset,after_traceset, check_trace,before_trace,after_trace, check_tracefile,before_tracefile,after_tracefile, @@ -635,7 +654,8 @@ void contextRemoveHooks(mainWindow *main_win , LttvHooks *before_event, LttvHooks *after_event) { - LttvTracesetContext * tsc = main_win->traceset_context; + LttvTracesetContext * tsc = + LTTV_TRACESET_CONTEXT(main_win->Traceset_Info->TracesetContext); lttv_traceset_context_remove_hooks(tsc,before_traceset,after_traceset, check_trace,before_trace,after_trace, check_tracefile,before_tracefile,after_tracefile, @@ -643,43 +663,6 @@ void contextRemoveHooks(mainWindow *main_win , } -/** - * Function to get the life span of the traceset - * @param main_win the main window the viewer belongs to. - * @param start start time of the traceset. - * @param end end time of the traceset. - */ - -void getTracesetTimeSpan(mainWindow *main_win, LttTime * start, LttTime* end) -{ - LttvTraceset * traceset = main_win->traceset; - int numTraces = lttv_traceset_number(traceset); - int i; - LttTime s, e; - LttvTraceContext *tc; - LttTrace * trace; - - for(i=0; itraceset_context->traces[i]; - trace = tc->t; - - ltt_trace_time_span_get(trace, &s, &e); - - if(i==0){ - *start = s; - *end = e; - }else{ - if(s.tv_sec < start->tv_sec || - (s.tv_sec == start->tv_sec && s.tv_nsec < start->tv_nsec)) - *start = s; - if(e.tv_sec > end->tv_sec || - (e.tv_sec == end->tv_sec && e.tv_nsec > end->tv_nsec)) - *end = e; - } - } -} - - /** * Function to add/remove event hooks for state * @param main_win the main window the viewer belongs to. @@ -687,12 +670,14 @@ void getTracesetTimeSpan(mainWindow *main_win, LttTime * start, LttTime* end) void stateAddEventHooks(mainWindow *main_win ) { - lttv_state_add_event_hooks((LttvTracesetState*)main_win->traceset_context); + lttv_state_add_event_hooks( + (LttvTracesetState*)main_win->Traceset_Info->TracesetContext); } void stateRemoveEventHooks(mainWindow *main_win ) { - lttv_state_remove_event_hooks((LttvTracesetState*)main_win->traceset_context); + lttv_state_remove_event_hooks( + (LttvTracesetState*)main_win->Traceset_Info->TracesetContext); } @@ -703,12 +688,14 @@ void stateRemoveEventHooks(mainWindow *main_win ) void statsAddEventHooks(mainWindow *main_win ) { - lttv_stats_add_event_hooks((LttvTracesetStats*)main_win->traceset_context); + lttv_stats_add_event_hooks( + (LttvTracesetStats*)main_win->Traceset_Info->TracesetContext); } void statsRemoveEventHooks(mainWindow *main_win ) { - lttv_stats_remove_event_hooks((LttvTracesetStats*)main_win->traceset_context); + lttv_stats_remove_event_hooks( + (LttvTracesetStats*)main_win->Traceset_Info->TracesetContext); } /** @@ -718,5 +705,5 @@ void statsRemoveEventHooks(mainWindow *main_win ) LttvTracesetStats* getTracesetStats(mainWindow *main_win) { - return (LttvTracesetStats*)main_win->traceset_context; + return main_win->Traceset_Info->TracesetContext; } diff --git a/ltt/branches/poly/lttv/modules/gui/API/menu.c b/ltt/branches/poly/lttv/modules/gui/API/menu.c index acaba636..06babb47 100644 --- a/ltt/branches/poly/lttv/modules/gui/API/menu.c +++ b/ltt/branches/poly/lttv/modules/gui/API/menu.c @@ -9,6 +9,7 @@ inline LttvMenus *lttv_menus_new() { * (functions). */ inline void lttv_menus_destroy(LttvMenus *h) { + g_critical("lttv_menus_destroy()"); g_array_free(h, TRUE); } diff --git a/ltt/branches/poly/lttv/modules/gui/API/toolbar.c b/ltt/branches/poly/lttv/modules/gui/API/toolbar.c index 48dc5947..ff16c42d 100644 --- a/ltt/branches/poly/lttv/modules/gui/API/toolbar.c +++ b/ltt/branches/poly/lttv/modules/gui/API/toolbar.c @@ -9,6 +9,7 @@ inline LttvToolbars *lttv_toolbars_new() { * (functions). */ inline void lttv_toolbars_destroy(LttvToolbars *h) { + g_critical("lttv_toolbars_destroy"); g_array_free(h, TRUE); } diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c b/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c index 9e5fe0a4..44f5e61c 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c @@ -14,10 +14,14 @@ #include #include #include +#include -#define PATH_LENGTH 256 +#define PATH_LENGTH 256 +#define DEFAULT_TIME_WIDTH_S 1 + +//extern LttvTracesetContext * gTracesetContext; +extern LttTrace *gInit_Trace ; -extern LttvTracesetContext * gTracesetContext; /** Array containing instanced objects. */ extern GSList * Main_Window_List; @@ -702,6 +706,8 @@ void on_MWindow_destroy (GtkObject *object, gpointer user_data) { + mainWindow *Main_Window = (mainWindow*)user_data; + g_printf("There are : %d windows\n",g_slist_length(Main_Window_List)); gWinCount--; @@ -853,12 +859,16 @@ void insertMenuToolbarItem(mainWindow * mw) void constructMainWin(mainWindow * parent, WindowCreationData * win_creation_data) { + g_critical("constructMainWin()"); // systemView * sv = NULL; /* System view */ - systemView * newSv; /* New system view displayed in the new window */ + //systemView * newSv; /* New system view displayed in the new window */ GtkWidget * newWindow; /* New generated main window */ mainWindow * newMWindow;/* New main window structure */ GtkNotebook * notebook; - + LttvIAttribute *attributes = + LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL)); + LttvAttributeValue value; + // if(parent) sv = parent->SystemView; newMWindow = g_new(mainWindow, 1); @@ -866,39 +876,100 @@ void constructMainWin(mainWindow * parent, WindowCreationData * win_creation_dat // Add the object's information to the module's array Main_Window_List = g_slist_append(Main_Window_List, newMWindow); + newWindow = create_MWindow(); gtk_widget_show (newWindow); - newSv = g_new(systemView, 1); + //newSv = g_new(systemView, 1); // if(sv){ // while(sv->Next) sv = sv->Next; // sv->Next = newSv; // } - newSv->EventDB = NULL; - newSv->SystemInfo = NULL; - newSv->Options = NULL; - newSv->Next = NULL; - newSv->Window = newMWindow; - + //newSv->EventDB = NULL; + //newSv->SystemInfo = NULL; + //newSv->Options = NULL; + //newSv->Next = NULL; + //newSv->Window = newMWindow; + + newMWindow->Attributes = attributes; + + newMWindow->Traceset_Info = g_new(TracesetInfo,1); + newMWindow->Traceset_Info->path = NULL ; + + + newMWindow->Traceset_Info->before_traceset = lttv_hooks_new(); + newMWindow->Traceset_Info->after_traceset = lttv_hooks_new(); + newMWindow->Traceset_Info->before_trace = lttv_hooks_new(); + newMWindow->Traceset_Info->after_trace = lttv_hooks_new(); + newMWindow->Traceset_Info->before_tracefile = lttv_hooks_new(); + newMWindow->Traceset_Info->after_tracefile = lttv_hooks_new(); + newMWindow->Traceset_Info->before_event = lttv_hooks_new(); + newMWindow->Traceset_Info->after_event = lttv_hooks_new(); + + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/before", + LTTV_POINTER, &value)); + *(value.v_pointer) = newMWindow->Traceset_Info->before_traceset; + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/after", + LTTV_POINTER, &value)); + *(value.v_pointer) = newMWindow->Traceset_Info->after_traceset; + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/before", + LTTV_POINTER, &value)); + *(value.v_pointer) = newMWindow->Traceset_Info->before_trace; + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/after", + LTTV_POINTER, &value)); + *(value.v_pointer) = newMWindow->Traceset_Info->after_trace; + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/before", + LTTV_POINTER, &value)); + *(value.v_pointer) = newMWindow->Traceset_Info->before_tracefile; + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/after", + LTTV_POINTER, &value)); + *(value.v_pointer) = newMWindow->Traceset_Info->after_tracefile; + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/before", + LTTV_POINTER, &value)); + *(value.v_pointer) = newMWindow->Traceset_Info->before_event; + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/after", + LTTV_POINTER, &value)); + *(value.v_pointer) = newMWindow->Traceset_Info->after_event; + + newMWindow->MWindow = newWindow; newMWindow->Tab = NULL; newMWindow->CurrentTab = NULL; - newMWindow->SystemView = newSv; + //newMWindow->SystemView = newSv; newMWindow->Attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL)); if(parent){ - newMWindow->traceset_context = parent->traceset_context; - newMWindow->traceset = parent->traceset; + newMWindow->Traceset_Info->traceset = + lttv_traceset_copy(parent->Traceset_Info->traceset); + +//FIXME copy not implemented in lower level + newMWindow->Traceset_Info->TracesetContext = + g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); + lttv_context_init( + LTTV_TRACESET_CONTEXT(newMWindow->Traceset_Info->TracesetContext), + newMWindow->Traceset_Info->traceset); + //newMWindow->traceset_context = parent->traceset_context; newMWindow->winCreationData = parent->winCreationData; }else{ - newMWindow->traceset_context = LTTV_TRACESET_CONTEXT(gTracesetContext); - newMWindow->traceset = (LTTV_TRACESET_CONTEXT(gTracesetContext))->ts; + newMWindow->Traceset_Info->traceset = lttv_traceset_new(); + + /* Add the command line trace */ + if(gInit_Trace != NULL) + lttv_traceset_add(newMWindow->Traceset_Info->traceset, gInit_Trace); + /* NOTE : the context must be recreated if we change the traceset, + * ie : adding/removing traces */ + newMWindow->Traceset_Info->TracesetContext = + g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); + lttv_context_init( + LTTV_TRACESET_CONTEXT(newMWindow->Traceset_Info->TracesetContext), + newMWindow->Traceset_Info->traceset); + newMWindow->winCreationData = win_creation_data; } insertMenuToolbarItem(newMWindow); - g_object_set_data(G_OBJECT(newWindow), "systemView", (gpointer)newSv); + //g_object_set_data(G_OBJECT(newWindow), "systemView", (gpointer)newSv); g_object_set_data(G_OBJECT(newWindow), "mainWindow", (gpointer)newMWindow); //create a default tab @@ -920,14 +991,21 @@ void constructMainWin(mainWindow * parent, WindowCreationData * win_creation_dat gWinCount++; } +void Tab_Destructor(tab *Tab) +{ + if(Tab->Attributes) + g_object_unref(Tab->Attributes); + g_free(Tab); +} + void * create_tab(GtkWidget* parent, GtkNotebook * notebook, char * label) { GList * list; tab * tmpTab; mainWindow * mwData; + LttTime TmpTime; mwData = get_window_data_struct(parent); - tmpTab = mwData->Tab; while(tmpTab && tmpTab->Next) tmpTab = tmpTab->Next; if(!tmpTab){ @@ -939,16 +1017,28 @@ void * create_tab(GtkWidget* parent, GtkNotebook * notebook, char * label) tmpTab = tmpTab->Next; } if(mwData->CurrentTab){ - tmpTab->traceStartTime = mwData->CurrentTab->traceStartTime; - tmpTab->traceEndTime = mwData->CurrentTab->traceEndTime; - tmpTab->startTime = mwData->CurrentTab->startTime; - tmpTab->endTime = mwData->CurrentTab->endTime; + // Will have to read directly at the main window level, as we want + // to be able to modify a traceset on the fly. + // tmpTab->traceStartTime = mwData->CurrentTab->traceStartTime; + // tmpTab->traceEndTime = mwData->CurrentTab->traceEndTime; + tmpTab->Time_Window = mwData->CurrentTab->Time_Window; tmpTab->currentTime = mwData->CurrentTab->currentTime; }else{ - getTracesetTimeSpan(mwData,&tmpTab->traceStartTime, &tmpTab->traceEndTime); - tmpTab->startTime = tmpTab->traceStartTime; - tmpTab->endTime = tmpTab->traceEndTime; - tmpTab->currentTime = tmpTab->traceStartTime; + // Will have to read directly at the main window level, as we want + // to be able to modify a traceset on the fly. + // getTracesetTimeSpan(mwData,&tmpTab->traceStartTime, &tmpTab->traceEndTime); + tmpTab->Time_Window.startTime = + LTTV_TRACESET_CONTEXT(mwData->Traceset_Info->TracesetContext)->Time_Span->startTime; + if(DEFAULT_TIME_WIDTH_S < + LTTV_TRACESET_CONTEXT(mwData->Traceset_Info->TracesetContext)->Time_Span->endTime.tv_sec) + TmpTime.tv_sec = DEFAULT_TIME_WIDTH_S; + else + TmpTime.tv_sec = + LTTV_TRACESET_CONTEXT(mwData->Traceset_Info->TracesetContext)->Time_Span->endTime.tv_sec; + TmpTime.tv_nsec = 0; + tmpTab->Time_Window.Time_Width = TmpTime ; + tmpTab->currentTime.tv_sec = TmpTime.tv_sec / 2; + tmpTab->currentTime.tv_nsec = 0 ; } tmpTab->Attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL)); // mwData->CurrentTab = tmpTab; @@ -960,8 +1050,13 @@ void * create_tab(GtkWidget* parent, GtkNotebook * notebook, char * label) tmpTab->label = gtk_label_new (label); gtk_widget_show (tmpTab->label); - gtk_notebook_append_page(notebook, (GtkWidget*)tmpTab->custom, tmpTab->label); + g_object_set_data_full( + G_OBJECT(tmpTab->custom), + "Tab_Info", + tmpTab, + (GDestroyNotify)Tab_Destructor); + gtk_notebook_append_page(notebook, (GtkWidget*)tmpTab->custom, tmpTab->label); list = gtk_container_get_children(GTK_CONTAINER(notebook)); gtk_notebook_set_current_page(notebook,g_list_length(list)-1); } diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/gtkcustom.c b/ltt/branches/poly/lttv/modules/gui/mainWin/src/gtkcustom.c index 385d715f..491e730c 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/gtkcustom.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/gtkcustom.c @@ -105,10 +105,11 @@ void gtk_custom_widget_add(GtkCustom * custom, GtkWidget * widget1) { GtkPaned * tmpPane; GtkWidget * w; - TimeInterval timeInterval; + TimeWindow Time_Window; LttTime time; double tmpValue; - + TimeInterval *Time_Span; + g_return_if_fail(GTK_IS_CUSTOM(custom)); g_object_ref(G_OBJECT(widget1)); @@ -121,26 +122,37 @@ void gtk_custom_widget_add(GtkCustom * custom, GtkWidget * widget1) gtk_widget_show(custom->hScrollbar); custom->hAdjust = gtk_range_get_adjustment(GTK_RANGE(custom->hScrollbar)); - GetTimeInterval(custom->mw,&timeInterval); + GetTimeWindow(custom->mw,&Time_Window); GetCurrentTime(custom->mw,&time); + Time_Span = LTTV_TRACESET_CONTEXT(custom->mw->Traceset_Info->TracesetContext)->Time_Span ; - tmpValue = timeInterval.startTime.tv_sec; + tmpValue = Time_Span->startTime.tv_sec; tmpValue *= NANSECOND_CONST; - tmpValue += timeInterval.startTime.tv_nsec; + tmpValue += Time_Span->startTime.tv_nsec; custom->hAdjust->lower = tmpValue; - tmpValue = timeInterval.endTime.tv_sec; + custom->hAdjust->value = tmpValue; + tmpValue = Time_Span->endTime.tv_sec; tmpValue *= NANSECOND_CONST; - tmpValue += timeInterval.endTime.tv_nsec; + tmpValue += Time_Span->endTime.tv_nsec; custom->hAdjust->upper = tmpValue; - tmpValue = time.tv_sec; + //tmpValue = time.tv_sec; + //tmpValue *= NANSECOND_CONST; + //tmpValue += time.tv_nsec; + //custom->hAdjust->value = tmpValue; + /* Step increment to 1/10 of visible area */ + tmpValue = Time_Window.Time_Width.tv_sec; tmpValue *= NANSECOND_CONST; - tmpValue += time.tv_nsec; - custom->hAdjust->value = tmpValue; - custom->hAdjust->step_increment = 1; - custom->hAdjust->page_increment = 100000000; - custom->hAdjust->page_size = 100000000; - - gtk_range_set_update_policy (GTK_RANGE(custom->hScrollbar), GTK_UPDATE_DISCONTINUOUS); + tmpValue += Time_Window.Time_Width.tv_nsec; + custom->hAdjust->step_increment = tmpValue / 10; + /* Page increment of whole visible area */ + custom->hAdjust->page_increment = tmpValue; + /* page_size to the whole visible area will take care that the + * scroll value + the shown area will never be more than what is + * in the trace. */ + custom->hAdjust->page_size = tmpValue; + + gtk_range_set_update_policy (GTK_RANGE(custom->hScrollbar), + GTK_UPDATE_DISCONTINUOUS); g_signal_connect(G_OBJECT(custom->hScrollbar), "value-changed", G_CALLBACK(gtk_custom_scroll_value_changed), custom); diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c b/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c index 19cb148e..f6f398ae 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c @@ -26,33 +26,26 @@ #include "callbacks.h" /* global variable */ -LttvTracesetStats * gTracesetContext = NULL; -static LttvTraceset * traceset; +//LttvTracesetStats * gTracesetContext = NULL; +//static LttvTraceset * traceset; WindowCreationData gWinCreationData; /** Array containing instanced objects. */ GSList * Main_Window_List = NULL ; -static LttvHooks - *before_traceset, - *after_traceset, - *before_trace, - *after_trace, - *before_tracefile, - *after_tracefile, - *before_event, - *after_event, +LttvHooks *main_hooks; +/* Initial trace from command line */ +LttTrace *gInit_Trace = NULL; + static char *a_trace; void lttv_trace_option(void *hook_data) { - LttTrace *trace; - - trace = ltt_trace_open(a_trace); - if(trace == NULL) g_critical("cannot open trace %s", a_trace); - lttv_traceset_add(traceset, trace); + gInit_Trace = ltt_trace_open(a_trace); + if(gInit_Trace == NULL) g_critical("cannot open trace %s", a_trace); + g_critical("lttv_trace_option : Init_Trace is %p", gInit_Trace); } /***************************************************************************** @@ -82,12 +75,6 @@ static gboolean Window_Creation_Hook(void *hook_data, void *call_data) add_pixmap_directory ("pixmaps"); add_pixmap_directory ("modules/gui/mainWin/pixmaps"); - - if(!gTracesetContext){ - gTracesetContext = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); - lttv_context_init(LTTV_TRACESET_CONTEXT(gTracesetContext), traceset); - } - constructMainWin(NULL, Window_Creation_Data); gtk_main (); @@ -101,7 +88,8 @@ static gboolean Window_Creation_Hook(void *hook_data, void *call_data) G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) { LttvAttributeValue value; - + + // Global attributes only used for interaction with main() here. LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); g_critical("GUI init()"); @@ -111,42 +99,6 @@ G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) { "pathname of the directory containing the trace", LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL); - traceset = lttv_traceset_new(); - - before_traceset = lttv_hooks_new(); - after_traceset = lttv_hooks_new(); - before_trace = lttv_hooks_new(); - after_trace = lttv_hooks_new(); - before_tracefile = lttv_hooks_new(); - after_tracefile = lttv_hooks_new(); - before_event = lttv_hooks_new(); - after_event = lttv_hooks_new(); - - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/before", - LTTV_POINTER, &value)); - *(value.v_pointer) = before_traceset; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/after", - LTTV_POINTER, &value)); - *(value.v_pointer) = after_traceset; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/before", - LTTV_POINTER, &value)); - *(value.v_pointer) = before_trace; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/after", - LTTV_POINTER, &value)); - *(value.v_pointer) = after_trace; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/before", - LTTV_POINTER, &value)); - *(value.v_pointer) = before_tracefile; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/after", - LTTV_POINTER, &value)); - *(value.v_pointer) = after_tracefile; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/before", - LTTV_POINTER, &value)); - *(value.v_pointer) = before_event; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/after", - LTTV_POINTER, &value)); - *(value.v_pointer) = after_event; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/before", LTTV_POINTER, &value)); g_assert((main_hooks = *(value.v_pointer)) != NULL); @@ -158,42 +110,78 @@ G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) { } -void -free_system_view(systemView * SystemView) -{ - if(!SystemView)return; - //free_EventDB(SystemView->EventDB); - //free_SystemInfo(SystemView->SystemInfo); - //free_Options(SystemView->Options); - if(SystemView->Next) - free_system_view(SystemView->Next); - g_free(SystemView); -} - -void free_tab(tab * Tab) -{ - if(!Tab) return; - if(Tab->custom->vbox) - gtk_widget_destroy(Tab->custom->vbox); - if(Tab->Attributes) - g_object_unref(Tab->Attributes); - - if(Tab->Next) free_tab(Tab->Next); - g_free(Tab); -} +//void +//free_system_view(systemView * SystemView) +//{ +// if(!SystemView)return; +// //free_EventDB(SystemView->EventDB); +// //free_SystemInfo(SystemView->SystemInfo); +// //free_Options(SystemView->Options); +// if(SystemView->Next) +// free_system_view(SystemView->Next); +// g_free(SystemView); +//} + +//MD : The tab is now only referenced by the notebook. The destroy will +//happend when notebook destroyed. +//void free_tab(tab * Tab) +//{ +// if(!Tab) return; +// if(Tab->custom->vbox) +// gtk_widget_destroy(Tab->custom->vbox); +// if(Tab->Attributes) +// g_object_unref(Tab->Attributes); + +// if(Tab->Next) free_tab(Tab->Next); +// g_free(Tab); +// Tab = NULL; +//} void mainWindow_free(mainWindow * mw) { + guint i, nb; + if(mw){ - Main_Window_List = g_slist_remove(Main_Window_List, mw); - //should free memory allocated dynamically first - free_system_view(mw->SystemView); - free_tab(mw->Tab); +// free_system_view(mw->SystemView); +// + //free_tab(mw->Tab); +g_critical("begin remove"); + lttv_hooks_destroy(mw->Traceset_Info->before_traceset); + lttv_hooks_destroy(mw->Traceset_Info->after_traceset); + lttv_hooks_destroy(mw->Traceset_Info->before_trace); + lttv_hooks_destroy(mw->Traceset_Info->after_trace); + lttv_hooks_destroy(mw->Traceset_Info->before_tracefile); + lttv_hooks_destroy(mw->Traceset_Info->after_tracefile); + lttv_hooks_destroy(mw->Traceset_Info->before_event); + lttv_hooks_destroy(mw->Traceset_Info->after_event); +g_critical("end remove"); + + + if(mw->Traceset_Info->path != NULL) + g_free(mw->Traceset_Info->path); + if(mw->Traceset_Info->TracesetContext != NULL) + lttv_context_fini(LTTV_TRACESET_CONTEXT(mw->Traceset_Info->TracesetContext)); + if(mw->Traceset_Info->traceset != NULL) { + nb = lttv_traceset_number(mw->Traceset_Info->traceset); + for(i = 0 ; i < nb ; i++) { + ltt_trace_close( + lttv_traceset_get(mw->Traceset_Info->traceset, i)); + } + } + + lttv_traceset_destroy(mw->Traceset_Info->traceset); + g_object_unref(mw->Attributes); - g_free(mw); + g_free(mw->Traceset_Info); + mw->Traceset_Info = NULL; + + Main_Window_List = g_slist_remove(Main_Window_List, mw); + + g_free(mw); + mw = NULL; } } @@ -206,8 +194,8 @@ mainWindow_Destructor(mainWindow * mw) // gtk_widget_destroy(mw->AboutBox); mw = NULL; } - - mainWindow_free(mw); + //mainWindow_free called when the object mw in the widget is unref. + //mainWindow_free(mw); } @@ -228,34 +216,15 @@ G_MODULE_EXPORT void destroy() { LttvAttributeValue value; - guint i, nb; - lttv_option_remove("trace"); - lttv_hooks_destroy(before_traceset); - lttv_hooks_destroy(after_traceset); - lttv_hooks_destroy(before_trace); - lttv_hooks_destroy(after_trace); - lttv_hooks_destroy(before_tracefile); - lttv_hooks_destroy(after_tracefile); - lttv_hooks_destroy(before_event); - lttv_hooks_destroy(after_event); lttv_hooks_remove_data(main_hooks, Window_Creation_Hook, &gWinCreationData); - nb = lttv_traceset_number(traceset); - for(i = 0 ; i < nb ; i++) { - ltt_trace_close(lttv_traceset_get(traceset, i)); - } - - lttv_traceset_destroy(traceset); - g_critical("GUI destroy()"); g_slist_foreach(Main_Window_List, destroy_walk, NULL ); g_slist_free(Main_Window_List); - - g_object_unref(gTracesetContext); } diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c index aae13cf7..032a7f50 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c @@ -6,6 +6,8 @@ #include "CFV.h" #include "Drawing.h" #include "Process_List.h" +#include "Event_Hooks.h" +#include "CFV-private.h" extern GSList *gControl_Flow_Data_List; @@ -13,38 +15,6 @@ extern GSList *gControl_Flow_Data_List; /***************************************************************************** * Control Flow Viewer class implementation * *****************************************************************************/ - - -struct _ControlFlowData { - - GtkWidget *Scrolled_Window_VC; - - ProcessList *Process_List; - Drawing_t *Drawing; - - //GtkWidget *HBox_V; - GtkWidget *Inside_HBox_V; - - GtkAdjustment *VAdjust_C ; - - /* Trace information */ - //TraceSet *Trace_Set; - //TraceStatistics *Trace_Statistics; - - /* Shown events information */ - guint First_Event, Last_Event; - LttTime Begin_Time, End_Time; - - - /* TEST DATA, TO BE READ FROM THE TRACE */ - gint Number_Of_Events ; - guint Currently_Selected_Event ; - gboolean Selected_Event ; - guint Number_Of_Process; - -} ; - - /** * Control Flow Viewer's constructor * @@ -61,7 +31,7 @@ GuiControlFlow(void) ControlFlowData* Control_Flow_Data = g_new(ControlFlowData,1) ; /* Create the Drawing */ - Control_Flow_Data->Drawing = Drawing_construct(); + Control_Flow_Data->Drawing = Drawing_construct(Control_Flow_Data); Drawing_Widget = Drawing_getWidget(Control_Flow_Data->Drawing); @@ -145,15 +115,15 @@ GuiControlFlow(void) Control_Flow_Data, (GDestroyNotify)GuiControlFlow_Destructor); - g_slist_append(gControl_Flow_Data_List,Control_Flow_Data); + gControl_Flow_Data_List = g_slist_append( + gControl_Flow_Data_List, + Control_Flow_Data); - //FIXME : data sent too fast. The widget must be + //WARNING : The widget must be //inserted in the main window before the Drawing area //can be configured (and this must happend bedore sending //data) - send_test_data(Control_Flow_Data->Process_List, - Control_Flow_Data->Drawing); - + return Control_Flow_Data; } @@ -176,6 +146,13 @@ GuiControlFlow_Destructor(ControlFlowData *Control_Flow_Data) /* Process List is removed with it's widget */ //ProcessList_destroy(Control_Flow_Data->Process_List); + UnregUpdateTimeWindow(Update_Time_Window_Hook, + Control_Flow_Data, + Control_Flow_Data->Scrolled_Window_VC->parent); + + UnregUpdateCurrentTime(Update_Current_Time_Hook, + Control_Flow_Data, + Control_Flow_Data->Scrolled_Window_VC->parent); g_slist_remove(gControl_Flow_Data_List,Control_Flow_Data); g_free(Control_Flow_Data); @@ -186,3 +163,19 @@ GtkWidget *GuiControlFlow_get_Widget(ControlFlowData *Control_Flow_Data) return Control_Flow_Data->Scrolled_Window_VC ; } +ProcessList *GuiControlFlow_get_Process_List + (ControlFlowData *Control_Flow_Data) +{ + return Control_Flow_Data->Process_List ; +} + +TimeWindow *GuiControlFlow_get_Time_Window(ControlFlowData *Control_Flow_Data) +{ + return &Control_Flow_Data->Time_Window; +} +LttTime *GuiControlFlow_get_Current_Time(ControlFlowData *Control_Flow_Data) +{ + return &Control_Flow_Data->Current_Time; +} + + diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.h b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.h index 1855fb27..548ae890 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.h @@ -2,6 +2,9 @@ #define _CFV_H #include +#include "lttv/common.h" +#include "lttv/mainWindow.h" +#include "Process_List.h" typedef struct _ControlFlowData ControlFlowData; @@ -12,5 +15,9 @@ GuiControlFlow_Destructor_Full(ControlFlowData *Control_Flow_Data); void GuiControlFlow_Destructor(ControlFlowData *Control_Flow_Data); GtkWidget *GuiControlFlow_get_Widget(ControlFlowData *Control_Flow_Data); +ProcessList *GuiControlFlow_get_Process_List(ControlFlowData *Control_Flow_Data); +TimeWindow *GuiControlFlow_get_Time_Window(ControlFlowData *Control_Flow_Data); +LttTime *GuiControlFlow_get_Current_Time(ControlFlowData *Control_Flow_Data); + #endif // _CFV_H diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c index 2f1312aa..cb2d049d 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c @@ -1,5 +1,6 @@ #include "Drawing.h" +#include "CFV.h" #include #include @@ -31,19 +32,20 @@ static GdkColor CF_Colors [] = }; -struct _Drawing_t { - GtkWidget *Drawing_Area_V; - GdkPixmap *Pixmap; +//struct _Drawing_t { +// GtkWidget *Drawing_Area_V; +// GdkPixmap *Pixmap; +// ControlFlowData *Control_Flow_Data; - gint height, width, depth; +// gint height, width, depth; -}; +//}; /* Function responsible for updating the exposed area. * It must call processTrace() to ask for this update. */ void Drawing_Data_Request(Drawing_t *Drawing, - GdkPixmap *Pixmap, + GdkPixmap **Pixmap, gint x, gint y, gint width, gint height) @@ -51,16 +53,19 @@ void Drawing_Data_Request(Drawing_t *Drawing, if(width < 0) return ; if(height < 0) return ; - gdk_draw_rectangle (Pixmap, + gdk_draw_rectangle (*Pixmap, Drawing->Drawing_Area_V->style->white_gc, TRUE, x, y, width, // do not overlap height); - Drawing_draw_line(Drawing, Pixmap, 10, 10, 50, 10, - Drawing->Drawing_Area_V->style->black_gc); - + send_test_process( + GuiControlFlow_get_Process_List(Drawing->Control_Flow_Data), + Drawing); + send_test_drawing( + GuiControlFlow_get_Process_List(Drawing->Control_Flow_Data), + Drawing, *Pixmap, x, y, width, height); } @@ -74,22 +79,29 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event, { Drawing_t *Drawing = (Drawing_t*)user_data; + /* New Pixmap, size of the configure event */ GdkPixmap *Pixmap = gdk_pixmap_new(widget->window, widget->allocation.width, widget->allocation.height, -1); + g_critical("drawing configure event"); + + /* If no old Pixmap present */ if(Drawing->Pixmap == NULL) { - Drawing->Pixmap = gdk_pixmap_new(widget->window, - widget->allocation.width, - widget->allocation.height, - -1); + Drawing->Pixmap = gdk_pixmap_new( + widget->window, + widget->allocation.width, + widget->allocation.height, + //ProcessList_get_height + // (GuiControlFlow_get_Process_List(Drawing->Control_Flow_Data)), + -1); Drawing->width = widget->allocation.width; Drawing->height = widget->allocation.height; - +g_critical("init data"); /* Initial data request */ - Drawing_Data_Request(Drawing, Drawing->Pixmap, 0, 0, + Drawing_Data_Request(Drawing, &Drawing->Pixmap, 0, 0, widget->allocation.width, widget->allocation.height); @@ -111,10 +123,11 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event, -1, -1); /* Request data for missing space */ - Drawing_Data_Request(Drawing, Pixmap, Drawing->width, 0, +g_critical("missing data"); + Drawing_Data_Request(Drawing, &Pixmap, Drawing->width, 0, widget->allocation.width - Drawing->width, widget->allocation.height); - Drawing_Data_Request(Drawing, Pixmap, 0, Drawing->height, + Drawing_Data_Request(Drawing, &Pixmap, 0, Drawing->height, Drawing->width, widget->allocation.height - Drawing->height); @@ -136,8 +149,6 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event, - g_critical("drawing configure event"); - if (Drawing->Pixmap) gdk_pixmap_unref(Drawing->Pixmap); @@ -167,12 +178,13 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) return FALSE; } -Drawing_t *Drawing_construct(void) +Drawing_t *Drawing_construct(ControlFlowData *Control_Flow_Data) { Drawing_t *Drawing = g_new(Drawing_t, 1); Drawing->Drawing_Area_V = gtk_drawing_area_new (); - + Drawing->Control_Flow_Data = Control_Flow_Data; + //gtk_widget_set_size_request(Drawing->Drawing_Area_V->window, 50, 50); g_object_set_data_full( G_OBJECT(Drawing->Drawing_Area_V), @@ -203,7 +215,6 @@ Drawing_t *Drawing_construct(void) // Drawing->Drawing_Area_V->allocation.height, // -1); - g_signal_connect (G_OBJECT(Drawing->Drawing_Area_V), "configure_event", G_CALLBACK (configure_event), @@ -284,6 +295,8 @@ void Drawing_Refresh ( Drawing_t *Drawing, guint x, guint y, guint width, guint height) { + GdkRectangle update_rect; + gdk_draw_drawable( Drawing->Drawing_Area_V->window, Drawing->Drawing_Area_V-> @@ -292,6 +305,13 @@ void Drawing_Refresh ( Drawing_t *Drawing, x, y, x, y, width, height); + + update_rect.x = 0 ; + update_rect.y = 0 ; + update_rect.width = Drawing->width; + update_rect.height = Drawing->height ; + gtk_widget_draw( Drawing->Drawing_Area_V, &update_rect); + } diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h index 947f9bfd..35402149 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h @@ -5,6 +5,7 @@ #include #include #include +#include "CFV.h" /* This part of the viewer does : * Draw horizontal lines, getting graphic context as arg. @@ -21,7 +22,19 @@ typedef struct _Drawing_t Drawing_t; -Drawing_t *Drawing_construct(void); + +//FIXME : TEMPORARILY FOR GC !! +struct _Drawing_t { + GtkWidget *Drawing_Area_V; + GdkPixmap *Pixmap; + ControlFlowData *Control_Flow_Data; + + gint height, width, depth; + +}; + + +Drawing_t *Drawing_construct(ControlFlowData *Control_Flow_Data); void Drawing_destroy(Drawing_t *Drawing); GtkWidget *Drawing_getWidget(Drawing_t *Drawing); diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c index 43b8fcbb..12cf5c4d 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c @@ -14,28 +14,140 @@ #include "CFV.h" #include "Process_List.h" #include "Drawing.h" +#include "CFV-private.h" -/* NOTE : no draing data should be sent there, as the drawing widget + +/* NOTE : no drawing data should be sent there, as the drawing widget * has not been initialized */ -void send_test_data(ProcessList *Process_List, Drawing_t *Drawing) +void send_test_drawing(ProcessList *Process_List, + Drawing_t *Drawing, + GdkPixmap *Pixmap, + gint x, gint y, // y not used here? + gint width, + gint height) // height won't be used here ? +{ + int i; + ProcessInfo Process_Info = {10000, 12000, 55600}; + //ProcessInfo Process_Info = {156, 14000, 55500}; + GtkTreeRowReference *got_RowRef; + + LttTime birth; + birth.tv_sec = 12000; + birth.tv_nsec = 55500; + g_critical("we have : x : %u, y : %u, width : %u, height : %u", x, y, width, height); + ProcessList_get_process_pixels(Process_List, + 1, + &birth, + &y, + &height); + + g_critical("we draw : x : %u, y : %u, width : %u, height : %u", x, y, width, height); + Drawing_draw_line( + Drawing, Pixmap, x, + y+(height/2), x + width, y+(height/2), + Drawing->Drawing_Area_V->style->black_gc); + + birth.tv_sec = 14000; + birth.tv_nsec = 55500; + + ProcessList_get_process_pixels(Process_List, + 156, + &birth, + &y, + &height); + + + Drawing_draw_line( + Drawing, Pixmap, x, + y+(height/2), x + width, y+(height/2), + Drawing->Drawing_Area_V->style->black_gc); + + g_critical("y : %u, height : %u", y, height); + + birth.tv_sec = 12000; + birth.tv_nsec = 55700; + + ProcessList_get_process_pixels(Process_List, + 10, + &birth, + &y, + &height); + + + Drawing_draw_line( + Drawing, Pixmap, x, + y+(height/2), x + width, y+(height/2), + Drawing->Drawing_Area_V->style->black_gc); + + g_critical("y : %u, height : %u", y, height); + + for(i=0; i<10; i++) + { + birth.tv_sec = i*12000; + birth.tv_nsec = i*55700; + + ProcessList_get_process_pixels(Process_List, + i, + &birth, + &y, + &height); + + + Drawing_draw_line( + Drawing, Pixmap, x, + y+(height/2), x + width, y+(height/2), + Drawing->Drawing_Area_V->style->black_gc); + + g_critical("y : %u, height : %u", y, height); + + } + + birth.tv_sec = 12000; + birth.tv_nsec = 55600; + + ProcessList_get_process_pixels(Process_List, + 10, + &birth, + &y, + &height); + + + Drawing_draw_line( + Drawing, Pixmap, x, + y+(height/2), x + width, y+(height/2), + Drawing->Drawing_Area_V->style->black_gc); + + g_critical("y : %u, height : %u", y, height); + +} + +void send_test_process(ProcessList *Process_List, Drawing_t *Drawing) { - guint height, size; + guint height, y; int i; ProcessInfo Process_Info = {10000, 12000, 55600}; //ProcessInfo Process_Info = {156, 14000, 55500}; GtkTreeRowReference *got_RowRef; LttTime birth; + + if(Process_List->Test_Process_Sent) return; + birth.tv_sec = 12000; birth.tv_nsec = 55500; ProcessList_add(Process_List, 1, &birth, - &height); - //Drawing_Insert_Square( Drawing, height, 5); + &y); + ProcessList_get_process_pixels(Process_List, + 1, + &birth, + &y, + &height); + Drawing_Insert_Square( Drawing, y, height); - g_critical("height : %u", height); + //g_critical("y : %u, height : %u", y, height); birth.tv_sec = 14000; birth.tv_nsec = 55500; @@ -43,11 +155,16 @@ void send_test_data(ProcessList *Process_List, Drawing_t *Drawing) ProcessList_add(Process_List, 156, &birth, - &height); - //Drawing_Insert_Square( Drawing, height, 5); - - g_critical("height : %u", height); - + &y); + ProcessList_get_process_pixels(Process_List, + 156, + &birth, + &y, + &height); + Drawing_Insert_Square( Drawing, y, height); + + //g_critical("y : %u, height : %u", y, height); + birth.tv_sec = 12000; birth.tv_nsec = 55700; @@ -55,6 +172,15 @@ void send_test_data(ProcessList *Process_List, Drawing_t *Drawing) 10, &birth, &height); + ProcessList_get_process_pixels(Process_List, + 10, + &birth, + &y, + &height); + Drawing_Insert_Square( Drawing, y, height); + + //g_critical("y : %u, height : %u", y, height); + //Drawing_Insert_Square( Drawing, height, 5); for(i=0; i<10; i++) @@ -66,10 +192,17 @@ void send_test_data(ProcessList *Process_List, Drawing_t *Drawing) i, &birth, &height); - //Drawing_Insert_Square( Drawing, height, 5); - + ProcessList_get_process_pixels(Process_List, + i, + &birth, + &y, + &height); + Drawing_Insert_Square( Drawing, y, height); + + // g_critical("y : %u, height : %u", y, height); + } - g_critical("height : %u", height); + //g_critical("height : %u", height); birth.tv_sec = 12000; birth.tv_nsec = 55600; @@ -77,27 +210,42 @@ void send_test_data(ProcessList *Process_List, Drawing_t *Drawing) ProcessList_add(Process_List, 10, &birth, - &height); - //Drawing_Insert_Square( Drawing, height, 5); - g_critical("height : %u", height); - + &y); + ProcessList_get_process_pixels(Process_List, + 10, + &birth, + &y, + &height); + Drawing_Insert_Square( Drawing, y, height); + + //g_critical("y : %u, height : %u", y, height); + ProcessList_add(Process_List, 10000, &birth, &height); + ProcessList_get_process_pixels(Process_List, + 10000, + &birth, + &y, + &height); + Drawing_Insert_Square( Drawing, y, height); + + //g_critical("y : %u, height : %u", y, height); + //Drawing_Insert_Square( Drawing, height, 5); - g_critical("height : %u", height); + //g_critical("height : %u", height); ProcessList_get_process_pixels(Process_List, 10000, &birth, - &height, &size); + &y, &height); ProcessList_remove( Process_List, 10000, &birth); - //Drawing_Remove_Square( Drawing, height, 5); + Drawing_Remove_Square( Drawing, y, height); if(got_RowRef = (GtkTreeRowReference*)g_hash_table_lookup( @@ -113,6 +261,8 @@ void send_test_data(ProcessList *Process_List, Drawing_t *Drawing) } + Process_List->Test_Process_Sent = TRUE; + } @@ -131,6 +281,16 @@ hGuiControlFlow(mainWindow *pmParentWindow) g_critical("hGuiControlFlow"); ControlFlowData *Control_Flow_Data = GuiControlFlow() ; + GetTimeWindow(pmParentWindow, + GuiControlFlow_get_Time_Window(Control_Flow_Data)); + GetCurrentTime(pmParentWindow, + GuiControlFlow_get_Current_Time(Control_Flow_Data)); + + // Unreg done in the GuiControlFlow_Destructor + RegUpdateTimeWindow(Update_Time_Window_Hook, Control_Flow_Data, + pmParentWindow); + RegUpdateCurrentTime(Update_Current_Time_Hook, Control_Flow_Data, + pmParentWindow); return GuiControlFlow_get_Widget(Control_Flow_Data) ; } @@ -199,3 +359,58 @@ int Draw_After_Hook(void *hook_data, void *call_data) return 0; } #endif + + + + +void Update_Time_Window_Hook(void *hook_data, void *call_data) +{ + ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data; + TimeWindow* Time_Window = + GuiControlFlow_get_Time_Window(Control_Flow_Data); + TimeWindow *New_Time_Window = ((TimeWindow*)call_data); + + // As the time interval change will mostly be used for + // zoom in and out, it's not useful to keep old drawing + // sections, as scale will be changed. + + + *Time_Window = *New_Time_Window; + g_critical("New time window HOOK : %u, %u to %u, %u", + Time_Window->startTime.tv_sec, + Time_Window->startTime.tv_nsec, + Time_Window->Time_Width.tv_sec, + Time_Window->Time_Width.tv_nsec); + + Drawing_Data_Request(Control_Flow_Data->Drawing, + &Control_Flow_Data->Drawing->Pixmap, + 0, 0, + Control_Flow_Data->Drawing->width, + Control_Flow_Data->Drawing->height); + + Drawing_Refresh(Control_Flow_Data->Drawing, + 0, 0, + Control_Flow_Data->Drawing->width, + Control_Flow_Data->Drawing->height); + +} + +void Update_Current_Time_Hook(void *hook_data, void *call_data) +{ + ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data; + LttTime* Current_Time = + GuiControlFlow_get_Current_Time(Control_Flow_Data); + *Current_Time = *((LttTime*)call_data); + g_critical("New Current time HOOK : %u, %u", Current_Time->tv_sec, + Current_Time->tv_nsec); + + /* If current time is inside time interval, just move the highlight + * bar */ + + /* Else, we have to change the time interval. We have to tell it + * to the main window. */ + /* The time interval change will take care of placing the current + * time at the center of the visible area */ + +} + diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.h b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.h index 479b3a35..13b3d3ae 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.h @@ -47,4 +47,8 @@ int Draw_Event_Hook(void *hook_data, void *call_data); int Draw_After_Hook(void *hook_data, void *call_data); +void Update_Time_Window_Hook(void *hook_data, void *call_data); +void Update_Current_Time_Hook(void *hook_data, void *call_data); + + #endif // _EVENT_HOOKS_H diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.c index a9da1fda..e3197541 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.c @@ -141,14 +141,14 @@ gboolean equ_fct(gconstpointer a, gconstpointer b) { if(((ProcessInfo*)a)->pid != ((ProcessInfo*)b)->pid) return 0; - g_critical("compare %u and %u",((ProcessInfo*)a)->pid,((ProcessInfo*)b)->pid); +// g_critical("compare %u and %u",((ProcessInfo*)a)->pid,((ProcessInfo*)b)->pid); if(((ProcessInfo*)a)->birth.tv_sec != ((ProcessInfo*)b)->birth.tv_sec) return 0; - g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_sec,((ProcessInfo*)b)->birth.tv_sec); +// g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_sec,((ProcessInfo*)b)->birth.tv_sec); if(((ProcessInfo*)a)->birth.tv_nsec != ((ProcessInfo*)b)->birth.tv_nsec) return 0; - g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_nsec,((ProcessInfo*)b)->birth.tv_nsec); +// g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_nsec,((ProcessInfo*)b)->birth.tv_nsec); return 1; } @@ -252,7 +252,9 @@ ProcessList *ProcessList_construct(void) "Process_List_Data", Process_List, (GDestroyNotify)ProcessList_destroy); - + + Process_List->Test_Process_Sent = 0; + return Process_List; } void ProcessList_destroy(ProcessList *Process_List) @@ -278,7 +280,7 @@ gint get_cell_height(GtkTreeView *TreeView) GtkCellRenderer *Renderer = g_list_first(Render_List)->data; gtk_tree_view_column_cell_get_size(Column, NULL, NULL, NULL, NULL, &height); - g_critical("cell 0 height : %u",height); + //g_critical("cell 0 height : %u",height); return height; } @@ -307,10 +309,10 @@ int ProcessList_add( ProcessList *Process_List, /* Add a new row to the model */ gtk_list_store_append ( Process_List->Store_M, &iter); - g_critical ( "iter before : %s", gtk_tree_path_to_string ( - gtk_tree_model_get_path ( - GTK_TREE_MODEL(Process_List->Store_M), - &iter))); + //g_critical ( "iter before : %s", gtk_tree_path_to_string ( + // gtk_tree_model_get_path ( + // GTK_TREE_MODEL(Process_List->Store_M), + // &iter))); gtk_list_store_set ( Process_List->Store_M, &iter, PROCESS_COLUMN, "name", PID_COLUMN, pid, @@ -327,10 +329,10 @@ int ProcessList_add( ProcessList *Process_List, (gpointer)Process_Info, (gpointer)RowRef); - g_critical ( "iter after : %s", gtk_tree_path_to_string ( - gtk_tree_model_get_path ( - GTK_TREE_MODEL(Process_List->Store_M), - &iter))); + //g_critical ( "iter after : %s", gtk_tree_path_to_string ( + // gtk_tree_model_get_path ( + // GTK_TREE_MODEL(Process_List->Store_M), + // &iter))); Process_List->Number_Of_Process++; *height = get_cell_height(GTK_TREE_VIEW(Process_List->Process_List_VC)) @@ -388,7 +390,7 @@ guint ProcessList_get_height(ProcessList *Process_List) gint ProcessList_get_process_pixels( ProcessList *Process_List, guint pid, LttTime *birth, - guint *x, + guint *y, guint *height) { ProcessInfo Process_Info; @@ -410,7 +412,7 @@ gint ProcessList_get_process_pixels( ProcessList *Process_List, *height = get_cell_height( GTK_TREE_VIEW(Process_List->Process_List_VC)); - *x = *height * path_indices[0]; + *y = *height * path_indices[0]; return 0; } else { diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.h b/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.h index 1daabdd6..f2fa69cb 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.h @@ -37,6 +37,7 @@ struct _ProcessList { GHashTable *Process_Hash; guint Number_Of_Process; + gboolean Test_Process_Sent; }; @@ -53,10 +54,10 @@ int ProcessList_add(ProcessList *Process_List, guint pid, LttTime *birth, // out : success (0) and height int ProcessList_remove(ProcessList *Process_List, guint pid, LttTime *birth); -guint ProcessList_get_pixels(ProcessList *Process_List); +guint ProcessList_get_height(ProcessList *Process_List); // Returns 0 on success gint ProcessList_get_process_pixels(ProcessList *Process_List, guint pid, LttTime *birth, - guint *x, guint *height); + guint *y, guint *height); #endif // _PROCESS_LIST_H diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/module.c b/ltt/branches/poly/lttv/modules/guiControlFlow/module.c index 5b73abae..7d47e9d1 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/module.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/module.c @@ -84,10 +84,10 @@ G_MODULE_EXPORT void destroy() { g_critical("GUI Control Flow Viewer destroy()"); int i; - ControlFlowData *Control_Flow_Data; - g_slist_foreach(gControl_Flow_Data_List, destroy_walk, NULL ); + g_slist_free(gControl_Flow_Data_List); + /* Unregister the toolbar insert button */ ToolbarItemUnreg(hGuiControlFlow); diff --git a/ltt/branches/poly/lttv/modules/guiEvents.c b/ltt/branches/poly/lttv/modules/guiEvents.c index dc062e7e..9b3e8641 100644 --- a/ltt/branches/poly/lttv/modules/guiEvents.c +++ b/ltt/branches/poly/lttv/modules/guiEvents.c @@ -55,7 +55,7 @@ static LttvHooks *before_event; static GSList *sEvent_Viewer_Data_List = NULL ; /** hook functions for update time interval, current time ... */ -gboolean updateTimeInterval(void * hook_data, void * call_data); +gboolean updateTimeWindow(void * hook_data, void * call_data); gboolean updateCurrentTime(void * hook_data, void * call_data); void remove_item_from_queue(GQueue * q, gboolean fromHead); void remove_all_items_from_queue(GQueue * q); @@ -85,7 +85,7 @@ typedef enum _ScrollDirection{ typedef struct _EventViewerData { mainWindow * mw; - TimeInterval time_interval; + TimeWindow time_window; LttTime current_time; LttvHooks * before_event_hooks; @@ -94,8 +94,9 @@ typedef struct _EventViewerData { GQueue * raw_trace_data_queue_tmp; //tmp buf to contain raw data unsigned current_event_index; double previous_value; //value of the slide - LttTime trace_start; - LttTime trace_end; + TimeInterval time_span; + // LttTime trace_start; + // LttTime trace_end; unsigned start_event_index; //the first event shown in the window unsigned end_event_index; //the last event shown in the window @@ -268,7 +269,7 @@ GuiEvents(mainWindow *pmParentWindow) unsigned size; Event_Viewer_Data->mw = pmParentWindow; - GetTimeInterval(Event_Viewer_Data->mw, &Event_Viewer_Data->time_interval); + GetTimeWindow(Event_Viewer_Data->mw, &Event_Viewer_Data->time_window); GetCurrentTime(Event_Viewer_Data->mw, &Event_Viewer_Data->current_time); Event_Viewer_Data->before_event_hooks = lttv_hooks_new(); @@ -277,7 +278,7 @@ GuiEvents(mainWindow *pmParentWindow) Event_Viewer_Data->raw_trace_data_queue = g_queue_new(); Event_Viewer_Data->raw_trace_data_queue_tmp = g_queue_new(); - RegUpdateTimeInterval(updateTimeInterval,Event_Viewer_Data, Event_Viewer_Data->mw); + RegUpdateTimeWindow(updateTimeWindow,Event_Viewer_Data, Event_Viewer_Data->mw); RegUpdateCurrentTime(updateCurrentTime,Event_Viewer_Data, Event_Viewer_Data->mw); Event_Viewer_Data->Scroll_Win = gtk_scrolled_window_new (NULL, NULL); @@ -435,11 +436,11 @@ GuiEvents(mainWindow *pmParentWindow) Event_Viewer_Data->Num_Visible_Events = 1; //get the life span of the traceset and set the upper of the scroll bar - getTracesetTimeSpan(Event_Viewer_Data->mw, &Event_Viewer_Data->trace_start, - &Event_Viewer_Data->trace_end); - time_value = Event_Viewer_Data->trace_end.tv_sec - Event_Viewer_Data->trace_start.tv_sec; + getTracesetTimeSpan(Event_Viewer_Data->mw, &Event_Viewer_Data->time_span); + + time_value = Event_Viewer_Data->time_span.endTime.tv_sec - Event_Viewer_Data->time_span.startTime.tv_sec; time_value *= NANSECOND_CONST; - time_value += (double)Event_Viewer_Data->trace_end.tv_nsec - Event_Viewer_Data->trace_start.tv_nsec; + time_value += (double)Event_Viewer_Data->time_span.endTime.tv_nsec - Event_Viewer_Data->time_span.startTime.tv_nsec; Event_Viewer_Data->VAdjust_C->upper = time_value; Event_Viewer_Data->append = TRUE; @@ -939,7 +940,7 @@ void get_test_data(double time_value, guint List_Height, remove_all_items_from_queue(Event_Viewer_Data->raw_trace_data_queue); end.tv_sec = G_MAXULONG; end.tv_nsec = G_MAXULONG; - start = Event_Viewer_Data->trace_start; + start = Event_Viewer_Data->time_span.startTime; value = (int)(time_value / NANSECOND_CONST); start.tv_sec += value; value = time_value / NANSECOND_CONST - value; @@ -988,9 +989,9 @@ void get_test_data(double time_value, guint List_Height, first = Event_Viewer_Data->raw_trace_data_queue->head; raw_data = (RawTraceData*)g_list_nth_data(first,Event_Number); value = raw_data->time.tv_sec; - value -= Event_Viewer_Data->trace_start.tv_sec; + value -= Event_Viewer_Data->time_span.startTime.tv_sec; value *= NANSECOND_CONST; - value -= Event_Viewer_Data->trace_start.tv_nsec; + value -= Event_Viewer_Data->time_span.startTime.tv_nsec; value += raw_data->time.tv_nsec; Event_Viewer_Data->VAdjust_C->value = value; g_signal_stop_emission_by_name(G_OBJECT(Event_Viewer_Data->VAdjust_C), "value-changed"); @@ -1135,7 +1136,7 @@ GuiEvents_free(EventViewerData *Event_Viewer_Data) g_queue_free(Event_Viewer_Data->raw_trace_data_queue); g_queue_free(Event_Viewer_Data->raw_trace_data_queue_tmp); - UnregUpdateTimeInterval(updateTimeInterval,Event_Viewer_Data, Event_Viewer_Data->mw); + UnregUpdateTimeWindow(updateTimeWindow,Event_Viewer_Data, Event_Viewer_Data->mw); UnregUpdateCurrentTime(updateCurrentTime,Event_Viewer_Data, Event_Viewer_Data->mw); sEvent_Viewer_Data_List = g_slist_remove(sEvent_Viewer_Data_List, Event_Viewer_Data); @@ -1202,10 +1203,10 @@ int Event_Selected_Hook(void *hook_data, void *call_data) } -gboolean updateTimeInterval(void * hook_data, void * call_data) +gboolean updateTimeWindow(void * hook_data, void * call_data) { EventViewerData *Event_Viewer_Data = (EventViewerData*) hook_data; - Event_Viewer_Data->time_interval = *(TimeInterval*)call_data; + Event_Viewer_Data->time_window = *(TimeWindow*)call_data; return FALSE; } diff --git a/ltt/branches/poly/lttv/modules/guiStatistic/.deps/guiStatistic.Plo b/ltt/branches/poly/lttv/modules/guiStatistic/.deps/guiStatistic.Plo index 85599466..224bf125 100644 --- a/ltt/branches/poly/lttv/modules/guiStatistic/.deps/guiStatistic.Plo +++ b/ltt/branches/poly/lttv/modules/guiStatistic/.deps/guiStatistic.Plo @@ -3,14 +3,14 @@ guiStatistic.lo guiStatistic.o: guiStatistic.c \ /usr/include/glib-2.0/glib/gtypes.h \ /usr/lib/glib-2.0/include/glibconfig.h \ /usr/include/glib-2.0/glib/gmacros.h \ - /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ - /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ - /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/lib/gcc-lib/i486-linux/3.3.2/include/stddef.h \ + /usr/lib/gcc-lib/i486-linux/3.3.2/include/limits.h \ + /usr/lib/gcc-lib/i486-linux/3.3.2/include/syslimits.h \ /usr/include/limits.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/gnu/stubs.h /usr/include/bits/posix1_lim.h \ /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ /usr/include/bits/posix2_lim.h \ - /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/float.h \ + /usr/lib/gcc-lib/i486-linux/3.3.2/include/float.h \ /usr/include/glib-2.0/glib/garray.h \ /usr/include/glib-2.0/glib/gasyncqueue.h \ /usr/include/glib-2.0/glib/gthread.h \ @@ -30,7 +30,7 @@ guiStatistic.lo guiStatistic.o: guiStatistic.c \ /usr/include/glib-2.0/glib/gunicode.h \ /usr/include/glib-2.0/glib/gmarkup.h \ /usr/include/glib-2.0/glib/gmessages.h \ - /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/lib/gcc-lib/i486-linux/3.3.2/include/stdarg.h \ /usr/include/glib-2.0/glib/gnode.h \ /usr/include/glib-2.0/glib/gpattern.h \ /usr/include/glib-2.0/glib/gprimes.h \ @@ -269,7 +269,8 @@ guiStatistic.lo guiStatistic.o: guiStatistic.c \ /usr/include/bits/stdio.h ../../../include/lttv/stats.h \ ../../../include/lttv/state.h ../../../include/lttv/processTrace.h \ ../../../include/lttv/traceset.h ../../../include/lttv/attribute.h \ - ../../../include/lttv/iattribute.h ../../../include/ltt/event.h \ + ../../../include/lttv/iattribute.h ../../../include/lttv/mainWindow.h \ + ../../../include/lttv/gtkcustom.h ../../../include/ltt/event.h \ /usr/include/string.h /usr/include/bits/string.h \ /usr/include/bits/string2.h /usr/include/stdlib.h \ ../icons/hGuiStatisticInsert.xpm @@ -284,11 +285,11 @@ guiStatistic.lo guiStatistic.o: guiStatistic.c \ /usr/include/glib-2.0/glib/gmacros.h: -/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h: +/usr/lib/gcc-lib/i486-linux/3.3.2/include/stddef.h: -/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h: +/usr/lib/gcc-lib/i486-linux/3.3.2/include/limits.h: -/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h: +/usr/lib/gcc-lib/i486-linux/3.3.2/include/syslimits.h: /usr/include/limits.h: @@ -306,7 +307,7 @@ guiStatistic.lo guiStatistic.o: guiStatistic.c \ /usr/include/bits/posix2_lim.h: -/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/float.h: +/usr/lib/gcc-lib/i486-linux/3.3.2/include/float.h: /usr/include/glib-2.0/glib/garray.h: @@ -356,7 +357,7 @@ guiStatistic.lo guiStatistic.o: guiStatistic.c \ /usr/include/glib-2.0/glib/gmessages.h: -/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h: +/usr/lib/gcc-lib/i486-linux/3.3.2/include/stdarg.h: /usr/include/glib-2.0/glib/gnode.h: @@ -924,6 +925,10 @@ guiStatistic.lo guiStatistic.o: guiStatistic.c \ ../../../include/lttv/iattribute.h: +../../../include/lttv/mainWindow.h: + +../../../include/lttv/gtkcustom.h: + ../../../include/ltt/event.h: /usr/include/string.h: diff --git a/ltt/branches/poly/lttv/modules/guiStatistic/guiStatistic.c b/ltt/branches/poly/lttv/modules/guiStatistic/guiStatistic.c index 46fa5fb8..ad3bbe3c 100644 --- a/ltt/branches/poly/lttv/modules/guiStatistic/guiStatistic.c +++ b/ltt/branches/poly/lttv/modules/guiStatistic/guiStatistic.c @@ -20,12 +20,15 @@ #include "../icons/hGuiStatisticInsert.xpm" +#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) +#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format) + #define PATH_LENGTH 256 static LttvModule *Main_Win_Module; /** Array containing instanced objects. Used when module is unloaded */ -GSList *gStatistic_Viewer_Data_List = NULL ; +static GSList *gStatistic_Viewer_Data_List = NULL ; typedef struct _StatisticViewerData StatisticViewerData; @@ -119,10 +122,7 @@ void destroy_walk(gpointer data, gpointer user_data) G_MODULE_EXPORT void destroy() { int i; - StatisticViewerData *Statistic_Viewer_Data; - g_critical("GUI Statistic Viewer destroy()"); - g_slist_foreach(gStatistic_Viewer_Data_List, destroy_walk, NULL ); g_slist_free(gStatistic_Viewer_Data_List); @@ -138,6 +138,7 @@ G_MODULE_EXPORT void destroy() { void GuiStatistic_free(StatisticViewerData *Statistic_Viewer_Data) { + g_critical("GuiStatistic_free()"); if(Statistic_Viewer_Data){ g_hash_table_destroy(Statistic_Viewer_Data->Statistic_Hash); gStatistic_Viewer_Data_List = g_slist_remove(gStatistic_Viewer_Data_List, Statistic_Viewer_Data); @@ -149,12 +150,12 @@ GuiStatistic_free(StatisticViewerData *Statistic_Viewer_Data) void GuiStatistic_Destructor(StatisticViewerData *Statistic_Viewer_Data) { + g_critical("GuiStatistic_Destructor()"); /* May already been done by GTK window closing */ if(GTK_IS_WIDGET(Statistic_Viewer_Data->HPaned_V)){ gtk_widget_destroy(Statistic_Viewer_Data->HPaned_V); Statistic_Viewer_Data = NULL; } - GuiStatistic_free(Statistic_Viewer_Data); } @@ -261,7 +262,9 @@ GuiStatistic(mainWindow *pmParentWindow) (GDestroyNotify)GuiStatistic_free); /* Add the object's information to the module's array */ - gStatistic_Viewer_Data_List = g_slist_append(gStatistic_Viewer_Data_List, Statistic_Viewer_Data); + gStatistic_Viewer_Data_List = g_slist_append( + gStatistic_Viewer_Data_List, + Statistic_Viewer_Data); get_traceset_stats(Statistic_Viewer_Data); diff --git a/ltt/branches/poly/lttv/processTrace.c b/ltt/branches/poly/lttv/processTrace.c index c4f650c4..339bc1af 100644 --- a/ltt/branches/poly/lttv/processTrace.c +++ b/ltt/branches/poly/lttv/processTrace.c @@ -37,6 +37,51 @@ lttv_context_new_tracefile_context(LttvTracesetContext *self) return LTTV_TRACESET_CONTEXT_GET_CLASS(self)->new_tracefile_context(self); } +/**************************************************************************** + * lttv_traceset_context_compute_time_span + * + * Keep the Time_Span is sync with on the fly addition and removal of traces + * in a trace set. It must be called each time a trace is added/removed from + * the traceset. It could be more efficient to call it only once a bunch + * of traces are loaded, but the calculation is not long, so it's not + * critical. + * + * Author : Xang Xiu Yang + * Imported from gtkTraceSet.c by Mathieu Desnoyers + ***************************************************************************/ +static void lttv_traceset_context_compute_time_span( + LttvTracesetContext *self, + TimeInterval *Time_Span) +{ + LttvTraceset * traceset = self->ts; + int numTraces = lttv_traceset_number(traceset); + int i; + LttTime s, e; + LttvTraceContext *tc; + LttTrace * trace; + + for(i=0; itraces[i]; + trace = tc->t; + + ltt_trace_time_span_get(trace, &s, &e); + + if(i==0){ + Time_Span->startTime = s; + Time_Span->endTime = e; + }else{ + if(s.tv_sec < Time_Span->startTime.tv_sec || + (s.tv_sec == Time_Span->startTime.tv_sec + && s.tv_nsec < Time_Span->startTime.tv_nsec)) + Time_Span->startTime = s; + if(e.tv_sec > Time_Span->endTime.tv_sec || + (e.tv_sec == Time_Span->endTime.tv_sec && + e.tv_nsec > Time_Span->endTime.tv_nsec)) + Time_Span->endTime = e; + } + } +} + static void init(LttvTracesetContext *self, LttvTraceset *ts) @@ -96,6 +141,8 @@ init(LttvTracesetContext *self, LttvTraceset *ts) tfc->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL); } } + self->Time_Span = g_new(TimeInterval,1); + lttv_traceset_context_compute_time_span(self, self->Time_Span); } @@ -109,9 +156,12 @@ void fini(LttvTracesetContext *self) LttvTraceset *ts = self->ts; + g_free(self->Time_Span); + lttv_hooks_destroy(self->before); lttv_hooks_destroy(self->after); - g_object_unref(self->a); + //FIXME : segfault + // g_object_unref(self->a); nb_trace = lttv_traceset_number(ts); diff --git a/ltt/branches/poly/lttv/stats.c b/ltt/branches/poly/lttv/stats.c index d0bb4cdf..311658c1 100644 --- a/ltt/branches/poly/lttv/stats.c +++ b/ltt/branches/poly/lttv/stats.c @@ -794,6 +794,7 @@ lttv_stats_remove_event_hooks(LttvTracesetStats *self) hook.id), hook.h, &g_array_index(after_hooks, LttvTraceHook, k)); } } + g_critical("lttv_stats_remove_event_hooks()"); g_array_free(before_hooks, TRUE); g_array_free(after_hooks, TRUE); } diff --git a/ltt/branches/poly/lttv/traceset.c b/ltt/branches/poly/lttv/traceset.c index 85e33225..aee03471 100644 --- a/ltt/branches/poly/lttv/traceset.c +++ b/ltt/branches/poly/lttv/traceset.c @@ -1,5 +1,6 @@ #include +#include /* A trace is a sequence of events gathered in the same tracing session. The events may be stored in several tracefiles in the same directory. @@ -8,6 +9,7 @@ */ struct _LttvTraceset { + char * filename; GPtrArray *traces; GPtrArray *attributes; LttvAttribute *a; @@ -19,13 +21,65 @@ LttvTraceset *lttv_traceset_new() LttvTraceset *s; s = g_new(LttvTraceset, 1); + s->filename = NULL; s->traces = g_ptr_array_new(); s->attributes = g_ptr_array_new(); s->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL); return s; } +LttvTraceset *lttv_traceset_copy(LttvTraceset *s_orig) +{ + int i; + LttvTraceset *s; + + s = g_new(LttvTraceset, 1); + s->filename = NULL; + s->traces = g_ptr_array_new(); + for(i=0;itraces->len;i++) + { + g_ptr_array_add( + s->traces, + ltt_trace_copy(g_ptr_array_index(s_orig->traces, i))); + } + s->attributes = g_ptr_array_new(); + for(i=0;iattributes->len;i++) + { + g_ptr_array_add( + s->attributes, + lttv_iattribute_deep_copy(g_ptr_array_index(s_orig->attributes, i))); + } + + s->a = LTTV_ATTRIBUTE(lttv_iattribute_deep_copy(LTTV_IATTRIBUTE(s_orig->a))); + return s; +} + +LttvTraceset *lttv_traceset_load(const gchar *filename) +{ + LttvTraceset *s = g_new(LttvTraceset,1); + FILE *tf; + + s->filename = g_strdup(filename); + tf = fopen(filename,"r"); + + g_critical("NOT IMPLEMENTED : load traceset data from a XML file"); + + fclose(tf); + return s; +} + +gint lttv_traceset_save(LttvTraceset *s) +{ + FILE *tf; + + tf = fopen(s->filename, "w"); + + g_critical("NOT IMPLEMENTED : save traceset data in a XML file"); + + fclose(tf); + return 0; +} void lttv_traceset_destroy(LttvTraceset *s) { int i, nb; @@ -39,7 +93,6 @@ void lttv_traceset_destroy(LttvTraceset *s) g_free(s); } - void lttv_traceset_add(LttvTraceset *s, LttTrace *t) { g_ptr_array_add(s->traces, t);