ros2_tracing/tracetools_trace/tracetools_trace/trace.py

55 lines
1.8 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
2019-06-24 10:36:39 +02:00
# Copyright 2019 Robert Bosch GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2019-06-24 10:45:29 +02:00
"""Entrypoint/script to setup and start an LTTng tracing session."""
2019-06-17 14:46:05 +02:00
import os
2019-06-23 16:02:48 +02:00
from tracetools_trace.tools import args
2019-06-07 10:42:40 +02:00
from tracetools_trace.tools import lttng
2019-06-07 11:28:09 +02:00
def main():
2019-06-23 16:02:48 +02:00
params = args.parse_args()
2019-06-06 09:29:23 +02:00
2019-06-23 16:02:48 +02:00
session_name = params.session_name
base_path = params.path
2019-06-17 14:46:05 +02:00
full_path = os.path.join(base_path, session_name)
2019-06-23 16:02:48 +02:00
ros_events = params.events_ust
kernel_events = params.events_kernel
ust_enabled = len(ros_events) > 0
kernel_enabled = len(kernel_events) > 0
if ust_enabled:
print(f'UST tracing enabled ({len(ros_events)} events)')
2019-06-23 16:02:48 +02:00
if params.list:
print(f'\tevents: {ros_events}')
else:
print('UST tracing disabled')
if kernel_enabled:
print(f'kernel tracing enabled ({len(kernel_events)} events)')
2019-06-23 16:02:48 +02:00
if params.list:
print(f'\tevents: {kernel_events}')
else:
print('kernel tracing disabled')
2019-06-06 09:36:16 +02:00
print(f'writting tracing session to: {full_path}')
2019-06-06 09:29:38 +02:00
input('press enter to start...')
2019-06-23 15:51:13 +02:00
lttng.lttng_init(session_name, full_path, ros_events=ros_events, kernel_events=kernel_events)
input('press enter to stop...')
print('stopping & destroying tracing session')
2019-06-23 15:51:13 +02:00
lttng.lttng_fini(session_name)