This repository will explain the steps to tracing Orocos components using LTTng and visualizing those traces using Trace Compass.
Be sure to have the following installed:
Also follow these guides to better understand all tools involved:
- LTTng Docs
- LTTng Function Tracing
- The Orocos Component Builder's Manual
- Trace Compass User Guide
- Trace Compass LTTng-UST analysis
The following are the steps from creating an Orocos component, tracing that component, and visualizing those traces in Trace Compass. The steps are included in the compile_component.sh and trace.sh scripts which will compile and begin tracing your component. They have been included in the example HelloWorld component.
- Create and compile Orocos component with debug flags:
# Creating a component is not included in compile_component.sh
$ orocreate-pkg HelloWorld component
$ mkdir build; cd build
# Compiler flags can be added to CMakeLists instead of in terminal: set(DCMAKE_CXX_FLAGS "-g -finstrument-functions ${CMAKE_CXX_FLAGS}")
$ cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/../../install -DCMAKE_CXX_FLAGS="-g -finstrument-functions"
$ make install
$ cd ..
$ export RTT_COMPONENT_PATH=$(pwd)/../install/lib/orocos:$RTT_COMPONENT_PATH
- Start LTTng tracing:
# Save traces in /out/ directory
$ lttng create demo_session -o ./out
# Enable all userspace traces
$ lttng enable-event -u -a
$ lttng add-context -u -t vpid -t vtid -t procname -t ip
$ lttng start
# start.ops is the components deployment script
$ LD_PRELOAD=liblttng-ust-cyg-profile.so:liblttng-ust-dl.so deployer -s start.ops
$ lttng stop
$ lttng destroy
- Save Traces:
# Save traces to text file
$ babeltrace ./out/ > trace_data.txt
-
Read the Trace Compass User guide on the available views for your trace. Examples:
Flame Graph:
Call Stack:
Along with Orocos components, ROS nodes also work very well with LTTng tracing and visualization. To do so just compile the workspace with "-g -finstrument-functions" flags and create a directory to store your traces.
# Insert in CMakeLists
$ set(DCMAKE_CXX_FLAGS "-g -finstrument-functions ${CMAKE_CXX_FLAGS}")
# Or in terminal to apply to all packages in workspace
$ catkin_make --cmake-args -DCMAKE_CXX_FLAGS="-g -finstrument-functions"
ROS node call stack example: