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_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute
),
259 LTTV_COMPUTATION_TRACESET
);
260 /* Destroy the traceset and the trace also */
261 lttv_traceset_destroy(ts
);
263 /* finally, remove the global attribute */
264 lttv_attribute_remove(attribute
, i
);
273 * Function to request data from a specific trace
275 * The memory allocated for the request will be managed by the API.
277 * @param trace the trace to compute
278 * @param module_name the name of the module which registered global computation
282 void lttvwindowtraces_background_request_queue
283 (LttvTrace
*trace
, gchar
*module_name
)
285 BackgroundRequest
*bg_req
;
286 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
287 LttvAttribute
*g_attribute
= lttv_global_attributes();
288 LttvAttribute
*module_attribute
;
289 LttvAttributeValue value
;
290 LttvAttributeType type
;
294 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
298 slist
= (GSList
**)(value
.v_pointer
);
300 /* Verify that the calculator is loaded */
301 g_assert(module_attribute
=
302 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
306 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
307 g_quark_from_string(module_name
),
309 if(type
== LTTV_NONE
) {
310 g_critical("Missing background calculator %s", module_name
);
314 bg_req
= g_new(BackgroundRequest
,1);
315 bg_req
->module_name
= g_quark_from_string(module_name
);
316 bg_req
->trace
= trace
;
318 *slist
= g_slist_append(*slist
, bg_req
);
320 /* Priority lower than live servicing */
321 g_idle_remove_by_data(trace
);
322 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 23),
323 (GSourceFunc
)lttvwindowtraces_process_pending_requests
,
326 /* FIXME : show message in status bar, need context and message id */
327 g_info("Background computation started for trace %p", trace
);
331 * Remove a background request from a trace.
333 * This should ONLY be used by the modules which registered the global hooks
334 * (module_name). If this is called by the viewers, it may lead to incomplete
335 * and incoherent background processing information.
337 * Even if the module which deals with the hooks removes the background
338 * requests, it may cause a problem if the module gets loaded again in the
339 * session : the data will be partially calculated. The calculation function
340 * must deal with this case correctly.
342 * @param trace the trace to compute
343 * @param module_name the name of the module which registered global computation
347 void lttvwindowtraces_background_request_remove
348 (LttvTrace
*trace
, gchar
*module_name
)
350 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
351 LttvAttributeValue value
;
355 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
359 slist
= (GSList
**)(value
.v_pointer
);
361 for(iter
=*slist
;iter
!=NULL
;) {
362 BackgroundRequest
*bg_req
=
363 (BackgroundRequest
*)iter
->data
;
365 if(bg_req
->module_name
== g_quark_from_string(module_name
)) {
366 GSList
*rem_iter
= iter
;
367 iter
=g_slist_next(iter
);
369 *slist
= g_slist_delete_link(*slist
, rem_iter
);
371 iter
=g_slist_next(iter
);
378 * Register a callback to be called when requested data is passed in the next
379 * queued background processing.
381 * @param owner owner of the background notification
382 * @param trace the trace computed
383 * @param notify_time time when notification hooks must be called
384 * @param notify_position position when notification hooks must be called
385 * @param notify Hook to call when the notify position is passed
388 void lttvwindowtraces_background_notify_queue
392 const LttvTracesetContextPosition
*notify_position
,
393 const LttvHooks
*notify
)
395 BackgroundNotify
*bg_notify
;
396 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
397 LttvAttributeValue value
;
400 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
404 slist
= (GSList
**)(value
.v_pointer
);
407 bg_notify
= g_new(BackgroundNotify
,1);
409 bg_notify
->owner
= owner
;
410 bg_notify
->trace
= trace
;
411 bg_notify
->notify_time
= notify_time
;
412 if(notify_position
!= NULL
) {
413 bg_notify
->notify_position
= lttv_traceset_context_position_new();
414 lttv_traceset_context_position_copy(bg_notify
->notify_position
,
417 bg_notify
->notify_position
= NULL
;
420 bg_notify
->notify
= lttv_hooks_new();
421 lttv_hooks_add_list(bg_notify
->notify
, notify
);
423 *slist
= g_slist_append(*slist
, bg_notify
);
427 * Register a callback to be called when requested data is passed in the current
428 * background processing.
430 * @param owner owner of the background notification
431 * @param trace the trace computed
432 * @param notify_time time when notification hooks must be called
433 * @param notify_position position when notification hooks must be called
434 * @param notify Hook to call when the notify position is passed
437 void lttvwindowtraces_background_notify_current
441 const LttvTracesetContextPosition
*notify_position
,
442 const LttvHooks
*notify
)
444 BackgroundNotify
*bg_notify
;
445 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
446 LttvAttributeValue value
;
449 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
453 slist
= (GSList
**)(value
.v_pointer
);
455 bg_notify
= g_new(BackgroundNotify
,1);
457 bg_notify
->owner
= owner
;
458 bg_notify
->trace
= trace
;
459 bg_notify
->notify_time
= notify_time
;
460 if(notify_position
!= NULL
) {
461 bg_notify
->notify_position
= lttv_traceset_context_position_new();
462 lttv_traceset_context_position_copy(bg_notify
->notify_position
,
465 bg_notify
->notify_position
= NULL
;
467 bg_notify
->notify
= lttv_hooks_new();
468 lttv_hooks_add_list(bg_notify
->notify
, notify
);
470 *slist
= g_slist_append(*slist
, bg_notify
);
474 static void notify_request_free(BackgroundNotify
*notify_req
)
476 if(notify_req
== NULL
) return;
478 if(notify_req
->notify_position
!= NULL
)
479 lttv_traceset_context_position_destroy(notify_req
->notify_position
);
480 if(notify_req
->notify
!= NULL
)
481 lttv_hooks_destroy(notify_req
->notify
);
486 * Removes all the notifications requests from a specific viewer.
488 * @param owner owner of the background notification
491 void lttvwindowtraces_background_notify_remove(gpointer owner
)
495 for(i
=0;i
<lttvwindowtraces_get_number();i
++) {
496 LttvAttribute
*attribute
;
497 LttvAttributeValue value
;
498 LttvTrace
*trace_v
= lttvwindowtraces_get_trace(i
);
502 g_assert(trace_v
!= NULL
);
504 attribute
= lttv_trace_attribute(trace_v
);
506 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
510 slist
= (GSList
**)(value
.v_pointer
);
512 for(iter
=*slist
;iter
!=NULL
;) {
514 BackgroundNotify
*bg_notify
= (BackgroundNotify
*)iter
->data
;
516 if(bg_notify
->owner
== owner
) {
517 GSList
*rem_iter
= iter
;
518 iter
=g_slist_next(iter
);
519 notify_request_free(bg_notify
);
520 *slist
= g_slist_remove_link(*slist
, rem_iter
);
522 iter
=g_slist_next(iter
);
526 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
530 slist
= (GSList
**)(value
.v_pointer
);
532 for(iter
=*slist
;iter
!=NULL
;) {
534 BackgroundNotify
*bg_notify
= (BackgroundNotify
*)iter
->data
;
536 if(bg_notify
->owner
== owner
) {
537 GSList
*rem_iter
= iter
;
538 iter
=g_slist_next(iter
);
539 notify_request_free(bg_notify
);
540 *slist
= g_slist_remove_link(*slist
, rem_iter
);
542 iter
=g_slist_next(iter
);
549 /* Background processing helper functions */
551 void lttvwindowtraces_add_computation_hooks(LttvAttributeName module_name
,
552 LttvTracesetContext
*tsc
,
553 LttvHooks
*hook_adder
)
555 LttvAttribute
*g_attribute
= lttv_global_attributes();
556 LttvAttribute
*module_attribute
;
557 LttvAttributeType type
;
558 LttvAttributeValue value
;
559 LttvHooks
*before_chunk_traceset
=NULL
;
560 LttvHooks
*before_chunk_trace
=NULL
;
561 LttvHooks
*before_chunk_tracefile
=NULL
;
562 LttvHooks
*event_hook
=NULL
;
563 LttvHooksById
*event_hook_by_id
=NULL
;
564 LttvTracesetStats
*tss
= LTTV_TRACESET_STATS(tsc
);
567 g_assert(module_attribute
=
568 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
571 g_assert(module_attribute
=
572 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
573 LTTV_IATTRIBUTE(module_attribute
),
576 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
577 LTTV_BEFORE_CHUNK_TRACESET
,
579 if(type
== LTTV_POINTER
) {
580 before_chunk_traceset
= (LttvHooks
*)*(value
.v_pointer
);
583 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
584 LTTV_BEFORE_CHUNK_TRACE
,
586 if(type
== LTTV_POINTER
) {
587 before_chunk_trace
= (LttvHooks
*)*(value
.v_pointer
);
590 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
591 LTTV_BEFORE_CHUNK_TRACEFILE
,
593 if(type
== LTTV_POINTER
) {
594 before_chunk_tracefile
= (LttvHooks
*)*(value
.v_pointer
);
597 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
600 if(type
== LTTV_POINTER
) {
601 event_hook
= (LttvHooks
*)*(value
.v_pointer
);
604 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
605 LTTV_EVENT_HOOK_BY_ID
,
607 if(type
== LTTV_POINTER
) {
608 event_hook_by_id
= (LttvHooksById
*)*(value
.v_pointer
);
611 /* Call the module's hook adder */
612 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
615 if(type
== LTTV_POINTER
) {
616 //lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss);
617 if(hook_adder
!= NULL
)
618 lttv_hooks_add_list(hook_adder
, (LttvHooks
*)*(value
.v_pointer
));
623 lttv_process_traceset_begin(tsc
,
624 before_chunk_traceset
,
626 before_chunk_tracefile
,
632 void lttvwindowtraces_remove_computation_hooks(LttvAttributeName module_name
,
633 LttvTracesetContext
*tsc
,
634 LttvHooks
*hook_remover
)
636 LttvAttribute
*g_attribute
= lttv_global_attributes();
637 LttvAttribute
*module_attribute
;
638 LttvAttributeType type
;
639 LttvAttributeValue value
;
640 LttvHooks
*after_chunk_traceset
=NULL
;
641 LttvHooks
*after_chunk_trace
=NULL
;
642 LttvHooks
*after_chunk_tracefile
=NULL
;
643 LttvHooks
*event_hook
=NULL
;
644 LttvHooksById
*event_hook_by_id
=NULL
;
645 LttvTracesetStats
*tss
= LTTV_TRACESET_STATS(tsc
);
647 g_assert(module_attribute
=
648 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
651 g_assert(module_attribute
=
652 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
653 LTTV_IATTRIBUTE(module_attribute
),
656 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
657 LTTV_AFTER_CHUNK_TRACESET
,
659 if(type
== LTTV_POINTER
) {
660 after_chunk_traceset
= (LttvHooks
*)*(value
.v_pointer
);
663 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
664 LTTV_AFTER_CHUNK_TRACE
,
666 if(type
== LTTV_POINTER
) {
667 after_chunk_trace
= (LttvHooks
*)*(value
.v_pointer
);
670 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
671 LTTV_AFTER_CHUNK_TRACEFILE
,
673 if(type
== LTTV_POINTER
) {
674 after_chunk_tracefile
= (LttvHooks
*)*(value
.v_pointer
);
677 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
680 if(type
== LTTV_POINTER
) {
681 event_hook
= (LttvHooks
*)*(value
.v_pointer
);
684 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
685 LTTV_EVENT_HOOK_BY_ID
,
687 if(type
== LTTV_POINTER
) {
688 event_hook_by_id
= (LttvHooksById
*)*(value
.v_pointer
);
691 lttv_process_traceset_end(tsc
,
692 after_chunk_traceset
,
694 after_chunk_tracefile
,
698 /* Call the module's hook remover */
699 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
702 if(type
== LTTV_POINTER
) {
703 //lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss);
704 if(hook_remover
!= NULL
)
705 lttv_hooks_add_list(hook_remover
, (LttvHooks
*)*(value
.v_pointer
));
710 void lttvwindowtraces_set_in_progress(LttvAttributeName module_name
,
713 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
714 LttvAttributeValue value
;
717 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
720 value
= lttv_iattribute_add(LTTV_IATTRIBUTE(attribute
),
723 /* the value is left unset. The only presence of the attribute is necessary.
727 void lttvwindowtraces_unset_in_progress(LttvAttributeName module_name
,
730 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
733 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
736 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
740 gboolean
lttvwindowtraces_get_in_progress(LttvAttributeName module_name
,
743 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
744 LttvAttributeType type
;
745 LttvAttributeValue value
;
748 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
751 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
754 /* The only presence of the attribute is necessary. */
755 if(type
== LTTV_NONE
)
761 void lttvwindowtraces_set_ready(LttvAttributeName module_name
,
764 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
765 LttvAttributeValue value
;
768 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
771 value
= lttv_iattribute_add(LTTV_IATTRIBUTE(attribute
),
774 /* the value is left unset. The only presence of the attribute is necessary.
778 void lttvwindowtraces_unset_ready(LttvAttributeName module_name
,
781 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
784 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
787 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
791 gboolean
lttvwindowtraces_get_ready(LttvAttributeName module_name
,
794 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
795 LttvAttributeType type
;
796 LttvAttributeValue value
;
799 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
802 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
805 /* The only presence of the attribute is necessary. */
806 if(type
== LTTV_NONE
)
813 /* lttvwindowtraces_process_pending_requests
815 * This internal function gets called by g_idle, taking care of the pending
821 gboolean
lttvwindowtraces_process_pending_requests(LttvTrace
*trace
)
823 LttvTracesetContext
*tsc
;
824 LttvTracesetStats
*tss
;
826 LttvAttribute
*attribute
;
827 LttvAttribute
*g_attribute
= lttv_global_attributes();
828 GSList
**list_out
, **list_in
, **notify_in
, **notify_out
;
829 LttvAttributeValue value
;
830 LttvAttributeType type
;
832 LttvHooks
*before_request
, *after_request
;
837 attribute
= lttv_trace_attribute(trace
);
839 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
842 g_assert(type
== LTTV_POINTER
);
843 list_out
= (GSList
**)(value
.v_pointer
);
845 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
846 LTTV_REQUESTS_CURRENT
,
848 g_assert(type
== LTTV_POINTER
);
849 list_in
= (GSList
**)(value
.v_pointer
);
851 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
854 g_assert(type
== LTTV_POINTER
);
855 notify_out
= (GSList
**)(value
.v_pointer
);
857 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
860 g_assert(type
== LTTV_POINTER
);
861 notify_in
= (GSList
**)(value
.v_pointer
);
863 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
864 LTTV_COMPUTATION_TRACESET
,
866 g_assert(type
== LTTV_POINTER
);
867 ts
= (LttvTraceset
*)*(value
.v_pointer
);
869 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
870 LTTV_COMPUTATION_TRACESET_CONTEXT
,
872 g_assert(type
== LTTV_POINTER
);
873 tsc
= (LttvTracesetContext
*)*(value
.v_pointer
);
874 tss
= (LttvTracesetStats
*)*(value
.v_pointer
);
875 g_assert(LTTV_IS_TRACESET_CONTEXT(tsc
));
876 g_assert(LTTV_IS_TRACESET_STATS(tss
));
878 /* There is no events requests pending : we should never have been called! */
879 g_assert(g_slist_length(*list_out
) != 0 || g_slist_length(*list_in
) != 0);
881 /* 0.1 Lock traces */
886 iter_trace
<lttv_traceset_number(tsc
->ts
);
888 LttvTrace
*trace_v
= lttv_traceset_get(tsc
->ts
,iter_trace
);
890 if(lttvwindowtraces_lock(trace_v
) != 0)
891 return TRUE
; /* Cannot get trace lock, try later */
895 /* 0.2 Sync tracefiles */
896 lttv_process_traceset_synchronize_tracefiles(tsc
);
898 /* 1. Before processing */
900 /* if list_in is empty */
901 if(g_slist_length(*list_in
) == 0) {
904 /* - Add all requests in list_out to list_in, empty list_out */
905 GSList
*iter
= *list_out
;
907 while(iter
!= NULL
) {
908 gboolean remove
= FALSE
;
909 gboolean free_data
= FALSE
;
911 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
915 *list_in
= g_slist_append(*list_in
, bg_req
);
920 GSList
*remove_iter
= iter
;
922 iter
= g_slist_next(iter
);
923 if(free_data
) g_free(remove_iter
->data
);
924 *list_out
= g_slist_remove_link(*list_out
, remove_iter
);
925 } else { // not remove
926 iter
= g_slist_next(iter
);
932 GSList
*iter
= *list_in
;
933 /* - for each request in list_in */
934 while(iter
!= NULL
) {
936 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
937 /* - set hooks'in_progress flag to TRUE */
938 lttvwindowtraces_set_in_progress(bg_req
->module_name
,
941 /* - call before request hook */
942 /* Get before request hook */
943 LttvAttribute
*module_attribute
;
945 g_assert(module_attribute
=
946 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
947 LTTV_IATTRIBUTE(g_attribute
),
950 g_assert(module_attribute
=
951 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
952 LTTV_IATTRIBUTE(module_attribute
),
953 bg_req
->module_name
)));
955 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
958 g_assert(type
== LTTV_POINTER
);
959 LttvHooks
*before_request
= (LttvHooks
*)*(value
.v_pointer
);
962 if(before_request
!= NULL
) lttv_hooks_call(before_request
, tsc
);
964 iter
= g_slist_next(iter
);
968 /* - seek trace to start */
970 LttTime start
= { 0, 0};
971 lttv_process_traceset_seek_time(tsc
, start
);
974 /* - Move all notifications from notify_out to notify_in. */
976 GSList
*iter
= *notify_out
;
977 g_assert(g_slist_length(*notify_in
) == 0);
979 while(iter
!= NULL
) {
980 gboolean remove
= FALSE
;
981 gboolean free_data
= FALSE
;
983 BackgroundNotify
*notify_req
= (BackgroundNotify
*)iter
->data
;
987 *notify_in
= g_slist_append(*notify_in
, notify_req
);
992 GSList
*remove_iter
= iter
;
994 iter
= g_slist_next(iter
);
996 notify_request_free((BackgroundNotify
*)remove_iter
->data
);
997 *notify_out
= g_slist_remove_link(*notify_out
, remove_iter
);
998 } else { // not remove
999 iter
= g_slist_next(iter
);
1006 GSList
*iter
= *list_in
;
1007 LttvHooks
*hook_adder
= lttv_hooks_new();
1008 /* - for each request in list_in */
1009 while(iter
!= NULL
) {
1011 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1012 /*- Call before chunk hooks for list_in*/
1013 /*- add hooks to context*/
1014 lttvwindowtraces_add_computation_hooks(bg_req
->module_name
,
1017 iter
= g_slist_next(iter
);
1019 lttv_hooks_call(hook_adder
,tsc
);
1020 lttv_hooks_destroy(hook_adder
);
1024 /* 2. call process traceset middle for a chunk */
1026 /*(assert list_in is not empty! : should not even be called in that case)*/
1027 LttTime end
= ltt_time_infinite
;
1028 g_assert(g_slist_length(*list_in
) != 0);
1030 lttv_process_traceset_middle(tsc
, end
, CHUNK_NUM_EVENTS
, NULL
);
1033 /* 3. After the chunk */
1035 /* 3.1 call after_chunk hooks for list_in */
1037 GSList
*iter
= *list_in
;
1038 LttvHooks
*hook_remover
= lttv_hooks_new();
1039 /* - for each request in list_in */
1040 while(iter
!= NULL
) {
1042 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1043 /* - Call after chunk hooks for list_in */
1044 /* - remove hooks from context */
1045 lttvwindowtraces_remove_computation_hooks(bg_req
->module_name
,
1048 iter
= g_slist_next(iter
);
1050 lttv_hooks_call(hook_remover
,tsc
);
1051 lttv_hooks_destroy(hook_remover
);
1054 /* 3.2 for each notify_in */
1056 GSList
*iter
= *notify_in
;
1057 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
1059 while(iter
!= NULL
) {
1060 gboolean remove
= FALSE
;
1061 gboolean free_data
= FALSE
;
1063 BackgroundNotify
*notify_req
= (BackgroundNotify
*)iter
->data
;
1065 /* - if current time >= notify time, call notify and remove from
1067 * - if current position >= notify position, call notify and remove
1071 ltt_time_compare(notify_req
->notify_time
, tfc
->timestamp
) <= 0)
1073 (notify_req
->notify_position
!= NULL
&&
1074 lttv_traceset_context_ctx_pos_compare(tsc
,
1075 notify_req
->notify_position
) >= 0)
1078 lttv_hooks_call(notify_req
->notify
, notify_req
);
1087 GSList
*remove_iter
= iter
;
1089 iter
= g_slist_next(iter
);
1091 notify_request_free((BackgroundNotify
*)remove_iter
->data
);
1092 *notify_in
= g_slist_remove_link(*notify_in
, remove_iter
);
1093 } else { // not remove
1094 iter
= g_slist_next(iter
);
1100 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
1101 /* 3.3 if end of trace reached */
1103 g_debug("Current time : %lu sec, %lu nsec",
1104 tfc
->timestamp
.tv_sec
, tfc
->timestamp
.tv_nsec
);
1105 if(tfc
== NULL
|| ltt_time_compare(tfc
->timestamp
,
1106 tsc
->time_span
.end_time
) > 0) {
1108 /* - for each request in list_in */
1110 GSList
*iter
= *list_in
;
1112 while(iter
!= NULL
) {
1113 gboolean remove
= FALSE
;
1114 gboolean free_data
= FALSE
;
1116 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1118 /* - set hooks'in_progress flag to FALSE */
1119 lttvwindowtraces_unset_in_progress(bg_req
->module_name
,
1121 /* - set hooks'ready flag to TRUE */
1122 lttvwindowtraces_set_ready(bg_req
->module_name
,
1124 /* - call after request hook */
1125 /* Get after request hook */
1126 LttvAttribute
*module_attribute
;
1128 g_assert(module_attribute
=
1129 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
1130 LTTV_IATTRIBUTE(g_attribute
),
1131 LTTV_COMPUTATION
)));
1133 g_assert(module_attribute
=
1134 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
1135 LTTV_IATTRIBUTE(module_attribute
),
1136 bg_req
->module_name
)));
1138 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute
),
1141 g_assert(type
== LTTV_POINTER
);
1142 LttvHooks
*after_request
= (LttvHooks
*)*(value
.v_pointer
);
1144 if(after_request
!= NULL
) lttv_hooks_call(after_request
, tsc
);
1145 /* - remove request */
1152 GSList
*remove_iter
= iter
;
1154 iter
= g_slist_next(iter
);
1155 if(free_data
) g_free(remove_iter
->data
);
1156 *list_in
= g_slist_remove_link(*list_in
, remove_iter
);
1157 } else { // not remove
1158 iter
= g_slist_next(iter
);
1163 /* - for each notifications in notify_in */
1165 GSList
*iter
= *notify_in
;
1167 while(iter
!= NULL
) {
1168 gboolean remove
= FALSE
;
1169 gboolean free_data
= FALSE
;
1171 BackgroundNotify
*notify_req
= (BackgroundNotify
*)iter
->data
;
1173 /* - call notify and remove from notify_in */
1174 lttv_hooks_call(notify_req
->notify
, notify_req
);
1181 GSList
*remove_iter
= iter
;
1183 iter
= g_slist_next(iter
);
1185 notify_request_free((BackgroundNotify
*)remove_iter
->data
);
1186 *notify_in
= g_slist_remove_link(*notify_in
, remove_iter
);
1187 } else { // not remove
1188 iter
= g_slist_next(iter
);
1193 /* - reset the context */
1194 LTTV_TRACESET_CONTEXT_GET_CLASS(tsc
)->fini(tsc
);
1195 LTTV_TRACESET_CONTEXT_GET_CLASS(tsc
)->init(tsc
,ts
);
1197 /* - if list_out is empty */
1198 if(g_slist_length(*list_out
) == 0) {
1199 /* - return FALSE (scheduler stopped) */
1200 g_debug("Background computation scheduler stopped");
1201 g_info("Background computation finished for trace %p", trace
);
1202 /* FIXME : remove status bar info, need context id and message id */
1208 /* 3.4 else, end of trace not reached */
1209 /* - return TRUE (scheduler still registered) */
1210 g_debug("Background computation left");
1215 /* 4. Unlock traces */
1217 //lttv_process_traceset_get_sync_data(tsc);
1221 iter_trace
<lttv_traceset_number(tsc
->ts
);
1223 LttvTrace
*trace_v
= lttv_traceset_get(tsc
->ts
, iter_trace
);
1225 lttvwindowtraces_unlock(trace_v
);
1234 * Register the background computation hooks for a specific module. It adds the
1235 * computation hooks to the global attrubutes, under "computation/module name".
1237 * @param module_name A GQuark : the name of the module which computes the
1240 void lttvwindowtraces_register_computation_hooks(LttvAttributeName module_name
,
1241 LttvHooks
*before_chunk_traceset
,
1242 LttvHooks
*before_chunk_trace
,
1243 LttvHooks
*before_chunk_tracefile
,
1244 LttvHooks
*after_chunk_traceset
,
1245 LttvHooks
*after_chunk_trace
,
1246 LttvHooks
*after_chunk_tracefile
,
1247 LttvHooks
*before_request
,
1248 LttvHooks
*after_request
,
1249 LttvHooks
*event_hook
,
1250 LttvHooksById
*event_hook_by_id
,
1251 LttvHooks
*hook_adder
,
1252 LttvHooks
*hook_remover
)
1254 LttvAttribute
*g_attribute
= lttv_global_attributes();
1255 LttvAttribute
*attribute
;
1256 LttvAttributeValue value
;
1258 g_assert(attribute
=
1259 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
1260 LTTV_COMPUTATION
)));
1262 g_assert(attribute
=
1263 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
1266 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1267 LTTV_BEFORE_CHUNK_TRACESET
,
1270 *(value
.v_pointer
) = before_chunk_traceset
;
1272 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1273 LTTV_BEFORE_CHUNK_TRACE
,
1276 *(value
.v_pointer
) = before_chunk_trace
;
1278 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1279 LTTV_BEFORE_CHUNK_TRACEFILE
,
1282 *(value
.v_pointer
) = before_chunk_tracefile
;
1284 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1285 LTTV_AFTER_CHUNK_TRACESET
,
1288 *(value
.v_pointer
) = after_chunk_traceset
;
1290 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1291 LTTV_AFTER_CHUNK_TRACE
,
1294 *(value
.v_pointer
) = after_chunk_trace
;
1296 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1297 LTTV_AFTER_CHUNK_TRACEFILE
,
1300 *(value
.v_pointer
) = after_chunk_tracefile
;
1302 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1303 LTTV_BEFORE_REQUEST
,
1306 *(value
.v_pointer
) = before_request
;
1308 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1312 *(value
.v_pointer
) = after_request
;
1314 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1318 *(value
.v_pointer
) = event_hook
;
1320 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1321 LTTV_EVENT_HOOK_BY_ID
,
1324 *(value
.v_pointer
) = event_hook_by_id
;
1326 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1330 *(value
.v_pointer
) = hook_adder
;
1332 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1336 *(value
.v_pointer
) = hook_remover
;
1342 * It removes all the requests than can be currently processed by the
1343 * background computation algorithm for all the traces (list_in and list_out).
1345 * Leaves the flag to in_progress or none.. depending if current or queue
1347 * @param module_name A GQuark : the name of the module which computes the
1350 void lttvwindowtraces_unregister_requests(LttvAttributeName module_name
)
1354 for(i
=0;i
<lttvwindowtraces_get_number();i
++) {
1355 LttvTrace
*trace_v
= lttvwindowtraces_get_trace(i
);
1356 g_assert(trace_v
!= NULL
);
1358 LttvAttribute
*attribute
= lttv_trace_attribute(trace_v
);
1359 LttvAttributeValue value
;
1360 GSList
**queue
, **current
;
1363 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1364 LTTV_REQUESTS_QUEUE
,
1367 queue
= (GSList
**)(value
.v_pointer
);
1370 while(iter
!= NULL
) {
1371 gboolean remove
= FALSE
;
1372 gboolean free_data
= FALSE
;
1374 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1376 if(bg_req
->module_name
== module_name
) {
1384 GSList
*remove_iter
= iter
;
1386 iter
= g_slist_next(iter
);
1387 if(free_data
) g_free(remove_iter
->data
);
1388 *queue
= g_slist_remove_link(*queue
, remove_iter
);
1389 } else { // not remove
1390 iter
= g_slist_next(iter
);
1395 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1396 LTTV_REQUESTS_CURRENT
,
1399 current
= (GSList
**)(value
.v_pointer
);
1402 while(iter
!= NULL
) {
1403 gboolean remove
= FALSE
;
1404 gboolean free_data
= FALSE
;
1406 BackgroundRequest
*bg_req
= (BackgroundRequest
*)iter
->data
;
1408 if(bg_req
->module_name
== module_name
) {
1416 GSList
*remove_iter
= iter
;
1418 iter
= g_slist_next(iter
);
1419 if(free_data
) g_free(remove_iter
->data
);
1420 *current
= g_slist_remove_link(*current
, remove_iter
);
1421 } else { // not remove
1422 iter
= g_slist_next(iter
);
1430 * Unregister the background computation hooks for a specific module.
1432 * It also removes all the requests than can be currently processed by the
1433 * background computation algorithm for all the traces (list_in and list_out).
1435 * @param module_name A GQuark : the name of the module which computes the
1439 void lttvwindowtraces_unregister_computation_hooks
1440 (LttvAttributeName module_name
)
1442 LttvAttribute
*g_attribute
= lttv_global_attributes();
1443 LttvAttribute
*attribute
;
1444 LttvAttributeValue value
;
1446 g_assert(attribute
=
1447 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
1448 LTTV_COMPUTATION
)));
1449 g_assert(attribute
=
1450 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute
),
1454 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1455 LTTV_BEFORE_CHUNK_TRACESET
,
1458 LttvHooks
*before_chunk_traceset
= (LttvHooks
*)*(value
.v_pointer
);
1459 if(before_chunk_traceset
!= NULL
)
1460 lttv_hooks_destroy(before_chunk_traceset
);
1462 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1463 LTTV_BEFORE_CHUNK_TRACE
,
1466 LttvHooks
*before_chunk_trace
= (LttvHooks
*)*(value
.v_pointer
);
1467 if(before_chunk_trace
!= NULL
)
1468 lttv_hooks_destroy(before_chunk_trace
);
1470 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1471 LTTV_BEFORE_CHUNK_TRACEFILE
,
1474 LttvHooks
*before_chunk_tracefile
= (LttvHooks
*)*(value
.v_pointer
);
1475 if(before_chunk_tracefile
!= NULL
)
1476 lttv_hooks_destroy(before_chunk_tracefile
);
1478 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1479 LTTV_AFTER_CHUNK_TRACESET
,
1482 LttvHooks
*after_chunk_traceset
= (LttvHooks
*)*(value
.v_pointer
);
1483 if(after_chunk_traceset
!= NULL
)
1484 lttv_hooks_destroy(after_chunk_traceset
);
1486 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1487 LTTV_AFTER_CHUNK_TRACE
,
1490 LttvHooks
*after_chunk_trace
= (LttvHooks
*)*(value
.v_pointer
);
1491 if(after_chunk_trace
!= NULL
)
1492 lttv_hooks_destroy(after_chunk_trace
);
1494 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1495 LTTV_AFTER_CHUNK_TRACEFILE
,
1498 LttvHooks
*after_chunk_tracefile
= (LttvHooks
*)*(value
.v_pointer
);
1499 if(after_chunk_tracefile
!= NULL
)
1500 lttv_hooks_destroy(after_chunk_tracefile
);
1502 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1503 LTTV_BEFORE_REQUEST
,
1506 LttvHooks
*before_request
= (LttvHooks
*)*(value
.v_pointer
);
1507 if(before_request
!= NULL
)
1508 lttv_hooks_destroy(before_request
);
1510 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1514 LttvHooks
*after_request
= (LttvHooks
*)*(value
.v_pointer
);
1515 if(after_request
!= NULL
)
1516 lttv_hooks_destroy(after_request
);
1518 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1522 LttvHooks
*event_hook
= (LttvHooks
*)*(value
.v_pointer
);
1523 if(event_hook
!= NULL
)
1524 lttv_hooks_destroy(event_hook
);
1526 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1527 LTTV_EVENT_HOOK_BY_ID
,
1530 LttvHooksById
*event_hook_by_id
= (LttvHooksById
*)*(value
.v_pointer
);
1531 if(event_hook_by_id
!= NULL
)
1532 lttv_hooks_by_id_destroy(event_hook_by_id
);
1534 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1538 LttvHooks
*hook_adder
= (LttvHooks
*)*(value
.v_pointer
);
1539 if(hook_adder
!= NULL
)
1540 lttv_hooks_destroy(hook_adder
);
1542 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute
),
1546 LttvHooks
*hook_remover
= (LttvHooks
*)*(value
.v_pointer
);
1547 if(hook_remover
!= NULL
)
1548 lttv_hooks_destroy(hook_remover
);
1551 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1552 LTTV_EVENT_HOOK_BY_ID
);
1553 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1556 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1557 LTTV_AFTER_REQUEST
);
1558 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1559 LTTV_BEFORE_REQUEST
);
1561 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1562 LTTV_AFTER_CHUNK_TRACEFILE
);
1563 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1564 LTTV_AFTER_CHUNK_TRACE
);
1565 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1566 LTTV_AFTER_CHUNK_TRACESET
);
1568 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1569 LTTV_BEFORE_CHUNK_TRACEFILE
);
1570 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1571 LTTV_BEFORE_CHUNK_TRACE
);
1572 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1573 LTTV_BEFORE_CHUNK_TRACESET
);
1574 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1576 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1579 /* finally, remove module name */
1580 g_assert(attribute
=
1581 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute
),
1582 LTTV_COMPUTATION
)));
1583 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1589 * Lock a trace so no other instance can use it.
1591 * @param trace The trace to lock.
1592 * @return 0 on success, -1 if cannot get lock.
1594 gint
lttvwindowtraces_lock(LttvTrace
*trace
)
1596 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
1597 LttvAttributeValue value
;
1598 LttvAttributeType type
;
1600 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
1603 /* Verify the absence of the lock. */
1604 if(type
!= LTTV_NONE
) {
1605 g_critical("Cannot take trace lock");
1609 value
= lttv_iattribute_add(LTTV_IATTRIBUTE(attribute
),
1612 /* the value is left unset. The only presence of the attribute is necessary.
1621 * @param trace The trace to unlock.
1622 * @return 0 on success, -1 if cannot unlock (not locked ?).
1624 gint
lttvwindowtraces_unlock(LttvTrace
*trace
)
1626 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
1627 LttvAttributeType type
;
1628 LttvAttributeValue value
;
1630 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
1633 /* Verify the presence of the lock. */
1634 if(type
== LTTV_NONE
) {
1635 g_critical("Cannot release trace lock");
1639 lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute
),
1646 * Verify if a trace is locked.
1648 * @param trace The trace to verify.
1649 * @return TRUE if locked, FALSE is unlocked.
1651 gint
lttvwindowtraces_get_lock_state(LttvTrace
*trace
)
1653 LttvAttribute
*attribute
= lttv_trace_attribute(trace
);
1654 LttvAttributeType type
;
1655 LttvAttributeValue value
;
1657 type
= lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute
),
1660 /* The only presence of the attribute is necessary. */
1661 if(type
== LTTV_NONE
)