From caac5cafe3fe46e4c2a52000a93ee36335bccb96 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Sat, 12 Oct 2019 17:27:09 -0700 Subject: [PATCH 1/5] Re-order args --- tracetools_trace/tracetools_trace/tools/args.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tracetools_trace/tracetools_trace/tools/args.py b/tracetools_trace/tracetools_trace/tools/args.py index dc56bb3..2088676 100644 --- a/tracetools_trace/tracetools_trace/tools/args.py +++ b/tracetools_trace/tracetools_trace/tools/args.py @@ -40,26 +40,27 @@ def parse_args(): def add_arguments(parser): parser.add_argument( - '--session-name', '-s', dest='session_name', + '-s', '--session-name', dest='session_name', default=path.append_timestamp('session'), help='the name of the tracing session (default: session-YYYYMMDDHHMMSS)') parser.add_argument( - '--path', '-p', dest='path', + '-p', '--path', dest='path', default=path.DEFAULT_BASE_PATH, help='path of the base directory for trace data (default: %(default)s)') arg = parser.add_argument( - '--ust', '-u', nargs='*', dest='events_ust', default=names.DEFAULT_EVENTS_ROS, + '-u', '--ust', nargs='*', dest='events_ust', + default=names.DEFAULT_EVENTS_ROS, help='the ROS UST events to enable (default: all events) ' '[to disable all UST events, ' 'provide this flag without any event name]') arg.completer = DefaultArgValueCompleter(arg) arg = parser.add_argument( - '--kernel', '-k', nargs='*', dest='events_kernel', + '-k', '--kernel', nargs='*', dest='events_kernel', default=names.DEFAULT_EVENTS_KERNEL, help='the kernel events to enable (default: all events) ' '[to disable all kernel events, ' 'provide this flag without any event name]') arg.completer = DefaultArgValueCompleter(arg) parser.add_argument( - '--list', '-l', dest='list', action='store_true', + '-l', '--list', dest='list', action='store_true', help='display lists of enabled events (default: %(default)s)') From 510a51510162301d8a370ed423c1646cc7252f3d Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Sat, 12 Oct 2019 17:27:31 -0700 Subject: [PATCH 2/5] Add is_trace_directory() util function --- tracetools_read/tracetools_read/trace.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tracetools_read/tracetools_read/trace.py b/tracetools_read/tracetools_read/trace.py index 02d2c27..73ae513 100644 --- a/tracetools_read/tracetools_read/trace.py +++ b/tracetools_read/tracetools_read/trace.py @@ -14,6 +14,7 @@ """Module with functions for reading traces.""" +import os from typing import Iterable from typing import List @@ -25,6 +26,22 @@ from . import DictEvent BabeltraceEvent = babeltrace.babeltrace.Event +def is_trace_directory(path: str) -> bool: + """ + Check recursively if a path is a trace directory. + + :param path: the path to check + :return: `True` if it is a trace directory, `False` otherwise + """ + path = os.path.expanduser(path) + if not os.path.isdir(path): + return False + tc = babeltrace.TraceCollection() + # Could still return an empty dict even if it is not a trace directory (recursively) + traces = tc.add_traces_recursive(path, 'ctf') + return traces is not None and len(traces) > 0 + + def get_trace_ctf_events(trace_directory: str) -> Iterable[BabeltraceEvent]: """ Get the events of a trace. From 9c14d36c79a17e9e22e66bdbf292e88abbec0543 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Sun, 13 Oct 2019 15:27:22 -0700 Subject: [PATCH 3/5] Add ros2trace_analysis to design document --- doc/design_ros_2.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/design_ros_2.md b/doc/design_ros_2.md index fe08a32..38fefce 100644 --- a/doc/design_ros_2.md +++ b/doc/design_ros_2.md @@ -575,6 +575,12 @@ We could look into making analyses work on both ROS 1 and ROS 2, through a commo * convert CTF traces to pickle files * wrap trace events in Python `dict` * handle and process trace events to gather data +* `ros2trace_analysis` + * provides a `ros2cli` extension with verbs + `$ ros2 trace-analysis` + * uses `tracetools_analysis` functions + `$ ros2 trace-analysis convert` + `$ ros2 trace-analysis process` ```plantuml @startuml @@ -633,6 +639,11 @@ tracetools_read <-- tracetools_analysis pandas <--- tracetools_analysis bokeh <--- tracetools_analysis +package ros2trace_analysis <> { +} +ros2cli <|-- ros2trace_analysis +tracetools_analysis <-- ros2trace_analysis + @enduml ``` From 25f1913409d5798cfbe7a8b1626f3d3d0e0e5032 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Sun, 13 Oct 2019 15:27:46 -0700 Subject: [PATCH 4/5] Link to design document in README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 188f058..e9aa6ac 100644 --- a/README.md +++ b/README.md @@ -45,3 +45,7 @@ By default, it will enable all ROS tracepoints and a few kernel tracepoints. The Another option is to use the `Trace` action in a launch file along with your `Node` action(s). See [this example launch file](./tracetools_launch/launch/example.launch.py) for more information. + +## Design + +See the [design document](./doc/design_ros_2.md). From ce17f503d1027ee603baa81d50f693e3df23b9fe Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Sun, 13 Oct 2019 15:29:21 -0700 Subject: [PATCH 5/5] Add launch tracing example --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e9aa6ac..1ff0150 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,11 @@ By default, it will enable all ROS tracepoints and a few kernel tracepoints. The ### Launch file trace action -Another option is to use the `Trace` action in a launch file along with your `Node` action(s). +Another option is to use the `Trace` action in a launch file along with your `Node` action(s). This way, tracing happens when launching the launch file. + +``` +$ ros2 launch tracetools_launch example.launch.py +``` See [this example launch file](./tracetools_launch/launch/example.launch.py) for more information.