//#include <pango/pango.h>
-#include <ltt/event.h>
-#include <ltt/time.h>
-#include <ltt/trace.h>
-
#include <lttv/lttv.h>
#include <lttv/hook.h>
#include <lttv/state.h>
// fixed #define TRACE_NUMBER 0
#define EXTRA_ALLOC 1024 // pixels
-/* Action to do when background computation completed.
- *
- * Wait for all the awaited computations to be over.
- */
-
-static gint histo_background_ready(void *hook_data, void *call_data)
-{
- HistoControlFlowData *histocontrol_flow_data = (HistoControlFlowData *)hook_data;
- LttvTrace *trace = (LttvTrace*)call_data;
-
- histoDrawing_t *drawing = histocontrol_flow_data->drawing;
- histocontrol_flow_data->background_info_waiting--;
-
- if(histocontrol_flow_data->background_info_waiting == 0) {
- g_message("Histocontrol flow viewer : background computation data ready.");
-
- histo_drawing_clear(drawing,0,drawing->width);
-
- gtk_widget_set_size_request(drawing->drawing_area,
- -1, -1);
- histo_redraw_notify(histocontrol_flow_data, NULL);
- }
-
- return 0;
-}
-
-
-/* Request background computation. Verify if it is in progress or ready first.
- * Only for each trace in the tab's traceset.
+/*
+ * Most functions here are inspired from the controlflow module.
+ * Look in gui/controlflow/eventhooks.c if you need to add more functionality
*/
-static void histo_request_background_data(HistoControlFlowData *histocontrol_flow_data)
-{
- LttvTracesetContext * tsc =
- lttvwindow_get_traceset_context(histocontrol_flow_data->tab);
- gint num_traces = lttv_traceset_number(tsc->ts);
- gint i;
- LttvTrace *trace;
- LttvTraceState *tstate;
-
- LttvHooks *histo_background_ready_hook =
- lttv_hooks_new();
- lttv_hooks_add(histo_background_ready_hook, histo_background_ready, histocontrol_flow_data,
- LTTV_PRIO_DEFAULT);
- histocontrol_flow_data->background_info_waiting = 0;
-
- for(i=0;i<num_traces;i++) {
- trace = lttv_traceset_get(tsc->ts, i);
- tstate = LTTV_TRACE_STATE(tsc->traces[i]);
-
- if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE
- && !tstate->has_precomputed_states) {
-
- if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
- trace) == FALSE) {
- /* We first remove requests that could have been done for the same
- * information. Happens when two viewers ask for it before servicing
- * starts.
- */
- if(!lttvwindowtraces_background_request_find(trace, "state"))
- lttvwindowtraces_background_request_queue(
- main_window_get_widget(histocontrol_flow_data->tab), trace, "state");
- lttvwindowtraces_background_notify_queue(histocontrol_flow_data,
- trace,
- ltt_time_infinite,
- NULL,
- histo_background_ready_hook);
- histocontrol_flow_data->background_info_waiting++;
- } else { /* in progress */
-
- lttvwindowtraces_background_notify_current(histocontrol_flow_data,
- trace,
- ltt_time_infinite,
- NULL,
- histo_background_ready_hook);
- histocontrol_flow_data->background_info_waiting++;
- }
- } else {
- /* Data ready. Be its nature, this viewer doesn't need to have
- * its data ready hook called there, because a background
- * request is always linked with a redraw.
- */
- }
-
- }
-
- lttv_hooks_destroy(histo_background_ready_hook);
-}
/**
* Histogram Viewer's constructor hook
TimeWindow time_window = lttvwindow_get_time_window( tab );
LttTime time_start, time_end;
- LttvTraceState *ts;
-
//find the tracehooks
- LttvTracesetContext *tsc = lttvwindow_get_traceset_context(tab);
+ LttvTraceset *traceset = lttvwindow_get_traceset(tab);
- LttvTraceset *traceset = tsc->ts;
nb_trace = lttv_traceset_number(traceset);
guint drawing_width= histocontrol_flow_data->drawing->width;
//start time for chunk.
// LttvHooksById *histo_event_by_id = lttv_hooks_by_id_new();//if necessary for filter!
// FIXME : eventually request for more traces
// fixed for(i = 0; i<MIN(TRACE_NUMBER+1, nb_trace);i++) {
+ //TODO ybrosseau 2012-07-10: Just do one request
for(i=0;i<nb_trace;i++) {
//should be in the loop or before?
EventsRequest *histo_events_request = g_new(EventsRequest, 1);
histo_after_chunk,
histo_events_request,
LTTV_PRIO_DEFAULT);
- ts = (LttvTraceState *)tsc->traces[i];
// Fill the events request
histo_events_request->owner = histocontrol_flow_data;
histo_events_request->viewer_data = histocontrol_flow_data;
histo_events_request->before_chunk_trace = NULL;
histo_events_request->before_chunk_tracefile= NULL;
histo_events_request->event = histo_count_event_hooks;
- histo_events_request->event_by_id_channel = NULL;//histo_event_by_id;//NULL;
histo_events_request->after_chunk_tracefile = NULL;
histo_events_request->after_chunk_trace = NULL;
histo_events_request->after_chunk_traceset = histo_after_chunk_traceset;//NULL;
int histo_count_event(void *hook_data, void *call_data){
guint x;//time to pixel
- guint i;// number of events
LttTime event_time;
- LttEvent *e;
+ LttvEvent *e;
guint *element;
EventsRequest *events_request = (EventsRequest*)hook_data;
g_info("Histogram: count_event() \n");
-
- LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
- LttvTracefileState *tfs = (LttvTracefileState *)call_data;
-
- e = ltt_tracefile_get_event(tfc->tf);
-
+ e = (LttvEvent *)call_data;
+#ifdef BABEL_CLEANUP
LttvFilter *histo_filter = histocontrol_flow_data->histo_main_win_filter;
if(histo_filter != NULL && histo_filter->head != NULL)
if(!lttv_filter_tree_parse(histo_filter->head,e,tfc->tf,
tfc->t_context->t,tfc,NULL,NULL))
return FALSE;
-
+#endif
TimeWindow time_window = lttvwindow_get_time_window(histocontrol_flow_data->tab);
- event_time = ltt_event_time(e);
+ event_time = lttv_event_get_timestamp(e);
histo_convert_time_to_pixels(
time_window,
return 0;
}
-
+/* TODO ybrosseau 2012-03-15: Cleanup line_src */
void histogram_show(HistoControlFlowData *histocontrol_flow_data,guint draw_begin,
guint draw_end)
{
GDK_JOIN_MITER);*/
//clean the area!
histo_drawing_clear(drawing,draw_begin,draw_end);
- LttTime t1,t2;
+ LttTime t1, t2;
TimeWindow time_window =
lttvwindow_get_time_window(histocontrol_flow_data->tab);
- guint val,h_val;
+ guint val, h_val;
- guint i,line_src,line_end;
+ guint i/*, line_src*/;
guint end_chunk=MIN(draw_end,(histocontrol_flow_data->number_of_process)->len);
for (i=draw_begin/*0*/;i<end_chunk/* (histocontrol_flow_data->number_of_process)->len*/;i++){
histo_convert_pixels_to_time(width, i+1,
time_window,
&t2);
- line_src=i;
+ /* line_src=i; */
//check if zoom in is used and more than 1 pixel correspond to each 1nsec
//used for drawing point (not line) on the screen.
int histo_event_selected_hook(void *hook_data, void *call_data)
{
- HistoControlFlowData *histocontrol_flow_data = (HistoControlFlowData*) hook_data;
guint *event_number = (guint*) call_data;
g_debug("DEBUG : event selected by main window : %u", *event_number);
//show number of event at current time
histo_drawing_update_vertical_ruler(drawing);
-
-#if 0
-
-/*// if( histo_new_time_window->time_width.tv_sec == histo_old_time_window->time_width.tv_sec
- && histo_new_time_window->time_width.tv_nsec == histo_old_time_window->time_width.tv_nsec)
- {
- // Same scale (scrolling)
- g_info("scrolling");
- /* For histogram,
- while scrolling no matter far or near ,
- right or left it's necessary to redraw whole screen!*/
-/*// LttTime *ns = &histo_new_time_window->start_time;
- LttTime *nw = &histo_new_time_window->time_width;
- LttTime *os = &histo_old_time_window->start_time;
- LttTime *ow = &histo_old_time_window->time_width;
- LttTime histo_old_end = histo_old_time_window->end_time;
- LttTime histo_new_end = histo_new_time_window->end_time;
- //if(ns<os+w<ns+w)
- //if(ns<os+w && os+w<ns+w)
- //if(ns<histo_old_end && os<ns)
-
- //added for histogram
- gtk_widget_queue_draw(drawing->drawing_area);
-
- drawing->damage_begin = 0;
- drawing->damage_end = drawing->width;
-
- //replaced for hisogram
- histo_request_event(histocontrol_flow_data,drawing->damage_begin,
- drawing->damage_end- drawing->damage_begin);
-/*
- if(ltt_time_compare(*ns, histo_old_end) == -1
- && ltt_time_compare(*os, *ns) == -1)
- {
- g_info("scrolling near right");
- // Scroll right, keep right part of the screen
- guint x = 0;
- guint width = drawing->width;
- histo_convert_time_to_pixels(
- *histo_old_time_window,
- *ns,
- width,
- &x);
-
- // Copy old data to new location
- //replaced for histogram:
- histo_copy_pixmap_region(drawing,NULL,
- drawing->drawing_area->style->black_gc,//drawing->gc,
- NULL,
- x, 0,
- 0, 0, (drawing->width-x)
- , -1);
-
- if(drawing->damage_begin == drawing->damage_end)
- drawing->damage_begin = drawing->width-x;
- else
- drawing->damage_begin = 0;
-
- drawing->damage_end = drawing->width;
-
-//(histo) copy corresponding array region too:
- guint i;
-
- for(i=0; i < histocontrol_flow_data->number_of_process->len-x;i++)
- {
- g_array_index(histocontrol_flow_data->number_of_process, guint, i) =
- g_array_index(histocontrol_flow_data->number_of_process, guint, i+x);
- }
-
- // Clear the data request background, but not SAFETY
-
-
-//not necessary for histo, because in before chunk ,it clears the area
-/* histo_rectangle_pixmap (
- drawing->drawing_area->style->black_gc,
- TRUE,
- drawing->damage_begin, 0,
- drawing->damage_end - drawing->damage_begin, // do not overlap
- -1,drawing);
-*/
- /* gtk_widget_queue_draw(drawing->drawing_area);
- //gtk_widget_queue_draw_area (drawing->drawing_area,
- // 0,0,
- // histocontrol_flow_data->drawing->width,
- // histocontrol_flow_data->drawing->height);
-
- // Get new data for the rest.
- //replaced for hisogram
- histo_request_event(histocontrol_flow_data,drawing->damage_begin,
- drawing->damage_end- drawing->damage_begin);
- } else {
- //if(ns<os<ns+w)
- //if(ns<os && os<ns+w)
- //if(ns<os && os<histo_new_end)
- if(ltt_time_compare(*ns,*os) == -1
- && ltt_time_compare(*os,histo_new_end) == -1)
- {
- g_info("scrolling near left");
- // Scroll left, keep left part of the screen
- guint x = 0;
- guint width = drawing->width;
- histo_convert_time_to_pixels(
- *histo_new_time_window,
- *os,
- width,
- &x);
-
- // Copy old data to new location
- //replaced for histogram
-
- histo_copy_pixmap_region(drawing,NULL,
- drawing->drawing_area->style->black_gc,//drawing->gc,
- NULL,
- 0, 0,
- x, 0, -1, -1);
- //(histo) copy corresponding array region too:
- guint i;
- for(i=histocontrol_flow_data->number_of_process->len; i > x-1;i--)
- {
- g_array_index(histocontrol_flow_data->number_of_process, guint, i) =
- g_array_index(histocontrol_flow_data->number_of_process, guint, i-x);
- }
-
- if(drawing->damage_begin == drawing->damage_end)
- drawing->damage_end = x;
- else
- drawing->damage_end =
- drawing->width;
-
- drawing->damage_begin = 0;
-
-
-//not necessary for histo, because in before chunk ,it clears the area
- /* histo_rectangle_pixmap (drawing->drawing_area->style->black_gc,
- TRUE,
- drawing->damage_begin, 0,
- drawing->damage_end - drawing->damage_begin, // do not overlap
- -1,drawing);
-*/
- /* gtk_widget_queue_draw(drawing->drawing_area);
- //gtk_widget_queue_draw_area (drawing->drawing_area,
- // 0,0,
- // histocontrol_flow_data->drawing->width,
- // histocontrol_flow_data->drawing->height);
-
-
- // Get new data for the rest.
-
-//replaced for hisogram
- histo_request_event(histocontrol_flow_data,drawing->damage_begin,
- drawing->damage_end- drawing->damage_begin);
-
- } else {
- 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
-
- //not necessary for histo, because in before chunk ,it clears the area
- /* histo_rectangle_pixmap (histocontrol_flow_data->drawing->drawing_area->style->black_gc,
- TRUE,
- 0, 0,
- histocontrol_flow_data->drawing->width,//+SAFETY, // do not overlap
- -1,drawing);
-*/
- //gtk_widget_queue_draw_area (drawing->drawing_area,
- // 0,0,
- // histocontrol_flow_data->drawing->width,
- // histocontrol_flow_data->drawing->height);
-/* gtk_widget_queue_draw(drawing->drawing_area);
-
- drawing->damage_begin = 0;
- drawing->damage_end = histocontrol_flow_data->drawing->width;
-/*
- histo_drawing_data_request(histocontrol_flow_data->drawing,
- 0, 0,
- histocontrol_flow_data->drawing->width,
- histocontrol_flow_data->drawing->height);*/
- //replaced for hisogram
- /* histo_request_event(histocontrol_flow_data,drawing->damage_begin,
- drawing->damage_end- drawing->damage_begin);
- }
- }
- }
- } else {
- // Different scale (zoom)
- g_info("zoom");
-
- //not necessary for histo, because in before chunk ,it clears the area
- /*
- histo_rectangle_pixmap (drawing->drawing_area->style->black_gc,
- TRUE,
- 0, 0,
- histocontrol_flow_data->drawing->width+SAFETY, // do not overlap
- -1,drawing);
-*/
- //gtk_widget_queue_draw_area (drawing->drawing_area,
- // 0,0,
- // histocontrol_flow_data->drawing->width,
- // histocontrol_flow_data->drawing->height);
-/*// gtk_widget_queue_draw(drawing->drawing_area);
-
- drawing->damage_begin = 0;
- drawing->damage_end = drawing->width;
-
- //replaced for hisogram
- histo_request_event(histocontrol_flow_data,drawing->damage_begin,
- drawing->damage_end- drawing->damage_begin);
- }
-
- // Update directly when scrolling
- gdk_window_process_updates(drawing->drawing_area->window,
- TRUE);
-
- //show number of event at current time
-
- histo_drawing_update_vertical_ruler(drawing);
-*/
-#endif
-
-//disabled for histogram, always redraw whole screen.
return 0;
}
}
LttTime time_end = ltt_time_add(time_begin, width);
- LttvTracesetContext * tsc =
- lttvwindow_get_traceset_context(histocontrol_flow_data->tab);
-
- LttTime trace_start = tsc->time_span.start_time;
- LttTime trace_end = tsc->time_span.end_time;
+ LttvTraceset *traceset =
+ lttvwindow_get_traceset(histocontrol_flow_data->tab);
+ TimeInterval time_span = lttv_traceset_get_time_span_real(traceset);
+
+ LttTime trace_start = time_span.start_time;
+ LttTime trace_end = time_span.end_time;
g_info("Histogram: New current time HOOK : %lu, %lu", current_time.tv_sec,
current_time.tv_nsec);
HistoControlFlowData *histocontrol_flow_data = (HistoControlFlowData*)hook_data;
histoDrawing_t *drawing =histocontrol_flow_data->drawing;
- LttvTracesetContext * tsc =
- lttvwindow_get_traceset_context(histocontrol_flow_data->tab);
-
histocontrol_flow_data->histo_main_win_filter =
(LttvFilter*)call_data;
//get_events(event_viewer_data->vadjust_c->value, event_viewer_data);
typedef struct _histo_ClosureData {
EventsRequest *events_request;
- LttvTracesetState *tss;
+ LttvTraceset *traceset;
LttTime end_time;
guint x_end;
} histo_ClosureData;
int histo_before_chunk(void *hook_data, void *call_data)
{
EventsRequest *histo_events_request = (EventsRequest*)hook_data;
- LttvTracesetState *histo_tss = (LttvTracesetState*)call_data;
- HistoControlFlowData *histo_cfd = (HistoControlFlowData*)histo_events_request->viewer_data;
+ LttvTraceset *histo_traceset = (LttvTraceset*)call_data;
#if 0
/* Desactivate sort */
gtk_tree_sortable_set_sort_column_id(
TRACE_COLUMN,
GTK_SORT_ASCENDING);
#endif //0
- histo_drawing_chunk_begin(histo_events_request, histo_tss);
+ histo_drawing_chunk_begin(histo_events_request, histo_traceset);
return 0;
}
{
EventsRequest *events_request = (EventsRequest*)hook_data;
HistoControlFlowData *histocontrol_flow_data = events_request->viewer_data;
- LttvTracesetState *tss = (LttvTracesetState*)call_data;
- LttvTracesetContext *tsc = (LttvTracesetContext*)call_data;
- LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc);
LttTime end_time;
histoDrawing_t *drawing = histocontrol_flow_data->drawing;
histocontrol_flow_data->chunk_has_begun = TRUE;
+#ifdef BABEL_CLEANUP
if(tfc != NULL)
end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time);
else /* end of traceset, or position now out of request : end */
+#endif
end_time = events_request->end_time;
guint x, x_end, width;