1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Michel Dagenais
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24 #include <lttv/tracecontext.h>
25 #include <ltt/event.h>
26 #include <ltt/facility.h>
27 #include <ltt/trace.h>
29 #include <lttv/filter.h>
32 #define min(a,b) (((a)<(b))?(a):(b))
35 gint
compare_tracefile(gconstpointer a
, gconstpointer b
)
39 const LttvTracefileContext
*trace_a
= (const LttvTracefileContext
*)a
;
40 const LttvTracefileContext
*trace_b
= (const LttvTracefileContext
*)b
;
42 if(likely(trace_a
!= trace_b
)) {
43 comparison
= ltt_time_compare(trace_a
->timestamp
, trace_b
->timestamp
);
44 if(unlikely(comparison
== 0)) {
45 if(trace_a
->index
< trace_b
->index
) comparison
= -1;
46 else if(trace_a
->index
> trace_b
->index
) comparison
= 1;
47 else if(trace_a
->t_context
->index
< trace_b
->t_context
->index
)
49 else if(trace_a
->t_context
->index
> trace_b
->t_context
->index
)
56 typedef struct _LttvTracefileContextPosition
{
57 LttEventPosition
*event
;
58 LttvTracefileContext
*tfc
;
59 gboolean used
; /* Tells if the tfc is at end of traceset position */
60 } LttvTracefileContextPosition
;
63 struct _LttvTracesetContextPosition
{
64 GArray
*tfcp
; /* Array of LttvTracefileContextPosition */
65 LttTime timestamp
; /* Current time at the saved position */
66 /* If ltt_time_infinite : no position is
67 * set, else, a position is set (may be end
68 * of trace, with ep->len == 0) */
71 void lttv_context_init(LttvTracesetContext
*self
, LttvTraceset
*ts
)
73 LTTV_TRACESET_CONTEXT_GET_CLASS(self
)->init(self
, ts
);
77 void lttv_context_fini(LttvTracesetContext
*self
)
79 LTTV_TRACESET_CONTEXT_GET_CLASS(self
)->fini(self
);
84 lttv_context_new_traceset_context(LttvTracesetContext
*self
)
86 return LTTV_TRACESET_CONTEXT_GET_CLASS(self
)->new_traceset_context(self
);
93 lttv_context_new_trace_context(LttvTracesetContext
*self
)
95 return LTTV_TRACESET_CONTEXT_GET_CLASS(self
)->new_trace_context(self
);
99 LttvTracefileContext
*
100 lttv_context_new_tracefile_context(LttvTracesetContext
*self
)
102 return LTTV_TRACESET_CONTEXT_GET_CLASS(self
)->new_tracefile_context(self
);
105 /****************************************************************************
106 * lttv_traceset_context_compute_time_span
108 * Keep the time span is sync with on the fly addition and removal of traces
109 * in a trace set. It must be called each time a trace is added/removed from
110 * the traceset. It could be more efficient to call it only once a bunch
111 * of traces are loaded, but the calculation is not long, so it's not
114 * Author : Xang Xiu Yang
115 ***************************************************************************/
116 static void lttv_traceset_context_compute_time_span(
117 LttvTracesetContext
*self
,
118 TimeInterval
*time_span
)
120 LttvTraceset
* traceset
= self
->ts
;
121 int numTraces
= lttv_traceset_number(traceset
);
124 LttvTraceContext
*tc
;
127 time_span
->start_time
.tv_sec
= 0;
128 time_span
->start_time
.tv_nsec
= 0;
129 time_span
->end_time
.tv_sec
= 0;
130 time_span
->end_time
.tv_nsec
= 0;
132 for(i
=0; i
<numTraces
;i
++){
133 tc
= self
->traces
[i
];
136 ltt_trace_time_span_get(trace
, &s
, &e
);
139 time_span
->start_time
= s
;
140 time_span
->end_time
= e
;
142 if(s
.tv_sec
< time_span
->start_time
.tv_sec
143 || (s
.tv_sec
== time_span
->start_time
.tv_sec
144 && s
.tv_nsec
< time_span
->start_time
.tv_nsec
))
145 time_span
->start_time
= s
;
146 if(e
.tv_sec
> time_span
->end_time
.tv_sec
147 || (e
.tv_sec
== time_span
->end_time
.tv_sec
148 && e
.tv_nsec
> time_span
->end_time
.tv_nsec
))
149 time_span
->end_time
= e
;
154 static void init_tracefile_context(LttTracefile
*tracefile
,
155 LttvTraceContext
*tc
)
157 LttvTracefileContext
*tfc
;
158 LttvTracesetContext
*tsc
= tc
->ts_context
;
160 tfc
= LTTV_TRACESET_CONTEXT_GET_CLASS(tsc
)->new_tracefile_context(tsc
);
162 tfc
->index
= tc
->tracefiles
->len
;
163 tc
->tracefiles
= g_array_append_val(tc
->tracefiles
, tfc
);
168 tfc
->event
= lttv_hooks_new();
169 tfc
->event_by_id
= lttv_hooks_by_id_new();
170 tfc
->a
= g_object_new(LTTV_ATTRIBUTE_TYPE
, NULL
);
175 init(LttvTracesetContext
*self
, LttvTraceset
*ts
)
179 LttvTraceContext
*tc
;
181 GData
**tracefiles_groups
;
183 struct compute_tracefile_group_args args
;
185 nb_trace
= lttv_traceset_number(ts
);
187 self
->traces
= g_new(LttvTraceContext
*, nb_trace
);
188 self
->a
= g_object_new(LTTV_ATTRIBUTE_TYPE
, NULL
);
189 self
->ts_a
= lttv_traceset_attribute(ts
);
190 for(i
= 0 ; i
< nb_trace
; i
++) {
191 tc
= LTTV_TRACESET_CONTEXT_GET_CLASS(self
)->new_trace_context(self
);
192 self
->traces
[i
] = tc
;
194 tc
->ts_context
= self
;
196 tc
->vt
= lttv_traceset_get(ts
, i
);
197 tc
->t
= lttv_trace(tc
->vt
);
198 tc
->a
= g_object_new(LTTV_ATTRIBUTE_TYPE
, NULL
);
199 tc
->t_a
= lttv_trace_attribute(tc
->vt
);
200 tc
->tracefiles
= g_array_sized_new(FALSE
, TRUE
,
201 sizeof(LttvTracefileContext
*), 10);
203 tracefiles_groups
= ltt_trace_get_tracefiles_groups(tc
->t
);
204 if(tracefiles_groups
!= NULL
) {
205 args
.func
= (ForEachTraceFileFunc
)init_tracefile_context
;
208 g_datalist_foreach(tracefiles_groups
,
209 (GDataForeachFunc
)compute_tracefile_group
,
214 nb_control
= ltt_trace_control_tracefile_number(tc
->t
);
215 nb_per_cpu
= ltt_trace_per_cpu_tracefile_number(tc
->t
);
216 nb_tracefile
= nb_control
+ nb_per_cpu
;
217 tc
->tracefiles
= g_new(LttvTracefileContext
*, nb_tracefile
);
219 for(j
= 0 ; j
< nb_tracefile
; j
++) {
220 tfc
= LTTV_TRACESET_CONTEXT_GET_CLASS(self
)->new_tracefile_context(self
);
221 tc
->tracefiles
[j
] = tfc
;
226 tfc
->tf
= ltt_trace_control_tracefile_get(tc
->t
, j
);
229 tfc
->control
= FALSE
;
230 tfc
->tf
= ltt_trace_per_cpu_tracefile_get(tc
->t
, j
- nb_control
);
234 tfc
->e
= ltt_event_new();
235 tfc
->event
= lttv_hooks_new();
236 tfc
->event_by_id
= lttv_hooks_by_id_new();
237 tfc
->a
= g_object_new(LTTV_ATTRIBUTE_TYPE
, NULL
);
242 self
->sync_position
= lttv_traceset_context_position_new(self
);
243 self
->pqueue
= g_tree_new(compare_tracefile
);
244 lttv_process_traceset_seek_time(self
, ltt_time_zero
);
245 lttv_traceset_context_compute_time_span(self
, &self
->time_span
);
250 void fini(LttvTracesetContext
*self
)
252 guint i
, j
, nb_trace
, nb_tracefile
;
254 LttvTraceContext
*tc
;
256 LttvTracefileContext
**tfc
;
258 LttvTraceset
*ts
= self
->ts
;
260 g_tree_destroy(self
->pqueue
);
261 g_object_unref(self
->a
);
262 lttv_traceset_context_position_destroy(self
->sync_position
);
264 nb_trace
= lttv_traceset_number(ts
);
266 for(i
= 0 ; i
< nb_trace
; i
++) {
267 tc
= self
->traces
[i
];
269 g_object_unref(tc
->a
);
271 nb_tracefile
= tc
->tracefiles
->len
;
273 for(j
= 0 ; j
< nb_tracefile
; j
++) {
274 tfc
= &g_array_index(tc
->tracefiles
, LttvTracefileContext
*, j
);
275 lttv_hooks_destroy((*tfc
)->event
);
276 lttv_hooks_by_id_destroy((*tfc
)->event_by_id
);
277 g_object_unref((*tfc
)->a
);
278 g_object_unref(*tfc
);
280 g_array_free(tc
->tracefiles
, TRUE
);
283 g_free(self
->traces
);
287 void lttv_traceset_context_add_hooks(LttvTracesetContext
*self
,
288 LttvHooks
*before_traceset
,
289 LttvHooks
*before_trace
,
290 LttvHooks
*before_tracefile
,
292 LttvHooksById
*event_by_id
)
294 LttvTraceset
*ts
= self
->ts
;
298 LttvTraceContext
*tc
;
300 lttv_hooks_call(before_traceset
, self
);
302 nb_trace
= lttv_traceset_number(ts
);
304 for(i
= 0 ; i
< nb_trace
; i
++) {
305 tc
= self
->traces
[i
];
306 lttv_trace_context_add_hooks(tc
,
315 void lttv_traceset_context_remove_hooks(LttvTracesetContext
*self
,
316 LttvHooks
*after_traceset
,
317 LttvHooks
*after_trace
,
318 LttvHooks
*after_tracefile
,
320 LttvHooksById
*event_by_id
)
323 LttvTraceset
*ts
= self
->ts
;
327 LttvTraceContext
*tc
;
329 nb_trace
= lttv_traceset_number(ts
);
331 for(i
= 0 ; i
< nb_trace
; i
++) {
332 tc
= self
->traces
[i
];
333 lttv_trace_context_remove_hooks(tc
,
340 lttv_hooks_call(after_traceset
, self
);
345 void lttv_trace_context_add_hooks(LttvTraceContext
*self
,
346 LttvHooks
*before_trace
,
347 LttvHooks
*before_tracefile
,
349 LttvHooksById
*event_by_id
)
351 guint i
, nb_tracefile
;
353 LttvTracefileContext
**tfc
;
355 lttv_hooks_call(before_trace
, self
);
357 nb_tracefile
= self
->tracefiles
->len
;
359 for(i
= 0 ; i
< nb_tracefile
; i
++) {
360 tfc
= &g_array_index(self
->tracefiles
, LttvTracefileContext
*, i
);
361 lttv_tracefile_context_add_hooks(*tfc
,
370 void lttv_trace_context_remove_hooks(LttvTraceContext
*self
,
371 LttvHooks
*after_trace
,
372 LttvHooks
*after_tracefile
,
374 LttvHooksById
*event_by_id
)
376 guint i
, nb_tracefile
;
378 LttvTracefileContext
**tfc
;
380 nb_tracefile
= self
->tracefiles
->len
;
382 for(i
= 0 ; i
< nb_tracefile
; i
++) {
383 tfc
= &g_array_index(self
->tracefiles
, LttvTracefileContext
*, i
);
384 lttv_tracefile_context_remove_hooks(*tfc
,
390 lttv_hooks_call(after_trace
, self
);
393 void lttv_tracefile_context_add_hooks(LttvTracefileContext
*self
,
394 LttvHooks
*before_tracefile
,
396 LttvHooksById
*event_by_id
)
402 lttv_hooks_call(before_tracefile
, self
);
403 lttv_hooks_add_list(self
->event
, event
);
404 if(event_by_id
!= NULL
) {
405 for(i
= 0; i
< event_by_id
->array
->len
; i
++) {
406 index
= g_array_index(event_by_id
->array
, guint
, i
);
407 hook
= lttv_hooks_by_id_find(self
->event_by_id
, index
);
408 lttv_hooks_add_list(hook
, lttv_hooks_by_id_get(event_by_id
, index
));
413 void lttv_tracefile_context_remove_hooks(LttvTracefileContext
*self
,
414 LttvHooks
*after_tracefile
,
416 LttvHooksById
*event_by_id
)
422 lttv_hooks_remove_list(self
->event
, event
);
423 if(event_by_id
!= NULL
) {
424 for(i
= 0; i
< event_by_id
->array
->len
; i
++) {
425 index
= g_array_index(event_by_id
->array
, guint
, i
);
426 hook
= lttv_hooks_by_id_get(self
->event_by_id
, index
);
428 lttv_hooks_remove_list(hook
, lttv_hooks_by_id_get(event_by_id
, index
));
432 lttv_hooks_call(after_tracefile
, self
);
437 void lttv_tracefile_context_add_hooks_by_id(LttvTracefileContext
*tfc
,
439 LttvHooks
*event_by_id
)
442 h
= lttv_hooks_by_id_find(tfc
->event_by_id
, i
);
443 lttv_hooks_add_list(h
, event_by_id
);
446 void lttv_tracefile_context_remove_hooks_by_id(LttvTracefileContext
*tfc
,
449 lttv_hooks_by_id_remove(tfc
->event_by_id
, i
);
452 static LttvTracesetContext
*
453 new_traceset_context(LttvTracesetContext
*self
)
455 return g_object_new(LTTV_TRACESET_CONTEXT_TYPE
, NULL
);
459 static LttvTraceContext
*
460 new_trace_context(LttvTracesetContext
*self
)
462 return g_object_new(LTTV_TRACE_CONTEXT_TYPE
, NULL
);
466 static LttvTracefileContext
*
467 new_tracefile_context(LttvTracesetContext
*self
)
469 return g_object_new(LTTV_TRACEFILE_CONTEXT_TYPE
, NULL
);
474 traceset_context_instance_init (GTypeInstance
*instance
, gpointer g_class
)
476 /* Be careful of anything which would not work well with shallow copies */
481 traceset_context_finalize (LttvTracesetContext
*self
)
483 G_OBJECT_CLASS(g_type_class_peek(g_type_parent(LTTV_TRACESET_CONTEXT_TYPE
)))
484 ->finalize(G_OBJECT(self
));
489 traceset_context_class_init (LttvTracesetContextClass
*klass
)
491 GObjectClass
*gobject_class
= G_OBJECT_CLASS(klass
);
493 gobject_class
->finalize
= (void (*)(GObject
*self
))traceset_context_finalize
;
496 klass
->new_traceset_context
= new_traceset_context
;
497 klass
->new_trace_context
= new_trace_context
;
498 klass
->new_tracefile_context
= new_tracefile_context
;
503 lttv_traceset_context_get_type(void)
505 static GType type
= 0;
507 static const GTypeInfo info
= {
508 sizeof (LttvTracesetContextClass
),
509 NULL
, /* base_init */
510 NULL
, /* base_finalize */
511 (GClassInitFunc
) traceset_context_class_init
, /* class_init */
512 NULL
, /* class_finalize */
513 NULL
, /* class_data */
514 sizeof (LttvTracesetContext
),
516 (GInstanceInitFunc
) traceset_context_instance_init
, /* instance_init */
517 NULL
/* Value handling */
520 type
= g_type_register_static (G_TYPE_OBJECT
, "LttvTracesetContextType",
528 trace_context_instance_init (GTypeInstance
*instance
, gpointer g_class
)
530 /* Be careful of anything which would not work well with shallow copies */
535 trace_context_finalize (LttvTraceContext
*self
)
537 G_OBJECT_CLASS(g_type_class_peek(g_type_parent(LTTV_TRACE_CONTEXT_TYPE
)))->
538 finalize(G_OBJECT(self
));
543 trace_context_class_init (LttvTraceContextClass
*klass
)
545 GObjectClass
*gobject_class
= G_OBJECT_CLASS(klass
);
547 gobject_class
->finalize
= (void (*)(GObject
*self
)) trace_context_finalize
;
552 lttv_trace_context_get_type(void)
554 static GType type
= 0;
556 static const GTypeInfo info
= {
557 sizeof (LttvTraceContextClass
),
558 NULL
, /* base_init */
559 NULL
, /* base_finalize */
560 (GClassInitFunc
) trace_context_class_init
, /* class_init */
561 NULL
, /* class_finalize */
562 NULL
, /* class_data */
563 sizeof (LttvTraceContext
),
565 (GInstanceInitFunc
) trace_context_instance_init
, /* instance_init */
566 NULL
/* Value handling */
569 type
= g_type_register_static (G_TYPE_OBJECT
, "LttvTraceContextType",
577 tracefile_context_instance_init (GTypeInstance
*instance
, gpointer g_class
)
579 /* Be careful of anything which would not work well with shallow copies */
584 tracefile_context_finalize (LttvTracefileContext
*self
)
586 G_OBJECT_CLASS(g_type_class_peek(g_type_parent(LTTV_TRACEFILE_CONTEXT_TYPE
)))
587 ->finalize(G_OBJECT(self
));
592 tracefile_context_class_init (LttvTracefileContextClass
*klass
)
594 GObjectClass
*gobject_class
= G_OBJECT_CLASS(klass
);
596 gobject_class
->finalize
= (void (*)(GObject
*self
))tracefile_context_finalize
;
601 lttv_tracefile_context_get_type(void)
603 static GType type
= 0;
605 static const GTypeInfo info
= {
606 sizeof (LttvTracefileContextClass
),
607 NULL
, /* base_init */
608 NULL
, /* base_finalize */
609 (GClassInitFunc
) tracefile_context_class_init
, /* class_init */
610 NULL
, /* class_finalize */
611 NULL
, /* class_data */
612 sizeof (LttvTracefileContext
),
614 (GInstanceInitFunc
) tracefile_context_instance_init
, /* instance_init */
615 NULL
/* Value handling */
618 type
= g_type_register_static (G_TYPE_OBJECT
, "LttvTracefileContextType",
626 static gboolean
get_first(gpointer key
, gpointer value
, gpointer user_data
) {
627 g_assert(key
== value
);
628 *((LttvTracefileContext
**)user_data
) = (LttvTracefileContext
*)value
;
633 // Test to see if pqueue is traversed in the right order.
634 static LttTime test_time
;
636 static gboolean
test_tree(gpointer key
, gpointer value
, gpointer user_data
) {
638 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)key
;
640 g_debug("Tracefile name %s, time %lu.%lu, tfi %u, ti %u",
641 g_quark_to_string(ltt_tracefile_name(tfc
->tf
)),
642 tfc
->timestamp
.tv_sec
, tfc
->timestamp
.tv_nsec
,
643 tfc
->index
, tfc
->t_context
->index
);
645 if(user_data
!= NULL
) {
646 if(((LttvTracefileContext
*)user_data
) == (LttvTracefileContext
*)value
) {
647 g_assert(compare_tracefile(user_data
, value
) == 0);
649 g_assert(compare_tracefile(user_data
, value
) != 0);
651 g_assert(ltt_time_compare(test_time
, tfc
->timestamp
) <= 0);
652 test_time
.tv_sec
= tfc
->timestamp
.tv_sec
;
653 test_time
.tv_nsec
= tfc
->timestamp
.tv_nsec
;
656 //g_assert(((LttvTracefileContext *)user_data) != (LttvTracefileContext *)value);
663 void lttv_process_traceset_begin(LttvTracesetContext
*self
,
664 LttvHooks
*before_traceset
,
665 LttvHooks
*before_trace
,
666 LttvHooks
*before_tracefile
,
668 LttvHooksById
*event_by_id
)
671 /* simply add hooks in context. _before hooks are called by add_hooks. */
672 /* It calls all before_traceset, before_trace, and before_tracefile hooks. */
673 lttv_traceset_context_add_hooks(self
,
682 enum read_state
{ LAST_NONE
, LAST_OK
, LAST_EMPTY
};
684 /* Note : a _middle must be preceded from a _seek or another middle */
685 guint
lttv_process_traceset_middle(LttvTracesetContext
*self
,
688 const LttvTracesetContextPosition
*end_position
)
690 GTree
*pqueue
= self
->pqueue
;
692 guint fac_id
, ev_id
, id
;
694 LttvTracefileContext
*tfc
;
702 enum read_state last_read_state
= LAST_NONE
;
704 gboolean last_ret
= FALSE
; /* return value of the last hook list called */
706 /* Get the next event from the pqueue, call its hooks,
707 reinsert in the pqueue the following event from the same tracefile
708 unless the tracefile is finished or the event is later than the
713 g_tree_foreach(pqueue
, get_first
, &tfc
);
714 /* End of traceset : tfc is NULL */
715 if(unlikely(tfc
== NULL
))
721 * - the maximum number of events specified?
722 * - the end position ?
724 * then the read is finished. We leave the queue in the same state and
728 if(unlikely(last_ret
== TRUE
||
729 ((count
>= nb_events
) && (nb_events
!= G_MAXULONG
)) ||
730 (end_position
!=NULL
&<tv_traceset_context_ctx_pos_compare(self
,
731 end_position
) == 0)||
732 ltt_time_compare(end
, tfc
->timestamp
) <= 0))
737 /* Get the tracefile with an event for the smallest time found. If two
738 or more tracefiles have events for the same time, hope that lookup
739 and remove are consistent. */
742 test_time
.tv_sec
= 0;
743 test_time
.tv_nsec
= 0;
744 g_debug("test tree before remove");
745 g_tree_foreach(pqueue
, test_tree
, tfc
);
747 g_tree_remove(pqueue
, tfc
);
750 test_time
.tv_sec
= 0;
751 test_time
.tv_nsec
= 0;
752 g_debug("test tree after remove");
753 g_tree_foreach(pqueue
, test_tree
, tfc
);
756 e
= ltt_tracefile_get_event(tfc
->tf
);
758 if(last_read_state
!= LAST_EMPTY
) {
759 /* Only call hooks if the last read has given an event or if we are at the
760 * first pass (not if last read returned end of tracefile) */
763 fac_id
= ltt_event_facility_id(e
);
764 ev_id
= ltt_event_eventtype_id(e
);
765 id
= GET_HOOK_ID(fac_id
, ev_id
);
766 last_ret
= lttv_hooks_call_merge(tfc
->event
, tfc
,
767 lttv_hooks_by_id_get(tfc
->event_by_id
, id
), tfc
);
770 read_ret
= ltt_tracefile_read(tfc
->tf
);
772 if(likely(!read_ret
)) {
773 //g_debug("An event is ready");
774 tfc
->timestamp
= ltt_event_time(e
);
775 g_assert(ltt_time_compare(tfc
->timestamp
, ltt_time_infinite
) != 0);
776 g_tree_insert(pqueue
, tfc
, tfc
);
778 test_time
.tv_sec
= 0;
779 test_time
.tv_nsec
= 0;
780 g_debug("test tree after event ready");
781 g_tree_foreach(pqueue
, test_tree
, NULL
);
784 last_read_state
= LAST_OK
;
786 tfc
->timestamp
= ltt_time_infinite
;
788 if(read_ret
== ERANGE
) {
789 last_read_state
= LAST_EMPTY
;
790 g_debug("End of trace");
792 g_error("Error happened in lttv_process_traceset_middle");
798 void lttv_process_traceset_end(LttvTracesetContext
*self
,
799 LttvHooks
*after_traceset
,
800 LttvHooks
*after_trace
,
801 LttvHooks
*after_tracefile
,
803 LttvHooksById
*event_by_id
)
805 /* Remove hooks from context. _after hooks are called by remove_hooks. */
806 /* It calls all after_traceset, after_trace, and after_tracefile hooks. */
807 lttv_traceset_context_remove_hooks(self
,
815 /* Subtile modification :
816 * if tracefile has no event at or after the time requested, it is not put in
817 * the queue, as the next read would fail.
819 * Don't forget to empty the traceset pqueue before calling this.
821 void lttv_process_trace_seek_time(LttvTraceContext
*self
, LttTime start
)
823 guint i
, nb_tracefile
;
827 LttvTracefileContext
**tfc
;
829 nb_tracefile
= self
->tracefiles
->len
;
831 GTree
*pqueue
= self
->ts_context
->pqueue
;
833 for(i
= 0 ; i
< nb_tracefile
; i
++) {
834 tfc
= &g_array_index(self
->tracefiles
, LttvTracefileContext
*, i
);
836 //g_tree_remove(pqueue, *tfc);
838 ret
= ltt_tracefile_seek_time((*tfc
)->tf
, start
);
839 if(ret
== EPERM
) g_error("error in lttv_process_trace_seek_time seek");
841 if(ret
== 0) { /* not ERANGE especially */
842 (*tfc
)->timestamp
= ltt_event_time(ltt_tracefile_get_event((*tfc
)->tf
));
843 g_assert(ltt_time_compare((*tfc
)->timestamp
, ltt_time_infinite
) != 0);
844 g_tree_insert(pqueue
, (*tfc
), (*tfc
));
846 (*tfc
)->timestamp
= ltt_time_infinite
;
850 test_time
.tv_sec
= 0;
851 test_time
.tv_nsec
= 0;
852 g_debug("test tree after seek_time");
853 g_tree_foreach(pqueue
, test_tree
, NULL
);
861 void lttv_process_traceset_seek_time(LttvTracesetContext
*self
, LttTime start
)
865 LttvTraceContext
*tc
;
867 g_tree_destroy(self
->pqueue
);
868 self
->pqueue
= g_tree_new(compare_tracefile
);
870 nb_trace
= lttv_traceset_number(self
->ts
);
871 for(i
= 0 ; i
< nb_trace
; i
++) {
872 tc
= self
->traces
[i
];
873 lttv_process_trace_seek_time(tc
, start
);
878 gboolean
lttv_process_traceset_seek_position(LttvTracesetContext
*self
,
879 const LttvTracesetContextPosition
*pos
)
883 /* If a position is set, seek the traceset to this position */
884 if(ltt_time_compare(pos
->timestamp
, ltt_time_infinite
) != 0) {
885 g_tree_destroy(self
->pqueue
);
886 self
->pqueue
= g_tree_new(compare_tracefile
);
888 for(i
=0;i
<pos
->tfcp
->len
; i
++) {
889 LttvTracefileContextPosition
*tfcp
=
890 &g_array_index(pos
->tfcp
, LttvTracefileContextPosition
, i
);
893 if(tfcp
->used
== TRUE
) {
894 if(ltt_tracefile_seek_position(tfcp
->tfc
->tf
, tfcp
->event
) != 0)
896 tfcp
->tfc
->timestamp
=
897 ltt_event_time(ltt_tracefile_get_event(tfcp
->tfc
->tf
));
898 g_assert(ltt_time_compare(tfcp
->tfc
->timestamp
,
899 ltt_time_infinite
) != 0);
900 g_tree_insert(self
->pqueue
, tfcp
->tfc
, tfcp
->tfc
);
903 tfcp
->tfc
->timestamp
= ltt_time_infinite
;
908 test_time
.tv_sec
= 0;
909 test_time
.tv_nsec
= 0;
910 g_debug("test tree after seek_position");
911 g_tree_foreach(self
->pqueue
, test_tree
, NULL
);
922 find_field(LttEventType
*et
, const GQuark field
)
933 if(field
== 0) return NULL
;
935 f
= ltt_eventtype_field(et
);
936 t
= ltt_eventtype_type(et
);
937 g_assert(ltt_type_class(t
) == LTT_STRUCT
);
938 nb
= ltt_type_member_number(t
);
939 for(i
= 0 ; i
< nb
; i
++) {
940 ltt_type_member_type(t
, i
, &name
);
941 if(name
== field
) break;
944 return ltt_field_member(f
, i
);
947 LttvTraceHookByFacility
*lttv_trace_hook_get_fac(LttvTraceHook
*th
,
950 return &g_array_index(th
->fac_index
, LttvTraceHookByFacility
, facility_id
);
953 /* Get the first facility corresponding to the name. As the types must be
954 * compatible, it is relevant to use the field name and sizes of the first
955 * facility to create data structures and assume the data will be compatible
956 * thorough the trace */
957 LttvTraceHookByFacility
*lttv_trace_hook_get_first(LttvTraceHook
*th
)
959 g_assert(th
->fac_list
->len
> 0);
960 return g_array_index(th
->fac_list
, LttvTraceHookByFacility
*, 0);
964 /* Returns 0 on success, -1 if fails. */
966 lttv_trace_find_hook(LttTrace
*t
, GQuark facility
, GQuark event
,
967 GQuark field1
, GQuark field2
, GQuark field3
, LttvHook h
, gpointer hook_data
,
972 LttEventType
*et
, *first_et
;
976 guint i
, fac_id
, ev_id
;
978 LttvTraceHookByFacility
*thf
, *first_thf
;
980 facilities
= ltt_trace_facility_get_by_name(t
, facility
);
982 if(unlikely(facilities
== NULL
)) goto facility_error
;
984 th
->fac_index
= g_array_sized_new(FALSE
, TRUE
,
985 sizeof(LttvTraceHookByFacility
),
987 th
->fac_index
= g_array_set_size(th
->fac_index
, NUM_FACILITIES
);
989 th
->fac_list
= g_array_sized_new(FALSE
, TRUE
,
990 sizeof(LttvTraceHookByFacility
*),
992 th
->fac_list
= g_array_set_size(th
->fac_list
, facilities
->len
);
994 fac_id
= g_array_index(facilities
, guint
, 0);
995 f
= ltt_trace_get_facility_by_num(t
, fac_id
);
997 et
= ltt_facility_eventtype_get_by_name(f
, event
);
998 if(unlikely(et
== NULL
)) goto event_error
;
1000 thf
= &g_array_index(th
->fac_index
, LttvTraceHookByFacility
, fac_id
);
1001 g_array_index(th
->fac_list
, LttvTraceHookByFacility
*, 0) = thf
;
1003 ev_id
= ltt_eventtype_id(et
);
1006 thf
->id
= GET_HOOK_ID(fac_id
, ev_id
);
1007 thf
->f1
= find_field(et
, field1
);
1008 thf
->f2
= find_field(et
, field2
);
1009 thf
->f3
= find_field(et
, field3
);
1010 thf
->hook_data
= hook_data
;
1015 /* Check for type compatibility too */
1016 for(i
=1;i
<facilities
->len
;i
++) {
1017 fac_id
= g_array_index(facilities
, guint
, i
);
1018 f
= ltt_trace_get_facility_by_num(t
, fac_id
);
1020 et
= ltt_facility_eventtype_get_by_name(f
, event
);
1021 if(unlikely(et
== NULL
)) goto event_error
;
1023 thf
= &g_array_index(th
->fac_index
, LttvTraceHookByFacility
, fac_id
);
1024 g_array_index(th
->fac_list
, LttvTraceHookByFacility
*, i
) = thf
;
1025 ev_id
= ltt_eventtype_id(et
);
1027 thf
->id
= GET_HOOK_ID(fac_id
, ev_id
);
1028 thf
->f1
= find_field(et
, field1
);
1029 if(check_fields_compatibility(first_et
, et
,
1030 first_thf
->f1
, thf
->f1
))
1033 thf
->f2
= find_field(et
, field2
);
1034 if(check_fields_compatibility(first_et
, et
,
1035 first_thf
->f2
, thf
->f2
))
1038 thf
->f3
= find_field(et
, field3
);
1039 if(check_fields_compatibility(first_et
, et
,
1040 first_thf
->f3
, thf
->f3
))
1042 thf
->hook_data
= hook_data
;
1050 g_error("Event type does not exist for event %s",
1051 g_quark_to_string(event
));
1054 g_error("No %s facility", g_quark_to_string(facility
));
1057 g_array_free(th
->fac_index
, TRUE
);
1058 g_array_free(th
->fac_list
, TRUE
);
1059 th
->fac_index
= NULL
;
1060 th
->fac_list
= NULL
;
1064 void lttv_trace_hook_destroy(LttvTraceHook
*th
)
1066 g_array_free(th
->fac_index
, TRUE
);
1067 g_array_free(th
->fac_list
, TRUE
);
1073 LttvTracesetContextPosition
*lttv_traceset_context_position_new(
1074 const LttvTracesetContext
*self
)
1076 guint num_traces
= lttv_traceset_number(self
->ts
);
1080 for(i
=0; i
<num_traces
;i
++) {
1081 GArray
* tracefiles
= self
->traces
[i
]->tracefiles
;
1083 guint num_tracefiles
= tracefiles
->len
;
1084 for(j
=0;j
<num_tracefiles
;j
++)
1087 LttvTracesetContextPosition
*pos
=
1088 g_new(LttvTracesetContextPosition
, 1);
1089 pos
->tfcp
= g_array_sized_new(FALSE
, TRUE
,
1090 sizeof(LttvTracefileContextPosition
),
1092 g_array_set_size(pos
->tfcp
, tf_count
);
1093 for(i
=0;i
<pos
->tfcp
->len
;i
++) {
1094 LttvTracefileContextPosition
*tfcp
=
1095 &g_array_index(pos
->tfcp
, LttvTracefileContextPosition
, i
);
1096 tfcp
->event
= ltt_event_position_new();
1099 pos
->timestamp
= ltt_time_infinite
;
1103 /* Save all positions, the ones with infinite time will have NULL
1105 /* note : a position must be destroyed when a trace is added/removed from a
1107 void lttv_traceset_context_position_save(const LttvTracesetContext
*self
,
1108 LttvTracesetContextPosition
*pos
)
1111 guint num_traces
= lttv_traceset_number(self
->ts
);
1114 pos
->timestamp
= ltt_time_infinite
;
1116 for(i
=0; i
<num_traces
;i
++) {
1117 GArray
* tracefiles
= self
->traces
[i
]->tracefiles
;
1119 guint num_tracefiles
= tracefiles
->len
;
1121 for(j
=0;j
<num_tracefiles
;j
++) {
1122 g_assert(tf_count
< pos
->tfcp
->len
);
1123 LttvTracefileContext
**tfc
= &g_array_index(tracefiles
,
1124 LttvTracefileContext
*, j
);
1125 LttvTracefileContextPosition
*tfcp
=
1126 &g_array_index(pos
->tfcp
, LttvTracefileContextPosition
, tf_count
);
1130 if(ltt_time_compare((*tfc
)->timestamp
, ltt_time_infinite
) != 0) {
1131 LttEvent
*event
= ltt_tracefile_get_event((*tfc
)->tf
);
1132 ltt_event_position(event
, tfcp
->event
);
1133 if(ltt_time_compare((*tfc
)->timestamp
, pos
->timestamp
) < 0)
1134 pos
->timestamp
= (*tfc
)->timestamp
;
1140 //g_array_append_val(pos->tfc, *tfc);
1141 //g_array_append_val(pos->ep, ep);
1148 void lttv_traceset_context_position_destroy(LttvTracesetContextPosition
*pos
)
1152 for(i
=0;i
<pos
->tfcp
->len
;i
++) {
1153 LttvTracefileContextPosition
*tfcp
=
1154 &g_array_index(pos
->tfcp
, LttvTracefileContextPosition
, i
);
1155 g_free(tfcp
->event
);
1159 g_array_free(pos
->tfcp
, TRUE
);
1163 void lttv_traceset_context_position_copy(LttvTracesetContextPosition
*dest
,
1164 const LttvTracesetContextPosition
*src
)
1167 LttvTracefileContextPosition
*src_tfcp
, *dest_tfcp
;
1169 g_assert(src
->tfcp
->len
== src
->tfcp
->len
);
1171 for(i
=0;i
<src
->tfcp
->len
;i
++) {
1173 &g_array_index(src
->tfcp
, LttvTracefileContextPosition
, i
);
1175 &g_array_index(dest
->tfcp
, LttvTracefileContextPosition
, i
);
1177 dest_tfcp
->used
= src_tfcp
->used
;
1178 dest_tfcp
->tfc
= src_tfcp
->tfc
;
1180 if(src_tfcp
->used
) {
1181 ltt_event_position_copy(
1186 dest
->timestamp
= src
->timestamp
;
1189 gint
lttv_traceset_context_ctx_pos_compare(const LttvTracesetContext
*self
,
1190 const LttvTracesetContextPosition
*pos
)
1195 if(pos
->tfcp
->len
== 0) {
1196 if(lttv_traceset_number(self
->ts
) == 0) return 0;
1199 if(lttv_traceset_number(self
->ts
) == 0)
1202 for(i
=0;i
<pos
->tfcp
->len
;i
++) {
1203 LttvTracefileContextPosition
*tfcp
=
1204 &g_array_index(pos
->tfcp
, LttvTracefileContextPosition
, i
);
1206 if(tfcp
->used
== FALSE
) {
1207 if(ltt_time_compare(tfcp
->tfc
->timestamp
, ltt_time_infinite
) < 0) {
1211 if(ltt_time_compare(tfcp
->tfc
->timestamp
, ltt_time_infinite
) == 0) {
1214 LttEvent
*event
= ltt_tracefile_get_event(tfcp
->tfc
->tf
);
1216 ret
= ltt_event_position_compare((LttEventPosition
*)event
,
1220 if(ret
!= 0) return ret
;
1227 gint
lttv_traceset_context_pos_pos_compare(
1228 const LttvTracesetContextPosition
*pos1
,
1229 const LttvTracesetContextPosition
*pos2
)
1234 if(pos1
->tfcp
->len
== 0) {
1235 if(pos2
->tfcp
->len
== 0) return 0;
1238 if(pos2
->tfcp
->len
== 0)
1241 for(i
=0;i
<pos1
->tfcp
->len
;i
++) {
1242 LttvTracefileContextPosition
*tfcp1
=
1243 &g_array_index(pos1
->tfcp
, LttvTracefileContextPosition
, i
);
1245 if(tfcp1
->used
== TRUE
) {
1246 for(j
=0;j
<pos2
->tfcp
->len
;j
++) {
1247 LttvTracefileContextPosition
*tfcp2
=
1248 &g_array_index(pos2
->tfcp
, LttvTracefileContextPosition
, j
);
1250 if(tfcp1
->tfc
== tfcp2
->tfc
) {
1251 if(tfcp2
->used
== TRUE
)
1252 ret
= ltt_event_position_compare(tfcp1
->event
, tfcp2
->event
);
1256 if(ret
!= 0) return ret
;
1261 for(j
=0;j
<pos2
->tfcp
->len
;j
++) {
1262 LttvTracefileContextPosition
*tfcp2
=
1263 &g_array_index(pos2
->tfcp
, LttvTracefileContextPosition
, j
);
1265 if(tfcp1
->tfc
== tfcp2
->tfc
)
1266 if(tfcp2
->used
== TRUE
) ret
= 1;
1267 if(ret
!= 0) return ret
;
1275 LttTime
lttv_traceset_context_position_get_time(
1276 const LttvTracesetContextPosition
*pos
)
1278 return pos
->timestamp
;
1282 LttvTracefileContext
*lttv_traceset_context_get_current_tfc(LttvTracesetContext
*self
)
1284 GTree
*pqueue
= self
->pqueue
;
1285 LttvTracefileContext
*tfc
= NULL
;
1287 g_tree_foreach(pqueue
, get_first
, &tfc
);
1292 /* lttv_process_traceset_synchronize_tracefiles
1294 * Use the sync_position field of the trace set context to synchronize each
1295 * tracefile with the previously saved position.
1297 * If no previous position has been saved, it simply does nothing.
1299 void lttv_process_traceset_synchronize_tracefiles(LttvTracesetContext
*tsc
)
1301 g_assert(lttv_process_traceset_seek_position(tsc
, tsc
->sync_position
) == 0);
1307 void lttv_process_traceset_get_sync_data(LttvTracesetContext
*tsc
)
1309 lttv_traceset_context_position_save(tsc
, tsc
->sync_position
);
1312 struct seek_back_data
{
1313 guint first_event
; /* Index of the first event in the array : we will always
1314 overwrite at this position : this is a circular array.
1317 guint n
; /* number of events requested */
1318 GPtrArray
*array
; /* array of LttvTracesetContextPositions pointers */
1322 static gint
seek_back_event_hook(void *hook_data
, void* call_data
)
1324 struct seek_back_data
*sd
= (struct seek_back_data
*)hook_data
;
1325 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1326 LttvTracesetContext
*tsc
= tfc
->t_context
->ts_context
;
1327 LttvTracesetContextPosition
*pos
;
1329 if(sd
->filter
!= NULL
) {
1330 if(!lttv_filter_tree_parse(sd
->filter
->head
,
1331 ltt_tracefile_get_event(tfc
->tf
),
1338 pos
= (LttvTracesetContextPosition
*)g_ptr_array_index (sd
->array
,
1341 lttv_traceset_context_position_save(tsc
, pos
);
1343 if(sd
->first_event
>= sd
->array
->len
- 1) sd
->first_event
= 0;
1344 else sd
->first_event
++;
1346 sd
->events_found
= min(sd
->n
, sd
->events_found
+ 1);
1351 /* Seek back n events back from the current position.
1354 * @self The trace set context
1355 * @n number of events to jump over
1356 * @first_offset The initial offset value used.
1357 * never put first_offset at ltt_time_zero.
1358 * @time_seeker Function pointer of the function to use to seek time :
1359 * either lttv_process_traceset_seek_time
1360 * or lttv_state_traceset_seek_time_closest
1361 * @filter The filter to call.
1363 * Return value : the number of events found (might be lower than the number
1364 * requested if beginning of traceset is reached).
1366 * The first search will go back first_offset and try to find the last n events
1367 * matching the filter. If there are not enough, it will try to go back from the
1368 * new trace point from first_offset*2, and so on, until beginning of trace or n
1371 * Note : this function does not take in account the LttvFilter : use the
1372 * similar function found in state.c instead.
1374 * Note2 : the caller must make sure that the LttvTracesetContext does not
1375 * contain any hook, as process_traceset_middle is used in this routine.
1377 guint
lttv_process_traceset_seek_n_backward(LttvTracesetContext
*self
,
1378 guint n
, LttTime first_offset
,
1379 seek_time_fct time_seeker
,
1382 if(lttv_traceset_number(self
->ts
) == 0) return 0;
1383 g_assert(ltt_time_compare(first_offset
, ltt_time_zero
) != 0);
1386 LttvTracesetContextPosition
*next_iter_end_pos
=
1387 lttv_traceset_context_position_new(self
);
1388 LttvTracesetContextPosition
*end_pos
=
1389 lttv_traceset_context_position_new(self
);
1390 LttvTracesetContextPosition
*saved_pos
=
1391 lttv_traceset_context_position_new(self
);
1393 LttTime time_offset
;
1394 struct seek_back_data sd
;
1395 LttvHooks
*hooks
= lttv_hooks_new();
1398 sd
.events_found
= 0;
1399 sd
.array
= g_ptr_array_sized_new(n
);
1402 g_ptr_array_set_size(sd
.array
, n
);
1404 g_ptr_array_index (sd
.array
, i
) = lttv_traceset_context_position_new(self
);
1407 lttv_traceset_context_position_save(self
, next_iter_end_pos
);
1408 lttv_traceset_context_position_save(self
, saved_pos
);
1409 /* Get the current time from which we will offset */
1410 time
= lttv_traceset_context_position_get_time(next_iter_end_pos
);
1411 /* the position saved might be end of traceset... */
1412 if(ltt_time_compare(time
, self
->time_span
.end_time
) > 0) {
1413 time
= self
->time_span
.end_time
;
1415 time_offset
= first_offset
;
1417 lttv_hooks_add(hooks
, seek_back_event_hook
, &sd
, LTTV_PRIO_DEFAULT
);
1419 lttv_process_traceset_begin(self
, NULL
, NULL
, NULL
, hooks
, NULL
);
1422 /* stop criteria : - n events found
1423 * - time < beginning of trace */
1424 if(ltt_time_compare(time
, self
->time_span
.start_time
) < 0) break;
1426 lttv_traceset_context_position_copy(end_pos
, next_iter_end_pos
);
1428 /* We must seek the traceset back to time - time_offset */
1429 /* this time becomes the new reference time */
1430 time
= ltt_time_sub(time
, time_offset
);
1432 time_seeker(self
, time
);
1433 lttv_traceset_context_position_save(self
, next_iter_end_pos
);
1434 /* Resync the time in case of a seek_closest */
1435 time
= lttv_traceset_context_position_get_time(next_iter_end_pos
);
1436 if(ltt_time_compare(time
, self
->time_span
.end_time
) > 0) {
1437 time
= self
->time_span
.end_time
;
1440 /* Process the traceset, calling a hook which adds events
1441 * to the array, overwriting the tail. It changes first_event and
1442 * events_found too. */
1443 /* We would like to have a clean context here : no other hook than our's */
1445 lttv_process_traceset_middle(self
, ltt_time_infinite
,
1446 G_MAXUINT
, end_pos
);
1448 if(sd
.events_found
< n
) {
1449 if(sd
.first_event
> 0) {
1450 /* Save the first position */
1451 LttvTracesetContextPosition
*pos
=
1452 (LttvTracesetContextPosition
*)g_ptr_array_index (sd
.array
, 0);
1453 lttv_traceset_context_position_copy(saved_pos
, pos
);
1455 g_assert(n
-sd
.events_found
<= sd
.array
->len
);
1456 /* Change array size to n - events_found */
1457 for(i
=n
-sd
.events_found
;i
<sd
.array
->len
;i
++) {
1458 LttvTracesetContextPosition
*pos
=
1459 (LttvTracesetContextPosition
*)g_ptr_array_index (sd
.array
, i
);
1460 lttv_traceset_context_position_destroy(pos
);
1462 g_ptr_array_set_size(sd
.array
, n
-sd
.events_found
);
1465 } else break; /* Second end criterion : n events found */
1467 time_offset
= ltt_time_mul(time_offset
, BACKWARD_SEEK_MUL
);
1470 lttv_traceset_context_position_destroy(end_pos
);
1471 lttv_traceset_context_position_destroy(next_iter_end_pos
);
1473 lttv_process_traceset_end(self
, NULL
, NULL
, NULL
, hooks
, NULL
);
1475 if(sd
.events_found
>= n
) {
1476 /* Seek the traceset to the first event in the circular array */
1477 LttvTracesetContextPosition
*pos
=
1478 (LttvTracesetContextPosition
*)g_ptr_array_index (sd
.array
,
1480 g_assert(lttv_process_traceset_seek_position(self
, pos
) == 0);
1482 /* Will seek to the last saved position : in the worst case, it will be the
1483 * original position (if events_found is 0) */
1484 g_assert(lttv_process_traceset_seek_position(self
, saved_pos
) == 0);
1487 for(i
=0;i
<sd
.array
->len
;i
++) {
1488 LttvTracesetContextPosition
*pos
=
1489 (LttvTracesetContextPosition
*)g_ptr_array_index (sd
.array
, i
);
1490 lttv_traceset_context_position_destroy(pos
);
1492 g_ptr_array_free(sd
.array
, TRUE
);
1494 lttv_hooks_destroy(hooks
);
1496 lttv_traceset_context_position_destroy(saved_pos
);
1498 return sd
.events_found
;
1502 struct seek_forward_data
{
1503 guint event_count
; /* event counter */
1504 guint n
; /* requested number of events to jump over */
1508 static gint
seek_forward_event_hook(void *hook_data
, void* call_data
)
1510 struct seek_forward_data
*sd
= (struct seek_forward_data
*)hook_data
;
1511 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1513 if(sd
->filter
!= NULL
) {
1514 if(!lttv_filter_tree_parse(sd
->filter
->head
,
1515 ltt_tracefile_get_event(tfc
->tf
),
1524 if(sd
->event_count
>= sd
->n
)
1530 /* Seek back n events forward from the current position
1533 * @self the trace set context
1534 * @n number of events to jump over
1535 * @filter filter to call.
1537 * returns : the number of events jumped over (may be less than requested if end
1538 * of traceset reached) */
1539 guint
lttv_process_traceset_seek_n_forward(LttvTracesetContext
*self
,
1540 guint n
, LttvFilter
*filter
)
1542 struct seek_forward_data sd
;
1546 LttvHooks
*hooks
= lttv_hooks_new();
1548 lttv_hooks_add(hooks
, seek_forward_event_hook
, &sd
, LTTV_PRIO_DEFAULT
);
1550 lttv_process_traceset_begin(self
, NULL
, NULL
, NULL
, hooks
, NULL
);
1552 /* it will end on the end of traceset, or the fact that the
1553 * hook returns TRUE.
1555 lttv_process_traceset_middle(self
, ltt_time_infinite
,
1558 /* Here, our position is either the end of traceset, or the exact position
1559 * after n events : leave it like this. */
1561 lttv_process_traceset_end(self
, NULL
, NULL
, NULL
, hooks
, NULL
);
1563 lttv_hooks_destroy(hooks
);
1565 return sd
.event_count
;