Backport message flow tracing
This commit is contained in:
		
							parent
							
								
									c261053186
								
							
						
					
					
						commit
						14181900b7
					
				
					 10 changed files with 168 additions and 1 deletions
				
			
		|  | @ -37,6 +37,18 @@ endif() | |||
| if(ENABLE_DEADLINE_MISSED) | ||||
|   set(DDS_HAS_DEADLINE_MISSED "1") | ||||
| endif() | ||||
| 
 | ||||
| find_package(PkgConfig) | ||||
| if(PkgConfig_FOUND) | ||||
|   pkg_check_modules(LTTNG lttng-ust) | ||||
|   if(LTTNG_FOUND) | ||||
|     message(STATUS "Building with LTTng instrumentation support") | ||||
|     set(DDS_HAS_LTTNG_TRACING "1") | ||||
|   else() | ||||
|     message(FATAL_ERROR "CYCLONE_ENABLE_TRACING requires lttng-ust") | ||||
|   endif() | ||||
| endif() | ||||
| 
 | ||||
| configure_file(features.h.in "${CMAKE_CURRENT_BINARY_DIR}/core/include/dds/features.h") | ||||
| 
 | ||||
| add_definitions(-DDDSI_INCLUDE_NETWORK_PARTITIONS -DDDSI_INCLUDE_SSM) | ||||
|  |  | |||
|  | @ -42,6 +42,10 @@ PREPEND(srcs_ddsc "${CMAKE_CURRENT_LIST_DIR}/src" | |||
|     dds_sertopic_builtintopic.c | ||||
| ) | ||||
| 
 | ||||
| if (DDS_HAS_LTTNG_TRACING) | ||||
|   list(APPEND srcs_ddsc "${CMAKE_CURRENT_LIST_DIR}/src/tracing_lttng.c") | ||||
| endif() | ||||
| 
 | ||||
