Hi,

I'm trying to use LTTng UST as a backend for function call tracing. The following pseudocode shows what we basically to:

ustcmd_set_marker_state( "call_trace", call, enter, 1, pid );
ustcmd_set_marker_state( "call_trace", call, inside, 1, pid );
ustcmd_set_marker_state( "call_trace", call, exit, 1, pid );

ustcmd_create_trace( "call_trace", pid );
ustcmd_start_trace( "call_trace", pid );

...
... Lots of auto-generated code that makes use of call.enter/inside/exit markers
...

ustcmd_stop_trace( "call_trace", pid );
ustcmd_destroy_trace( "call_trace", pid );

This works very well in general but whenever an executable runs only for a very short amount of time I run into troubles with stopping/destroying my "call_trace" properly.

This is caused by the fact that stop/destroy_trace runs before buffer consumption completed on the ust-consumerd side. This is easy to prevent by some code that implements waiting for buffer consumption. Fortunately this is already available in tracectl.c keepalive().

The following patch puts the "waiting for buffer consumption" code into its own function and makes it visible externally via ust/ustctl.h. Using function wait_for_buffer_consumption() before stop/destroy_trace solves the problem for me.

Please apply the patch from the attachment to the ust trunk to make wait_for_buffer_consumption()available for everyone.

Thanks,
Paul

diff --git a/include/ust/tracectl.h b/include/ust/tracectl.h
index c0ee7b1..63e0204 100644
--- a/include/ust/tracectl.h
+++ b/include/ust/tracectl.h
@@ -23,6 +23,7 @@ typedef struct ust_fork_info {
 } ust_fork_info_t;
 
 extern void ust_potential_exec(void);
+extern void wait_for_buffer_consumption();
 
 extern void ust_before_fork(ust_fork_info_t *fork_info);
 extern void ust_after_fork_parent(ust_fork_info_t *fork_info);
diff --git a/libust/tracectl.c b/libust/tracectl.c
index 33c7280..b2063e1 100644
--- a/libust/tracectl.c
+++ b/libust/tracectl.c
@@ -1548,6 +1548,16 @@ static void __attribute__((destructor)) keepalive()
 		return;
 	}
 
+	wait_for_buffer_consumption();
+
+	destroy_traces();
+
+	/* Ask the listener to stop and clean up. */
+	stop_listener();
+}
+
+void wait_for_buffer_consumption()
+{
 	if (trace_recording() && CMM_LOAD_SHARED(buffers_to_export)) {
 		int total = 0;
 		DBG("Keeping process alive for consumer daemon...");
@@ -1563,11 +1573,6 @@ static void __attribute__((destructor)) keepalive()
 		}
 		DBG("Finally dying...");
 	}
-
-	destroy_traces();
-
-	/* Ask the listener to stop and clean up. */
-	stop_listener();
 }
 
 void ust_potential_exec(void)


_______________________________________________
ltt-dev mailing list
[email protected]
http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev

Reply via email to