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 */
23 #include <sys/types.h>
28 #include <ltt/trace.h>
30 #include <lttv/lttv.h>
31 #include <lttv/traceset.h>
32 #include <lttv/attribute.h>
33 #include <lttv/tracecontext.h>
34 #include <lttvwindow/lttvwindowtraces.h>
35 #include <lttvwindow/lttvwindow.h> // for CHUNK_NUM_EVENTS
38 typedef struct _BackgroundRequest
{
39 LttvAttributeName module_name
; /* Hook path in global attributes,
40 where all standard hooks under computation/.
42 LttvTrace
*trace
; /* trace concerned */
45 typedef struct _BackgroundNotify
{
47 LttvTrace
*trace
; /* trace */
49 LttvTracesetContextPosition
*notify_position
;
50 LttvHooks
*notify
; /* Hook to call when the notify is
51 passed, or at the end of trace */
57 gboolean
lttvwindowtraces_process_pending_requests(LttvTrace
*trace
);
59 /* Get a trace by its path name.
61 * @param path path of the trace on the virtual file system.
62 * @return Pointer to trace if found
63 * NULL is returned if the trace is not present
66 LttvTrace
*lttvwindowtraces_get_trace_by_name(gchar
*path
)
68 LttvAttribute
*attribute
= lttv_global_attributes();
71 for(i
=0;i
<lttvwindowtraces_get_number();i
++) {
72 LttvTrace
*trace_v
= lttvwindowtraces_get_trace(i
);
75 g_assert(trace_v
!= NULL
);
77 trace
= lttv_trace(trace_v
);
78 g_assert(trace
!= NULL
);
79 name
= ltt_trace_name(trace
);
81 if(strcmp(name
, path
) == 0) {
90 /* Get a trace by its number identifier */
92 LttvTrace
*lttvwindowtraces_get_trace(guint num
)
94 LttvAttribute
*g_attribute
= lttv_global_attributes();
95 LttvAttribute
*attribute
;
96 LttvAttributeType type
;
97 LttvAttributeName name
;
98 LttvAttributeValue value
;
101 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
104 type
= lttv_iattribute_get(LTTV_IATTRIBUTE(attribute
), num
, &name
, &value
);
106 if(type
== LTTV_POINTER
) {
107 return (LttvTrace
*)*(value
.v_pointer
);
113 /* Total number of traces */
115 guint
lttvwindowtraces_get_number()
117 LttvAttribute
*g_attribute
= lttv_global_attributes();
118 LttvAttribute
*attribute
;
119 LttvAttributeValue value
;
122 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
125 return ( lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute
)) );
128 /* Add a trace to the global attributes */
130 void lttvwindowtraces_add_trace(LttvTrace
*trace
)
132 LttvAttribute
*g_attribute
= lttv_global_attributes();
133 LttvAttribute
*attribute
;
134 LttvAttributeValue value
;
137 gchar attribute_path
[PATH_MAX
];
139 if(stat(ltt_trace_name(lttv_trace(trace
)), &buf
)) {
140 g_warning("lttvwindowtraces_add_trace: Trace %s not found",
141 ltt_trace_name(lttv_trace(trace
)));
145 snprintf(attribute_path
, PATH_MAX
, "%lu:%lu", buf
.st_dev
, buf
.st_ino
) >= 0);
148 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
151 value
= lttv_attribute_add(attribute
,
152 g_quark_from_string(attribute_path
),
155 *(value
.v_pointer
) = (gpointer
)trace
;
157 /* create new traceset and tracesetcontext */
159 LttvTracesetStats
*tss
;
161 attribute
= lttv_trace_attribute(trace
);
162 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
163 LTTV_COMPUTATION_TRACESET
,
166 ts
= lttv_traceset_new();
167 *(value
.v_pointer
) = ts
;
169 lttv_traceset_add(ts
,trace
);
171 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
172 LTTV_COMPUTATION_TRACESET_CONTEXT
,
175 tss
= g_object_new(LTTV_TRACESET_STATS_TYPE
, NULL
);
176 *(value
.v_pointer
) = tss
;
178 lttv_context_init(LTTV_TRACESET_CONTEXT(tss
), ts
);
180 value
= lttv_attribute_add(attribute
,
184 value
= lttv_attribute_add(attribute
,
185 LTTV_REQUESTS_CURRENT
,
188 value
= lttv_attribute_add(attribute
,
192 value
= lttv_attribute_add(attribute
,
198 /* Remove a trace from the global attributes */
200 void lttvwindowtraces_remove_trace(LttvTrace
*trace
)
202 LttvAttribute
*g_attribute
= lttv_global_attributes();
203 LttvAttribute
*attribute
;
204 LttvAttributeValue value
;
208 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
211 for(i
=0;i
<lttvwindowtraces_get_number();i
++) {
212 LttvTrace
*trace_v
= lttvwindowtraces_get_trace(i
);
214 g_assert(trace_v
!= NULL
);
216 /* Remove and background computation that could be in progress */
217 g_idle_remove_by_data(trace_v
);
219 if(trace_v
== trace
) {
221 LttvAttribute
*l_attribute
;
223 /* create new traceset and tracesetcontext */
225 LttvTracesetStats
*tss
;
227 l_attribute
= lttv_trace_attribute(trace
);
230 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute
),
231 LTTV_REQUESTS_QUEUE
);
233 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute
),
234 LTTV_REQUESTS_CURRENT
);
236 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute
),
239 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute
),
240 LTTV_NOTIFY_CURRENT
);
242 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(l_attribute
),
243 LTTV_COMPUTATION_TRACESET
,
246 ts
= (LttvTraceset
*)*(value
.v_pointer
);
248 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(l_attribute
),
249 LTTV_COMPUTATION_TRACESET_CONTEXT
,
252 tss
= (LttvTracesetStats
*)*(value
.v_pointer
);
254 lttv_context_fini(LTTV_TRACESET_CONTEXT(tss
));
256 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute
),
257 LTTV_COMPUTATION_TRACESET_CONTEXT
);
258 lttv_traceset_destroy(ts
);
259 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute
),
260 LTTV_COMPUTATION_TRACESET
);
262 /* finally, remove the global attribute */
263 lttv_attribute_remove(attribute
, i
);
272 * Function to request data from a specific trace
274 * The memory allocated for the request will be managed by the API.
276 * @param trace the trace to compute
277 * @param module_name the name of the module which registered global computation
281 void lttvwindowtraces_background_request_queue
282 (LttvTrace
*trace
, gchar
*module_name
)
284 BackgroundRequest
*bg_req
;
285 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
286 LttvAttribute
*g_attribute
= lttv_global_attributes();
287 LttvAttribute
*module_attribute
;
288 LttvAttributeValue value
;
289 LttvAttributeType type
;
293 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
297 slist
= (GSList
**)(value
.v_pointer
);
299 /* Verify that the calculator is loaded */
300 g_assert(module_attribute
=
301 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
305 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
306 g_quark_from_string(module_name
),
308 if(type
== LTTV_NONE
) {
309 g_critical("Missing background calculator %s", module_name
);
313 bg_req
= g_new(BackgroundRequest
,1);
314 bg_req
->module_name
= g_quark_from_string(module_name
);
315 bg_req
->trace
= trace
;
317 *slist
= g_slist_append(*slist
, bg_req
);
319 /* Priority lower than live servicing */
320 g_idle_remove_by_data(trace
);
321 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 23),
322 (GSourceFunc
)lttvwindowtraces_process_pending_requests
,
325 /* FIXME : show message in status bar, need context and message id */
326 g_info("Background computation started for trace %p", trace
);
330 * Remove a background request from a trace.
332 * This should ONLY be used by the modules which registered the global hooks
333 * (module_name). If this is called by the viewers, it may lead to incomplete
334 * and incoherent background processing information.
336 * Even if the module which deals with the hooks removes the background
337 * requests, it may cause a problem if the module gets loaded again in the
338 * session : the data will be partially calculated. The calculation function
339 * must deal with this case correctly.
341 * @param trace the trace to compute
342 * @param module_name the name of the module which registered global computation
346 void lttvwindowtraces_background_request_remove
347 (LttvTrace
*trace
, gchar
*module_name
)
349 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
350 LttvAttributeValue value
;
354 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
358 slist
= (GSList
**)(value
.v_pointer
);
360 for(iter
=*slist
;iter
!=NULL
;) {
361 BackgroundRequest
*bg_req
=
362 (BackgroundRequest
*)iter
->data
;
364 if(bg_req
->module_name
== g_quark_from_string(module_name
)) {
365 GSList
*rem_iter
= iter
;
366 iter
=g_slist_next(iter
);
368 *slist
= g_slist_delete_link(*slist
, rem_iter
);
370 iter
=g_slist_next(iter
);
377 * Register a callback to be called when requested data is passed in the next
378 * queued background processing.
380 * @param owner owner of the background notification
381 * @param trace the trace computed
382 * @param notify_time time when notification hooks must be called
383 * @param notify_position position when notification hooks must be called
384 * @param notify Hook to call when the notify position is passed
387 void lttvwindowtraces_background_notify_queue
391 const LttvTracesetContextPosition
*notify_position
,
392 const LttvHooks
*notify
)
394 BackgroundNotify
*bg_notify
;
395 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
396 LttvAttributeValue value
;
399 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
403 slist
= (GSList
**)(value
.v_pointer
);
406 bg_notify
= g_new(BackgroundNotify
,1);
408 bg_notify
->owner
= owner
;
409 bg_notify
->trace
= trace
;
410 bg_notify
->notify_time
= notify_time
;
411 if(notify_position
!= NULL
) {
412 bg_notify
->notify_position
= lttv_traceset_context_position_new();
413 lttv_traceset_context_position_copy(bg_notify
->notify_position
,
416 bg_notify
->notify_position
= NULL
;
419 bg_notify
->notify
= lttv_hooks_new();
420 lttv_hooks_add_list(bg_notify
->notify
, notify
);
422 *slist
= g_slist_append(*slist
, bg_notify
);
426 * Register a callback to be called when requested data is passed in the current
427 * background processing.
429 * @param owner owner of the background notification
430 * @param trace the trace computed
431 * @param notify_time time when notification hooks must be called
432 * @param notify_position position when notification hooks must be called
433 * @param notify Hook to call when the notify position is passed
436 void lttvwindowtraces_background_notify_current
440 const LttvTracesetContextPosition
*notify_position
,
441 const LttvHooks
*notify
)
443 BackgroundNotify
*bg_notify
;
444 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
445 LttvAttributeValue value
;
448 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
452 slist
= (GSList
**)(value
.v_pointer
);
454 bg_notify
= g_new(BackgroundNotify
,1);
456 bg_notify
->owner
= owner
;
457 bg_notify
->trace
= trace
;
458 bg_notify
->notify_time
= notify_time
;
459 if(notify_position
!= NULL
) {
460 bg_notify
->notify_position
= lttv_traceset_context_position_new();
461 lttv_traceset_context_position_copy(bg_notify
->notify_position
,
464 bg_notify
->notify_position
= NULL
;
466 bg_notify
->notify
= lttv_hooks_new();
467 lttv_hooks_add_list(bg_notify
->notify
, notify
);
469 *slist
= g_slist_append(*slist
, bg_notify
);
473 static void notify_request_free(BackgroundNotify
*notify_req
)
475 if(notify_req
== NULL
) return;
477 if(notify_req
->notify_position
!= NULL
)
478 lttv_traceset_context_position_destroy(notify_req
->notify_position
);
479 if(notify_req
->notify
!= NULL
)
480 lttv_hooks_destroy(notify_req
->notify
);
485 * Removes all the notifications requests from a specific viewer.
487 * @param owner owner of the background notification
490 void lttvwindowtraces_background_notify_remove(gpointer owner
)
494 for(i
=0;i
<lttvwindowtraces_get_number();i
++) {
495 LttvAttribute
*attribute
;
496 LttvAttributeValue value
;
497 LttvTrace
*trace_v
= lttvwindowtraces_get_trace(i
);
501 g_assert(trace_v
!= NULL
);
503 attribute
= lttv_trace_attribute(trace_v
);
505 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
509 slist
= (GSList
**)(value
.v_pointer
);
511 for(iter
=*slist
;iter
!=NULL
;) {
513 BackgroundNotify
*bg_notify
= (BackgroundNotify
*)iter
->data
;
515 if(bg_notify
->owner
== owner
) {
516 GSList
*rem_iter
= iter
;
517 iter
=g_slist_next(iter
);
518 notify_request_free(bg_notify
);
519 *slist
= g_slist_remove_link(*slist
, rem_iter
);
521 iter
=g_slist_next(iter
);
525 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
529 slist
= (GSList
**)(value
.v_pointer
);
531 for(iter
=*slist
;iter
!=NULL
;) {
533 BackgroundNotify
*bg_notify
= (BackgroundNotify
*)iter
->data
;
535 if(bg_notify
->owner
== owner
) {
536 GSList
*rem_iter
= iter
;
537 iter
=g_slist_next(iter
);
538 notify_request_free(bg_notify
);
539 *slist
= g_slist_remove_link(*slist
, rem_iter
);
541 iter
=g_slist_next(iter
);
548 /* Background processing helper functions */
550 void lttvwindowtraces_add_computation_hooks(LttvAttributeName module_name
,
551 LttvTracesetContext
*tsc
,
552 LttvHooks
*hook_adder
)
554 LttvAttribute
*g_attribute
= lttv_global_attributes();
555 LttvAttribute
*module_attribute
;
556 LttvAttributeType type
;
557 LttvAttributeValue value
;
558 LttvHooks
*before_chunk_traceset
=NULL
;
559 LttvHooks
*before_chunk_trace
=NULL
;
560 LttvHooks
*before_chunk_tracefile
=NULL
;
561 LttvHooks
*event_hook
=NULL
;
562 LttvHooksById
*event_hook_by_id
=NULL
;
563 LttvTracesetStats
*tss
= LTTV_TRACESET_STATS(tsc
);
566 g_assert(module_attribute
=
567 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
570 g_assert(module_attribute
=
571 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
572 LTTV_IATTRIBUTE(module_attribute
),
575 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
576 LTTV_BEFORE_CHUNK_TRACESET
,
578 if(type
== LTTV_POINTER
) {
579 before_chunk_traceset
= (LttvHooks
*)*(value
.v_pointer
);
582 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
583 LTTV_BEFORE_CHUNK_TRACE
,
585 if(type
== LTTV_POINTER
) {
586 before_chunk_trace
= (LttvHooks
*)*(value
.v_pointer
);
589 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
590 LTTV_BEFORE_CHUNK_TRACEFILE
,
592 if(type
== LTTV_POINTER
) {
593 before_chunk_tracefile
= (LttvHooks
*)*(value
.v_pointer
);
596 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
599 if(type
== LTTV_POINTER
) {
600 event_hook
= (LttvHooks
*)*(value
.v_pointer
);
603 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
604 LTTV_EVENT_HOOK_BY_ID
,
606 if(type
== LTTV_POINTER
) {
607 event_hook_by_id
= (LttvHooksById
*)*(value
.v_pointer
);
610 /* Call the module's hook adder */
611 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
614 if(type
== LTTV_POINTER
) {
615 //lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss);
616 if(hook_adder
!= NULL
)
617 lttv_hooks_add_list(hook_adder
, (LttvHooks
*)*(value
.v_pointer
));
622 lttv_process_traceset_begin(tsc
,
623 before_chunk_traceset
,
625 before_chunk_tracefile
,
631 void lttvwindowtraces_remove_computation_hooks(LttvAttributeName module_name
,
632 LttvTracesetContext
*tsc
,
633 LttvHooks
*hook_remover
)
635 LttvAttribute
*g_attribute
= lttv_global_attributes();
636 LttvAttribute
*module_attribute
;
637 LttvAttributeType type
;
638 LttvAttributeValue value
;
639 LttvHooks
*after_chunk_traceset
=NULL
;
640 LttvHooks
*after_chunk_trace
=NULL
;
641 LttvHooks
*after_chunk_tracefile
=NULL
;
642 LttvHooks
*event_hook
=NULL
;
643 LttvHooksById
*event_hook_by_id
=NULL
;
644 LttvTracesetStats
*tss
= LTTV_TRACESET_STATS(tsc
);
646 g_assert(module_attribute
=
647 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
650 g_assert(module_attribute
=
651 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
652 LTTV_IATTRIBUTE(module_attribute
),
655 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
656 LTTV_AFTER_CHUNK_TRACESET
,
658 if(type
== LTTV_POINTER
) {
659 after_chunk_traceset
= (LttvHooks
*)*(value
.v_pointer
);
662 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
663 LTTV_AFTER_CHUNK_TRACE
,
665 if(type
== LTTV_POINTER
) {
666 after_chunk_trace
= (LttvHooks
*)*(value
.v_pointer
);
669 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
670 LTTV_AFTER_CHUNK_TRACEFILE
,
672 if(type
== LTTV_POINTER
) {
673 after_chunk_tracefile
= (LttvHooks
*)*(value
.v_pointer
);
676 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
679 if(type
== LTTV_POINTER
) {
680 event_hook
= (LttvHooks
*)*(value
.v_pointer
);
683 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
684 LTTV_EVENT_HOOK_BY_ID
,
686 if(type
== LTTV_POINTER
) {
687 event_hook_by_id
= (LttvHooksById
*)*(value
.v_pointer
);
690 lttv_process_traceset_end(tsc
,
691 after_chunk_traceset
,
693 after_chunk_tracefile
,
697 /* Call the module's hook remover */
698 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
701 if(type
== LTTV_POINTER
) {
702 //lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss);
703 if(hook_remover
!= NULL
)
704 lttv_hooks_add_list(hook_remover
, (LttvHooks
*)*(value
.v_pointer
));
709 void lttvwindowtraces_set_in_progress(LttvAttributeName module_name
,
712 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
713 LttvAttributeValue value
;
716 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
719 value
= lttv_iattribute_add(LTTV_IATTRIBUTE(attribute
),
722 /* the value is left unset. The only presence of the attribute is necessary.
726 void lttvwindowtraces_unset_in_progress(LttvAttributeName module_name
,
729 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
732 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
735 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
739 gboolean
lttvwindowtraces_get_in_progress(LttvAttributeName module_name
,
742 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
743 LttvAttributeType type
;
744 LttvAttributeValue value
;
747 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
750 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
753 /* The only presence of the attribute is necessary. */
754 if(type
== LTTV_NONE
)
760 void lttvwindowtraces_set_ready(LttvAttributeName module_name
,
763 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
764 LttvAttributeValue value
;
767 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
770 value
= lttv_iattribute_add(LTTV_IATTRIBUTE(attribute
),
773 /* the value is left unset. The only presence of the attribute is necessary.
777 void lttvwindowtraces_unset_ready(LttvAttributeName module_name
,
780 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
783 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
786 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
790 gboolean
lttvwindowtraces_get_ready(LttvAttributeName module_name
,
793 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
794 LttvAttributeType type
;
795 LttvAttributeValue value
;
798 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
801 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
804 /* The only presence of the attribute is necessary. */
805 if(type
== LTTV_NONE
)
812 /* lttvwindowtraces_process_pending_requests
814 * This internal function gets called by g_idle, taking care of the pending
820 gboolean
lttvwindowtraces_process_pending_requests(LttvTrace
*trace
)
822 LttvTracesetContext
*tsc
;
823 LttvTracesetStats
*tss
;
825 LttvAttribute
*attribute
;
826 LttvAttribute
*g_attribute
= lttv_global_attributes();
827 GSList
**list_out
, **list_in
, **notify_in
, **notify_out
;
828 LttvAttributeValue value
;
829 LttvAttributeType type
;
831 LttvHooks
*before_request
, *after_request
;
836 attribute
= lttv_trace_attribute(trace
);
838 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
841 g_assert(type
== LTTV_POINTER
);
842 list_out
= (GSList
**)(value
.v_pointer
);
844 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
845 LTTV_REQUESTS_CURRENT
,
847 g_assert(type
== LTTV_POINTER
);
848 list_in
= (GSList
**)(value
.v_pointer
);
850 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
853 g_assert(type
== LTTV_POINTER
);
854 notify_out
= (GSList
**)(value
.v_pointer
);
856 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
859 g_assert(type
== LTTV_POINTER
);
860 notify_in
= (GSList
**)(value
.v_pointer
);
862 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
863 LTTV_COMPUTATION_TRACESET
,
865 g_assert(type
== LTTV_POINTER
);
866 ts
= (LttvTraceset
*)*(value
.v_pointer
);
868 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
869 LTTV_COMPUTATION_TRACESET_CONTEXT
,
871 g_assert(type
== LTTV_POINTER
);
872 tsc
= (LttvTracesetContext
*)*(value
.v_pointer
);
873 tss
= (LttvTracesetStats
*)*(value
.v_pointer
);
874 g_assert(LTTV_IS_TRACESET_CONTEXT(tsc
));
875 g_assert(LTTV_IS_TRACESET_STATS(tss
));
877 /* There is no events requests pending : we should never have been called! */
878 g_assert(g_slist_length(*list_out
) != 0 || g_slist_length(*list_in
) != 0);
880 /* 0.1 Lock traces */
885 iter_trace
<lttv_traceset_number(tsc
->ts
);
887 LttvTrace
*trace_v
= lttv_traceset_get(tsc
->ts
,iter_trace
);
889 if(lttvwindowtraces_lock(trace_v
) != 0)
890 return TRUE
; /* Cannot get trace lock, try later */
894 /* 0.2 Sync tracefiles */
895 lttv_process_traceset_synchronize_tracefiles(tsc
);
897 /* 1. Before processing */
899 /* if list_in is empty */
900 if(g_slist_length(*list_in
) == 0) {
903 /* - Add all requests in list_out to list_in, empty list_out */
904 GSList
*iter
= *list_out
;
906 while(iter
!= NULL
) {
907 gboolean remove
= FALSE
;
908 gboolean free_data
= FALSE
;
910 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
914 *list_in
= g_slist_append(*list_in
, bg_req
);
919 GSList
*remove_iter
= iter
;
921 iter
= g_slist_next(iter
);
922 if(free_data
) g_free(remove_iter
->data
);
923 *list_out
= g_slist_remove_link(*list_out
, remove_iter
);
924 } else { // not remove
925 iter
= g_slist_next(iter
);
931 GSList
*iter
= *list_in
;
932 /* - for each request in list_in */
933 while(iter
!= NULL
) {
935 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
936 /* - set hooks'in_progress flag to TRUE */
937 lttvwindowtraces_set_in_progress(bg_req
->module_name
,
940 /* - call before request hook */
941 /* Get before request hook */
942 LttvAttribute
*module_attribute
;
944 g_assert(module_attribute
=
945 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
946 LTTV_IATTRIBUTE(g_attribute
),
949 g_assert(module_attribute
=
950 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
951 LTTV_IATTRIBUTE(module_attribute
),
952 bg_req
->module_name
)));
954 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
957 g_assert(type
== LTTV_POINTER
);
958 LttvHooks
*before_request
= (LttvHooks
*)*(value
.v_pointer
);
961 if(before_request
!= NULL
) lttv_hooks_call(before_request
, tsc
);
963 iter
= g_slist_next(iter
);
967 /* - seek trace to start */
969 LttTime start
= { 0, 0};
970 lttv_process_traceset_seek_time(tsc
, start
);
973 /* - Move all notifications from notify_out to notify_in. */
975 GSList
*iter
= *notify_out
;
976 g_assert(g_slist_length(*notify_in
) == 0);
978 while(iter
!= NULL
) {
979 gboolean remove
= FALSE
;
980 gboolean free_data
= FALSE
;
982 BackgroundNotify
*notify_req
= (BackgroundNotify
*)iter
->data
;
986 *notify_in
= g_slist_append(*notify_in
, notify_req
);
991 GSList
*remove_iter
= iter
;
993 iter
= g_slist_next(iter
);
995 notify_request_free((BackgroundNotify
*)remove_iter
->data
);
996 *notify_out
= g_slist_remove_link(*notify_out
, remove_iter
);
997 } else { // not remove
998 iter
= g_slist_next(iter
);
1005 GSList
*iter
= *list_in
;
1006 LttvHooks
*hook_adder
= lttv_hooks_new();
1007 /* - for each request in list_in */
1008 while(iter
!= NULL
) {
1010 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1011 /*- Call before chunk hooks for list_in*/
1012 /*- add hooks to context*/
1013 lttvwindowtraces_add_computation_hooks(bg_req
->module_name
,
1016 iter
= g_slist_next(iter
);
1018 lttv_hooks_call(hook_adder
,tsc
);
1019 lttv_hooks_destroy(hook_adder
);
1023 /* 2. call process traceset middle for a chunk */
1025 /*(assert list_in is not empty! : should not even be called in that case)*/
1026 LttTime end
= { G_MAXUINT
, G_MAXUINT
};
1027 g_assert(g_slist_length(*list_in
) != 0);
1029 lttv_process_traceset_middle(tsc
, end
, CHUNK_NUM_EVENTS
, NULL
);
1032 /* 3. After the chunk */
1034 /* 3.1 call after_chunk hooks for list_in */
1036 GSList
*iter
= *list_in
;
1037 LttvHooks
*hook_remover
= lttv_hooks_new();
1038 /* - for each request in list_in */
1039 while(iter
!= NULL
) {
1041 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1042 /* - Call after chunk hooks for list_in */
1043 /* - remove hooks from context */
1044 lttvwindowtraces_remove_computation_hooks(bg_req
->module_name
,
1047 iter
= g_slist_next(iter
);
1049 lttv_hooks_call(hook_remover
,tsc
);
1050 lttv_hooks_destroy(hook_remover
);
1053 /* 3.2 for each notify_in */
1055 GSList
*iter
= *notify_in
;
1056 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
1058 while(iter
!= NULL
) {
1059 gboolean remove
= FALSE
;
1060 gboolean free_data
= FALSE
;
1062 BackgroundNotify
*notify_req
= (BackgroundNotify
*)iter
->data
;
1064 /* - if current time >= notify time, call notify and remove from
1066 * - if current position >= notify position, call notify and remove
1070 ltt_time_compare(notify_req
->notify_time
, tfc
->timestamp
) <= 0)
1072 (notify_req
->notify_position
!= NULL
&&
1073 lttv_traceset_context_ctx_pos_compare(tsc
,
1074 notify_req
->notify_position
) >= 0)
1077 lttv_hooks_call(notify_req
->notify
, notify_req
);
1086 GSList
*remove_iter
= iter
;
1088 iter
= g_slist_next(iter
);
1090 notify_request_free((BackgroundNotify
*)remove_iter
->data
);
1091 *notify_in
= g_slist_remove_link(*notify_in
, remove_iter
);
1092 } else { // not remove
1093 iter
= g_slist_next(iter
);
1099 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
1100 /* 3.3 if end of trace reached */
1102 g_debug("Current time : %lu sec, %lu nsec",
1103 tfc
->timestamp
.tv_sec
, tfc
->timestamp
.tv_nsec
);
1104 if(tfc
== NULL
|| ltt_time_compare(tfc
->timestamp
,
1105 tsc
->time_span
.end_time
) > 0) {
1107 /* - for each request in list_in */
1109 GSList
*iter
= *list_in
;
1111 while(iter
!= NULL
) {
1112 gboolean remove
= FALSE
;
1113 gboolean free_data
= FALSE
;
1115 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1117 /* - set hooks'in_progress flag to FALSE */
1118 lttvwindowtraces_unset_in_progress(bg_req
->module_name
,
1120 /* - set hooks'ready flag to TRUE */
1121 lttvwindowtraces_set_ready(bg_req
->module_name
,
1123 /* - call after request hook */
1124 /* Get after request hook */
1125 LttvAttribute
*module_attribute
;
1127 g_assert(module_attribute
=
1128 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
1129 LTTV_IATTRIBUTE(g_attribute
),
1130 LTTV_COMPUTATION
)));
1132 g_assert(module_attribute
=
1133 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
1134 LTTV_IATTRIBUTE(module_attribute
),
1135 bg_req
->module_name
)));
1137 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
1140 g_assert(type
== LTTV_POINTER
);
1141 LttvHooks
*after_request
= (LttvHooks
*)*(value
.v_pointer
);
1143 if(after_request
!= NULL
) lttv_hooks_call(after_request
, tsc
);
1144 /* - remove request */
1151 GSList
*remove_iter
= iter
;
1153 iter
= g_slist_next(iter
);
1154 if(free_data
) g_free(remove_iter
->data
);
1155 *list_in
= g_slist_remove_link(*list_in
, remove_iter
);
1156 } else { // not remove
1157 iter
= g_slist_next(iter
);
1162 /* - for each notifications in notify_in */
1164 GSList
*iter
= *notify_in
;
1166 while(iter
!= NULL
) {
1167 gboolean remove
= FALSE
;
1168 gboolean free_data
= FALSE
;
1170 BackgroundNotify
*notify_req
= (BackgroundNotify
*)iter
->data
;
1172 /* - call notify and remove from notify_in */
1173 lttv_hooks_call(notify_req
->notify
, notify_req
);
1180 GSList
*remove_iter
= iter
;
1182 iter
= g_slist_next(iter
);
1184 notify_request_free((BackgroundNotify
*)remove_iter
->data
);
1185 *notify_in
= g_slist_remove_link(*notify_in
, remove_iter
);
1186 } else { // not remove
1187 iter
= g_slist_next(iter
);
1192 /* - reset the context */
1193 LTTV_TRACESET_CONTEXT_GET_CLASS(tsc
)->fini(tsc
);
1194 LTTV_TRACESET_CONTEXT_GET_CLASS(tsc
)->init(tsc
,ts
);
1196 /* - if list_out is empty */
1197 if(g_slist_length(*list_out
) == 0) {
1198 /* - return FALSE (scheduler stopped) */
1199 g_debug("Background computation scheduler stopped");
1200 g_info("Background computation finished for trace %p", trace
);
1201 /* FIXME : remove status bar info, need context id and message id */
1207 /* 3.4 else, end of trace not reached */
1208 /* - return TRUE (scheduler still registered) */
1209 g_debug("Background computation left");
1214 /* 4. Unlock traces */
1216 //lttv_process_traceset_get_sync_data(tsc);
1220 iter_trace
<lttv_traceset_number(tsc
->ts
);
1222 LttvTrace
*trace_v
= lttv_traceset_get(tsc
->ts
, iter_trace
);
1224 lttvwindowtraces_unlock(trace_v
);
1233 * Register the background computation hooks for a specific module. It adds the
1234 * computation hooks to the global attrubutes, under "computation/module name".
1236 * @param module_name A GQuark : the name of the module which computes the
1239 void lttvwindowtraces_register_computation_hooks(LttvAttributeName module_name
,
1240 LttvHooks
*before_chunk_traceset
,
1241 LttvHooks
*before_chunk_trace
,
1242 LttvHooks
*before_chunk_tracefile
,
1243 LttvHooks
*after_chunk_traceset
,
1244 LttvHooks
*after_chunk_trace
,
1245 LttvHooks
*after_chunk_tracefile
,
1246 LttvHooks
*before_request
,
1247 LttvHooks
*after_request
,
1248 LttvHooks
*event_hook
,
1249 LttvHooksById
*event_hook_by_id
,
1250 LttvHooks
*hook_adder
,
1251 LttvHooks
*hook_remover
)
1253 LttvAttribute
*g_attribute
= lttv_global_attributes();
1254 LttvAttribute
*attribute
;
1255 LttvAttributeValue value
;
1257 g_assert(attribute
=
1258 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
1259 LTTV_COMPUTATION
)));
1261 g_assert(attribute
=
1262 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
1265 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1266 LTTV_BEFORE_CHUNK_TRACESET
,
1269 *(value
.v_pointer
) = before_chunk_traceset
;
1271 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1272 LTTV_BEFORE_CHUNK_TRACE
,
1275 *(value
.v_pointer
) = before_chunk_trace
;
1277 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1278 LTTV_BEFORE_CHUNK_TRACEFILE
,
1281 *(value
.v_pointer
) = before_chunk_tracefile
;
1283 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1284 LTTV_AFTER_CHUNK_TRACESET
,
1287 *(value
.v_pointer
) = after_chunk_traceset
;
1289 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1290 LTTV_AFTER_CHUNK_TRACE
,
1293 *(value
.v_pointer
) = after_chunk_trace
;
1295 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1296 LTTV_AFTER_CHUNK_TRACEFILE
,
1299 *(value
.v_pointer
) = after_chunk_tracefile
;
1301 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1302 LTTV_BEFORE_REQUEST
,
1305 *(value
.v_pointer
) = before_request
;
1307 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1311 *(value
.v_pointer
) = after_request
;
1313 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1317 *(value
.v_pointer
) = event_hook
;
1319 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1320 LTTV_EVENT_HOOK_BY_ID
,
1323 *(value
.v_pointer
) = event_hook_by_id
;
1325 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1329 *(value
.v_pointer
) = hook_adder
;
1331 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1335 *(value
.v_pointer
) = hook_remover
;
1341 * It removes all the requests than can be currently processed by the
1342 * background computation algorithm for all the traces (list_in and list_out).
1344 * Leaves the flag to in_progress or none.. depending if current or queue
1346 * @param module_name A GQuark : the name of the module which computes the
1349 void lttvwindowtraces_unregister_requests(LttvAttributeName module_name
)
1353 for(i
=0;i
<lttvwindowtraces_get_number();i
++) {
1354 LttvTrace
*trace_v
= lttvwindowtraces_get_trace(i
);
1355 g_assert(trace_v
!= NULL
);
1357 LttvAttribute
*attribute
= lttv_trace_attribute(trace_v
);
1358 LttvAttributeValue value
;
1359 GSList
**queue
, **current
;
1362 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1363 LTTV_REQUESTS_QUEUE
,
1366 queue
= (GSList
**)(value
.v_pointer
);
1369 while(iter
!= NULL
) {
1370 gboolean remove
= FALSE
;
1371 gboolean free_data
= FALSE
;
1373 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1375 if(bg_req
->module_name
== module_name
) {
1383 GSList
*remove_iter
= iter
;
1385 iter
= g_slist_next(iter
);
1386 if(free_data
) g_free(remove_iter
->data
);
1387 *queue
= g_slist_remove_link(*queue
, remove_iter
);
1388 } else { // not remove
1389 iter
= g_slist_next(iter
);
1394 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1395 LTTV_REQUESTS_CURRENT
,
1398 current
= (GSList
**)(value
.v_pointer
);
1401 while(iter
!= NULL
) {
1402 gboolean remove
= FALSE
;
1403 gboolean free_data
= FALSE
;
1405 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1407 if(bg_req
->module_name
== module_name
) {
1415 GSList
*remove_iter
= iter
;
1417 iter
= g_slist_next(iter
);
1418 if(free_data
) g_free(remove_iter
->data
);
1419 *current
= g_slist_remove_link(*current
, remove_iter
);
1420 } else { // not remove
1421 iter
= g_slist_next(iter
);
1429 * Unregister the background computation hooks for a specific module.
1431 * It also removes all the requests than can be currently processed by the
1432 * background computation algorithm for all the traces (list_in and list_out).
1434 * @param module_name A GQuark : the name of the module which computes the
1438 void lttvwindowtraces_unregister_computation_hooks
1439 (LttvAttributeName module_name
)
1441 LttvAttribute
*g_attribute
= lttv_global_attributes();
1442 LttvAttribute
*attribute
;
1443 LttvAttributeValue value
;
1445 g_assert(attribute
=
1446 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
1447 LTTV_COMPUTATION
)));
1448 g_assert(attribute
=
1449 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
1453 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1454 LTTV_BEFORE_CHUNK_TRACESET
,
1457 LttvHooks
*before_chunk_traceset
= (LttvHooks
*)*(value
.v_pointer
);
1458 if(before_chunk_traceset
!= NULL
)
1459 lttv_hooks_destroy(before_chunk_traceset
);
1461 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1462 LTTV_BEFORE_CHUNK_TRACE
,
1465 LttvHooks
*before_chunk_trace
= (LttvHooks
*)*(value
.v_pointer
);
1466 if(before_chunk_trace
!= NULL
)
1467 lttv_hooks_destroy(before_chunk_trace
);
1469 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1470 LTTV_BEFORE_CHUNK_TRACEFILE
,
1473 LttvHooks
*before_chunk_tracefile
= (LttvHooks
*)*(value
.v_pointer
);
1474 if(before_chunk_tracefile
!= NULL
)
1475 lttv_hooks_destroy(before_chunk_tracefile
);
1477 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1478 LTTV_AFTER_CHUNK_TRACESET
,
1481 LttvHooks
*after_chunk_traceset
= (LttvHooks
*)*(value
.v_pointer
);
1482 if(after_chunk_traceset
!= NULL
)
1483 lttv_hooks_destroy(after_chunk_traceset
);
1485 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1486 LTTV_AFTER_CHUNK_TRACE
,
1489 LttvHooks
*after_chunk_trace
= (LttvHooks
*)*(value
.v_pointer
);
1490 if(after_chunk_trace
!= NULL
)
1491 lttv_hooks_destroy(after_chunk_trace
);
1493 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1494 LTTV_AFTER_CHUNK_TRACEFILE
,
1497 LttvHooks
*after_chunk_tracefile
= (LttvHooks
*)*(value
.v_pointer
);
1498 if(after_chunk_tracefile
!= NULL
)
1499 lttv_hooks_destroy(after_chunk_tracefile
);
1501 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1502 LTTV_BEFORE_REQUEST
,
1505 LttvHooks
*before_request
= (LttvHooks
*)*(value
.v_pointer
);
1506 if(before_request
!= NULL
)
1507 lttv_hooks_destroy(before_request
);
1509 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1513 LttvHooks
*after_request
= (LttvHooks
*)*(value
.v_pointer
);
1514 if(after_request
!= NULL
)
1515 lttv_hooks_destroy(after_request
);
1517 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1521 LttvHooks
*event_hook
= (LttvHooks
*)*(value
.v_pointer
);
1522 if(event_hook
!= NULL
)
1523 lttv_hooks_destroy(event_hook
);
1525 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1526 LTTV_EVENT_HOOK_BY_ID
,
1529 LttvHooksById
*event_hook_by_id
= (LttvHooksById
*)*(value
.v_pointer
);
1530 if(event_hook_by_id
!= NULL
)
1531 lttv_hooks_by_id_destroy(event_hook_by_id
);
1533 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1537 LttvHooks
*hook_adder
= (LttvHooks
*)*(value
.v_pointer
);
1538 if(hook_adder
!= NULL
)
1539 lttv_hooks_destroy(hook_adder
);
1541 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1545 LttvHooks
*hook_remover
= (LttvHooks
*)*(value
.v_pointer
);
1546 if(hook_remover
!= NULL
)
1547 lttv_hooks_destroy(hook_remover
);
1550 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1551 LTTV_EVENT_HOOK_BY_ID
);
1552 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1555 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1556 LTTV_AFTER_REQUEST
);
1557 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1558 LTTV_BEFORE_REQUEST
);
1560 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1561 LTTV_AFTER_CHUNK_TRACEFILE
);
1562 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1563 LTTV_AFTER_CHUNK_TRACE
);
1564 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1565 LTTV_AFTER_CHUNK_TRACESET
);
1567 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1568 LTTV_BEFORE_CHUNK_TRACEFILE
);
1569 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1570 LTTV_BEFORE_CHUNK_TRACE
);
1571 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1572 LTTV_BEFORE_CHUNK_TRACESET
);
1573 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1575 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1578 /* finally, remove module name */
1579 g_assert(attribute
=
1580 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
1581 LTTV_COMPUTATION
)));
1582 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1588 * Lock a trace so no other instance can use it.
1590 * @param trace The trace to lock.
1591 * @return 0 on success, -1 if cannot get lock.
1593 gint
lttvwindowtraces_lock(LttvTrace
*trace
)
1595 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
1596 LttvAttributeValue value
;
1597 LttvAttributeType type
;
1599 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
1602 /* Verify the absence of the lock. */
1603 if(type
!= LTTV_NONE
) {
1604 g_critical("Cannot take trace lock");
1608 value
= lttv_iattribute_add(LTTV_IATTRIBUTE(attribute
),
1611 /* the value is left unset. The only presence of the attribute is necessary.
1620 * @param trace The trace to unlock.
1621 * @return 0 on success, -1 if cannot unlock (not locked ?).
1623 gint
lttvwindowtraces_unlock(LttvTrace
*trace
)
1625 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
1626 LttvAttributeType type
;
1627 LttvAttributeValue value
;
1629 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
1632 /* Verify the presence of the lock. */
1633 if(type
== LTTV_NONE
) {
1634 g_critical("Cannot release trace lock");
1638 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1645 * Verify if a trace is locked.
1647 * @param trace The trace to verify.
1648 * @return TRUE if locked, FALSE is unlocked.
1650 gint
lttvwindowtraces_get_lock_state(LttvTrace
*trace
)
1652 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
1653 LttvAttributeType type
;
1654 LttvAttributeValue value
;
1656 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
1659 /* The only presence of the attribute is necessary. */
1660 if(type
== LTTV_NONE
)