From 4104af14c5b426d3fa7520c993a397fd02e6c28f Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Mon, 25 Mar 2024 20:32:33 -0700 Subject: [PATCH] Address errors related to trace_event_t This commit results from changes that were made in the effort to eliminate warnings. The changes were good, but the problem that I have is that I wish for everything that will be used by code outside of the runtime to be in the trace/api directory. --- core/CMakeLists.txt | 3 + core/federated/federate.c | 2 - include/core/tracepoint.h | 2 + trace/api/CMakeLists.txt | 2 + trace/api/trace.h | 127 ----------------------------- trace/api/types/CMakeLists.txt | 3 + trace/api/types/trace_types.h | 144 +++++++++++++++++++++++++++++++++ trace/impl/src/trace_impl.c | 1 + 8 files changed, 155 insertions(+), 129 deletions(-) create mode 100644 trace/api/types/CMakeLists.txt create mode 100644 trace/api/types/trace_types.h diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 3000ee723..1b80c329d 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -62,6 +62,9 @@ if (DEFINED LF_TRACE) message(STATUS "linking trace plugin library ${LF_TRACE_PLUGIN}") target_link_libraries(reactor-c PUBLIC lf::trace-api) target_link_libraries(reactor-c PRIVATE "${LF_TRACE_PLUGIN}") +else() + include(${LF_ROOT}/trace/api/types/CMakeLists.txt) + target_link_libraries(reactor-c PUBLIC lf::trace-api-types) endif() include(${LF_ROOT}/version/api/CMakeLists.txt) diff --git a/core/federated/federate.c b/core/federated/federate.c index 922d803e0..584e9fc3b 100644 --- a/core/federated/federate.c +++ b/core/federated/federate.c @@ -140,9 +140,7 @@ static void send_tag(unsigned char type, tag_t tag) { LF_MUTEX_UNLOCK(&lf_outbound_socket_mutex); return; } -#ifdef LF_TRACE trace_event_t event_type = (type == MSG_TYPE_NEXT_EVENT_TAG) ? send_NET : send_LTC; -#endif // Trace the event when tracing is enabled tracepoint_federate_to_rti(event_type, _lf_my_fed_id, &tag); write_to_socket_fail_on_error(&_fed.socket_TCP_RTI, bytes_to_write, buffer, &lf_outbound_socket_mutex, diff --git a/include/core/tracepoint.h b/include/core/tracepoint.h index f6e369a1e..0eb8252b3 100644 --- a/include/core/tracepoint.h +++ b/include/core/tracepoint.h @@ -37,6 +37,8 @@ #include "net_common.h" #endif // FEDERATED +#include "trace_types.h" + #ifdef LF_TRACE #include "trace.h" diff --git a/trace/api/CMakeLists.txt b/trace/api/CMakeLists.txt index c639096ea..2c0edc677 100644 --- a/trace/api/CMakeLists.txt +++ b/trace/api/CMakeLists.txt @@ -1,3 +1,5 @@ add_library(lf-trace-api INTERFACE) add_library(lf::trace-api ALIAS lf-trace-api) +include(${CMAKE_CURRENT_LIST_DIR}/types/CMakeLists.txt) +target_link_libraries(lf-trace-api INTERFACE lf::trace-api-types) target_include_directories(lf-trace-api INTERFACE ${CMAKE_CURRENT_LIST_DIR}) diff --git a/trace/api/trace.h b/trace/api/trace.h index afe538c48..e3955bcca 100644 --- a/trace/api/trace.h +++ b/trace/api/trace.h @@ -6,133 +6,6 @@ #include "lf_core_version.h" -/** - * Trace event types. If you update this, be sure to update the - * string representation below. Also, create a tracepoint function - * for each event type. - */ -typedef enum { - reaction_starts, - reaction_ends, - reaction_deadline_missed, - schedule_called, - user_event, - user_value, - worker_wait_starts, - worker_wait_ends, - scheduler_advancing_time_starts, - scheduler_advancing_time_ends, - federated, // Everything below this is for tracing federated interactions. - // Sending messages - send_ACK, - send_FAILED, - send_TIMESTAMP, - send_NET, - send_LTC, - send_STOP_REQ, - send_STOP_REQ_REP, - send_STOP_GRN, - send_FED_ID, - send_PTAG, - send_TAG, - send_REJECT, - send_RESIGN, - send_PORT_ABS, - send_CLOSE_RQ, - send_TAGGED_MSG, - send_P2P_TAGGED_MSG, - send_MSG, - send_P2P_MSG, - send_ADR_AD, - send_ADR_QR, - // Receiving messages - receive_ACK, - receive_FAILED, - receive_TIMESTAMP, - receive_NET, - receive_LTC, - receive_STOP_REQ, - receive_STOP_REQ_REP, - receive_STOP_GRN, - receive_FED_ID, - receive_PTAG, - receive_TAG, - receive_REJECT, - receive_RESIGN, - receive_PORT_ABS, - receive_CLOSE_RQ, - receive_TAGGED_MSG, - receive_P2P_TAGGED_MSG, - receive_MSG, - receive_P2P_MSG, - receive_ADR_AD, - receive_ADR_QR, - receive_UNIDENTIFIED, - NUM_EVENT_TYPES -} trace_event_t; - -/** - * String description of event types. - */ -static const char *trace_event_names[] = { - "Reaction starts", - "Reaction ends", - "Reaction deadline missed", - "Schedule called", - "User-defined event", - "User-defined valued event", - "Worker wait starts", - "Worker wait ends", - "Scheduler advancing time starts", - "Scheduler advancing time ends", - "Federated marker", - // Sending messages - "Sending ACK", - "Sending FAILED", - "Sending TIMESTAMP", - "Sending NET", - "Sending LTC", - "Sending STOP_REQ", - "Sending STOP_REQ_REP", - "Sending STOP_GRN", - "Sending FED_ID", - "Sending PTAG", - "Sending TAG", - "Sending REJECT", - "Sending RESIGN", - "Sending PORT_ABS", - "Sending CLOSE_RQ", - "Sending TAGGED_MSG", - "Sending P2P_TAGGED_MSG", - "Sending MSG", - "Sending P2P_MSG", - "Sending ADR_AD", - "Sending ADR_QR", - // Receiving messages - "Receiving ACK", - "Receiving FAILED", - "Receiving TIMESTAMP", - "Receiving NET", - "Receiving LTC", - "Receiving STOP_REQ", - "Receiving STOP_REQ_REP", - "Receiving STOP_GRN", - "Receiving FED_ID", - "Receiving PTAG", - "Receiving TAG", - "Receiving REJECT", - "Receiving RESIGN", - "Receiving PORT_ABS", - "Receiving CLOSE_RQ", - "Receiving TAGGED_MSG", - "Receiving P2P_TAGGED_MSG", - "Receiving MSG", - "Receiving P2P_MSG", - "Receiving ADR_AD", - "Receiving ADR_QR", - "Receiving UNIDENTIFIED", -}; - /** * @brief Return a description of the compile-time properties of the current * plugin. diff --git a/trace/api/types/CMakeLists.txt b/trace/api/types/CMakeLists.txt new file mode 100644 index 000000000..6576ab87a --- /dev/null +++ b/trace/api/types/CMakeLists.txt @@ -0,0 +1,3 @@ +add_library(lf-trace-api-types INTERFACE) +add_library(lf::trace-api-types ALIAS lf-trace-api-types) +target_include_directories(lf-trace-api-types INTERFACE ${CMAKE_CURRENT_LIST_DIR}) diff --git a/trace/api/types/trace_types.h b/trace/api/types/trace_types.h new file mode 100644 index 000000000..9ecbb997e --- /dev/null +++ b/trace/api/types/trace_types.h @@ -0,0 +1,144 @@ +/** + * @file trace-types.h + * @author Peter Donovan + * @brief Definitions that are needed by both implementors and callers of the + * trace API regardless of whether tracing is enabled at compile time. + * + * @copyright Copyright (c) 2024 + */ + +#ifndef TRACE_TYPES_H +#define TRACE_TYPES_H + +/** + * Trace event types. If you update this, be sure to update the + * string representation below. Also, create a tracepoint function + * for each event type. + */ +typedef enum { + reaction_starts, + reaction_ends, + reaction_deadline_missed, + schedule_called, + user_event, + user_value, + worker_wait_starts, + worker_wait_ends, + scheduler_advancing_time_starts, + scheduler_advancing_time_ends, + federated, // Everything below this is for tracing federated interactions. + // Sending messages + send_ACK, + send_FAILED, + send_TIMESTAMP, + send_NET, + send_LTC, + send_STOP_REQ, + send_STOP_REQ_REP, + send_STOP_GRN, + send_FED_ID, + send_PTAG, + send_TAG, + send_REJECT, + send_RESIGN, + send_PORT_ABS, + send_CLOSE_RQ, + send_TAGGED_MSG, + send_P2P_TAGGED_MSG, + send_MSG, + send_P2P_MSG, + send_ADR_AD, + send_ADR_QR, + // Receiving messages + receive_ACK, + receive_FAILED, + receive_TIMESTAMP, + receive_NET, + receive_LTC, + receive_STOP_REQ, + receive_STOP_REQ_REP, + receive_STOP_GRN, + receive_FED_ID, + receive_PTAG, + receive_TAG, + receive_REJECT, + receive_RESIGN, + receive_PORT_ABS, + receive_CLOSE_RQ, + receive_TAGGED_MSG, + receive_P2P_TAGGED_MSG, + receive_MSG, + receive_P2P_MSG, + receive_ADR_AD, + receive_ADR_QR, + receive_UNIDENTIFIED, + NUM_EVENT_TYPES +} trace_event_t; + +/** + * String description of event types. + */ +static const char *trace_event_names[] = { + "Reaction starts", + "Reaction ends", + "Reaction deadline missed", + "Schedule called", + "User-defined event", + "User-defined valued event", + "Worker wait starts", + "Worker wait ends", + "Scheduler advancing time starts", + "Scheduler advancing time ends", + "Federated marker", + // Sending messages + "Sending ACK", + "Sending FAILED", + "Sending TIMESTAMP", + "Sending NET", + "Sending LTC", + "Sending STOP_REQ", + "Sending STOP_REQ_REP", + "Sending STOP_GRN", + "Sending FED_ID", + "Sending PTAG", + "Sending TAG", + "Sending REJECT", + "Sending RESIGN", + "Sending PORT_ABS", + "Sending CLOSE_RQ", + "Sending TAGGED_MSG", + "Sending P2P_TAGGED_MSG", + "Sending MSG", + "Sending P2P_MSG", + "Sending ADR_AD", + "Sending ADR_QR", + // Receiving messages + "Receiving ACK", + "Receiving FAILED", + "Receiving TIMESTAMP", + "Receiving NET", + "Receiving LTC", + "Receiving STOP_REQ", + "Receiving STOP_REQ_REP", + "Receiving STOP_GRN", + "Receiving FED_ID", + "Receiving PTAG", + "Receiving TAG", + "Receiving REJECT", + "Receiving RESIGN", + "Receiving PORT_ABS", + "Receiving CLOSE_RQ", + "Receiving TAGGED_MSG", + "Receiving P2P_TAGGED_MSG", + "Receiving MSG", + "Receiving P2P_MSG", + "Receiving ADR_AD", + "Receiving ADR_QR", + "Receiving UNIDENTIFIED", +}; + +static inline void _suppress_unused_variable_warning_for_static_variable() { + (void) trace_event_names; +} + +#endif diff --git a/trace/impl/src/trace_impl.c b/trace/impl/src/trace_impl.c index bd577b337..a2f2a690c 100644 --- a/trace/impl/src/trace_impl.c +++ b/trace/impl/src/trace_impl.c @@ -254,6 +254,7 @@ void lf_tracing_tracepoint(int worker, trace_record_nodeps_t* tr) { } void lf_tracing_global_init(char* process_name, char* process_names, int fedid, int max_num_local_threads) { + (void) process_names; trace_mutex = lf_platform_mutex_new(); if (!trace_mutex) { fprintf(stderr, "WARNING: Failed to initialize trace mutex.\n");