Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion trick_source/sim_services/CommandLineArguments/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ TRICK_CXXFLAGS += -I$(GTEST_HOME)/include -I$(TRICK_HOME)/include -g ${TRICK_SYS
MM_OBJECTS = $(TRICK_HOME)/trick_source/sim_services/MemoryManager/object_${TRICK_HOST_CPU}/extract_bitfield.o \
$(TRICK_HOME)/trick_source/sim_services/MemoryManager/object_${TRICK_HOST_CPU}/extract_unsigned_bitfield.o

TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick_mm -ltrick_units -ltrick -ltrick_mm -ltrick_units -ltrick -ltrick_pyip -ltrick_connection_handlers -ltrick_comm -ltrick_mm -ltrick_units -ltrick
#TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick_mm -ltrick_units -ltrick -ltrick_mm -ltrick_units -ltrick -ltrick_pyip -ltrick_connection_handlers -ltrick_comm -ltrick_mm -ltrick_units -ltrick -ltrick_mm
TRICK_LIB_NAMES = trick_mm trick_units trick trick_pyip trick_connection_handlers trick_comm
ifeq ($(TRICK_HOST_TYPE),Linux)
TRICK_LIBS = -L${TRICK_LIB_DIR} -Wl,--start-group $(addprefix -l,$(TRICK_LIB_NAMES)) -Wl,--end-group
else ifeq ($(TRICK_HOST_TYPE),Darwin)
TRICK_LIBS = -L${TRICK_LIB_DIR} $(addprefix -l, $(TRICK_LIB_NAMES))
else
$(error Unsupported platform: $(shell uname))
endif

TRICK_EXEC_LINK_LIBS += -L${GTEST_HOME}/lib64 -L${GTEST_HOME}/lib -lgtest -lgtest_main -lpthread


Expand Down
10 changes: 9 additions & 1 deletion trick_source/sim_services/Executive/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ COVERAGE_FLAGS += -fprofile-arcs -ftest-coverage -O0
# Flags passed to the preprocessor.
TRICK_CPPFLAGS += -I$(GTEST_HOME)/include -I$(TRICK_HOME)/include -g ${TRICK_SYSTEM_CXXFLAGS} ${TRICK_TEST_FLAGS}

TRICK_LIBS = -L ${TRICK_LIB_DIR} -ltrick_mm -ltrick_units -ltrick -ltrick_pyip -ltrick_connection_handlers -ltrick_comm
#TRICK_LIBS = -L ${TRICK_LIB_DIR} -ltrick_mm -ltrick_units -ltrick -ltrick_pyip -ltrick_connection_handlers -ltrick_comm -ltrick_mm
TRICK_LIB_NAMES = trick_mm trick_units trick trick_pyip trick_connection_handlers trick_comm
ifeq ($(TRICK_HOST_TYPE),Linux)
TRICK_LIBS = -L${TRICK_LIB_DIR} -Wl,--start-group $(addprefix -l,$(TRICK_LIB_NAMES)) -Wl,--end-group
else ifeq ($(TRICK_HOST_TYPE),Darwin)
TRICK_LIBS = -L${TRICK_LIB_DIR} $(addprefix -l, $(TRICK_LIB_NAMES))
else
$(error Unsupported platform: $(shell uname))
endif
TRICK_EXEC_LINK_LIBS += -L${GTEST_HOME}/lib64 -L${GTEST_HOME}/lib -lgtest -lgtest_main
TRICK_SYSTEM_LDFLAGS += ${COVERAGE_FLAGS}

Expand Down
10 changes: 9 additions & 1 deletion trick_source/sim_services/Integrator/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../../../share/trick/makefiles/Mak
# Flags passed to the preprocessor.
TRICK_CPPFLAGS += -I$(GTEST_HOME)/include -I$(TRICK_HOME)/include -I${TRICK_HOME}/trick_source -I${TRICK_HOME}/include/trick/compat -g -DUSE_ER7_UTILS_INTEGRATORS=1 -DTEST ${TRICK_SYSTEM_CXXFLAGS} ${TRICK_TEST_FLAGS}

TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick -ltrick_mm -ltrick_units -ltrick_mm -ltrick_pyip -ltrick_connection_handlers -ltrick_comm -ltrick_mm -ltrick_units -ltrick
#TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick -ltrick_mm -ltrick_units -ltrick_mm -ltrick_pyip -ltrick_connection_handlers -ltrick_comm -ltrick_mm -ltrick_units -ltrick -ltrick_mm
TRICK_LIB_NAMES = trick trick_mm trick_units trick_pyip trick_connection_handlers trick_comm
ifeq ($(TRICK_HOST_TYPE),Linux)
TRICK_LIBS = -L${TRICK_LIB_DIR} -Wl,--start-group $(addprefix -l,$(TRICK_LIB_NAMES)) -Wl,--end-group
else ifeq ($(TRICK_HOST_TYPE),Darwin)
TRICK_LIBS = -L${TRICK_LIB_DIR} $(addprefix -l, $(TRICK_LIB_NAMES))
else
$(error Unsupported platform: $(shell uname))
endif
TRICK_EXEC_LINK_LIBS += -L${GTEST_HOME}/lib64 -L${GTEST_HOME}/lib -lgtest -lgtest_main

# All tests produced by this Makefile. Remember to add new tests you
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ REF2 *Trick::MemoryManager::ref_attributes(const char* name) {
name as requested as "name" */
if ( context->result->reference ) {
free(context->result->reference) ;
context->result->reference = NULL;
}
context->result->reference = strdup(name);
result = context->result;
Expand Down
13 changes: 13 additions & 0 deletions trick_source/sim_services/MemoryManager/ref_free.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ extern "C" void ref_free(REF2 * ref) {
// The reference string was allocated with strdup.
if ( ref->reference ) {
free(ref->reference) ;
ref->reference = NULL;
}

// Free units string
if (ref->units) {
free(ref->units);
ref->units = NULL;
}

// Free ref_attr, however, not freeing the shared attr
if (ref->ref_attr) {
free(ref->ref_attr);
ref->ref_attr = NULL;
}
}
return ;
Expand Down
11 changes: 10 additions & 1 deletion trick_source/sim_services/MemoryManager/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ TRICK_SYSTEM_LDFLAGS += ${COVERAGE_FLAGS}

# Flags passed to the preprocessor.
TRICK_CPPFLAGS += -I$(GTEST_HOME)/include -I$(TRICK_HOME)/include -g -Wno-sign-compare ${COVERAGE_FLAGS} ${TRICK_SYSTEM_CXXFLAGS} ${TRICK_TEST_FLAGS}
TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick_mm -ltrick_units -ltrick -ltrick_mm -ltrick_units -ltrick -ltrick_connection_handlers -ltrick_pyip -ltrick -ltrick_comm
#TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick_mm -ltrick_units -ltrick -ltrick_mm -ltrick_units -ltrick -ltrick_connection_handlers -ltrick_pyip -ltrick -ltrick_comm
TRICK_LIB_NAMES = trick_mm trick_units trick trick_connection_handlers trick_pyip trick_comm
ifeq ($(TRICK_HOST_TYPE),Linux)
TRICK_LIBS = -L${TRICK_LIB_DIR} -Wl,--start-group $(addprefix -l,$(TRICK_LIB_NAMES)) -Wl,--end-group
else ifeq ($(TRICK_HOST_TYPE),Darwin)
TRICK_LIBS = -L${TRICK_LIB_DIR} $(addprefix -l, $(TRICK_LIB_NAMES))
else
$(error Unsupported platform: $(shell uname))
endif

TRICK_EXEC_LINK_LIBS += -L${GTEST_HOME}/lib64 -L${GTEST_HOME}/lib -lgtest -lgtest_main -lpthread

# ==================================================================================
Expand Down
10 changes: 9 additions & 1 deletion trick_source/sim_services/ScheduledJobQueue/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../../../share/trick/makefiles/Mak

# Flags passed to the preprocessor.
TRICK_CPPFLAGS += -I$(GTEST_HOME)/include -I$(TRICK_HOME)/include -g ${TRICK_SYSTEM_CXXFLAGS} ${TRICK_TEST_FLAGS}
TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick_mm -ltrick_units -ltrick -ltrick_mm -ltrick_units -ltrick -ltrick_pyip -ltrick_connection_handlers -ltrick_comm -ltrick
#TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick_mm -ltrick_units -ltrick -ltrick_mm -ltrick_units -ltrick -ltrick_pyip -ltrick_connection_handlers -ltrick_comm -ltrick
TRICK_LIB_NAMES = trick_mm trick_units trick trick_pyip trick_connection_handlers trick_comm
ifeq ($(TRICK_HOST_TYPE),Linux)
TRICK_LIBS = -L${TRICK_LIB_DIR} -Wl,--start-group $(addprefix -l,$(TRICK_LIB_NAMES)) -Wl,--end-group
else ifeq ($(TRICK_HOST_TYPE),Darwin)
TRICK_LIBS = -L${TRICK_LIB_DIR} $(addprefix -l, $(TRICK_LIB_NAMES))
else
$(error Unsupported platform: $(shell uname))
endif
TRICK_EXEC_LINK_LIBS += -L${GTEST_HOME}/lib64 -L${GTEST_HOME}/lib -lgtest -lgtest_main

# All tests produced by this Makefile. Remember to add new tests you
Expand Down
26 changes: 24 additions & 2 deletions trick_source/sim_services/VariableServer/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,30 @@ TRICK_SYSTEM_CXXFLAGS := $(subst -isystem,-I,$(TRICK_SYSTEM_CXXFLAGS)) -Wno-unus

# Flags passed to the preprocessor.
TRICK_CXXFLAGS += -I$(GTEST_HOME)/include -I$(TRICK_HOME)/include -g -Wno-sign-compare ${TRICK_SYSTEM_CXXFLAGS} ${TRICK_TEST_FLAGS}
TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick_mm -ltrick_units -ltrick_comm -ltrick_pyip -ltrick -ltrick_mm -ltrick_units -ltrick_comm -ltrick_pyip -ltrick -ltrick_var_binary_parser -ltrick_connection_handlers -ltrick_comm
TRICK_EXEC_LINK_LIBS += -L${GTEST_HOME}/lib64 -L${GTEST_HOME}/lib -lgtest -lgtest_main -lgmock -lpthread
# TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick_mm -ltrick_units -ltrick_comm -ltrick_pyip -ltrick -ltrick_mm -ltrick_units -ltrick_comm -ltrick_pyip -ltrick -ltrick_var_binary_parser -ltrick_connection_handlers -ltrick_comm -ltrick_mm
# Keeping this repteitive list of libraries to avoid circular dependency issues for reference.
# The repetition and ordering matters because of how the linker resolves symbols in static libraries.
# The linker processes libraries left to right, in a single pass, so if there are circular dependencies,
# by repeating the libraries, we give the linker multiple opportunities to resolve those dependencies.
# For Linux, we can use --start-group and --end-group to let the linker iterate through the libraries
# without listing libs repeatedly until all symbols are resolved.
# For macOS, it does not support --start-group and --end-group. But it doesn't seem to have issues
# with circular dependencies. The standard macOS linker seems to handle re-scanning automatically.
# So just list the libraries once. If we run into circular dependency issues in the future, we may need to explore
# other options or list the libraries multiple times.
# For reference, neither -all_load nor -force_load is meant to resolve circular dependencies for macOS.
TRICK_LIB_NAMES = trick_mm trick_units trick_comm trick_pyip trick trick_var_binary_parser trick_connection_handlers
ifeq ($(TRICK_HOST_TYPE),Linux)
TRICK_LIBS = -L${TRICK_LIB_DIR} -Wl,--start-group $(addprefix -l,$(TRICK_LIB_NAMES)) -Wl,--end-group
else ifeq ($(TRICK_HOST_TYPE),Darwin)
# TRICK_LIBS = $(foreach lib,$(TRICK_LIB_NAMES),-Wl,-force_load,${TRICK_HOME}/lib/lib$(lib).a)
# TRICK_LIBS = -L${TRICK_LIB_DIR} -Wl,-all_load $(addprefix -l,$(TRICK_LIB_NAMES))
TRICK_LIBS = -L${TRICK_LIB_DIR} $(addprefix -l, $(TRICK_LIB_NAMES))
else
$(error Unsupported platform: $(shell uname))
endif

TRICK_EXEC_LINK_LIBS += -L${GTEST_HOME}/lib64 -L${GTEST_HOME}/lib -lgtest -lgtest_main -lgmock -lpthread

# All tests produced by this Makefile. Remember to add new tests you
# created to the list.
Expand Down
9 changes: 5 additions & 4 deletions trick_source/sim_services/VariableServer/var_server_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,11 @@ int var_set_base( const char * var , T value , const char * units ) {
ref->units = NULL ;
}
ref_assignment(ref , &v_tree) ;
if(ref->units != NULL) {
free(ref->units) ;
ref->units = NULL;
}

// Free allocated memory within a REF2 structure. Does not free the REF2 itself
ref_free(ref) ;

// Free the REF2 structure itself
free(ref) ;
ref = NULL;
} else {
Expand Down
Loading