1 /* This file is part of the Linux Trace Toolkit Graphic User Interface
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
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,
19 /* This file is the API used to launch any background computation on a trace */
21 /* Here is the implementation of the API */
27 #include <sys/types.h>
33 #include <ltt/trace.h>
35 #include <lttv/lttv.h>
36 #include <lttv/traceset.h>
37 #include <lttv/attribute.h>
38 #include <lttv/tracecontext.h>
39 #include <lttvwindow/lttvwindowtraces.h>
40 #include <lttvwindow/lttvwindow.h> // for CHUNK_NUM_EVENTS
43 typedef struct _BackgroundRequest
{
44 LttvAttributeName module_name
; /* Hook path in global attributes,
45 where all standard hooks under computation/.
47 LttvTrace
*trace
; /* trace concerned */
50 typedef struct _BackgroundNotify
{
52 LttvTrace
*trace
; /* trace */
54 LttvTracesetContextPosition
*notify_position
;
55 LttvHooks
*notify
; /* Hook to call when the notify is
56 passed, or at the end of trace */
62 gboolean
lttvwindowtraces_process_pending_requests(LttvTrace
*trace
);
64 /* Get a trace by its path name.
66 * @param path path of the trace on the virtual file system.
67 * @return Pointer to trace if found
68 * NULL is returned if the trace is not present
71 LttvTrace
*lttvwindowtraces_get_trace_by_name(gchar
*path
)
75 for(i
=0;i
<lttvwindowtraces_get_number();i
++) {
76 LttvTrace
*trace_v
= lttvwindowtraces_get_trace(i
);
79 g_assert(trace_v
!= NULL
);
81 trace
= lttv_trace(trace_v
);
82 g_assert(trace
!= NULL
);
83 name
= ltt_trace_name(trace
);
85 if(strcmp(name
, path
) == 0) {
94 /* Get a trace by its number identifier */
96 LttvTrace
*lttvwindowtraces_get_trace(guint num
)
98 LttvAttribute
*g_attribute
= lttv_global_attributes();
99 LttvAttribute
*attribute
;
100 LttvAttributeType type
;
101 LttvAttributeName name
;
102 LttvAttributeValue value
;
105 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
108 type
= lttv_iattribute_get(LTTV_IATTRIBUTE(attribute
), num
, &name
, &value
);
110 if(type
== LTTV_POINTER
) {
111 return (LttvTrace
*)*(value
.v_pointer
);
117 /* Total number of traces */
119 guint
lttvwindowtraces_get_number()
121 LttvAttribute
*g_attribute
= lttv_global_attributes();
122 LttvAttribute
*attribute
;
123 LttvAttributeValue value
;
126 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
129 return ( lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute
)) );
132 /* Add a trace to the global attributes */
134 void lttvwindowtraces_add_trace(LttvTrace
*trace
)
136 LttvAttribute
*g_attribute
= lttv_global_attributes();
137 LttvAttribute
*attribute
;
138 LttvAttributeValue value
;
141 gchar attribute_path
[PATH_MAX
];
143 if(stat(g_quark_to_string(ltt_trace_name(lttv_trace(trace
))), &buf
)) {
144 g_warning("lttvwindowtraces_add_trace: Trace %s not found",
145 g_quark_to_string(ltt_trace_name(lttv_trace(trace
))));
149 snprintf(attribute_path
, PATH_MAX
, "%llu:%llu", buf
.st_dev
, buf
.st_ino
) >= 0);
152 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
155 value
= lttv_attribute_add(attribute
,
156 g_quark_from_string(attribute_path
),
159 *(value
.v_pointer
) = (gpointer
)trace
;
161 /* create new traceset and tracesetcontext */
163 LttvTracesetStats
*tss
;
165 attribute
= lttv_trace_attribute(trace
);
166 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
167 LTTV_COMPUTATION_TRACESET
,
170 ts
= lttv_traceset_new();
171 *(value
.v_pointer
) = ts
;
173 lttv_traceset_add(ts
,trace
);
175 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
176 LTTV_COMPUTATION_TRACESET_CONTEXT
,
179 tss
= g_object_new(LTTV_TRACESET_STATS_TYPE
, NULL
);
180 *(value
.v_pointer
) = tss
;
182 lttv_context_init(LTTV_TRACESET_CONTEXT(tss
), ts
);
184 value
= lttv_attribute_add(attribute
,
188 value
= lttv_attribute_add(attribute
,
189 LTTV_REQUESTS_CURRENT
,
192 value
= lttv_attribute_add(attribute
,
196 value
= lttv_attribute_add(attribute
,
202 /* Remove a trace from the global attributes */
204 void lttvwindowtraces_remove_trace(LttvTrace
*trace
)
206 LttvAttribute
*g_attribute
= lttv_global_attributes();
207 LttvAttribute
*attribute
;
208 LttvAttributeValue value
;
212 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
215 for(i
=0;i
<lttvwindowtraces_get_number();i
++) {
216 LttvTrace
*trace_v
= lttvwindowtraces_get_trace(i
);
218 g_assert(trace_v
!= NULL
);
220 /* Remove and background computation that could be in progress */
221 g_idle_remove_by_data(trace_v
);
223 if(trace_v
== trace
) {
225 LttvAttribute
*l_attribute
;
227 /* destroy traceset and tracesetcontext */
229 LttvTracesetStats
*tss
;
231 l_attribute
= lttv_trace_attribute(trace
);
234 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute
),
235 LTTV_REQUESTS_QUEUE
);
237 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute
),
238 LTTV_REQUESTS_CURRENT
);
240 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute
),
243 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute
),
244 LTTV_NOTIFY_CURRENT
);
246 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(l_attribute
),
247 LTTV_COMPUTATION_TRACESET
,
250 ts
= (LttvTraceset
*)*(value
.v_pointer
);
252 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(l_attribute
),
253 LTTV_COMPUTATION_TRACESET_CONTEXT
,
256 tss
= (LttvTracesetStats
*)*(value
.v_pointer
);
258 lttv_context_fini(LTTV_TRACESET_CONTEXT(tss
));
260 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute
),
261 LTTV_COMPUTATION_TRACESET_CONTEXT
);
262 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute
),
263 LTTV_COMPUTATION_TRACESET
);
264 /* Destroy the traceset and the trace also */
265 lttv_traceset_destroy(ts
);
267 /* finally, remove the global attribute */
268 lttv_attribute_remove(attribute
, i
);
277 * Function to request data from a specific trace
279 * The memory allocated for the request will be managed by the API.
281 * @param trace the trace to compute
282 * @param module_name the name of the module which registered global computation
286 void lttvwindowtraces_background_request_queue
287 (LttvTrace
*trace
, gchar
*module_name
)
289 BackgroundRequest
*bg_req
;
290 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
291 LttvAttribute
*g_attribute
= lttv_global_attributes();
292 LttvAttribute
*module_attribute
;
293 LttvAttributeValue value
;
294 LttvAttributeType type
;
298 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
302 slist
= (GSList
**)(value
.v_pointer
);
304 /* Verify that the calculator is loaded */
305 g_assert(module_attribute
=
306 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
310 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
311 g_quark_from_string(module_name
),
313 if(type
== LTTV_NONE
) {
314 g_critical("Missing background calculator %s", module_name
);
318 bg_req
= g_new(BackgroundRequest
,1);
319 bg_req
->module_name
= g_quark_from_string(module_name
);
320 bg_req
->trace
= trace
;
322 *slist
= g_slist_append(*slist
, bg_req
);
324 /* Priority lower than live servicing */
325 g_idle_remove_by_data(trace
);
326 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 23),
327 (GSourceFunc
)lttvwindowtraces_process_pending_requests
,
330 /* FIXME : show message in status bar, need context and message id */
331 g_info("Background computation started for trace %p", trace
);
335 * Remove a background request from a trace.
337 * This should ONLY be used by the modules which registered the global hooks
338 * (module_name). If this is called by the viewers, it may lead to incomplete
339 * and incoherent background processing information.
341 * Even if the module which deals with the hooks removes the background
342 * requests, it may cause a problem if the module gets loaded again in the
343 * session : the data will be partially calculated. The calculation function
344 * must deal with this case correctly.
346 * @param trace the trace to compute
347 * @param module_name the name of the module which registered global computation
351 void lttvwindowtraces_background_request_remove
352 (LttvTrace
*trace
, gchar
*module_name
)
354 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
355 LttvAttributeValue value
;
359 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
363 slist
= (GSList
**)(value
.v_pointer
);
365 for(iter
=*slist
;iter
!=NULL
;) {
366 BackgroundRequest
*bg_req
=
367 (BackgroundRequest
*)iter
->data
;
369 if(bg_req
->module_name
== g_quark_from_string(module_name
)) {
370 GSList
*rem_iter
= iter
;
371 iter
=g_slist_next(iter
);
373 *slist
= g_slist_delete_link(*slist
, rem_iter
);
375 iter
=g_slist_next(iter
);
382 * Register a callback to be called when requested data is passed in the next
383 * queued background processing.
385 * @param owner owner of the background notification
386 * @param trace the trace computed
387 * @param notify_time time when notification hooks must be called
388 * @param notify_position position when notification hooks must be called
389 * @param notify Hook to call when the notify position is passed
392 void lttvwindowtraces_background_notify_queue
396 const LttvTracesetContextPosition
*notify_position
,
397 const LttvHooks
*notify
)
399 BackgroundNotify
*bg_notify
;
400 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
401 LttvAttributeValue value
;
404 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
408 slist
= (GSList
**)(value
.v_pointer
);
411 bg_notify
= g_new(BackgroundNotify
,1);
413 bg_notify
->owner
= owner
;
414 bg_notify
->trace
= trace
;
415 bg_notify
->notify_time
= notify_time
;
416 if(notify_position
!= NULL
) {
417 bg_notify
->notify_position
= lttv_traceset_context_position_new();
418 lttv_traceset_context_position_copy(bg_notify
->notify_position
,
421 bg_notify
->notify_position
= NULL
;
424 bg_notify
->notify
= lttv_hooks_new();
425 lttv_hooks_add_list(bg_notify
->notify
, notify
);
427 *slist
= g_slist_append(*slist
, bg_notify
);
431 * Register a callback to be called when requested data is passed in the current
432 * background processing.
434 * @param owner owner of the background notification
435 * @param trace the trace computed
436 * @param notify_time time when notification hooks must be called
437 * @param notify_position position when notification hooks must be called
438 * @param notify Hook to call when the notify position is passed
441 void lttvwindowtraces_background_notify_current
445 const LttvTracesetContextPosition
*notify_position
,
446 const LttvHooks
*notify
)
448 BackgroundNotify
*bg_notify
;
449 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
450 LttvAttributeValue value
;
453 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
457 slist
= (GSList
**)(value
.v_pointer
);
459 bg_notify
= g_new(BackgroundNotify
,1);
461 bg_notify
->owner
= owner
;
462 bg_notify
->trace
= trace
;
463 bg_notify
->notify_time
= notify_time
;
464 if(notify_position
!= NULL
) {
465 bg_notify
->notify_position
= lttv_traceset_context_position_new();
466 lttv_traceset_context_position_copy(bg_notify
->notify_position
,
469 bg_notify
->notify_position
= NULL
;
471 bg_notify
->notify
= lttv_hooks_new();
472 lttv_hooks_add_list(bg_notify
->notify
, notify
);
474 *slist
= g_slist_append(*slist
, bg_notify
);
478 static void notify_request_free(BackgroundNotify
*notify_req
)
480 if(notify_req
== NULL
) return;
482 if(notify_req
->notify_position
!= NULL
)
483 lttv_traceset_context_position_destroy(notify_req
->notify_position
);
484 if(notify_req
->notify
!= NULL
)
485 lttv_hooks_destroy(notify_req
->notify
);
490 * Removes all the notifications requests from a specific viewer.
492 * @param owner owner of the background notification
495 void lttvwindowtraces_background_notify_remove(gpointer owner
)
499 for(i
=0;i
<lttvwindowtraces_get_number();i
++) {
500 LttvAttribute
*attribute
;
501 LttvAttributeValue value
;
502 LttvTrace
*trace_v
= lttvwindowtraces_get_trace(i
);
506 g_assert(trace_v
!= NULL
);
508 attribute
= lttv_trace_attribute(trace_v
);
510 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
514 slist
= (GSList
**)(value
.v_pointer
);
516 for(iter
=*slist
;iter
!=NULL
;) {
518 BackgroundNotify
*bg_notify
= (BackgroundNotify
*)iter
->data
;
520 if(bg_notify
->owner
== owner
) {
521 GSList
*rem_iter
= iter
;
522 iter
=g_slist_next(iter
);
523 notify_request_free(bg_notify
);
524 *slist
= g_slist_remove_link(*slist
, rem_iter
);
526 iter
=g_slist_next(iter
);
530 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
534 slist
= (GSList
**)(value
.v_pointer
);
536 for(iter
=*slist
;iter
!=NULL
;) {
538 BackgroundNotify
*bg_notify
= (BackgroundNotify
*)iter
->data
;
540 if(bg_notify
->owner
== owner
) {
541 GSList
*rem_iter
= iter
;
542 iter
=g_slist_next(iter
);
543 notify_request_free(bg_notify
);
544 *slist
= g_slist_remove_link(*slist
, rem_iter
);
546 iter
=g_slist_next(iter
);
553 /* Background processing helper functions */
555 void lttvwindowtraces_add_computation_hooks(LttvAttributeName module_name
,
556 LttvTracesetContext
*tsc
,
557 LttvHooks
*hook_adder
)
559 LttvAttribute
*g_attribute
= lttv_global_attributes();
560 LttvAttribute
*module_attribute
;
561 LttvAttributeType type
;
562 LttvAttributeValue value
;
563 LttvHooks
*before_chunk_traceset
=NULL
;
564 LttvHooks
*before_chunk_trace
=NULL
;
565 LttvHooks
*before_chunk_tracefile
=NULL
;
566 LttvHooks
*event_hook
=NULL
;
567 LttvHooksById
*event_hook_by_id
=NULL
;
568 LttvTracesetStats
*tss
= LTTV_TRACESET_STATS(tsc
);
571 g_assert(module_attribute
=
572 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
575 g_assert(module_attribute
=
576 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
577 LTTV_IATTRIBUTE(module_attribute
),
580 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
581 LTTV_BEFORE_CHUNK_TRACESET
,
583 if(type
== LTTV_POINTER
) {
584 before_chunk_traceset
= (LttvHooks
*)*(value
.v_pointer
);
587 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
588 LTTV_BEFORE_CHUNK_TRACE
,
590 if(type
== LTTV_POINTER
) {
591 before_chunk_trace
= (LttvHooks
*)*(value
.v_pointer
);
594 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
595 LTTV_BEFORE_CHUNK_TRACEFILE
,
597 if(type
== LTTV_POINTER
) {
598 before_chunk_tracefile
= (LttvHooks
*)*(value
.v_pointer
);
601 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
604 if(type
== LTTV_POINTER
) {
605 event_hook
= (LttvHooks
*)*(value
.v_pointer
);
608 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
609 LTTV_EVENT_HOOK_BY_ID
,
611 if(type
== LTTV_POINTER
) {
612 event_hook_by_id
= (LttvHooksById
*)*(value
.v_pointer
);
615 /* Call the module's hook adder */
616 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
619 if(type
== LTTV_POINTER
) {
620 //lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss);
621 if(hook_adder
!= NULL
)
622 lttv_hooks_add_list(hook_adder
, (LttvHooks
*)*(value
.v_pointer
));
627 lttv_process_traceset_begin(tsc
,
628 before_chunk_traceset
,
630 before_chunk_tracefile
,
636 void lttvwindowtraces_remove_computation_hooks(LttvAttributeName module_name
,
637 LttvTracesetContext
*tsc
,
638 LttvHooks
*hook_remover
)
640 LttvAttribute
*g_attribute
= lttv_global_attributes();
641 LttvAttribute
*module_attribute
;
642 LttvAttributeType type
;
643 LttvAttributeValue value
;
644 LttvHooks
*after_chunk_traceset
=NULL
;
645 LttvHooks
*after_chunk_trace
=NULL
;
646 LttvHooks
*after_chunk_tracefile
=NULL
;
647 LttvHooks
*event_hook
=NULL
;
648 LttvHooksById
*event_hook_by_id
=NULL
;
649 LttvTracesetStats
*tss
= LTTV_TRACESET_STATS(tsc
);
651 g_assert(module_attribute
=
652 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
655 g_assert(module_attribute
=
656 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
657 LTTV_IATTRIBUTE(module_attribute
),
660 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
661 LTTV_AFTER_CHUNK_TRACESET
,
663 if(type
== LTTV_POINTER
) {
664 after_chunk_traceset
= (LttvHooks
*)*(value
.v_pointer
);
667 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
668 LTTV_AFTER_CHUNK_TRACE
,
670 if(type
== LTTV_POINTER
) {
671 after_chunk_trace
= (LttvHooks
*)*(value
.v_pointer
);
674 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
675 LTTV_AFTER_CHUNK_TRACEFILE
,
677 if(type
== LTTV_POINTER
) {
678 after_chunk_tracefile
= (LttvHooks
*)*(value
.v_pointer
);
681 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
684 if(type
== LTTV_POINTER
) {
685 event_hook
= (LttvHooks
*)*(value
.v_pointer
);
688 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
689 LTTV_EVENT_HOOK_BY_ID
,
691 if(type
== LTTV_POINTER
) {
692 event_hook_by_id
= (LttvHooksById
*)*(value
.v_pointer
);
695 lttv_process_traceset_end(tsc
,
696 after_chunk_traceset
,
698 after_chunk_tracefile
,
702 /* Call the module's hook remover */
703 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
706 if(type
== LTTV_POINTER
) {
707 //lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss);
708 if(hook_remover
!= NULL
)
709 lttv_hooks_add_list(hook_remover
, (LttvHooks
*)*(value
.v_pointer
));
714 void lttvwindowtraces_set_in_progress(LttvAttributeName module_name
,
717 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
718 LttvAttributeValue value
;
721 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
724 value
= lttv_iattribute_add(LTTV_IATTRIBUTE(attribute
),
727 /* the value is left unset. The only presence of the attribute is necessary.
731 void lttvwindowtraces_unset_in_progress(LttvAttributeName module_name
,
734 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
737 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
740 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
744 gboolean
lttvwindowtraces_get_in_progress(LttvAttributeName module_name
,
747 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
748 LttvAttributeType type
;
749 LttvAttributeValue value
;
752 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
755 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
758 /* The only presence of the attribute is necessary. */
759 if(type
== LTTV_NONE
)
765 void lttvwindowtraces_set_ready(LttvAttributeName module_name
,
768 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
769 LttvAttributeValue value
;
772 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
775 value
= lttv_iattribute_add(LTTV_IATTRIBUTE(attribute
),
778 /* the value is left unset. The only presence of the attribute is necessary.
782 void lttvwindowtraces_unset_ready(LttvAttributeName module_name
,
785 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
788 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
791 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
795 gboolean
lttvwindowtraces_get_ready(LttvAttributeName module_name
,
798 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
799 LttvAttributeType type
;
800 LttvAttributeValue value
;
803 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
806 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
809 /* The only presence of the attribute is necessary. */
810 if(type
== LTTV_NONE
)
817 /* lttvwindowtraces_process_pending_requests
819 * This internal function gets called by g_idle, taking care of the pending
825 gboolean
lttvwindowtraces_process_pending_requests(LttvTrace
*trace
)
827 LttvTracesetContext
*tsc
;
828 LttvTracesetStats
*tss
;
830 LttvAttribute
*attribute
;
831 LttvAttribute
*g_attribute
= lttv_global_attributes();
832 GSList
**list_out
, **list_in
, **notify_in
, **notify_out
;
833 LttvAttributeValue value
;
834 LttvAttributeType type
;
840 attribute
= lttv_trace_attribute(trace
);
842 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
845 g_assert(type
== LTTV_POINTER
);
846 list_out
= (GSList
**)(value
.v_pointer
);
848 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
849 LTTV_REQUESTS_CURRENT
,
851 g_assert(type
== LTTV_POINTER
);
852 list_in
= (GSList
**)(value
.v_pointer
);
854 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
857 g_assert(type
== LTTV_POINTER
);
858 notify_out
= (GSList
**)(value
.v_pointer
);
860 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
863 g_assert(type
== LTTV_POINTER
);
864 notify_in
= (GSList
**)(value
.v_pointer
);
866 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
867 LTTV_COMPUTATION_TRACESET
,
869 g_assert(type
== LTTV_POINTER
);
870 ts
= (LttvTraceset
*)*(value
.v_pointer
);
872 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
873 LTTV_COMPUTATION_TRACESET_CONTEXT
,
875 g_assert(type
== LTTV_POINTER
);
876 tsc
= (LttvTracesetContext
*)*(value
.v_pointer
);
877 tss
= (LttvTracesetStats
*)*(value
.v_pointer
);
878 g_assert(LTTV_IS_TRACESET_CONTEXT(tsc
));
879 g_assert(LTTV_IS_TRACESET_STATS(tss
));
881 /* There is no events requests pending : we should never have been called! */
882 g_assert(g_slist_length(*list_out
) != 0 || g_slist_length(*list_in
) != 0);
884 /* 0.1 Lock traces */
889 iter_trace
<lttv_traceset_number(tsc
->ts
);
891 LttvTrace
*trace_v
= lttv_traceset_get(tsc
->ts
,iter_trace
);
893 if(lttvwindowtraces_lock(trace_v
) != 0)
894 return TRUE
; /* Cannot get trace lock, try later */
898 /* 0.2 Sync tracefiles */
899 lttv_process_traceset_synchronize_tracefiles(tsc
);
901 /* 1. Before processing */
903 /* if list_in is empty */
904 if(g_slist_length(*list_in
) == 0) {
907 /* - Add all requests in list_out to list_in, empty list_out */
908 GSList
*iter
= *list_out
;
910 while(iter
!= NULL
) {
911 gboolean remove
= FALSE
;
912 gboolean free_data
= FALSE
;
914 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
918 *list_in
= g_slist_append(*list_in
, bg_req
);
923 GSList
*remove_iter
= iter
;
925 iter
= g_slist_next(iter
);
926 if(free_data
) g_free(remove_iter
->data
);
927 *list_out
= g_slist_remove_link(*list_out
, remove_iter
);
928 } else { // not remove
929 iter
= g_slist_next(iter
);
935 GSList
*iter
= *list_in
;
936 /* - for each request in list_in */
937 while(iter
!= NULL
) {
939 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
940 /* - set hooks'in_progress flag to TRUE */
941 lttvwindowtraces_set_in_progress(bg_req
->module_name
,
944 /* - call before request hook */
945 /* Get before request hook */
946 LttvAttribute
*module_attribute
;
948 g_assert(module_attribute
=
949 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
950 LTTV_IATTRIBUTE(g_attribute
),
953 g_assert(module_attribute
=
954 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
955 LTTV_IATTRIBUTE(module_attribute
),
956 bg_req
->module_name
)));
958 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
961 g_assert(type
== LTTV_POINTER
);
962 LttvHooks
*before_request
= (LttvHooks
*)*(value
.v_pointer
);
964 if(before_request
!= NULL
) lttv_hooks_call(before_request
, tsc
);
966 iter
= g_slist_next(iter
);
970 /* - seek trace to start */
972 LttTime start
= { 0, 0};
973 lttv_process_traceset_seek_time(tsc
, start
);
976 /* - Move all notifications from notify_out to notify_in. */
978 GSList
*iter
= *notify_out
;
979 g_assert(g_slist_length(*notify_in
) == 0);
981 while(iter
!= NULL
) {
982 gboolean remove
= FALSE
;
983 gboolean free_data
= FALSE
;
985 BackgroundNotify
*notify_req
= (BackgroundNotify
*)iter
->data
;
989 *notify_in
= g_slist_append(*notify_in
, notify_req
);
994 GSList
*remove_iter
= iter
;
996 iter
= g_slist_next(iter
);
998 notify_request_free((BackgroundNotify
*)remove_iter
->data
);
999 *notify_out
= g_slist_remove_link(*notify_out
, remove_iter
);
1000 } else { // not remove
1001 iter
= g_slist_next(iter
);
1008 GSList
*iter
= *list_in
;
1009 LttvHooks
*hook_adder
= lttv_hooks_new();
1010 /* - for each request in list_in */
1011 while(iter
!= NULL
) {
1013 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1014 /*- Call before chunk hooks for list_in*/
1015 /*- add hooks to context*/
1016 lttvwindowtraces_add_computation_hooks(bg_req
->module_name
,
1019 iter
= g_slist_next(iter
);
1021 lttv_hooks_call(hook_adder
,tsc
);
1022 lttv_hooks_destroy(hook_adder
);
1026 /* 2. call process traceset middle for a chunk */
1028 /*(assert list_in is not empty! : should not even be called in that case)*/
1029 LttTime end
= ltt_time_infinite
;
1030 g_assert(g_slist_length(*list_in
) != 0);
1032 lttv_process_traceset_middle(tsc
, end
, CHUNK_NUM_EVENTS
, NULL
);
1035 /* 3. After the chunk */
1037 /* 3.1 call after_chunk hooks for list_in */
1039 GSList
*iter
= *list_in
;
1040 LttvHooks
*hook_remover
= lttv_hooks_new();
1041 /* - for each request in list_in */
1042 while(iter
!= NULL
) {
1044 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1045 /* - Call after chunk hooks for list_in */
1046 /* - remove hooks from context */
1047 lttvwindowtraces_remove_computation_hooks(bg_req
->module_name
,
1050 iter
= g_slist_next(iter
);
1052 lttv_hooks_call(hook_remover
,tsc
);
1053 lttv_hooks_destroy(hook_remover
);
1056 /* 3.2 for each notify_in */
1058 GSList
*iter
= *notify_in
;
1059 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
1061 while(iter
!= NULL
) {
1062 gboolean remove
= FALSE
;
1063 gboolean free_data
= FALSE
;
1065 BackgroundNotify
*notify_req
= (BackgroundNotify
*)iter
->data
;
1067 /* - if current time >= notify time, call notify and remove from
1069 * - if current position >= notify position, call notify and remove
1073 ltt_time_compare(notify_req
->notify_time
, tfc
->timestamp
) <= 0)
1075 (notify_req
->notify_position
!= NULL
&&
1076 lttv_traceset_context_ctx_pos_compare(tsc
,
1077 notify_req
->notify_position
) >= 0)
1080 lttv_hooks_call(notify_req
->notify
, notify_req
);
1089 GSList
*remove_iter
= iter
;
1091 iter
= g_slist_next(iter
);
1093 notify_request_free((BackgroundNotify
*)remove_iter
->data
);
1094 *notify_in
= g_slist_remove_link(*notify_in
, remove_iter
);
1095 } else { // not remove
1096 iter
= g_slist_next(iter
);
1102 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
1103 /* 3.3 if end of trace reached */
1105 g_debug("Current time : %lu sec, %lu nsec",
1106 tfc
->timestamp
.tv_sec
, tfc
->timestamp
.tv_nsec
);
1107 if(tfc
== NULL
|| ltt_time_compare(tfc
->timestamp
,
1108 tsc
->time_span
.end_time
) > 0) {
1110 /* - for each request in list_in */
1112 GSList
*iter
= *list_in
;
1114 while(iter
!= NULL
) {
1115 gboolean remove
= FALSE
;
1116 gboolean free_data
= FALSE
;
1118 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1120 /* - set hooks'in_progress flag to FALSE */
1121 lttvwindowtraces_unset_in_progress(bg_req
->module_name
,
1123 /* - set hooks'ready flag to TRUE */
1124 lttvwindowtraces_set_ready(bg_req
->module_name
,
1126 /* - call after request hook */
1127 /* Get after request hook */
1128 LttvAttribute
*module_attribute
;
1130 g_assert(module_attribute
=
1131 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
1132 LTTV_IATTRIBUTE(g_attribute
),
1133 LTTV_COMPUTATION
)));
1135 g_assert(module_attribute
=
1136 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
1137 LTTV_IATTRIBUTE(module_attribute
),
1138 bg_req
->module_name
)));
1140 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
1143 g_assert(type
== LTTV_POINTER
);
1144 LttvHooks
*after_request
= (LttvHooks
*)*(value
.v_pointer
);
1146 if(after_request
!= NULL
) lttv_hooks_call(after_request
, tsc
);
1147 /* - remove request */
1154 GSList
*remove_iter
= iter
;
1156 iter
= g_slist_next(iter
);
1157 if(free_data
) g_free(remove_iter
->data
);
1158 *list_in
= g_slist_remove_link(*list_in
, remove_iter
);
1159 } else { // not remove
1160 iter
= g_slist_next(iter
);
1165 /* - for each notifications in notify_in */
1167 GSList
*iter
= *notify_in
;
1169 while(iter
!= NULL
) {
1170 gboolean remove
= FALSE
;
1171 gboolean free_data
= FALSE
;
1173 BackgroundNotify
*notify_req
= (BackgroundNotify
*)iter
->data
;
1175 /* - call notify and remove from notify_in */
1176 lttv_hooks_call(notify_req
->notify
, notify_req
);
1183 GSList
*remove_iter
= iter
;
1185 iter
= g_slist_next(iter
);
1187 notify_request_free((BackgroundNotify
*)remove_iter
->data
);
1188 *notify_in
= g_slist_remove_link(*notify_in
, remove_iter
);
1189 } else { // not remove
1190 iter
= g_slist_next(iter
);
1195 /* - reset the context */
1196 LTTV_TRACESET_CONTEXT_GET_CLASS(tsc
)->fini(tsc
);
1197 LTTV_TRACESET_CONTEXT_GET_CLASS(tsc
)->init(tsc
,ts
);
1199 /* - if list_out is empty */
1200 if(g_slist_length(*list_out
) == 0) {
1201 /* - return FALSE (scheduler stopped) */
1202 g_debug("Background computation scheduler stopped");
1203 g_info("Background computation finished for trace %p", trace
);
1204 /* FIXME : remove status bar info, need context id and message id */
1210 /* 3.4 else, end of trace not reached */
1211 /* - return TRUE (scheduler still registered) */
1212 g_debug("Background computation left");
1218 /* 4. Unlock traces */
1220 //lttv_process_traceset_get_sync_data(tsc);
1224 iter_trace
<lttv_traceset_number(tsc
->ts
);
1226 LttvTrace
*trace_v
= lttv_traceset_get(tsc
->ts
, iter_trace
);
1228 lttvwindowtraces_unlock(trace_v
);
1238 * Register the background computation hooks for a specific module. It adds the
1239 * computation hooks to the global attrubutes, under "computation/module name".
1241 * @param module_name A GQuark : the name of the module which computes the
1244 void lttvwindowtraces_register_computation_hooks(LttvAttributeName module_name
,
1245 LttvHooks
*before_chunk_traceset
,
1246 LttvHooks
*before_chunk_trace
,
1247 LttvHooks
*before_chunk_tracefile
,
1248 LttvHooks
*after_chunk_traceset
,
1249 LttvHooks
*after_chunk_trace
,
1250 LttvHooks
*after_chunk_tracefile
,
1251 LttvHooks
*before_request
,
1252 LttvHooks
*after_request
,
1253 LttvHooks
*event_hook
,
1254 LttvHooksById
*event_hook_by_id
,
1255 LttvHooks
*hook_adder
,
1256 LttvHooks
*hook_remover
)
1258 LttvAttribute
*g_attribute
= lttv_global_attributes();
1259 LttvAttribute
*attribute
;
1260 LttvAttributeValue value
;
1262 g_assert(attribute
=
1263 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
1264 LTTV_COMPUTATION
)));
1266 g_assert(attribute
=
1267 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
1270 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1271 LTTV_BEFORE_CHUNK_TRACESET
,
1274 *(value
.v_pointer
) = before_chunk_traceset
;
1276 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1277 LTTV_BEFORE_CHUNK_TRACE
,
1280 *(value
.v_pointer
) = before_chunk_trace
;
1282 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1283 LTTV_BEFORE_CHUNK_TRACEFILE
,
1286 *(value
.v_pointer
) = before_chunk_tracefile
;
1288 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1289 LTTV_AFTER_CHUNK_TRACESET
,
1292 *(value
.v_pointer
) = after_chunk_traceset
;
1294 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1295 LTTV_AFTER_CHUNK_TRACE
,
1298 *(value
.v_pointer
) = after_chunk_trace
;
1300 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1301 LTTV_AFTER_CHUNK_TRACEFILE
,
1304 *(value
.v_pointer
) = after_chunk_tracefile
;
1306 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1307 LTTV_BEFORE_REQUEST
,
1310 *(value
.v_pointer
) = before_request
;
1312 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1316 *(value
.v_pointer
) = after_request
;
1318 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1322 *(value
.v_pointer
) = event_hook
;
1324 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1325 LTTV_EVENT_HOOK_BY_ID
,
1328 *(value
.v_pointer
) = event_hook_by_id
;
1330 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1334 *(value
.v_pointer
) = hook_adder
;
1336 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1340 *(value
.v_pointer
) = hook_remover
;
1346 * It removes all the requests than can be currently processed by the
1347 * background computation algorithm for all the traces (list_in and list_out).
1349 * Leaves the flag to in_progress or none.. depending if current or queue
1351 * @param module_name A GQuark : the name of the module which computes the
1354 void lttvwindowtraces_unregister_requests(LttvAttributeName module_name
)
1358 for(i
=0;i
<lttvwindowtraces_get_number();i
++) {
1359 LttvTrace
*trace_v
= lttvwindowtraces_get_trace(i
);
1360 g_assert(trace_v
!= NULL
);
1362 LttvAttribute
*attribute
= lttv_trace_attribute(trace_v
);
1363 LttvAttributeValue value
;
1364 GSList
**queue
, **current
;
1367 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1368 LTTV_REQUESTS_QUEUE
,
1371 queue
= (GSList
**)(value
.v_pointer
);
1374 while(iter
!= NULL
) {
1375 gboolean remove
= FALSE
;
1376 gboolean free_data
= FALSE
;
1378 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1380 if(bg_req
->module_name
== module_name
) {
1388 GSList
*remove_iter
= iter
;
1390 iter
= g_slist_next(iter
);
1391 if(free_data
) g_free(remove_iter
->data
);
1392 *queue
= g_slist_remove_link(*queue
, remove_iter
);
1393 } else { // not remove
1394 iter
= g_slist_next(iter
);
1399 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1400 LTTV_REQUESTS_CURRENT
,
1403 current
= (GSList
**)(value
.v_pointer
);
1406 while(iter
!= NULL
) {
1407 gboolean remove
= FALSE
;
1408 gboolean free_data
= FALSE
;
1410 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1412 if(bg_req
->module_name
== module_name
) {
1420 GSList
*remove_iter
= iter
;
1422 iter
= g_slist_next(iter
);
1423 if(free_data
) g_free(remove_iter
->data
);
1424 *current
= g_slist_remove_link(*current
, remove_iter
);
1425 } else { // not remove
1426 iter
= g_slist_next(iter
);
1434 * Unregister the background computation hooks for a specific module.
1436 * It also removes all the requests than can be currently processed by the
1437 * background computation algorithm for all the traces (list_in and list_out).
1439 * @param module_name A GQuark : the name of the module which computes the
1443 void lttvwindowtraces_unregister_computation_hooks
1444 (LttvAttributeName module_name
)
1446 LttvAttribute
*g_attribute
= lttv_global_attributes();
1447 LttvAttribute
*attribute
;
1448 LttvAttributeValue value
;
1450 g_assert(attribute
=
1451 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
1452 LTTV_COMPUTATION
)));
1453 g_assert(attribute
=
1454 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
1458 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1459 LTTV_BEFORE_CHUNK_TRACESET
,
1462 LttvHooks
*before_chunk_traceset
= (LttvHooks
*)*(value
.v_pointer
);
1463 if(before_chunk_traceset
!= NULL
)
1464 lttv_hooks_destroy(before_chunk_traceset
);
1466 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1467 LTTV_BEFORE_CHUNK_TRACE
,
1470 LttvHooks
*before_chunk_trace
= (LttvHooks
*)*(value
.v_pointer
);
1471 if(before_chunk_trace
!= NULL
)
1472 lttv_hooks_destroy(before_chunk_trace
);
1474 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1475 LTTV_BEFORE_CHUNK_TRACEFILE
,
1478 LttvHooks
*before_chunk_tracefile
= (LttvHooks
*)*(value
.v_pointer
);
1479 if(before_chunk_tracefile
!= NULL
)
1480 lttv_hooks_destroy(before_chunk_tracefile
);
1482 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1483 LTTV_AFTER_CHUNK_TRACESET
,
1486 LttvHooks
*after_chunk_traceset
= (LttvHooks
*)*(value
.v_pointer
);
1487 if(after_chunk_traceset
!= NULL
)
1488 lttv_hooks_destroy(after_chunk_traceset
);
1490 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1491 LTTV_AFTER_CHUNK_TRACE
,
1494 LttvHooks
*after_chunk_trace
= (LttvHooks
*)*(value
.v_pointer
);
1495 if(after_chunk_trace
!= NULL
)
1496 lttv_hooks_destroy(after_chunk_trace
);
1498 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1499 LTTV_AFTER_CHUNK_TRACEFILE
,
1502 LttvHooks
*after_chunk_tracefile
= (LttvHooks
*)*(value
.v_pointer
);
1503 if(after_chunk_tracefile
!= NULL
)
1504 lttv_hooks_destroy(after_chunk_tracefile
);
1506 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1507 LTTV_BEFORE_REQUEST
,
1510 LttvHooks
*before_request
= (LttvHooks
*)*(value
.v_pointer
);
1511 if(before_request
!= NULL
)
1512 lttv_hooks_destroy(before_request
);
1514 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1518 LttvHooks
*after_request
= (LttvHooks
*)*(value
.v_pointer
);
1519 if(after_request
!= NULL
)
1520 lttv_hooks_destroy(after_request
);
1522 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1526 LttvHooks
*event_hook
= (LttvHooks
*)*(value
.v_pointer
);
1527 if(event_hook
!= NULL
)
1528 lttv_hooks_destroy(event_hook
);
1530 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1531 LTTV_EVENT_HOOK_BY_ID
,
1534 LttvHooksById
*event_hook_by_id
= (LttvHooksById
*)*(value
.v_pointer
);
1535 if(event_hook_by_id
!= NULL
)
1536 lttv_hooks_by_id_destroy(event_hook_by_id
);
1538 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1542 LttvHooks
*hook_adder
= (LttvHooks
*)*(value
.v_pointer
);
1543 if(hook_adder
!= NULL
)
1544 lttv_hooks_destroy(hook_adder
);
1546 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1550 LttvHooks
*hook_remover
= (LttvHooks
*)*(value
.v_pointer
);
1551 if(hook_remover
!= NULL
)
1552 lttv_hooks_destroy(hook_remover
);
1555 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1556 LTTV_EVENT_HOOK_BY_ID
);
1557 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1560 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1561 LTTV_AFTER_REQUEST
);
1562 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1563 LTTV_BEFORE_REQUEST
);
1565 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1566 LTTV_AFTER_CHUNK_TRACEFILE
);
1567 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1568 LTTV_AFTER_CHUNK_TRACE
);
1569 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1570 LTTV_AFTER_CHUNK_TRACESET
);
1572 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1573 LTTV_BEFORE_CHUNK_TRACEFILE
);
1574 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1575 LTTV_BEFORE_CHUNK_TRACE
);
1576 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1577 LTTV_BEFORE_CHUNK_TRACESET
);
1578 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1580 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1583 /* finally, remove module name */
1584 g_assert(attribute
=
1585 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
1586 LTTV_COMPUTATION
)));
1587 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1593 * Lock a trace so no other instance can use it.
1595 * @param trace The trace to lock.
1596 * @return 0 on success, -1 if cannot get lock.
1598 gint
lttvwindowtraces_lock(LttvTrace
*trace
)
1600 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
1601 LttvAttributeValue value
;
1602 LttvAttributeType type
;
1604 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
1607 /* Verify the absence of the lock. */
1608 if(type
!= LTTV_NONE
) {
1609 g_critical("Cannot take trace lock");
1613 value
= lttv_iattribute_add(LTTV_IATTRIBUTE(attribute
),
1616 /* the value is left unset. The only presence of the attribute is necessary.
1625 * @param trace The trace to unlock.
1626 * @return 0 on success, -1 if cannot unlock (not locked ?).
1628 gint
lttvwindowtraces_unlock(LttvTrace
*trace
)
1630 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
1631 LttvAttributeType type
;
1632 LttvAttributeValue value
;
1634 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
1637 /* Verify the presence of the lock. */
1638 if(type
== LTTV_NONE
) {
1639 g_critical("Cannot release trace lock");
1643 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1650 * Verify if a trace is locked.
1652 * @param trace The trace to verify.
1653 * @return TRUE if locked, FALSE is unlocked.
1655 gint
lttvwindowtraces_get_lock_state(LttvTrace
*trace
)
1657 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
1658 LttvAttributeType type
;
1659 LttvAttributeValue value
;
1661 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
1664 /* The only presence of the attribute is necessary. */
1665 if(type
== LTTV_NONE
)