diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36fb04e..ed07554 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,3 +69,11 @@ coverage: - colcon coveragepy-result --packages-select $PACKAGES_LIST --verbose --coverage-report-args -m allow_failure: true <<: *global_artifacts + +trigger_gen_docs: + stage: report + only: + refs: + - master + - foxy + trigger: micro-ROS/ros_tracing/ros2_tracing-api diff --git a/README.md b/README.md index 91fd86f..73cdc89 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,8 @@ Library to support instrumenting ROS packages, including core packages. This package claims to be in the **Quality Level 3** category, see the [Quality Declaration](./tracetools/QUALITY_DECLARATION.md) for more details. +See the [API documentation](https://micro-ros.gitlab.io/ros_tracing/ros2_tracing-api/). + ### tracetools_launch Package containing tools to enable tracing through launch files. diff --git a/tracetools/.gitignore b/tracetools/.gitignore new file mode 100644 index 0000000..90b0816 --- /dev/null +++ b/tracetools/.gitignore @@ -0,0 +1 @@ +doc_output/ diff --git a/tracetools/Doxyfile b/tracetools/Doxyfile new file mode 100644 index 0000000..8ba3973 --- /dev/null +++ b/tracetools/Doxyfile @@ -0,0 +1,32 @@ +# All settings not listed here will use the Doxygen default values. +# To use, see: https://gitlab.com/micro-ROS/ros_tracing/ros2_tracing-api + +PROJECT_NAME = "tracetools" +PROJECT_NUMBER = $(PROJECT_NUMBER) +PROJECT_BRIEF = "Tracing tools and instrumentation for ROS 2" + +INPUT = ./include + +RECURSIVE = YES +OUTPUT_DIRECTORY = doc_output + +EXTRACT_ALL = YES +SORT_MEMBER_DOCS = NO + +GENERATE_LATEX = NO + +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = NO +PREDEFINED = \ + "TRACETOOLS_PUBLIC=" + +EXCLUDE_SYMBOLS = \ + "DECLARE_TRACEPOINT" \ + "_demangle_symbol" \ + "_get_symbol_funcptr" + +# Tag files that do not exist will produce a warning and cross-project linking will not work. +TAGFILES += "../../../data/cppreference-doxygen-web.tag.xml=http://en.cppreference.com/w/" +# Uncomment to generate tag files for cross-project linking. +GENERATE_TAGFILE = "../../../data/tracetools.tag" diff --git a/tracetools/QUALITY_DECLARATION.md b/tracetools/QUALITY_DECLARATION.md index 193e1e7..bbb0aa0 100644 --- a/tracetools/QUALITY_DECLARATION.md +++ b/tracetools/QUALITY_DECLARATION.md @@ -73,7 +73,9 @@ It does not currently have a features list with links to the corresponding featu ### Public API Documentation [3.ii] -`tracetools` does not currently have documentation for its public API. +`tracetools` has embedded API documentation which can be generated using doxygen. The latest version can be viewed [here](https://micro-ros.gitlab.io/ros_tracing/ros2_tracing-api/). + +New additions to the public API require documentation before being added. ### License [3.iii] @@ -175,7 +177,7 @@ The table below compares the requirements in REP-2004 with the current state of |2.v| Documentation policy for change requests | ✓ | |3| **Documentation** || |3.i| Per feature documentation | ✓ | -|3.ii| Public API documentation | | +|3.ii| Public API documentation | ✓ | |3.iii| Declared license(s) | ✓ | |3.iv| Copyright in source files | ✓ | |3.v.a| Quality declaration linked to from README | ✓ | diff --git a/tracetools/include/tracetools/tracetools.h b/tracetools/include/tracetools/tracetools.h index 79b60e5..79dabb4 100644 --- a/tracetools/include/tracetools/tracetools.h +++ b/tracetools/include/tracetools/tracetools.h @@ -12,6 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +/** \mainpage tracetools: tracing tools and instrumentation for ROS 2 + * + * `tracetools` provides utilities to instrument ROS. + * It provides two main headers: + * + * - tracetools/tracetools.h + * - instrumentation functions + * - tracetools/utils.hpp + * - utility functions + */ + #ifndef TRACETOOLS__TRACETOOLS_H_ #define TRACETOOLS__TRACETOOLS_H_ @@ -22,10 +33,14 @@ #include "tracetools/visibility_control.hpp" #ifndef TRACETOOLS_DISABLED +/// Call a tracepoint. +/** + * This is the preferred method over calling the actual function directly. + */ # define TRACEPOINT(event_name, ...) \ (ros_trace_ ## event_name)(__VA_ARGS__) # define DECLARE_TRACEPOINT(event_name, ...) \ - TRACETOOLS_PUBLIC void(ros_trace_ ## event_name)(__VA_ARGS__); + TRACETOOLS_PUBLIC void ros_trace_ ## event_name(__VA_ARGS__); #else # define TRACEPOINT(event_name, ...) ((void) (0)) # define DECLARE_TRACEPOINT(event_name, ...) @@ -36,20 +51,32 @@ extern "C" { #endif +/// Get tracing compilation status. /** - * Report whether tracing is compiled in + * \return `true` if tracing is enabled, `false` otherwise */ TRACETOOLS_PUBLIC bool ros_trace_compile_status(); +/// `rcl_init` /** - * tp: rcl_init + * Initialisation for the whole process. + * Notes the `tracetools` version automatically. + * + * \param[in] context_handle pointer to the `rcl_context_t` handle */ DECLARE_TRACEPOINT( rcl_init, const void * context_handle) +/// `rcl_node_init` /** - * tp: rcl_node_init + * Node initialisation. + * Links a `rcl_node_t` handle to its `rmw_node_t` handle. + * + * \param[in] node_handle pointer to the node's `rcl_node_t` handle + * \param[in] rmw_handle pointer to the node's `rmw_node_t` handle + * \param[in] node_name node name + * \param[in] node_namespace node namespace */ DECLARE_TRACEPOINT( rcl_node_init, @@ -58,8 +85,17 @@ DECLARE_TRACEPOINT( const char * node_name, const char * node_namespace) +/// `rcl_publisher_init` /** - * tp: rcl_publisher_init + * Publisher initialisation. + * Links a `rcl_publisher_t` handle to its `rcl_node_t` handle + * and its `rmw_publisher_t` handle, and links it to a topic name. + * + * \param[in] publisher_handle pointer to the publisher's `rcl_publisher_t` handle + * \param[in] node_handle pointer to the `rcl_node_t` handle of the node the publisher belongs to + * \param[in] rmw_publisher_handle pointer to the publisher's `rmw_publisher_t` handle + * \param[in] topic_name full topic name + * \param[in] queue_depth publisher history depth */ DECLARE_TRACEPOINT( rcl_publisher_init, @@ -69,8 +105,18 @@ DECLARE_TRACEPOINT( const char * topic_name, const size_t queue_depth) +/// `rcl_subscription_init` /** - * tp: rcl_subscription_init + * Subscription initialisation. + * Links a `rcl_subscription_t` handle to its `rcl_node_t` handle + * and its `rmw_subscription_t` handle, and links it to a topic name. + * + * \param[in] subscription_handle pointer to the subscription's `rcl_subscription_t` handle + * \param[in] node_handle + * pointer to the `rcl_node_t` handle of the node the subscription belongs to + * \param[in] rmw_subscription_handle pointer to the subscription's `rmw_subscription_t` handle + * \param[in] topic_name full topic name + * \param[in] queue_depth subscription history depth */ DECLARE_TRACEPOINT( rcl_subscription_init, @@ -80,24 +126,44 @@ DECLARE_TRACEPOINT( const char * topic_name, const size_t queue_depth) +/// `rclcpp_subscription_init` /** - * tp: rclcpp_subscription_init + * Subscription object initialisation. + * Links the `rclcpp::*Subscription*` object to a `rcl_subscription_t` handle. + * Needed since there could be more than 1 `rclcpp::*Subscription*` object + * for one `rcl` subscription (e.g. when using intra-process). + * + * \param[in] subscription_handle + * pointer to the `rcl_subscription_t` handle of the subscription this object belongs to + * \param[in] subscription pointer to this subscription object (e.g. `rclcpp::*Subscription*`) */ DECLARE_TRACEPOINT( rclcpp_subscription_init, const void * subscription_handle, const void * subscription) +/// `rclcpp_subscription_callback_added` /** - * tp: rclcpp_subscription_callback_added + * Link a subscription callback object to a subscription object. + * + * \param[in] subscription pointer to the subscription object this callback belongs to + * \param[in] callback pointer to this callback object (e.g. `rclcpp::AnySubscriptionCallback`) */ DECLARE_TRACEPOINT( rclcpp_subscription_callback_added, const void * subscription, const void * callback) +/// `rcl_service_init` /** - * tp: rcl_service_init + * Service initialisation. + * Links a `rcl_service_t` handle to its `rcl_node_t` handle + * and its `rmw_service_t` handle, and links it to a service name. + * + * \param[in] service_handle pointer to the service's `rcl_service_t` handle + * \param[in] node_handle pointer to the `rcl_node_t` handle of the node the service belongs to + * \param[in] rmw_service_handle pointer to the service's `rmw_service_t` handle + * \param[in] service_name full service name */ DECLARE_TRACEPOINT( rcl_service_init, @@ -106,16 +172,29 @@ DECLARE_TRACEPOINT( const void * rmw_service_handle, const char * service_name) +/// `rclcpp_service_callback_added` /** - * tp: rclcpp_service_callback_added + * Link a service callback object to a service. + * + * \param[in] service_handle + * pointer to the `rcl_service_t` handle of the service this callback belongs to + * \param[in] callback pointer to this callback object (e.g. `rclcpp::AnyServiceCallback`) */ DECLARE_TRACEPOINT( rclcpp_service_callback_added, const void * service_handle, const void * callback) +/// `rcl_client_init` /** - * tp: rcl_client_init + * Client initialisation. + * Links a `rcl_client_t` handle to its `rcl_node_t` handle + * and its `rmw_client_t` handle, and links it to a client name. + * + * \param[in] client_handle pointer to the client's `rcl_client_t` handle + * \param[in] node_handle pointer to the `rcl_node_t` handle of the node the client belongs to + * \param[in] rmw_client_handle pointer to the client's `rmw_client_t` handle + * \param[in] service_name full client name */ DECLARE_TRACEPOINT( rcl_client_init, @@ -124,40 +203,68 @@ DECLARE_TRACEPOINT( const void * rmw_client_handle, const char * service_name) +/// `rcl_timer_init` /** - * tp: rcl_timer_init + * Timer initialisation. + * Notes the timer's period. + * + * \param[in] timer_handle pointer to the timer's `rcl_timer_t` handle + * \param[in] period period in nanoseconds */ DECLARE_TRACEPOINT( rcl_timer_init, const void * timer_handle, int64_t period) +/// `rclcpp_timer_callback_added` /** - * tp: rclcpp_timer_callback_added + * Link a timer callback object to its `rcl_timer_t` handle. + * + * \param[in] timer_handle + * pointer to the `rcl_timer_t` handle of the timer this callback belongs to + * \param[in] callback pointer to the callback object (`std::function`) */ DECLARE_TRACEPOINT( rclcpp_timer_callback_added, const void * timer_handle, const void * callback) +/// `rclcpp_callback_register` /** - * tp: rclcpp_callback_register + * Register a demangled function symbol with a callback. + * + * \param[in] callback pointer to the callback object + * (e.g. `rclcpp::AnySubscriptionCallback`, + * `rclcpp::AnyServiceCallback`, timer `std::function`, etc.) + * \param[in] function_symbol demangled symbol of the callback function/lambda, + * see \ref get_symbol() */ DECLARE_TRACEPOINT( rclcpp_callback_register, const void * callback, const char * function_symbol) +/// `callback_start` /** - * tp: callback_start + * Start of a callback. + * + * \param[in] callback pointer to this callback object + * (e.g. `rclcpp::AnySubscriptionCallback`, + * `rclcpp::AnyServiceCallback`, timer `std::function`, etc.) + * \param[in] is_intra_process whether this callback is done via intra-process or not */ DECLARE_TRACEPOINT( callback_start, const void * callback, const bool is_intra_process) +/// `callback_end` /** - * tp: callback_end + * End of a callback. + * + * \param[in] callback pointer to this callback object + * (e.g. `rclcpp::AnySubscriptionCallback`, + * `rclcpp::AnyServiceCallback`, timer `std::function`, etc.) */ DECLARE_TRACEPOINT( callback_end, diff --git a/tracetools/include/tracetools/utils.hpp b/tracetools/include/tracetools/utils.hpp index 77f4811..e3c934d 100644 --- a/tracetools/include/tracetools/utils.hpp +++ b/tracetools/include/tracetools/utils.hpp @@ -20,12 +20,21 @@ #include "tracetools/visibility_control.hpp" +/// Default symbol, used when address resolution fails. #define SYMBOL_UNKNOWN "UNKNOWN" TRACETOOLS_PUBLIC const char * _demangle_symbol(const char * mangled); TRACETOOLS_PUBLIC const char * _get_symbol_funcptr(void * funcptr); +/// Get symbol from an std::function object. +/** + * If function address resolution or symbol demangling fails, + * this will return a string that starts with \ref SYMBOL_UNKNOWN. + * + * \param[in] f the std::function object + * \return the symbol, or a placeholder + */ template const char * get_symbol(std::function f) { @@ -40,7 +49,13 @@ const char * get_symbol(std::function f) return _demangle_symbol(f.target_type().name()); } -// Fallback meant for lambdas with captures +/// Get symbol from a function-related object. +/** + * Fallback meant for lambdas with captures. + * + * \param[in] l a generic object + * \return the symbol + */ template const char * get_symbol(L && l) { diff --git a/tracetools_test/docs/.gitignore b/tracetools_test/docs/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/tracetools_test/docs/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/tracetools_test/docs/Makefile b/tracetools_test/docs/Makefile new file mode 100644 index 0000000..69fe55e --- /dev/null +++ b/tracetools_test/docs/Makefile @@ -0,0 +1,19 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/tracetools_test/docs/source/about.rst b/tracetools_test/docs/source/about.rst new file mode 100644 index 0000000..e9f97ab --- /dev/null +++ b/tracetools_test/docs/source/about.rst @@ -0,0 +1,4 @@ +About +===== + +Testing utilities and tests for the `tracetools package `_. diff --git a/tracetools_test/docs/source/api.rst b/tracetools_test/docs/source/api.rst new file mode 100644 index 0000000..1ff35bc --- /dev/null +++ b/tracetools_test/docs/source/api.rst @@ -0,0 +1,8 @@ +API +=== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + api/trace_test_case diff --git a/tracetools_test/docs/source/api/trace_test_case.rst b/tracetools_test/docs/source/api/trace_test_case.rst new file mode 100644 index 0000000..ac37bd6 --- /dev/null +++ b/tracetools_test/docs/source/api/trace_test_case.rst @@ -0,0 +1,4 @@ +TraceTestCase +============= + +.. automodule:: tracetools_test.case diff --git a/tracetools_test/docs/source/conf.py b/tracetools_test/docs/source/conf.py new file mode 100644 index 0000000..e99e1ee --- /dev/null +++ b/tracetools_test/docs/source/conf.py @@ -0,0 +1,218 @@ +# Copyright 2019 Open Source Robotics Foundation, Inc. +# +# 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. + +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/master/config + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +import os +import sys +# tracetools_test +sys.path.insert(0, os.path.abspath('../../')) +# # tracetools_launch +# sys.path.insert(0, os.path.abspath('../../../tracetools_launch/')) +# # tracetools_read +# sys.path.insert(0, os.path.abspath('../../../tracetools_read/')) +# # tracetools_trace +# sys.path.insert(0, os.path.abspath('../../../tracetools_trace/')) + + +# -- Project information ----------------------------------------------------- + +project = 'tracetools_test' +copyright = '2019, Robert Bosch GmbH' # noqa +author = 'Robert Bosch GmbH' + +# The short X.Y version +version = os.environ.get('SPHINX_VERSION_SHORT', '') +# The full version, including alpha/beta/rc tags +release = os.environ.get('SPHINX_VERSION_FULL', '') + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx_autodoc_typehints', + 'sphinx.ext.autosummary', + 'sphinx.ext.doctest', + 'sphinx.ext.coverage', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +# exclude_patterns = [] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = None + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +# html_static_path = [] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'tracetools_test-doc' + + +# -- Options for LaTeX output ------------------------------------------------ + +# latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +# +# 'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +# +# 'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +# +# 'preamble': '', + +# Latex figure (float) alignment +# +# 'figure_align': 'htbp', +# } + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +# latex_documents = [ +# (master_doc, 'rclpy.tex', 'rclpy Documentation', +# 'Esteve Fernandez', 'manual'), +# ] + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +# man_pages = [ +# (master_doc, 'rclpy', 'rclpy Documentation', +# [author], 1) +# ] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +# texinfo_documents = [ +# (master_doc, 'rclpy', 'rclpy Documentation', +# author, 'rclpy', 'One line description of project.', +# 'Miscellaneous'), +# ] + + +# -- Options for Epub output ------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = project + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +# +# epub_identifier = '' + +# A unique identification for the text. +# +# epub_uid = '' + +# A list of files that should not be packed into the epub file. +# epub_exclude_files = ['search.html'] + + +# -- Extension configuration ------------------------------------------------- + +# Ignore these +autodoc_mock_imports = [ + 'tracetools_launch', + 'tracetools_read', + 'tracetools_trace', + 'launch', + 'launch_ros', +] + +autoclass_content = 'both' + +autodoc_default_options = { + 'members': None, + 'undoc-members': True, +} diff --git a/tracetools_test/docs/source/index.rst b/tracetools_test/docs/source/index.rst new file mode 100644 index 0000000..f149a5e --- /dev/null +++ b/tracetools_test/docs/source/index.rst @@ -0,0 +1,17 @@ +tracetools_test +=============== + +tracetools_test provides testing utilities and tests for the `tracetools package `_. + +.. toctree:: + :maxdepth: 3 + + about + api + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search`