| PREPEND(hdrs_public_ddsc "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include/dds>$<INSTALL_INTERFACE:include/dds>" | ||||
|     dds.h | ||||
|     ddsc/dds_public_error.h | ||||
|  | @ -81,6 +85,7 @@ PREPEND(hdrs_private_ddsc "${CMAKE_CURRENT_LIST_DIR}/src" | |||
|     dds__whc_builtintopic.h | ||||
|     dds__serdata_builtintopic.h | ||||
|     dds__get_status.h | ||||
|     tracing_lttng.h | ||||
| ) | ||||
| 
 | ||||
| generate_export_header( | ||||
|  | @ -108,6 +113,10 @@ target_include_directories(ddsc | |||
|     INTERFACE | ||||
|         $<INSTALL_INTERFACE:include>) | ||||
| 
 | ||||
| if (DDS_HAS_LTTNG_TRACING) | ||||
|   target_link_libraries(ddsc PRIVATE ${LTTNG_LIBRARIES}) | ||||
| endif() | ||||
| 
 | ||||
| install( | ||||
|   DIRECTORY | ||||
|       "${CMAKE_CURRENT_LIST_DIR}/include/" | ||||
|  |  | |||
|  | @ -20,6 +20,7 @@ | |||
| #include "dds/ddsi/q_entity.h" | ||||
| #include "dds/ddsi/ddsi_domaingv.h" | ||||
| #include "dds/ddsi/ddsi_sertopic.h" | ||||
| #include "tracing_lttng.h" | ||||
| 
 | ||||
| /*
 | ||||
|   dds_read_impl: Core read/take function. Usually maxs is size of buf and si | ||||
|  | @ -128,6 +129,7 @@ static dds_return_t dds_read_impl (bool take, dds_entity_t reader_or_condition, | |||
|   } | ||||
|   dds_entity_unpin (entity); | ||||
|   thread_state_asleep (ts1); | ||||
|   TRACEPOINT(read, (const void *)rd, (const void *)*buf); | ||||
|   return ret; | ||||
| 
 | ||||
| #undef NC_CLEAR_LOAN_OUT | ||||
|  |  | |||
|  | @ -33,6 +33,7 @@ | |||
| #include "dds/ddsi/ddsi_entity_index.h" | ||||
| #include "dds/ddsi/ddsi_security_omg.h" | ||||
| #include "dds/ddsi/ddsi_statistics.h" | ||||
| #include "tracing_lttng.h" | ||||
| 
 | ||||
| DECL_ENTITY_LOCK_UNLOCK (extern inline, dds_reader) | ||||
| 
 | ||||
|  | @ -547,6 +548,11 @@ static dds_entity_t dds_create_reader_int (dds_entity_t participant_or_subscribe | |||
|   dds_topic_allow_set_qos (tp); | ||||
|   dds_topic_unpin (tp); | ||||
|   dds_subscriber_unlock (sub); | ||||
| 
 | ||||
|   dds_guid_t guid; | ||||
|   (void)dds_get_guid(reader, &guid); | ||||
|   TRACEPOINT(create_reader, (const void *)rd, rd->m_topic->m_ktopic->name, guid.v); | ||||
| 
 | ||||
|   return reader; | ||||
| 
 | ||||
| #ifdef DDSI_INCLUDE_SECURITY | ||||
|  |  | |||
|  | @ -26,6 +26,7 @@ | |||
| #include "dds/ddsi/q_radmin.h" | ||||
| #include "dds/ddsi/ddsi_domaingv.h" | ||||
| #include "dds/ddsi/ddsi_deliver_locally.h" | ||||
| #include "tracing_lttng.h" | ||||
| 
 | ||||
| dds_return_t dds_write (dds_entity_t writer, const void *data) | ||||
| { | ||||
|  | @ -168,6 +169,8 @@ dds_return_t dds_write_impl (dds_writer *wr, const void * data, dds_time_t tstam | |||
|   if (data == NULL) | ||||
|     return DDS_RETCODE_BAD_PARAMETER; | ||||
| 
 | ||||
|   TRACEPOINT(write, (const void *)wr, (const char *)data, tstamp); | ||||
| 
 | ||||
|   /* Check for topic filter */ | ||||
|   if (wr->m_topic->filter_fn && !writekey) | ||||
|     if (! wr->m_topic->filter_fn (data, wr->m_topic->filter_ctx)) | ||||
|  |  | |||
|  | @ -32,6 +32,7 @@ | |||
| #include "dds__whc.h" | ||||
| #include "dds__statistics.h" | ||||
| #include "dds/ddsi/ddsi_statistics.h" | ||||
| #include "tracing_lttng.h" | ||||
| 
 | ||||
| DECL_ENTITY_LOCK_UNLOCK (extern inline, dds_writer) | ||||
| 
 | ||||
|  | @ -395,6 +396,11 @@ dds_entity_t dds_create_writer (dds_entity_t participant_or_publisher, dds_entit | |||
|   dds_topic_allow_set_qos (tp); | ||||
|   dds_topic_unpin (tp); | ||||
|   dds_publisher_unlock (pub); | ||||
| 
 | ||||
|   dds_guid_t guid; | ||||
|   (void)dds_get_guid(writer, &guid); | ||||
|   TRACEPOINT(create_writer, (const void *)wr, wr->m_topic->m_ktopic->name, guid.v); | ||||
| 
 | ||||
|   return writer; | ||||
| 
 | ||||
| #ifdef DDSI_INCLUDE_SECURITY | ||||
|  |  | |||
							
								
								
									
										16
									
								
								src/core/ddsc/src/tracing_lttng.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/core/ddsc/src/tracing_lttng.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,16 @@ | |||
| /*
 | ||||
|  * Copyright(c) 2021 Christophe Bedard | ||||
|  * | ||||
|  * This program and the accompanying materials are made available under the | ||||
|  * terms of the Eclipse Public License v. 2.0 which is available at | ||||
|  * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
 | ||||
|  * v. 1.0 which is available at | ||||
|  * http://www.eclipse.org/org/documents/edl-v10.php.
 | ||||
|  * | ||||
|  * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||||
|  */ | ||||
| 
 | ||||
| #define TRACEPOINT_CREATE_PROBES | ||||
| 
 | ||||
| #define TRACEPOINT_DEFINE | ||||
| #include "tracing_lttng.h" | ||||
							
								
								
									
										110
									
								
								src/core/ddsc/src/tracing_lttng.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								src/core/ddsc/src/tracing_lttng.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,110 @@ | |||
| /*
 | ||||
|  * Copyright(c) 2021 Christophe Bedard | ||||
|  * | ||||
|  * This program and the accompanying materials are made available under the | ||||
|  * terms of the Eclipse Public License v. 2.0 which is available at | ||||
|  * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
 | ||||
|  * v. 1.0 which is available at | ||||
|  * http://www.eclipse.org/org/documents/edl-v10.php.
 | ||||
|  * | ||||
|  * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||||
|  */ | ||||
| 
 | ||||
| // Provide fake header guard for cpplint
 | ||||
| #undef _DDS_LTTNG_H_ | ||||
| #ifndef _DDS_LTTNG_H_ | ||||
| #define _DDS_LTTNG_H_ | ||||
| 
 | ||||
| #include "dds/features.h" | ||||
| 
 | ||||
| #undef TRACEPOINT_PROVIDER | ||||
| #define TRACEPOINT_PROVIDER dds | ||||
| 
 | ||||
| #define TRACEPOINT(event_name, ...) \ | ||||
|   tracepoint(TRACEPOINT_PROVIDER, event_name, __VA_ARGS__) | ||||
| 
 | ||||
| #undef TRACEPOINT_INCLUDE | ||||
| #define TRACEPOINT_INCLUDE "tracing_lttng.h" | ||||
| 
 | ||||
| #if !defined(__DDS_LTTNG_H_) || defined(TRACEPOINT_HEADER_MULTI_READ) | ||||
| #define __DDS_LTTNG_H_ | ||||
| 
 | ||||
| #include <lttng/tracepoint.h> | ||||
| 
 | ||||
| #ifndef LTTNG_UST_HAVE_SDT_INTEGRATION | ||||
| #  ifdef _MSC_VER | ||||
| #    pragma message ("lttng-ust has not been configured & built with SDT integration (--with-sdt)") | ||||
| #  else | ||||
| #    warning lttng-ust has not been configured & built with SDT integration (--with-sdt) | ||||
| #  endif | ||||
| #endif | ||||
| 
 | ||||
| #include <stdint.h> | ||||
| #include <stdbool.h> | ||||
| 
 | ||||
| #define DDS_GID_STORAGE_SIZE 16u | ||||
| 
 | ||||
| TRACEPOINT_EVENT( | ||||
|   TRACEPOINT_PROVIDER, | ||||
|   create_writer, | ||||
|   TP_ARGS( | ||||
|     const void *, writer_arg, | ||||
|     char *, topic_name_arg, | ||||
|     const uint8_t *, gid_arg | ||||
|   ), | ||||
|   TP_FIELDS( | ||||
|     ctf_integer_hex(const void *, writer, writer_arg) | ||||
|     ctf_string(topic_name, topic_name_arg) | ||||
|     ctf_array(uint8_t, gid, gid_arg, DDS_GID_STORAGE_SIZE) | ||||
|   ) | ||||
| ) | ||||
| 
 | ||||
| TRACEPOINT_EVENT( | ||||
|   TRACEPOINT_PROVIDER, | ||||
|   create_reader, | ||||
|   TP_ARGS( | ||||
|     const void *, reader_arg, | ||||
|     char *, topic_name_arg, | ||||
|     const uint8_t *, gid_arg | ||||
|   ), | ||||
|   TP_FIELDS( | ||||
|     ctf_integer_hex(const void *, reader, reader_arg) | ||||
|     ctf_string(topic_name, topic_name_arg) | ||||
|     ctf_array(uint8_t, gid, gid_arg, DDS_GID_STORAGE_SIZE) | ||||
|   ) | ||||
| ) | ||||
| 
 | ||||
| TRACEPOINT_EVENT( | ||||
|   TRACEPOINT_PROVIDER, | ||||
|   write, | ||||
|   TP_ARGS( | ||||
|     const void *, writer_arg, | ||||
|     const void *, data_arg, | ||||
|     int64_t, timestamp_arg | ||||
|   ), | ||||
|   TP_FIELDS( | ||||
|     ctf_integer_hex(const void *, writer, writer_arg) | ||||
|     ctf_integer_hex(const void *, data, data_arg) | ||||
|     ctf_integer(int64_t, timestamp, timestamp_arg) | ||||
|   ) | ||||
| ) | ||||
| 
 | ||||
| TRACEPOINT_EVENT( | ||||
|   TRACEPOINT_PROVIDER, | ||||
|   read, | ||||
|   TP_ARGS( | ||||
|     const void *, reader_arg, | ||||
|     const void *, buffer_arg | ||||
|   ), | ||||
|   TP_FIELDS( | ||||
|     ctf_integer_hex(const void *, reader, reader_arg) | ||||
|     ctf_integer_hex(const void *, buffer, buffer_arg) | ||||
|   ) | ||||
| ) | ||||
| 
 | ||||
| #endif  // __DDS_LTTNG_H_
 | ||||
| 
 | ||||
| #include <lttng/tracepoint-event.h> | ||||
| 
 | ||||
| #endif  // _DDS_LTTNG_H_
 | ||||
| 
 | ||||
|  | @ -129,7 +129,7 @@ ddsrt_thread_setname(const char *__restrict name) | |||
|      name exceeds the limit, so silently truncate. */ | ||||
|   char buf[MAXTHREADNAMESIZE + 1] = ""; | ||||
|   (void)ddsrt_strlcpy(buf, name, sizeof(buf)); | ||||
|   (void)pthread_setname_np(pthread_self(), name); | ||||
|   (void)pthread_setname_np(pthread_self(), buf); | ||||
| #elif defined(__APPLE__) | ||||
|   (void)pthread_setname_np(name); | ||||
| #elif defined(__FreeBSD__) | ||||
|  |  | |||
|  | @ -21,4 +21,7 @@ | |||
| /* Whether or not support for generating "deadline missed" events is included */ | ||||
| #cmakedefine DDS_HAS_DEADLINE_MISSED @DDS_HAS_DEADLINE_MISSED@ | ||||
| 
 | ||||
| /* Whether or not support for LTTng tracing instrumentation is included */ | ||||
| #cmakedefine DDS_HAS_LTTNG_TRACING @DDS_HAS_LTTNG_TRACING@ | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue