I am trying to understand custom memory allocators for ROS2. To understand the functioning of tlsf
I am using tlsf_example
wrapper project present in src/ros2/realtime_support
. I have added dummy print statements to src/ros2/tlsf/tlsf/src/tlsf.c
, to just verify if my changes are being applied. The colcon command I ran to build is colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug --packages-select tlsf tlsf_cpp
. I am running the binary present in src/install/tlsf_cpp/lib/tlsf_cpp
. But I don't see any of my changes being outputed to terminal. I also tried using gdb
but I am not getting any source line info for tlsf_malloc
function defined in tlsf.c
file.
CMakeLists.txt
file for tlsf.c
cmake_minimum_required(VERSION 3.5)
project(tlsf)
if(WIN32 OR APPLE OR ANDROID)
message(STATUS "tlsf allocator does not target Windows, OSX or Android, skipping...")
return()
endif()
# Default to C11
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 11)
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -g -O0)
endif()
find_package(ament_cmake REQUIRED)
add_library(${PROJECT_NAME} STATIC src/tlsf.c src/target.h include/tlsf/tlsf.h)
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/tlsf>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
set_target_properties(${PROJECT_NAME} PROPERTIES C_VISIBILITY_PRESET hidden)
ament_export_targets(export_${PROJECT_NAME})
# Disable linting for now.
#if(BUILD_TESTING)
# find_package(ament_lint_auto REQUIRED)
# ament_lint_auto_find_test_dependencies()
#endif()
ament_package()
install(DIRECTORY include/
DESTINATION include/${PROJECT_NAME}
)
install(
TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
I am sure that the build command touches tlsf.c
file after changes but I am unable to observe any changes in the output. I want to know whether the application I am running actually links to the changed file, is there any way to achieve this? What changes should I do to the CMakeLists.txt
file for tlsf
? Is the binary I ran the correct binary to expect changes? Also how can I debug tlsf_malloc
function in ROS2? I have very little idea about ROS build system, any resources to learn more about it are welcome.