Skip to content

Commit

Permalink
Address errors related to trace_event_t
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
petervdonovan committed Mar 28, 2024
1 parent a637ff0 commit 4104af1
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 129 deletions.
3 changes: 3 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions core/federated/federate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions include/core/tracepoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include "net_common.h"
#endif // FEDERATED

#include "trace_types.h"

#ifdef LF_TRACE

#include "trace.h"
Expand Down
2 changes: 2 additions & 0 deletions trace/api/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
127 changes: 0 additions & 127 deletions trace/api/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions trace/api/types/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
144 changes: 144 additions & 0 deletions trace/api/types/trace_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/**
* @file trace-types.h
* @author Peter Donovan <[email protected]>
* @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
1 change: 1 addition & 0 deletions trace/impl/src/trace_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 4104af1

Please sign in to comment.