T-trace: Tracing Applications
This tutorial demonstrates how you can insert tracepoints in Tizen native applications and then run the T-trace tool to view the results.
This feature is supported in mobile applications only.
Warm-up
Become familiar with the T-trace API basics by learning about:
-
Initializing Tracing
Initialize tracing for use.
-
Inserting Tracepoints
Create custom tracepoints in your application.
Initializing Tracing
To initialize tracing:
- To use the functions and data types of the T-trace API, include the <trace.h> header file in your application:
#include <trace.h>
- Make sure you have the libttrace.so T-trace library. The T-trace library provides a tracing function to write traces to the system trace buffer.
- Check that the following prerequisites are fulfilled:
- linux-2.6.27 kernel
- debugfs mounted on /sys/kernel/debug
Inserting Tracepoints
To insert tracepoints:
- Use synchronous tracing.
If the trace event starts and ends in a same context within the same process, thread, and function, use the trace_begin() and trace_end() functions to track the event. Note that every trace_begin() function matches up with a trace_end() function that occurs after it.
int main(void) { int integer = 12; trace_begin("event name: %d", integer); trace_end(); return 0; }
- Use asynchronous tracing.
If the trace event starts and ends in a different context, use the trace_async_begin() and trace_async_end() functions to track the event. Note that every trace_async_begin() function matches with a trace_async_end() function that has the same name and cookie. As the cookie provides an identifier among several events, it must have a unique integer value.
void function1() { int cookies_f1 = 123; trace_async_begin(cookies, "event name"); } void function2() { int cookies_f2 = 123; trace_async_end(cookies_f2, "event name"); }
- Track the trace counter.
To track the change of an integer counter on your application, use the trace_update_counter() function:
void function2(int count) { trace_update_counter(count, "event_name"); }