Attribute a;
LttvAttribute *new;
-
+
i = (unsigned)g_hash_table_lookup(self->names, GUINT_TO_POINTER(name));
if(i != 0) {
a = g_array_index(self->attributes, Attribute, i - 1);
/* Initialize glib and by default ignore info and debug messages */
g_type_init();
- //g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_SIGNALS);
- g_log_set_handler(NULL, G_LOG_LEVEL_INFO, ignore_and_drop_message, NULL);
- g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, ignore_and_drop_message, NULL);
+ g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_SIGNALS);
+ //g_log_set_handler(NULL, G_LOG_LEVEL_INFO, ignore_and_drop_message, NULL);
+ //g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, ignore_and_drop_message, NULL);
/* Have an attributes subtree to store hooks to be registered by modules. */
/*CHECK why dynamically allocate the time span... and the casing is wroNg*/
self->Time_Span = g_new(TimeInterval,1);
lttv_traceset_context_compute_time_span(self, self->Time_Span);
+ self->e = NULL;
}
while(TRUE) {
tfc = NULL;
g_tree_foreach(pqueue, get_first, &tfc);
- if(tfc == NULL) return count;
+ if(tfc == NULL)
+ {
+ self->e = event;
+ return count;
+ }
/* Have we reached the maximum number of events specified? However,
continue for all the events with the same time stamp (CHECK?). Then,
if(count >= nb_events &&
ltt_time_compare(tfc->timestamp, previous_timestamp) != 0)
- return count;
+ {
+ self->e = event;
+ return count;
+ }
previous_timestamp = tfc->timestamp;
LttvAttribute *ts_a;
TimeInterval *Time_Span;
GTree *pqueue;
+ LttEvent *e; /* Last event read by lttv_process_traceset_middle */
};
struct _LttvTracesetContextClass {
{
return t->ref_count;
}
+
+guint lttv_trace_ref(LttvTrace * t)
+{
+ t->ref_count++;
+
+ return t->ref_count;
+}
+
+guint lttv_trace_unref(LttvTrace * t)
+{
+ if(t->ref_count > 0)
+ t->ref_count--;
+
+ return t->ref_count;
+}
+
guint lttv_trace_get_ref_number(LttvTrace * t);
+guint lttv_trace_ref(LttvTrace * t);
+
+guint lttv_trace_unref(LttvTrace * t);
+
#endif // TRACESET_H
#ifndef _CFV_PRIVATE_H
#define _CFV_PRIVATE_H
+
struct _ControlFlowData {
GtkWidget *scrolled_window;
//guint currently_Selected_Event ;
guint number_of_process;
+ /* hooks for trace read */
+ LttvHooks *event;
+ LttvHooks *after_event;
+ LttvHooks *after_traceset;
+ EventRequest *event_request;
+
} ;
/* Get trace statistics */
//control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
+ /* Create reading hooks */
+ control_flow_data->event = lttv_hooks_new();
+ control_flow_data->after_event = lttv_hooks_new();
+ control_flow_data->after_traceset = lttv_hooks_new();
+ control_flow_data->event_request = g_new(EventRequest, 1);
+
gtk_widget_show(drawing_widget);
gtk_widget_show(process_list_widget);
gtk_widget_show(control_flow_data->h_paned);
g_signal_connect (G_OBJECT (process_list_widget), "grab-focus",
G_CALLBACK (control_flow_grab_focus),
control_flow_data);
-
-
+
+
return control_flow_data;
}
//ProcessList_destroy(control_flow_data->process_list);
if(control_flow_data->mw != NULL)
{
+ /* Delete reading hooks */
+ lttv_hooks_destroy(control_flow_data->event);
+ lttv_hooks_destroy(control_flow_data->after_event);
+ lttv_hooks_destroy(control_flow_data->after_traceset);
+ g_free(control_flow_data->event_request);
+
lttvwindow_unregister_time_window_notify(control_flow_data->mw,
update_time_window_hook,
control_flow_data);
#include <lttv/hook.h>
#include "drawing.h"
+#include "eventhooks.h"
#include "cfv.h"
#include "cfv-private.h"
-#include "eventhooks.h"
#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)
const TimeWindow *time_window = lttvwindow_get_time_window(drawing->control_flow_data->mw);
- ControlFlowData *control_flow_data =
- (ControlFlowData*)g_object_get_data(
- G_OBJECT(drawing->drawing_area), "control_flow_data");
+ ControlFlowData *control_flow_data = drawing->control_flow_data;
+ // (ControlFlowData*)g_object_get_data(
+ // G_OBJECT(drawing->drawing_area), "control_flow_data");
- LttTime start, end;
+ LttTime start, time_end;
LttTime window_end = ltt_time_add(time_window->time_width,
time_window->start_time);
- g_debug("req : window_end : %u, %u", window_end.tv_sec,
- window_end.tv_nsec);
+ g_debug("req : window start_time : %u, %u", time_window->start_time.tv_sec,
+ time_window->start_time.tv_nsec);
- g_debug("req : time width : %u, %u", time_window->time_width.tv_sec,
+ g_debug("req : window time width : %u, %u", time_window->time_width.tv_sec,
time_window->time_width.tv_nsec);
+ g_debug("req : window_end : %u, %u", window_end.tv_sec,
+ window_end.tv_nsec);
+
g_debug("x is : %i, x+width is : %i", x, x+width);
convert_pixels_to_time(drawing->drawing_area->allocation.width, x,
window_end,
&start);
- convert_pixels_to_time(drawing->drawing_area->allocation.width, x + width,
+ convert_pixels_to_time(drawing->drawing_area->allocation.width, x+width,
time_window->start_time,
window_end,
- &end);
+ &time_end);
LttvTracesetContext * tsc =
lttvwindow_get_traceset_context(control_flow_data->mw);
(LttvTracesetState*)tsc;
// Let's call processTrace() !!
- EventRequest event_request; // Variable freed at the end of the function.
- event_request.control_flow_data = control_flow_data;
- event_request.time_begin = start;
- event_request.time_end = end;
- event_request.x_begin = x;
- event_request.x_end = x+width;
-
- g_debug("req : start : %u, %u", event_request.time_begin.tv_sec,
- event_request.time_begin.tv_nsec);
-
- g_debug("req : end : %u, %u", event_request.time_end.tv_sec,
- event_request.time_end.tv_nsec);
-
- LttvHooks *event = lttv_hooks_new();
- LttvHooks *after_event = lttv_hooks_new();
- LttvHooks *after_traceset = lttv_hooks_new();
- lttv_hooks_add(after_traceset, after_data_request, &event_request);
- lttv_hooks_add(event, draw_event_hook, &event_request);
- //Modified by xiangxiu: state update hooks are added by the main window
- //lttv_state_add_event_hooks(tsc);
- lttv_hooks_add(after_event, draw_after_hook, &event_request);
+
+ EventRequest *event_request = control_flow_data->event_request;
+ event_request->control_flow_data = control_flow_data;
+ event_request->time_begin = start;
+ event_request->time_end = time_end;
+
+ event_request->x_begin = x;
+ event_request->x_end = x+width;
+
+ g_debug("req : start : %u, %u", event_request->time_begin.tv_sec,
+ event_request->time_begin.tv_nsec);
+
+ g_debug("req : end : %u, %u", event_request->time_end.tv_sec,
+ event_request->time_end.tv_nsec);
+
+ lttv_hooks_add(control_flow_data->after_traceset, after_data_request, event_request);
+ lttv_hooks_add(control_flow_data->event, draw_event_hook, event_request);
+ lttv_hooks_add(control_flow_data->after_event, draw_after_hook, event_request);
//lttv_process_traceset_seek_time(tsc, start);
- lttv_state_traceset_seek_time_closest(tss, start);
+ //lttv_state_traceset_seek_time_closest(tss, start);
// FIXME : would like to place the after_traceset hook after the traceset,
// but the traceset context state is not valid anymore.
lttv_traceset_context_add_hooks(tsc,
- NULL, after_traceset, NULL, NULL, NULL, NULL,
+ NULL, control_flow_data->after_traceset, NULL, NULL, NULL, NULL,
//NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, event, after_event);
- lttv_process_traceset(tsc, end, G_MAXULONG);
- //after_data_request((void*)&event_request,(void*)tsc);
- lttv_traceset_context_remove_hooks(tsc,
- NULL, after_traceset, NULL, NULL, NULL, NULL,
- // NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, event, after_event);
- //Modified by xiangxiu: state update hooks are removed by the main window
- //lttv_state_remove_event_hooks(tsc);
+ NULL, NULL, NULL, control_flow_data->event, control_flow_data->after_event);
+ TimeWindow time_request;
+ time_request.start_time = start;
+ time_request.time_width = ltt_time_sub(time_end, start);
+
+ lttvwindow_time_interval_request(drawing->control_flow_data->mw,
+ time_request, G_MAXUINT,
+ after_process_traceset_hook,
+ control_flow_data);
+
+ //lttv_process_traceset(tsc, end, G_MAXULONG);
+}
+
+
+
+
+void drawing_data_request_end(Drawing_t *drawing,
+ TimeWindow req_time_window)
+{
+ gint x, x_end, width;
+
+ LttvTracesetContext * tsc =
+ lttvwindow_get_traceset_context(drawing->control_flow_data->mw);
+
+ const TimeWindow *time_window = lttvwindow_get_time_window(drawing->control_flow_data->mw);
- lttv_hooks_destroy(after_traceset);
- lttv_hooks_destroy(event);
- lttv_hooks_destroy(after_event);
+ //FIXME ? removing hooks during processtrace can BREAK things!
+ lttv_traceset_context_remove_hooks(tsc,
+ NULL, drawing->control_flow_data->after_traceset, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ drawing->control_flow_data->event,
+ drawing->control_flow_data->after_event);
+ g_debug("End of data request");
+ LttTime window_end = ltt_time_add(time_window->time_width,
+ time_window->start_time);
+
+ LttTime req_window_end = ltt_time_add(req_time_window.time_width,
+ req_time_window.start_time);
+
+ convert_time_to_pixels(
+ time_window->start_time,
+ window_end,
+ req_time_window.start_time,
+ drawing->width,
+ &x);
+
+ convert_time_to_pixels(
+ time_window->start_time,
+ window_end,
+ req_window_end,
+ drawing->width,
+ &x_end);
+
+ width = x_end - x;
+
+ /* ask for the buffer to be redrawn */
+ gtk_widget_queue_draw_area ( drawing->drawing_area,
+ x, 0,
+ width, drawing->height);
+
}
-
+
+
/* Callbacks */
/* Initial data request */
+ /* no, do initial data request in the expose event */
// Do not need to ask for data of 1 pixel : not synchronized with
// main window time at this moment.
- drawing_data_request(drawing, &drawing->pixmap, 0, 0,
- widget->allocation.width,
- widget->allocation.height);
+ //drawing_data_request(drawing, &drawing->pixmap, 0, 0,
+ // widget->allocation.width,
+ // widget->allocation.height);
drawing->width = widget->allocation.width;
drawing->height = widget->allocation.height;
+
+ drawing->data_injected = FALSE;
return TRUE;
}
-#ifdef NOTUSE
-// /* Draw empty background */
-// gdk_draw_rectangle (pixmap,
-// widget->style->black_gc,
-// TRUE,
-// 0, 0,
-// widget->allocation.width,
-// widget->allocation.height);
-
- /* Copy old data to new pixmap */
- gdk_draw_drawable (pixmap,
- widget->style->black_gc,
- drawing->pixmap,
- 0, 0,
- 0, 0,
- -1, -1);
-
- if (drawing->pixmap)
- gdk_pixmap_unref(drawing->pixmap);
-
- drawing->pixmap = pixmap;
-
- // Clear the bottom part of the image (SAFETY)
- gdk_draw_rectangle (pixmap,
- widget->style->black_gc,
- TRUE,
- 0, drawing->height+SAFETY,
- drawing->width+SAFETY, // do not overlap
- (widget->allocation.height) - drawing->height);
-
- // Clear the right part of the image (SAFETY)
- gdk_draw_rectangle (pixmap,
- widget->style->black_gc,
- TRUE,
- drawing->width+SAFETY, 0,
- (widget->allocation.width) - drawing->width, // do not overlap
- drawing->height+SAFETY);
-
- /* Clear the backgound for data request, but not SAFETY */
- gdk_draw_rectangle (pixmap,
- drawing->drawing_area->style->black_gc,
- TRUE,
- drawing->width + SAFETY, 0,
- widget->allocation.width - drawing->width, // do not overlap
- widget->allocation.height+SAFETY);
-
- /* Request data for missing space */
- g_info("missing data request");
- drawing_data_request(drawing, &pixmap, drawing->width, 0,
- widget->allocation.width - drawing->width,
- widget->allocation.height);
-
- drawing->width = widget->allocation.width;
- drawing->height = widget->allocation.height;
-
- return TRUE;
-#endif //NOTUSE
}
expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
{
Drawing_t *drawing = (Drawing_t*)user_data;
+
const TimeWindow *time_window = lttvwindow_get_time_window(drawing->control_flow_data->mw);
const LttTime* current_time =
lttvwindow_get_current_time(drawing->control_flow_data->mw);
G_OBJECT(widget),
"control_flow_data");
- g_debug("drawing expose event");
-
- guint x=0;
+ guint cursor_x=0;
LttTime window_end = ltt_time_add(time_window->time_width,
time_window->start_time);
window_end,
*current_time,
widget->allocation.width,
- &x);
+ &cursor_x);
+
+
+
+
+ if(!drawing->data_injected)
+ {
+ drawing_data_request(drawing, &drawing->pixmap, 0, 0,
+ widget->allocation.width,
+ widget->allocation.height);
+ drawing->data_injected = TRUE;
+ }
+ /* update the screen from the pixmap buffer */
gdk_draw_pixmap(widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
drawing->pixmap,
event->area.x, event->area.y,
event->area.width, event->area.height);
- if(x >= event->area.x && x <= event->area.x+event->area.width)
- {
- gint8 dash_list[] = { 1, 2 };
- GdkGC *gc = gdk_gc_new(control_flow_data->drawing->pixmap);
- gdk_gc_copy(gc, widget->style->white_gc);
- gdk_gc_set_line_attributes(gc,
- 1,
- GDK_LINE_ON_OFF_DASH,
- GDK_CAP_BUTT,
- GDK_JOIN_MITER);
- gdk_gc_set_dashes(gc,
- 0,
- dash_list,
- 2);
- drawing_draw_line(NULL, widget->window,
- x, event->area.y,
- x, event->area.y+event->area.height,
- gc);
- gdk_gc_unref(gc);
- }
+
+ /* Draw the dotted lines */
+
+ gint8 dash_list[] = { 1, 2 };
+ GdkGC *gc = gdk_gc_new(control_flow_data->drawing->pixmap);
+ gdk_gc_copy(gc, widget->style->white_gc);
+ gdk_gc_set_line_attributes(gc,
+ 1,
+ GDK_LINE_ON_OFF_DASH,
+ GDK_CAP_BUTT,
+ GDK_JOIN_MITER);
+ gdk_gc_set_dashes(gc,
+ 0,
+ dash_list,
+ 2);
+ drawing_draw_line(NULL, widget->window,
+ cursor_x, 0,
+ cursor_x, drawing->height,
+ gc);
+ gdk_gc_unref(gc);
+
+
+
+
+ return FALSE;
+}
+
+static gboolean
+after_expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
+{
+ //g_assert(0);
+ g_critical("AFTER EXPOSE");
+
return FALSE;
+
+
}
+
/* mouse click */
static gboolean
button_press_event( GtkWidget *widget, GdkEventButton *event, gpointer user_data )
drawing->pango_layout =
gtk_widget_create_pango_layout(drawing->drawing_area, NULL);
+ drawing->height = 0;
+ drawing->width = 0;
+ drawing->depth = 0;
+
+ drawing->data_injected = FALSE;
+
//gtk_widget_set_size_request(drawing->drawing_area->window, 50, 50);
g_object_set_data_full(
G_OBJECT(drawing->drawing_area),
G_CALLBACK (expose_event),
(gpointer)drawing);
+ g_signal_connect_after (G_OBJECT(drawing->drawing_area),
+ "expose_event",
+ G_CALLBACK (after_expose_event),
+ (gpointer)drawing);
+
g_signal_connect (G_OBJECT(drawing->drawing_area),
"button-press-event",
G_CALLBACK (button_press_event),
}
-void drawing_refresh ( Drawing_t *drawing,
- guint x, guint y,
- guint width, guint height)
-{
- g_info("Drawing.c : drawing_refresh %u, %u, %u, %u", x, y, width, height);
- GdkRectangle update_rect;
-
- gdk_draw_drawable(
- drawing->drawing_area->window,
- drawing->drawing_area->
- style->fg_gc[GTK_WIDGET_STATE (drawing->drawing_area)],
- GDK_DRAWABLE(drawing->pixmap),
- 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, &update_rect);
-
-}
-
-
void drawing_draw_line( Drawing_t *drawing,
GdkPixmap *pixmap,
guint x1, guint y1,
PangoLayout *pango_layout;
- gint height, width, depth;
+ gint height, width, depth;
+ gboolean data_injected;
};
GtkWidget *drawing_get_widget(Drawing_t *drawing);
GtkWidget *drawing_get_drawing_area(Drawing_t *drawing);
-//void drawing_Refresh ( Drawing_t *drawing,
-// guint x, guint y,
-// guint width, guint height);
-
void drawing_draw_line( Drawing_t *drawing,
GdkPixmap *pixmap,
guint x1, guint y1,
void drawing_update_ruler(Drawing_t *drawing, TimeWindow *time_window);
+void drawing_data_request_end(Drawing_t *drawing,
+ TimeWindow req_time_window);
+
+
#endif // _DRAWING_H
{
EventRequest *event_request = (EventRequest*)hook_data;
ControlFlowData *control_flow_data = event_request->control_flow_data;
+ MainWindow *mw = control_flow_data->mw;
LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
LttTime evtime = ltt_event_time(e);
const TimeWindow *time_window =
- lttvwindow_get_time_window(control_flow_data->mw);
+ lttvwindow_get_time_window(mw);
LttTime end_time = ltt_time_add(time_window->start_time,
time_window->time_width);
gint update_time_window_hook(void *hook_data, void *call_data)
{
ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
+ Drawing_t *drawing = control_flow_data->drawing;
+
const TimeWindowNotifyData *time_window_nofify_data =
((const TimeWindowNotifyData *)call_data);
0, 0,
-1, -1);
- convert_time_to_pixels(
- *ns,
- new_end,
- old_end,
- width,
- &x);
-
- *old_time_window = *new_time_window;
/* Clear the data request background, but not SAFETY */
gdk_draw_rectangle (control_flow_data->drawing->pixmap,
control_flow_data->drawing->drawing_area->style->black_gc,
x+SAFETY, 0,
control_flow_data->drawing->width - x, // do not overlap
control_flow_data->drawing->height+SAFETY);
+
+ gtk_widget_queue_draw_area (drawing->drawing_area,
+ 0,0,
+ control_flow_data->drawing->width - x,
+ control_flow_data->drawing->height);
+
/* Get new data for the rest. */
drawing_data_request(control_flow_data->drawing,
&control_flow_data->drawing->pixmap,
control_flow_data->drawing->width - x,
control_flow_data->drawing->height);
- drawing_refresh(control_flow_data->drawing,
- 0, 0,
- control_flow_data->drawing->width,
- control_flow_data->drawing->height);
-
-
} else {
//if(ns<os<ns+w)
//if(ns<os && os<ns+w)
x, 0,
-1, -1);
- //*old_time_window = *new_time_window;
+ *old_time_window = *new_time_window;
/* Clean the data request background */
gdk_draw_rectangle (control_flow_data->drawing->pixmap,
0, 0,
x, // do not overlap
control_flow_data->drawing->height+SAFETY);
+
+ gtk_widget_queue_draw_area (drawing->drawing_area,
+ x,0,
+ control_flow_data->drawing->width - x,
+ control_flow_data->drawing->height);
+
/* Get new data for the rest. */
drawing_data_request(control_flow_data->drawing,
&control_flow_data->drawing->pixmap,
x,
control_flow_data->drawing->height);
- drawing_refresh(control_flow_data->drawing,
- 0, 0,
- control_flow_data->drawing->width,
- control_flow_data->drawing->height);
-
} else {
- g_info("scrolling far");
- /* Cannot reuse any part of the screen : far jump */
- //*old_time_window = *new_time_window;
-
-
- gdk_draw_rectangle (control_flow_data->drawing->pixmap,
- control_flow_data->drawing->drawing_area->style->black_gc,
- TRUE,
- 0, 0,
- control_flow_data->drawing->width+SAFETY, // do not overlap
- control_flow_data->drawing->height+SAFETY);
-
- 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,
+ if(ltt_time_compare(*ns,*os) == 0)
+ {
+ g_info("not scrolling");
+ } else {
+ g_info("scrolling far");
+ /* Cannot reuse any part of the screen : far jump */
+
+
+ gdk_draw_rectangle (control_flow_data->drawing->pixmap,
+ control_flow_data->drawing->drawing_area->style->black_gc,
+ TRUE,
0, 0,
- control_flow_data->drawing->width,
- control_flow_data->drawing->height);
+ control_flow_data->drawing->width+SAFETY, // do not overlap
+ control_flow_data->drawing->height+SAFETY);
+
+ gtk_widget_queue_draw_area (drawing->drawing_area,
+ 0,0,
+ control_flow_data->drawing->width,
+ control_flow_data->drawing->height);
+
+ drawing_data_request(control_flow_data->drawing,
+ &control_flow_data->drawing->pixmap,
+ 0, 0,
+ control_flow_data->drawing->width,
+ control_flow_data->drawing->height);
+
+ }
}
}
} else {
/* Different scale (zoom) */
g_info("zoom");
- //*old_time_window = *new_time_window;
-
gdk_draw_rectangle (control_flow_data->drawing->pixmap,
control_flow_data->drawing->drawing_area->style->black_gc,
TRUE,
control_flow_data->drawing->width+SAFETY, // do not overlap
control_flow_data->drawing->height+SAFETY);
+ gtk_widget_queue_draw_area (drawing->drawing_area,
+ 0,0,
+ control_flow_data->drawing->width,
+ control_flow_data->drawing->height);
drawing_data_request(control_flow_data->drawing,
&control_flow_data->drawing->pixmap,
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);
}
return 0;
}
+gint after_process_traceset_hook(void *hook_data, void *call_data)
+{
+ ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
+ TimeRequest *time_request = (TimeRequest *)call_data;
+
+ drawing_data_request_end(control_flow_data->drawing,
+ time_request->time_window);
+ return 0;
+}
+
+
+
gint update_current_time_hook(void *hook_data, void *call_data)
{
ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
+ Drawing_t *drawing = control_flow_data->drawing;
LttTime current_time = *((LttTime*)call_data);
lttvwindow_report_time_window(control_flow_data->mw, &new_time_window);
}
- gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
+ //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
+ gtk_widget_queue_draw_area(drawing->drawing_area,
+ 0,0,
+ drawing->width,
+ drawing->height);
return 0;
}
* for each process
* draw closing line
* new default prev and current
+ * then finally remove reading hooks.
*/
int after_data_request(void *hook_data, void *call_data)
{
g_hash_table_foreach(process_list->process_hash, draw_closure,
(void*)&closure_data);
+
+ /* Remove reading hooks */
+ // Cannot do this here, will break processtrace!
+ //drawing_data_request_end(control_flow_data->drawing);
}
gint update_current_time_hook(void *hook_data, void *call_data);
-
-
+gint after_process_traceset_hook(void *hook_data, void *call_data);
#endif // _EVENT_HOOKS_H
update_time_window, event_viewer_data);
lttvwindow_register_current_time_notify(event_viewer_data->mw,
update_current_time,event_viewer_data);
- lttvwindow_register_show(event_viewer_data->mw,
+ lttvwindow_register_show_notify(event_viewer_data->mw,
show_event_detail,event_viewer_data);
lttvwindow_register_traceset_notify(event_viewer_data->mw,
traceset_changed,event_viewer_data);
if(!first)break;
raw_data = (RawTraceData*)g_list_nth_data(first,0);
end = raw_data->time;
- end.tv_nsec--;
+ if(end.tv_nsec != 0)
+ end.tv_nsec--;
+ else
+ end.tv_sec--; // even if tv_sec == 0, wrapping should give a real big
+ // value, so will read all the trace.
ltt_event_position_get(raw_data->ep, &block_num, &event_num, &tf);
if(size !=0){
if(event_num > minNum){
update_time_window, event_viewer_data);
lttvwindow_unregister_current_time_notify(event_viewer_data->mw,
update_current_time, event_viewer_data);
- lttvwindow_unregister_show(event_viewer_data->mw,
+ lttvwindow_unregister_show_notify(event_viewer_data->mw,
show_event_detail, event_viewer_data);
lttvwindow_unregister_traceset_notify(event_viewer_data->mw,
traceset_changed, event_viewer_data);
#include "callbacks.h"
#include "interface.h"
#include "support.h"
+#include <ltt/trace.h>
+#include <ltt/facility.h>
+#include <ltt/time.h>
+#include <ltt/event.h>
#include <lttv/lttv.h>
+#include <lttv/module.h>
+#include <lttv/iattribute.h>
+#include <lttv/stats.h>
#include <lttvwindow/mainwindow.h>
#include <lttvwindow/menu.h>
#include <lttvwindow/toolbar.h>
#include <lttvwindow/viewer.h>
-#include <lttv/module.h>
#include <lttvwindow/gtkdirsel.h>
-#include <lttv/iattribute.h>
#include <lttvwindow/lttvfilter.h>
-#include <ltt/trace.h>
-#include <ltt/facility.h>
#define PATH_LENGTH 256
#define DEFAULT_TIME_WIDTH_S 1
static int g_win_count = 0;
-// MD : keep old directory
+/** MD : keep old directory. */
static char remember_plugins_dir[PATH_LENGTH] = "";
static char remember_trace_dir[PATH_LENGTH] = "";
LttvTracesetSelector * construct_traceset_selector(LttvTraceset * traceset);
-void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window);
+void call_pending_read_hooks(MainWindow * mw_data);
unsigned get_max_event_number(MainWindow * mw_data);
enum {
GtkWidget * viewer;
LttvTracesetSelector * s;
TimeInterval * time_interval;
- TimeWindow time_window, t;
mw_data = get_window_data_struct(widget);
if(!mw_data->current_tab) return;
if(viewer)
{
gtk_multi_vpaned_widget_add(multi_vpaned, viewer);
- // Added by MD
- // g_object_unref(G_OBJECT(viewer));
-
- time_window = mw_data->current_tab->time_window;
- time_interval = (TimeInterval*)g_object_get_data(G_OBJECT(viewer), TRACESET_TIME_SPAN);
- if(time_interval){
- t = time_window;
- time_window.start_time = time_interval->startTime;
- time_window.time_width = ltt_time_sub(time_interval->endTime,time_interval->startTime);
- }
-
- redraw_viewer(mw_data,&time_window);
- lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
- if(time_interval){
- lttvwindow_report_time_window(mw_data,&t);
- }
+ // We unref here, because it is now referenced by the multi_vpaned!
+ g_object_unref(G_OBJECT(viewer));
+
+ // The viewer will show itself when it receives a show notify
+ // So we call the show notify hooks here. It will
+ // typically add hooks for reading, we call process trace, and the
+ // end of reading hook will call gtk_widget_show and unregister the
+ // hooks.
+ // Note that show notify gets the time_requested through the call_data.
+ //show_viewer(mw_data);
+ // in expose now call_pending_read_hooks(mw_data);
}
}
/* open_traceset will open a traceset saved in a file
* Right now, it is not finished yet, (not working)
+ * FIXME
*/
void open_traceset(GtkWidget * widget, gpointer user_data)
}
-/* redraw_viewer parses the traceset first by calling
+/* call_pending_read_hooks parses the traceset first by calling
* process_traceset, then display all viewers of
* the current tab
+ * It will then remove all entries from the time_requests array.
*/
-void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window)
+gint compare_time_request(TimeRequest *a, TimeRequest *b)
+{
+ return ltt_time_compare(a->time_window.start_time, b->time_window.start_time);
+}
+
+void call_pending_read_hooks(MainWindow * mw_data)
{
unsigned max_nb_events;
GdkWindow * win;
GdkCursor * new;
GtkWidget* widget;
- LttvTracesetContext *tsc =
+ int i;
+ LttvTracesetContext *tsc;
+
+ /* Current tab check : if no current tab is present, no hooks to call. */
+ /* It makes the expose works.. */
+ if(mw_data->current_tab == NULL)
+ return;
+
+ if(mw_data->current_tab->time_requests->len == 0)
+ return;
+
+ LttvHooks *tmp_hooks = lttv_hooks_new();
+
+ tsc =
LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->
traceset_context);
gdk_cursor_unref(new);
gdk_window_stick(win);
gdk_window_unstick(win);
-
+
+
+ g_array_sort(mw_data->current_tab->time_requests,
+ (GCompareFunc)compare_time_request);
+
+
//update time window of each viewer, let viewer insert hooks needed by process_traceset
- lttvwindow_report_time_window(mw_data, time_window);
+ //lttvwindow_report_time_window(mw_data, time_window);
- max_nb_events = get_max_event_number(mw_data);
-
- lttv_process_traceset_seek_time(tsc, time_window->start_time);
- lttv_process_traceset(tsc,
- ltt_time_add(time_window->start_time,time_window->time_width),
- max_nb_events);
+ //max_nb_events = get_max_event_number(mw_data);
//call hooks to show each viewer and let them remove hooks
- show_viewer(mw_data);
+ //show_viewer(mw_data);
+ // FIXME
+ // call process trace for each time interval
+ // Will have to be combined!
+ g_critical("SIZE time req len : %d", mw_data->current_tab->time_requests->len);
+
+ //g_assert(mw_data->current_tab->time_requests->len <= 1); //FIXME
+ /* Go through each time request. As they are already sorted by start_time,
+ * we check with the current event time if processing is needed. */
+ for(i=0; i < mw_data->current_tab->time_requests->len; i++)
+ {
+ g_critical("RUN i %d", i);
+ TimeRequest *time_request =
+ &g_array_index(mw_data->current_tab->time_requests, TimeRequest, i);
+ LttTime end_time = ltt_time_add( time_request->time_window.start_time,
+ time_request->time_window.time_width);
+
+ if(i == 0 || !(ltt_time_compare(time_request->time_window.start_time, ltt_event_time(tsc->e))<0) )
+ {
+ /* do it if first request or start_time >= last event's time */
+ lttv_process_traceset_seek_time(tsc, time_request->time_window.start_time);
+ lttv_process_traceset(tsc, end_time, time_request->num_events);
+ }
+
+ /* Call the end of process_traceset hook */
+ lttv_hooks_add(tmp_hooks,
+ time_request->after_hook,
+ time_request->after_hook_data);
+ lttv_hooks_call(tmp_hooks, time_request);
+ lttv_hooks_remove(tmp_hooks, time_request->after_hook);
+ }
+
+ /* Free the time requests */
+ g_array_free(mw_data->current_tab->time_requests, TRUE);
+ mw_data->current_tab->time_requests =
+ g_array_new(FALSE, FALSE, sizeof(TimeRequest));
+
+ mw_data->current_tab->time_request_pending = FALSE;
+
+ lttv_hooks_destroy(tmp_hooks);
+
//set the cursor back to normal
gdk_window_set_cursor(win, NULL);
}
LttTrace *trace;
LttvTrace * trace_v;
LttvTraceset * traceset;
- LttvTracesetStats* tmp_context;
const char * dir;
gint id;
+ gint i;
MainWindow * mw_data = get_window_data_struct(widget);
GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select a trace");
gtk_dir_selection_hide_fileop_buttons(file_selector);
case GTK_RESPONSE_OK:
dir = gtk_dir_selection_get_dir (file_selector);
strncpy(remember_trace_dir, dir, PATH_LENGTH);
- if(!dir || strlen(dir) ==0){
- gtk_widget_destroy((GtkWidget*)file_selector);
- break;
+ if(!dir || strlen(dir) == 0){
+ gtk_widget_destroy((GtkWidget*)file_selector);
+ break;
}
trace = ltt_trace_open(dir);
if(trace == NULL) g_critical("cannot open trace %s", dir);
trace_v = lttv_trace_new(trace);
traceset = mw_data->current_tab->traceset_info->traceset;
- // Keep the context until the new one is created.
- tmp_context = mw_data->current_tab->traceset_info->traceset_context;
- mw_data->current_tab->traceset_info->traceset_context = NULL;
+ //Keep a reference to the traces so they are not freed.
+ for(i=0; i<lttv_traceset_number(traceset); i++)
+ {
+ LttvTrace * trace = lttv_traceset_get(traceset, i);
+ lttv_trace_ref(trace);
+ }
+
+ //remove state update hooks
+ lttv_state_remove_event_hooks(
+ (LttvTracesetState*)mw_data->current_tab->traceset_info->traceset_context);
+
+ lttv_context_fini(LTTV_TRACESET_CONTEXT(
+ mw_data->current_tab->traceset_info->traceset_context));
+ g_object_unref(mw_data->current_tab->traceset_info->traceset_context);
+
lttv_traceset_add(traceset, trace_v);
+
+ /* Create new context */
mw_data->current_tab->traceset_info->traceset_context =
g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
lttv_context_init(
//add state update hooks
lttv_state_add_event_hooks(
(LttvTracesetState*)mw_data->current_tab->traceset_info->traceset_context);
- if(tmp_context != NULL)
+ //Remove local reference to the traces.
+ for(i=0; i<lttv_traceset_number(traceset); i++)
{
- //remove state update hooks
- lttv_state_remove_event_hooks(
- (LttvTracesetState*)tmp_context);
- lttv_context_fini(LTTV_TRACESET_CONTEXT(tmp_context));
- g_object_unref(tmp_context);
+ LttvTrace * trace = lttv_traceset_get(traceset, i);
+ lttv_trace_unref(trace);
}
-
add_trace_into_traceset_selector(mw_data->current_tab->multi_vpaned, trace);
gtk_widget_destroy((GtkWidget*)file_selector);
//update current tab
- update_traceset(mw_data);
+ //update_traceset(mw_data);
//get_traceset_time_span(mw_data,LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)->Time_Span);
- if(lttv_traceset_number(mw_data->current_tab->traceset_info->traceset) == 1 ||
- ltt_time_compare(mw_data->current_tab->current_time,
- LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)->Time_Span->startTime)<0){
- mw_data->current_tab->current_time =
- LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)->Time_Span->startTime;
- mw_data->current_tab->time_window.start_time = mw_data->current_tab->current_time;
- mw_data->current_tab->time_window.time_width.tv_sec = DEFAULT_TIME_WIDTH_S;
- mw_data->current_tab->time_window.time_width.tv_nsec = 0;
+ if(
+ lttv_traceset_number(mw_data->current_tab->traceset_info->traceset) == 1
+ || ltt_time_compare(mw_data->current_tab->current_time,
+ LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->
+ traceset_context)->Time_Span->startTime)<0)
+ {
+ /* Set initial time if this is the first trace in the traceset */
+ mw_data->current_tab->current_time =
+ LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->
+ traceset_context)->Time_Span->startTime;
+ mw_data->current_tab->time_window.start_time =
+ mw_data->current_tab->current_time;
+ mw_data->current_tab->time_window.time_width.tv_sec =
+ DEFAULT_TIME_WIDTH_S;
+ mw_data->current_tab->time_window.time_width.tv_nsec = 0;
}
- redraw_viewer(mw_data, &(mw_data->current_tab->time_window));
- lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
+ /* Call the updatetraceset hooks */
+
+ SetTraceset(mw_data, (gpointer)traceset);
+ // in expose now call_pending_read_hooks(mw_data);
+
+ //lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
break;
case GTK_RESPONSE_REJECT:
case GTK_RESPONSE_CANCEL:
LttTrace *trace;
LttvTrace * trace_v;
LttvTraceset * traceset;
- LttvTracesetStats* tmp_context;
- gint i, nb_trace;
+ gint i, j, nb_trace;
char ** name, *remove_trace_name;
MainWindow * mw_data = get_window_data_struct(widget);
LttvTracesetSelector * s;
trace_v = lttv_traceset_get(traceset, i);
if(lttv_trace_get_ref_number(trace_v) <= 1)
ltt_trace_close(lttv_trace(trace_v));
-
- // Keep the context until the new one is created.
- tmp_context = mw_data->current_tab->traceset_info->traceset_context;
- mw_data->current_tab->traceset_info->traceset_context = NULL;
+
+ //Keep a reference to the traces so they are not freed.
+ for(j=0; j<lttv_traceset_number(traceset); j++)
+ {
+ LttvTrace * trace = lttv_traceset_get(traceset, j);
+ lttv_trace_ref(trace);
+ }
+
+ //remove state update hooks
+ lttv_state_remove_event_hooks(
+ (LttvTracesetState*)mw_data->current_tab->traceset_info->traceset_context);
+ lttv_context_fini(LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context));
+ g_object_unref(mw_data->current_tab->traceset_info->traceset_context);
+
lttv_traceset_remove(traceset, i);
+ lttv_trace_unref(trace_v); // Remove local reference
if(!lttv_trace_get_ref_number(trace_v))
lttv_trace_destroy(trace_v);
+
mw_data->current_tab->traceset_info->traceset_context =
g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
- lttv_context_init(
+ lttv_context_init(
LTTV_TRACESET_CONTEXT(mw_data->current_tab->
traceset_info->traceset_context),traceset);
//add state update hooks
- lttv_state_add_event_hooks(
+ lttv_state_add_event_hooks(
(LttvTracesetState*)mw_data->current_tab->traceset_info->traceset_context);
- if(tmp_context != NULL){
- //remove state update hooks
- lttv_state_remove_event_hooks(
- (LttvTracesetState*)tmp_context);
- lttv_context_fini(LTTV_TRACESET_CONTEXT(tmp_context));
- g_object_unref(tmp_context);
- }
+ //Remove local reference to the traces.
+ for(j=0; j<lttv_traceset_number(traceset); j++)
+ {
+ LttvTrace * trace = lttv_traceset_get(traceset, j);
+ lttv_trace_unref(trace);
+ }
+
-
//update current tab
- update_traceset(mw_data);
+ //update_traceset(mw_data);
if(nb_trace > 1){
- redraw_viewer(mw_data, &(mw_data->current_tab->time_window));
- lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
+
+ SetTraceset(mw_data, (gpointer)traceset);
+ // in expose now call_pending_read_hooks(mw_data);
+
+ //lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
}else{
if(mw_data->current_tab){
while(mw_data->current_tab->multi_vpaned->num_children){
/* save will save the traceset to a file
- * Not implemented yet
+ * Not implemented yet FIXME
*/
void save(GtkWidget * widget, gpointer user_data)
void zoom(GtkWidget * widget, double size)
{
TimeInterval *time_span;
- TimeWindow time_window;
- LttTime current_time, time_delta, time_s, time_e, time_t;
+ TimeWindow new_time_window;
+ LttTime current_time, time_delta, time_s, time_e, time_tmp;
MainWindow * mw_data = get_window_data_struct(widget);
if(size == 1) return;
time_span = LTTV_TRACESET_CONTEXT(mw_data->current_tab->
traceset_info->traceset_context)->Time_Span;
- time_window = mw_data->current_tab->time_window;
+ new_time_window = mw_data->current_tab->time_window;
current_time = mw_data->current_tab->current_time;
time_delta = ltt_time_sub(time_span->endTime,time_span->startTime);
if(size == 0){
- time_window.start_time = time_span->startTime;
- time_window.time_width = time_delta;
+ new_time_window.start_time = time_span->startTime;
+ new_time_window.time_width = time_delta;
}else{
- time_window.time_width = ltt_time_div(time_window.time_width, size);
- if(ltt_time_compare(time_window.time_width,time_delta) > 0)
- time_window.time_width = time_delta;
-
- time_t = ltt_time_div(time_window.time_width, 2);
- if(ltt_time_compare(current_time, time_t) < 0){
- time_s = time_span->startTime;
- } else {
- time_s = ltt_time_sub(current_time,time_t);
+ new_time_window.time_width = ltt_time_div(new_time_window.time_width, size);
+ if(ltt_time_compare(new_time_window.time_width,time_delta) > 0)
+ { /* Case where zoom out is bigger than trace length */
+ new_time_window.start_time = time_span->startTime;
+ new_time_window.time_width = time_delta;
}
- time_e = ltt_time_add(current_time,time_t);
- if(ltt_time_compare(time_span->startTime, time_s) > 0){
- time_s = time_span->startTime;
- }else if(ltt_time_compare(time_span->endTime, time_e) < 0){
- time_e = time_span->endTime;
- time_s = ltt_time_sub(time_e,time_window.time_width);
+ else
+ {
+ /* Center the image on the current time */
+ g_critical("update is HERE");
+ new_time_window.start_time =
+ ltt_time_sub(current_time, ltt_time_div(new_time_window.time_width, 2.0));
+ /* If on borders, don't fall off */
+ if(ltt_time_compare(new_time_window.start_time, time_span->startTime) <0)
+ {
+ new_time_window.start_time = time_span->startTime;
+ }
+ else
+ {
+ if(ltt_time_compare(
+ ltt_time_add(new_time_window.start_time, new_time_window.time_width),
+ time_span->endTime) > 0)
+ {
+ new_time_window.start_time =
+ ltt_time_sub(time_span->endTime, new_time_window.time_width);
+ }
+ }
+
}
- time_window.start_time = time_s;
+
+
+
+ //time_tmp = ltt_time_div(new_time_window.time_width, 2);
+ //if(ltt_time_compare(current_time, time_tmp) < 0){
+ // time_s = time_span->startTime;
+ //} else {
+ // time_s = ltt_time_sub(current_time,time_tmp);
+ //}
+ //time_e = ltt_time_add(current_time,time_tmp);
+ //if(ltt_time_compare(time_span->startTime, time_s) > 0){
+ // time_s = time_span->startTime;
+ //}else if(ltt_time_compare(time_span->endTime, time_e) < 0){
+ // time_e = time_span->endTime;
+ // time_s = ltt_time_sub(time_e,new_time_window.time_width);
+ //}
+ //new_time_window.start_time = time_s;
}
- redraw_viewer(mw_data, &time_window);
- lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
- gtk_multi_vpaned_set_adjust(mw_data->current_tab->multi_vpaned, FALSE);
+
+ //lttvwindow_report_time_window(mw_data, &new_time_window);
+ //call_pending_read_hooks(mw_data);
+
+ //lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
+ set_time_window(mw_data, &new_time_window);
+ // in expose now call_pending_read_hooks(mw_data);
+ gtk_multi_vpaned_set_adjust(mw_data->current_tab->multi_vpaned, &new_time_window, FALSE);
}
void zoom_in(GtkWidget * widget, gpointer user_data)
strcpy(label,"Page");
if(get_label(mw_data, label,"Get the name of the tab","Please input tab's name"))
- create_tab (mw_data, mw_data, notebook, label);
+ create_tab (NULL, mw_data, notebook, label);
}
void
return;
}
if(get_filter_selection(s, "Configure trace and tracefile filter", "Select traces and tracefiles")){
- update_traceset(mw_data);
- redraw_viewer(mw_data, &(mw_data->current_tab->time_window));
- lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
+ //FIXME report filter change
+ //update_traceset(mw_data);
+ //call_pending_read_hooks(mw_data);
+ //lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
}
}
return FALSE;
}
-
/* Set current tab
*/
new_window = create_MWindow();
gtk_widget_show (new_window);
- new_m_window->attributes = attributes;
-
new_m_window->mwindow = new_window;
new_m_window->tab = NULL;
new_m_window->current_tab = NULL;
- new_m_window->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
+ new_m_window->attributes = attributes;
new_m_window->hash_menu_item = g_hash_table_new_full (g_str_hash, g_str_equal,
main_window_destroy_hash_key,
insert_menu_toolbar_item(new_m_window, NULL);
g_object_set_data(G_OBJECT(new_window), "mainWindow", (gpointer)new_m_window);
-
//create a default tab
notebook = (GtkNotebook *)lookup_widget(new_m_window->mwindow, "MNotebook");
if(notebook == NULL){
}
//for now there is no name field in LttvTraceset structure
//Use "Traceset" as the label for the default tab
- create_tab(parent, new_m_window, notebook,"Traceset");
+ create_tab(parent, new_m_window, notebook, "Traceset");
g_object_set_data_full(
G_OBJECT(new_m_window->mwindow),
// lttv_trace_destroy(trace);
}
}
- lttv_traceset_destroy(tab_instance->traceset_info->traceset);
+ lttv_traceset_destroy(tab_instance->traceset_info->traceset);
+ g_array_free(tab_instance->time_requests, TRUE);
g_free(tab_instance->traceset_info);
g_free(tab_instance);
}
Tab * tmp_tab;
MainWindow * mw_data = current_window;
LttTime tmp_time;
-
+
//create a new tab data structure
tmp_tab = mw_data->tab;
while(tmp_tab && tmp_tab->next) tmp_tab = tmp_tab->next;
//construct and initialize the traceset_info
tmp_tab->traceset_info = g_new(TracesetInfo,1);
if(parent){
- tmp_tab->traceset_info->traceset =
- lttv_traceset_copy(parent->current_tab->traceset_info->traceset);
- }else{
+ if(parent->current_tab){
+ tmp_tab->traceset_info->traceset =
+ lttv_traceset_new();
+ //FIXME lttv_traceset_copy(parent->current_tab->traceset_info->traceset);
+ }else{
+ tmp_tab->traceset_info->traceset = lttv_traceset_new();
+ }
+
+ }else{ /* Initial window */
if(mw_data->current_tab){
tmp_tab->traceset_info->traceset =
- lttv_traceset_copy(mw_data->current_tab->traceset_info->traceset);
+ lttv_traceset_new();
+ //FIXME lttv_traceset_copy(mw_data->current_tab->traceset_info->traceset);
}else{
tmp_tab->traceset_info->traceset = lttv_traceset_new();
/* Add the command line trace */
- if(g_init_trace != NULL)
+ if(g_init_trace != NULL){
lttv_traceset_add(tmp_tab->traceset_info->traceset, g_init_trace);
+ }
}
}
+
//FIXME copy not implemented in lower level
tmp_tab->traceset_info->traceset_context =
g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
+ g_assert(tmp_tab->traceset_info->traceset_context != NULL);
lttv_context_init(
LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context),
tmp_tab->traceset_info->traceset);
lttv_state_add_event_hooks(
(LttvTracesetState*)tmp_tab->traceset_info->traceset_context);
-
//determine the current_time and time_window of the tab
if(mw_data->current_tab){
// Will have to read directly at the main window level, as we want
tmp_tab->current_time.tv_nsec =
LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->startTime.tv_nsec;
}
+ /* Become the current tab */
+ mw_data->current_tab = tmp_tab;
+
tmp_tab->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
- // mw_data->current_tab = tmp_tab;
tmp_tab->multi_vpaned = (GtkMultiVPaned*)gtk_multi_vpaned_new();
tmp_tab->multi_vpaned->mw = mw_data;
gtk_widget_show((GtkWidget*)tmp_tab->multi_vpaned);
tmp_tab->label = gtk_label_new (label);
gtk_widget_show (tmp_tab->label);
+ tmp_tab->time_requests = g_array_new(FALSE, FALSE, sizeof(TimeRequest));
+ tmp_tab->time_request_pending = FALSE;
+
g_object_set_data_full(
G_OBJECT(tmp_tab->multi_vpaned),
"Tab_Info",
gtk_notebook_append_page(notebook, (GtkWidget*)tmp_tab->multi_vpaned, tmp_tab->label);
list = gtk_container_get_children(GTK_CONTAINER(notebook));
gtk_notebook_set_current_page(notebook,g_list_length(list)-1);
- if(g_list_length(list)>1)
- gtk_notebook_set_show_tabs(notebook, TRUE);
+ // always show : not if(g_list_length(list)>1)
+ gtk_notebook_set_show_tabs(notebook, TRUE);
+
}
}
}
}
+
+/**
+ * Function to show each viewer in the current tab.
+ * It will be called by main window, call show on each registered viewer,
+ * will call process traceset and then it will
+ * @param main_win the main window the viewer belongs to.
+ */
+//FIXME Only one time request maximum for now!
+void show_viewer(MainWindow *main_win)
+{
+ LttvAttributeValue value;
+ LttvHooks * tmp;
+ int i;
+ LttvTracesetContext * tsc =
+ (LttvTracesetContext*)main_win->current_tab->
+ traceset_info->traceset_context;
+
+ g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+ "hooks/showviewer", LTTV_POINTER, &value));
+ tmp = (LttvHooks*)*(value.v_pointer);
+ if(tmp == NULL)
+ {
+ g_warning("The viewer(s) did not add any show hook");
+ return;
+ }
+
+
+ // Call the show, where viewers add hooks to context and fill the
+ // time and number of events requested it the time_requests GArray.
+ lttv_hooks_call(tmp, NULL);
+
+
+}
+
+
+gboolean execute_time_requests(MainWindow * mw)
+{
+ call_pending_read_hooks(mw);
+
+ return FALSE; // automatically removed from the list of event sources
+}
+
void construct_main_window(MainWindow * parent);
void main_window_free(MainWindow * mw);
void main_window_destructor(MainWindow * mw);
+void show_viewer(MainWindow *main_win);
+
/* callback functions*/
GdkEventConfigure *event,
gpointer user_data);
+gboolean
+on_MWindow_expose (GtkWidget *widget,
+ GdkEventExpose *event,
+ gpointer user_data);
+gboolean
+on_MWindow_after (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
+
+
+
void
on_insert_viewer_test_activate (GtkMenuItem *menuitem,
gpointer user_data);
GtkNotebookPage *page,
guint page_num,
gpointer user_data);
+
+gboolean execute_time_requests(MainWindow * mw);
static void gtk_multi_vpaned_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-void gtk_multi_vpaned_scroll_value_changed (GtkRange *range, gpointer multi_vpaned);
+void gtk_multi_vpaned_scroll_value_changed (GtkAdjustment *adjust, gpointer multi_vpaned);
gboolean gtk_multi_vpaned_destroy(GtkObject *object,
gpointer user_data)
}
}
-void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, gboolean first_time)
+void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, const TimeWindow *time_window, gboolean first_time)
{
- TimeWindow time_window = multi_vpaned->mw->current_tab->time_window;
+ //TimeWindow time_window = multi_vpaned->mw->current_tab->time_window;
TimeInterval *time_span;
- double tmp, start;
- double range = 0;
+ double len, start;
if(first_time){
return;
}
- start = ltt_time_to_double(time_window.start_time) * NANOSECONDS_PER_SECOND;
- tmp = multi_vpaned->hadjust->upper - multi_vpaned->hadjust->lower;
+ start = ltt_time_to_double(time_window->start_time) * NANOSECONDS_PER_SECOND;
+ len = multi_vpaned->hadjust->upper - multi_vpaned->hadjust->lower;
multi_vpaned->hadjust->page_increment = ltt_time_to_double(
- time_window.time_width) * NANOSECONDS_PER_SECOND;
+ time_window->time_width) * NANOSECONDS_PER_SECOND;
- if(multi_vpaned->hadjust->page_increment >= tmp - range)
- multi_vpaned->hadjust->value = multi_vpaned->hadjust->lower;
- if(start + multi_vpaned->hadjust->page_increment >= multi_vpaned->hadjust->upper - range)
- multi_vpaned->hadjust->value = start;
+ //if(multi_vpaned->hadjust->page_increment >= len )
+ // multi_vpaned->hadjust->value = multi_vpaned->hadjust->lower;
+ //if(start + multi_vpaned->hadjust->page_increment >= multi_vpaned->hadjust->upper )
+ // multi_vpaned->hadjust->value = start;
+ multi_vpaned->hadjust->value = start;
/* page_size to the whole visible area will take care that the
* scroll value + the shown area will never be more than what is
multi_vpaned->hadjust->step_increment = multi_vpaned->hadjust->page_increment / 10;
gtk_adjustment_changed (multi_vpaned->hadjust);
+
}
void gtk_multi_vpaned_widget_add(GtkMultiVPaned * multi_vpaned, GtkWidget * widget1)
gtk_widget_show(multi_vpaned->hscrollbar);
multi_vpaned->hadjust = gtk_range_get_adjustment(GTK_RANGE(multi_vpaned->hscrollbar));
- gtk_multi_vpaned_set_adjust(multi_vpaned, TRUE);
+ gtk_multi_vpaned_set_adjust(multi_vpaned, &multi_vpaned->mw->current_tab->time_window, TRUE);
gtk_range_set_update_policy (GTK_RANGE(multi_vpaned->hscrollbar),
GTK_UPDATE_CONTINUOUS);
//changed by Mathieu Desnoyers, was :
// GTK_UPDATE_DISCONTINUOUS);
- g_signal_connect(G_OBJECT(multi_vpaned->hscrollbar), "value-changed",
+ g_signal_connect(G_OBJECT(multi_vpaned->hadjust), "value-changed",
G_CALLBACK(gtk_multi_vpaned_scroll_value_changed), multi_vpaned);
+ g_signal_connect(G_OBJECT(multi_vpaned->hadjust), "changed",
+ G_CALLBACK(gtk_multi_vpaned_scroll_value_changed), multi_vpaned);
+
multi_vpaned->vbox = gtk_vbox_new(FALSE,0);
gtk_widget_show(multi_vpaned->vbox);
void gtk_multi_vpaned_set_scroll_value(GtkMultiVPaned * multi_vpaned, double value)
{
gtk_adjustment_set_value(multi_vpaned->hadjust, value);
- g_signal_stop_emission_by_name(G_OBJECT(multi_vpaned->hscrollbar), "value-changed");
+ //g_signal_stop_emission_by_name(G_OBJECT(multi_vpaned->hscrollbar), "value-changed");
}
-void gtk_multi_vpaned_scroll_value_changed(GtkRange *range, gpointer multi_vpaned_arg)
+void gtk_multi_vpaned_scroll_value_changed(GtkAdjustment *adjust, gpointer multi_vpaned_arg)
{
TimeWindow time_window;
TimeInterval *time_span;
LttTime time;
GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned*)multi_vpaned_arg;
- gdouble value = gtk_range_get_value(range);
+ gdouble value = gtk_adjustment_get_value(adjust);
gdouble upper, lower, ratio;
time_window = multi_vpaned->mw->current_tab->time_window;
if(ltt_time_compare(time,time_window.time_width) < 0){
time_window.time_width = time;
}
- lttvwindow_report_time_window(multi_vpaned->mw, &time_window);
+ set_time_window(multi_vpaned->mw, &time_window);
+ // done in expose now call_pending_read_hooks(multi_vpaned->mw);
}
void gtk_multi_vpaned_widget_delete(GtkMultiVPaned * multi_vpaned);
void gtk_multi_vpaned_widget_move_up(GtkMultiVPaned * multi_vpaned);
void gtk_multi_vpaned_widget_move_down(GtkMultiVPaned * multi_vpaned);
-void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, gboolean first_time);
+void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, const TimeWindow * time_window, gboolean first_time);
void gtk_multi_vpaned_set_data(GtkMultiVPaned * multi_vpaned, char * key, gpointer value);
gpointer gtk_multi_vpaned_get_data(GtkMultiVPaned * multi_vpaned, char * key);
GtkWidget * gtk_multi_vpaned_get_widget(GtkMultiVPaned * multi_vpaned);
g_signal_connect ((gpointer) MWindow, "configure-event",
G_CALLBACK (on_MWindow_configure),
NULL);
+
// g_signal_connect ((gpointer) EmptyTraceset, "activate",
// G_CALLBACK (on_empty_traceset_activate),
// NULL);
/* Traceset related information */
TracesetInfo * traceset_info;
+
+ /* A list of time requested for the next process trace */
+ GArray *time_requests;
+ gboolean time_request_pending;
};
+typedef struct _TimeRequest {
+ TimeWindow time_window;
+ guint num_events;
+ LttvHook after_hook;
+ gpointer after_hook_data;
+} TimeRequest;
+
/**
* Remove menu and toolbar item when a module unloaded
*/
*
*/
-#include <lttvwindow/common.h>
#include <ltt/ltt.h>
#include <lttv/lttv.h>
+#include <lttv/state.h>
+#include <lttv/stats.h>
+#include <lttv/tracecontext.h>
+#include <lttvwindow/common.h>
#include <lttvwindow/mainwindow.h>
#include <lttvwindow/viewer.h>
-#include <lttv/tracecontext.h>
#include <lttvwindow/toolbar.h>
#include <lttvwindow/menu.h>
-#include <lttv/state.h>
-#include <lttv/stats.h>
+#include <lttvwindow/callbacks.h> // for execute_time_requests
/**
tmp = (LttvHooks*)*(value.v_pointer);
if(tmp == NULL) return 1;
+
lttv_hooks_call(tmp,traceset);
-
+
return 0;
}
lttv_hooks_call(tmp, NULL);
}
+void set_time_window_adjustment(MainWindow * main_win, const TimeWindow* new_time_window)
+{
+ gtk_multi_vpaned_set_adjust(main_win->current_tab->multi_vpaned, new_time_window, FALSE);
+}
-/**
- * Function to show each viewer in the current tab.
- * It will be called by main window after it called process_traceset
- * @param main_win the main window the viewer belongs to.
- */
-
-void show_viewer(MainWindow *main_win)
+void set_time_window(MainWindow * main_win, const TimeWindow *time_window)
{
LttvAttributeValue value;
LttvHooks * tmp;
+
+ TimeWindowNotifyData time_window_notify_data;
+ TimeWindow old_time_window = main_win->current_tab->time_window;
+ time_window_notify_data.old_time_window = &old_time_window;
+ main_win->current_tab->time_window = *time_window;
+ time_window_notify_data.new_time_window =
+ &(main_win->current_tab->time_window);
+
g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
- "hooks/showviewer", LTTV_POINTER, &value));
+ "hooks/updatetimewindow", LTTV_POINTER, &value));
tmp = (LttvHooks*)*(value.v_pointer);
if(tmp == NULL) return;
- lttv_hooks_call(tmp, NULL);
-}
-
+ lttv_hooks_call(tmp, &time_window_notify_data);
+}
/**
* API parts
lttv_hooks_remove_data(tmp, hook, hook_data);
}
-
/**
* Function to register a hook function for a viewer to set/update its
* current time.
* @param main_win the main window the viewer belongs to.
*/
-void lttvwindow_register_show(MainWindow *main_win,
+void lttvwindow_register_show_notify(MainWindow *main_win,
LttvHook hook, gpointer hook_data)
{
LttvAttributeValue value;
* @param main_win the main window the viewer belongs to.
*/
-void lttvwindow_unregister_show(MainWindow * main_win,
+void lttvwindow_unregister_show_notify(MainWindow * main_win,
LttvHook hook, gpointer hook_data)
{
LttvAttributeValue value;
void lttvwindow_report_time_window(MainWindow *main_win,
TimeWindow *time_window)
{
- LttvAttributeValue value;
- LttvHooks * tmp;
-
- TimeWindowNotifyData time_window_notify_data;
- TimeWindow old_time_window = main_win->current_tab->time_window;
- time_window_notify_data.old_time_window = &old_time_window;
- main_win->current_tab->time_window = *time_window;
- time_window_notify_data.new_time_window =
- &(main_win->current_tab->time_window);
-
- gtk_multi_vpaned_set_scroll_value(main_win->current_tab->multi_vpaned,
- ltt_time_to_double(time_window->start_time)
- * NANOSECONDS_PER_SECOND );
- g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
- "hooks/updatetimewindow", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL) return;
- lttv_hooks_call(tmp, &time_window_notify_data);
+ set_time_window(main_win, time_window);
+ set_time_window_adjustment(main_win, time_window);
}
+
/**
* Function to set the current time/event of the current tab.
* It will be called by a viewer's signal handle associated with
}
+/**
+ * Function to request data in a specific time interval to the main window.
+ * The main window will use this time interval and the others present
+ * to get the data from the process trace.
+ * @param main_win the main window the viewer belongs to.
+ * @param paned a pointer to a pane where the viewer is contained.
+ */
+
+void lttvwindow_time_interval_request(MainWindow *main_win,
+ TimeWindow time_requested, guint num_events,
+ LttvHook after_process_traceset,
+ gpointer after_process_traceset_data)
+{
+ TimeRequest time_request;
+
+ time_request.time_window = time_requested;
+ time_request.num_events = num_events;
+ time_request.after_hook = after_process_traceset;
+ time_request.after_hook_data = after_process_traceset_data;
+
+ g_array_append_val(main_win->current_tab->time_requests, time_request);
+
+ if(!main_win->current_tab->time_request_pending)
+ {
+ /* Redraw has +20 priority. We want a prio higher than that, so +19 */
+ g_idle_add_full((G_PRIORITY_HIGH_IDLE + 19),
+ (GSourceFunc)execute_time_requests,
+ main_win,
+ NULL);
+ main_win->current_tab->time_request_pending = TRUE;
+ }
+}
+
+
/**
* Function to get the current time interval of the current traceset.
* @param main_win the main window the viewer belongs to.
*/
-void lttvwindow_register_show(MainWindow *main_win,
+void lttvwindow_register_show_notify(MainWindow *main_win,
LttvHook hook, gpointer hook_data);
* @param main_win the main window the viewer belongs to.
*/
-void lttvwindow_unregister_show(MainWindow * main_win,
+void lttvwindow_unregister_show_notify(MainWindow * main_win,
LttvHook hook, gpointer hook_data);
//FIXME : can we do this through normal GTK signals ?
void lttvwindow_report_focus(MainWindow *main_win, gpointer paned);
+
+/**
+ * Function to request data in a specific time interval to the main window.
+ * The main window will use this time interval and the others present
+ * to get the data from the process trace.
+ * @param main_win the main window the viewer belongs to.
+ * @param paned a pointer to a pane where the viewer is contained.
+ */
+
+void lttvwindow_time_interval_request(MainWindow *main_win,
+ TimeWindow time_requested, guint num_events,
+ LttvHook after_process_traceset,
+ gpointer after_process_traceset_data);
+
/**
* Function to get the life span of the traceset
* @param main_win the main window the viewer belongs to.
if(statistic_viewer_data){
lttvwindow_unregister_time_window_notify(statistic_viewer_data->mw,
statistic_update_time_window,statistic_viewer_data);
- lttvwindow_unregister_show(statistic_viewer_data->mw,
+ lttvwindow_unregister_show_notify(statistic_viewer_data->mw,
statistic_show_viewer,statistic_viewer_data);
lttvwindow_unregister_traceset_notify(statistic_viewer_data->mw,
statistic_traceset_changed,statistic_viewer_data);
lttvwindow_register_time_window_notify(statistic_viewer_data->mw,
statistic_update_time_window,statistic_viewer_data);
- lttvwindow_register_show(statistic_viewer_data->mw,
+ lttvwindow_register_show_notify(statistic_viewer_data->mw,
statistic_show_viewer,statistic_viewer_data);
lttvwindow_register_traceset_notify(statistic_viewer_data->mw,
statistic_traceset_changed,statistic_viewer_data);